···22VERSION = 533PATCHLEVEL = 1344SUBLEVEL = 055-EXTRAVERSION = -rc666-NAME = Frozen Wasteland55+EXTRAVERSION = -rc766+NAME = Opossums on Parade7788# *DOCUMENTATION*99# To see a list of typical targets execute "make help"···929929# Limit inlining across translation units to reduce binary size930930KBUILD_LDFLAGS += -mllvm -import-instr-limit=5931931932932-# Check for frame size exceeding threshold during prolog/epilog insertion.932932+# Check for frame size exceeding threshold during prolog/epilog insertion933933+# when using lld < 13.0.0.933934ifneq ($(CONFIG_FRAME_WARN),0)935935+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)934936KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)937937+endif935938endif936939endif937940
···902902 unsafe_copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set), badframe_block);903903 user_write_access_end();904904905905+ /* Save the siginfo outside of the unsafe block. */906906+ if (copy_siginfo_to_user(&frame->info, &ksig->info))907907+ goto badframe;908908+905909 /* Make sure signal handler doesn't get spurious FP exceptions */906910 tsk->thread.fp_state.fpscr = 0;907911···918914 goto badframe;919915 regs->nip = (unsigned long) &frame->tramp[0];920916 }921921-922922-923923- /* Save the siginfo outside of the unsafe block. */924924- if (copy_siginfo_to_user(&frame->info, &ksig->info))925925- goto badframe;926917927918 /* Allocate a dummy caller frame for the signal handler. */928919 newsp = ((unsigned long)frame) - __SIGNAL_FRAMESIZE;
···578578 * PKRU state is switched eagerly because it needs to be valid before we579579 * return to userland e.g. for a copy_to_user() operation.580580 */581581- if (current->mm) {581581+ if (!(current->flags & PF_KTHREAD)) {582582+ /*583583+ * If the PKRU bit in xsave.header.xfeatures is not set,584584+ * then the PKRU component was in init state, which means585585+ * XRSTOR will set PKRU to 0. If the bit is not set then586586+ * get_xsave_addr() will return NULL because the PKRU value587587+ * in memory is not valid. This means pkru_val has to be588588+ * set to 0 and not to init_pkru_value.589589+ */582590 pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU);583583- if (pk)584584- pkru_val = pk->pkru;591591+ pkru_val = pk ? pk->pkru : 0;585592 }586593 __write_pkru(pkru_val);587594}
···307307 return 0;308308 }309309310310- if (!access_ok(buf, size))311311- return -EACCES;310310+ if (!access_ok(buf, size)) {311311+ ret = -EACCES;312312+ goto out;313313+ }312314313313- if (!static_cpu_has(X86_FEATURE_FPU))314314- return fpregs_soft_set(current, NULL,315315- 0, sizeof(struct user_i387_ia32_struct),316316- NULL, buf) != 0;315315+ if (!static_cpu_has(X86_FEATURE_FPU)) {316316+ ret = fpregs_soft_set(current, NULL, 0,317317+ sizeof(struct user_i387_ia32_struct),318318+ NULL, buf);319319+ goto out;320320+ }317321318322 if (use_xsave()) {319323 struct _fpx_sw_bytes fx_sw_user;···373369 fpregs_unlock();374370 return 0;375371 }372372+373373+ /*374374+ * The above did an FPU restore operation, restricted to375375+ * the user portion of the registers, and failed, but the376376+ * microcode might have modified the FPU registers377377+ * nevertheless.378378+ *379379+ * If the FPU registers do not belong to current, then380380+ * invalidate the FPU register state otherwise the task might381381+ * preempt current and return to user space with corrupted382382+ * FPU registers.383383+ *384384+ * In case current owns the FPU registers then no further385385+ * action is required. The fixup below will handle it386386+ * correctly.387387+ */388388+ if (test_thread_flag(TIF_NEED_FPU_LOAD))389389+ __cpu_invalidate_fpregs_state();390390+376391 fpregs_unlock();377392 } else {378393 /*···400377 */401378 ret = __copy_from_user(&env, buf, sizeof(env));402379 if (ret)403403- goto err_out;380380+ goto out;404381 envp = &env;405382 }406383···428405 if (use_xsave() && !fx_only) {429406 u64 init_bv = xfeatures_mask_user() & ~user_xfeatures;430407431431- if (using_compacted_format()) {432432- ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx);433433- } else {434434- ret = __copy_from_user(&fpu->state.xsave, buf_fx, state_size);435435-436436- if (!ret && state_size > offsetof(struct xregs_state, header))437437- ret = validate_user_xstate_header(&fpu->state.xsave.header);438438- }408408+ ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx);439409 if (ret)440440- goto err_out;410410+ goto out;441411442412 sanitize_restored_user_xstate(&fpu->state, envp, user_xfeatures,443413 fx_only);···450434 ret = __copy_from_user(&fpu->state.fxsave, buf_fx, state_size);451435 if (ret) {452436 ret = -EFAULT;453453- goto err_out;437437+ goto out;454438 }455439456440 sanitize_restored_user_xstate(&fpu->state, envp, user_xfeatures,···468452 } else {469453 ret = __copy_from_user(&fpu->state.fsave, buf_fx, state_size);470454 if (ret)471471- goto err_out;455455+ goto out;472456473457 fpregs_lock();474458 ret = copy_kernel_to_fregs_err(&fpu->state.fsave);···479463 fpregs_deactivate(fpu);480464 fpregs_unlock();481465482482-err_out:466466+out:483467 if (ret)484468 fpu__clear_user_states(fpu);485469 return ret;
···14101410 if (!apic_x2apic_mode(apic))14111411 valid_reg_mask |= APIC_REG_MASK(APIC_ARBPRI);1412141214131413+ if (alignment + len > 4)14141414+ return 1;14151415+14131416 if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset)))14141417 return 1;14151418
+25-1
arch/x86/kvm/mmu/mmu.c
···47394739 context->inject_page_fault = kvm_inject_page_fault;47404740}4741474147424742+static union kvm_mmu_role kvm_calc_nested_mmu_role(struct kvm_vcpu *vcpu)47434743+{47444744+ union kvm_mmu_role role = kvm_calc_shadow_root_page_role_common(vcpu, false);47454745+47464746+ /*47474747+ * Nested MMUs are used only for walking L2's gva->gpa, they never have47484748+ * shadow pages of their own and so "direct" has no meaning. Set it47494749+ * to "true" to try to detect bogus usage of the nested MMU.47504750+ */47514751+ role.base.direct = true;47524752+47534753+ if (!is_paging(vcpu))47544754+ role.base.level = 0;47554755+ else if (is_long_mode(vcpu))47564756+ role.base.level = is_la57_mode(vcpu) ? PT64_ROOT_5LEVEL :47574757+ PT64_ROOT_4LEVEL;47584758+ else if (is_pae(vcpu))47594759+ role.base.level = PT32E_ROOT_LEVEL;47604760+ else47614761+ role.base.level = PT32_ROOT_LEVEL;47624762+47634763+ return role;47644764+}47654765+47424766static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu)47434767{47444744- union kvm_mmu_role new_role = kvm_calc_mmu_role_common(vcpu, false);47684768+ union kvm_mmu_role new_role = kvm_calc_nested_mmu_role(vcpu);47454769 struct kvm_mmu *g_context = &vcpu->arch.nested_mmu;4746477047474771 if (new_role.as_u64 == g_context->mmu_role.as_u64)
+3-3
arch/x86/kvm/svm/avic.c
···221221 return &avic_physical_id_table[index];222222}223223224224-/**224224+/*225225 * Note:226226 * AVIC hardware walks the nested page table to check permissions,227227 * but does not use the SPA address specified in the leaf page···764764 return ret;765765}766766767767-/**767767+/*768768 * Note:769769 * The HW cannot support posting multicast/broadcast770770 * interrupts to a vCPU. So, we still use legacy interrupt···10051005 WRITE_ONCE(*(svm->avic_physical_id_cache), entry);10061006}1007100710081008-/**10081008+/*10091009 * This function is called during VCPU halt/unhalt.10101010 */10111011static void avic_set_running(struct kvm_vcpu *vcpu, bool is_run)
+15-5
arch/x86/kvm/svm/sev.c
···199199 sev->misc_cg = NULL;200200}201201202202-static void sev_unbind_asid(struct kvm *kvm, unsigned int handle)202202+static void sev_decommission(unsigned int handle)203203{204204 struct sev_data_decommission decommission;205205+206206+ if (!handle)207207+ return;208208+209209+ decommission.handle = handle;210210+ sev_guest_decommission(&decommission, NULL);211211+}212212+213213+static void sev_unbind_asid(struct kvm *kvm, unsigned int handle)214214+{205215 struct sev_data_deactivate deactivate;206216207217 if (!handle)···224214 sev_guest_deactivate(&deactivate, NULL);225215 up_read(&sev_deactivate_lock);226216227227- /* decommission handle */228228- decommission.handle = handle;229229- sev_guest_decommission(&decommission, NULL);217217+ sev_decommission(handle);230218}231219232220static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)···349341350342 /* Bind ASID to this guest */351343 ret = sev_bind_asid(kvm, start.handle, error);352352- if (ret)344344+ if (ret) {345345+ sev_decommission(start.handle);353346 goto e_free_session;347347+ }354348355349 /* return handle to userspace */356350 params.handle = start.handle;
+1
arch/x86/kvm/vmx/vmx.c
···62476247 switch (kvm_get_apic_mode(vcpu)) {62486248 case LAPIC_MODE_INVALID:62496249 WARN_ONCE(true, "Invalid local APIC state");62506250+ break;62506251 case LAPIC_MODE_DISABLED:62516252 break;62526253 case LAPIC_MODE_XAPIC:
···118118 if (!IS_ENABLED(CONFIG_EFI))119119 return;120120121121- if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA)121121+ if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA ||122122+ (efi_mem_type(addr) == EFI_BOOT_SERVICES_DATA &&123123+ efi_mem_attributes(addr) & EFI_MEMORY_RUNTIME))122124 desc->flags |= IORES_MAP_ENCRYPTED;123125}124126
+7-1
arch/x86/mm/numa.c
···254254255255 /* make sure all non-reserved blocks are inside the limits */256256 bi->start = max(bi->start, low);257257- bi->end = min(bi->end, high);257257+258258+ /* preserve info for non-RAM areas above 'max_pfn': */259259+ if (bi->end > high) {260260+ numa_add_memblk_to(bi->nid, high, bi->end,261261+ &numa_reserved_meminfo);262262+ bi->end = high;263263+ }258264259265 /* and there's no empty block */260266 if (bi->start >= bi->end)
+44
arch/x86/pci/fixup.c
···779779DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x15b1, pci_amd_enable_64bit_bar);780780DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1601, pci_amd_enable_64bit_bar);781781782782+#define RS690_LOWER_TOP_OF_DRAM2 0x30783783+#define RS690_LOWER_TOP_OF_DRAM2_VALID 0x1784784+#define RS690_UPPER_TOP_OF_DRAM2 0x31785785+#define RS690_HTIU_NB_INDEX 0xA8786786+#define RS690_HTIU_NB_INDEX_WR_ENABLE 0x100787787+#define RS690_HTIU_NB_DATA 0xAC788788+789789+/*790790+ * Some BIOS implementations support RAM above 4GB, but do not configure the791791+ * PCI host to respond to bus master accesses for these addresses. These792792+ * implementations set the TOP_OF_DRAM_SLOT1 register correctly, so PCI DMA793793+ * works as expected for addresses below 4GB.794794+ *795795+ * Reference: "AMD RS690 ASIC Family Register Reference Guide" (pg. 2-57)796796+ * https://www.amd.com/system/files/TechDocs/43372_rs690_rrg_3.00o.pdf797797+ */798798+static void rs690_fix_64bit_dma(struct pci_dev *pdev)799799+{800800+ u32 val = 0;801801+ phys_addr_t top_of_dram = __pa(high_memory - 1) + 1;802802+803803+ if (top_of_dram <= (1ULL << 32))804804+ return;805805+806806+ pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX,807807+ RS690_LOWER_TOP_OF_DRAM2);808808+ pci_read_config_dword(pdev, RS690_HTIU_NB_DATA, &val);809809+810810+ if (val)811811+ return;812812+813813+ pci_info(pdev, "Adjusting top of DRAM to %pa for 64-bit DMA support\n", &top_of_dram);814814+815815+ pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX,816816+ RS690_UPPER_TOP_OF_DRAM2 | RS690_HTIU_NB_INDEX_WR_ENABLE);817817+ pci_write_config_dword(pdev, RS690_HTIU_NB_DATA, top_of_dram >> 32);818818+819819+ pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX,820820+ RS690_LOWER_TOP_OF_DRAM2 | RS690_HTIU_NB_INDEX_WR_ENABLE);821821+ pci_write_config_dword(pdev, RS690_HTIU_NB_DATA,822822+ top_of_dram | RS690_LOWER_TOP_OF_DRAM2_VALID);823823+}824824+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma);825825+782826#endif
-10
drivers/cpufreq/Kconfig.arm
···19192020 If in doubt, say N.21212222-config ACPI_CPPC_CPUFREQ_FIE2323- bool "Frequency Invariance support for CPPC cpufreq driver"2424- depends on ACPI_CPPC_CPUFREQ && GENERIC_ARCH_TOPOLOGY2525- default y2626- help2727- This extends frequency invariance support in the CPPC cpufreq driver,2828- by using CPPC delivered and reference performance counters.2929-3030- If in doubt, say N.3131-3222config ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM3323 tristate "Allwinner nvmem based SUN50I CPUFreq driver"3424 depends on ARCH_SUNXI
+12-233
drivers/cpufreq/cppc_cpufreq.c
···10101111#define pr_fmt(fmt) "CPPC Cpufreq:" fmt12121313-#include <linux/arch_topology.h>1413#include <linux/kernel.h>1514#include <linux/module.h>1615#include <linux/delay.h>1716#include <linux/cpu.h>1817#include <linux/cpufreq.h>1918#include <linux/dmi.h>2020-#include <linux/irq_work.h>2121-#include <linux/kthread.h>2219#include <linux/time.h>2320#include <linux/vmalloc.h>2424-#include <uapi/linux/sched/types.h>25212622#include <asm/unaligned.h>2723···5660 .oem_revision = 0,5761 }5862};5959-6060-#ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE6161-6262-/* Frequency invariance support */6363-struct cppc_freq_invariance {6464- int cpu;6565- struct irq_work irq_work;6666- struct kthread_work work;6767- struct cppc_perf_fb_ctrs prev_perf_fb_ctrs;6868- struct cppc_cpudata *cpu_data;6969-};7070-7171-static DEFINE_PER_CPU(struct cppc_freq_invariance, cppc_freq_inv);7272-static struct kthread_worker *kworker_fie;7373-static bool fie_disabled;7474-7575-static struct cpufreq_driver cppc_cpufreq_driver;7676-static unsigned int hisi_cppc_cpufreq_get_rate(unsigned int cpu);7777-static int cppc_perf_from_fbctrs(struct cppc_cpudata *cpu_data,7878- struct cppc_perf_fb_ctrs fb_ctrs_t0,7979- struct cppc_perf_fb_ctrs fb_ctrs_t1);8080-8181-/**8282- * cppc_scale_freq_workfn - CPPC arch_freq_scale updater for frequency invariance8383- * @work: The work item.8484- *8585- * The CPPC driver register itself with the topology core to provide its own8686- * implementation (cppc_scale_freq_tick()) of topology_scale_freq_tick() which8787- * gets called by the scheduler on every tick.8888- *8989- * Note that the arch specific counters have higher priority than CPPC counters,9090- * if available, though the CPPC driver doesn't need to have any special9191- * handling for that.9292- *9393- * On an invocation of cppc_scale_freq_tick(), we schedule an irq work (since we9494- * reach here from hard-irq context), which then schedules a normal work item9595- * and cppc_scale_freq_workfn() updates the per_cpu arch_freq_scale variable9696- * based on the counter updates since the last tick.9797- */9898-static void cppc_scale_freq_workfn(struct kthread_work *work)9999-{100100- struct cppc_freq_invariance *cppc_fi;101101- struct cppc_perf_fb_ctrs fb_ctrs = {0};102102- struct cppc_cpudata *cpu_data;103103- unsigned long local_freq_scale;104104- u64 perf;105105-106106- cppc_fi = container_of(work, struct cppc_freq_invariance, work);107107- cpu_data = cppc_fi->cpu_data;108108-109109- if (cppc_get_perf_ctrs(cppc_fi->cpu, &fb_ctrs)) {110110- pr_warn("%s: failed to read perf counters\n", __func__);111111- return;112112- }113113-114114- cppc_fi->prev_perf_fb_ctrs = fb_ctrs;115115- perf = cppc_perf_from_fbctrs(cpu_data, cppc_fi->prev_perf_fb_ctrs,116116- fb_ctrs);117117-118118- perf <<= SCHED_CAPACITY_SHIFT;119119- local_freq_scale = div64_u64(perf, cpu_data->perf_caps.highest_perf);120120- if (WARN_ON(local_freq_scale > 1024))121121- local_freq_scale = 1024;122122-123123- per_cpu(arch_freq_scale, cppc_fi->cpu) = local_freq_scale;124124-}125125-126126-static void cppc_irq_work(struct irq_work *irq_work)127127-{128128- struct cppc_freq_invariance *cppc_fi;129129-130130- cppc_fi = container_of(irq_work, struct cppc_freq_invariance, irq_work);131131- kthread_queue_work(kworker_fie, &cppc_fi->work);132132-}133133-134134-static void cppc_scale_freq_tick(void)135135-{136136- struct cppc_freq_invariance *cppc_fi = &per_cpu(cppc_freq_inv, smp_processor_id());137137-138138- /*139139- * cppc_get_perf_ctrs() can potentially sleep, call that from the right140140- * context.141141- */142142- irq_work_queue(&cppc_fi->irq_work);143143-}144144-145145-static struct scale_freq_data cppc_sftd = {146146- .source = SCALE_FREQ_SOURCE_CPPC,147147- .set_freq_scale = cppc_scale_freq_tick,148148-};149149-150150-static void cppc_freq_invariance_policy_init(struct cpufreq_policy *policy,151151- struct cppc_cpudata *cpu_data)152152-{153153- struct cppc_perf_fb_ctrs fb_ctrs = {0};154154- struct cppc_freq_invariance *cppc_fi;155155- int i, ret;156156-157157- if (cppc_cpufreq_driver.get == hisi_cppc_cpufreq_get_rate)158158- return;159159-160160- if (fie_disabled)161161- return;162162-163163- for_each_cpu(i, policy->cpus) {164164- cppc_fi = &per_cpu(cppc_freq_inv, i);165165- cppc_fi->cpu = i;166166- cppc_fi->cpu_data = cpu_data;167167- kthread_init_work(&cppc_fi->work, cppc_scale_freq_workfn);168168- init_irq_work(&cppc_fi->irq_work, cppc_irq_work);169169-170170- ret = cppc_get_perf_ctrs(i, &fb_ctrs);171171- if (ret) {172172- pr_warn("%s: failed to read perf counters: %d\n",173173- __func__, ret);174174- fie_disabled = true;175175- } else {176176- cppc_fi->prev_perf_fb_ctrs = fb_ctrs;177177- }178178- }179179-}180180-181181-static void __init cppc_freq_invariance_init(void)182182-{183183- struct sched_attr attr = {184184- .size = sizeof(struct sched_attr),185185- .sched_policy = SCHED_DEADLINE,186186- .sched_nice = 0,187187- .sched_priority = 0,188188- /*189189- * Fake (unused) bandwidth; workaround to "fix"190190- * priority inheritance.191191- */192192- .sched_runtime = 1000000,193193- .sched_deadline = 10000000,194194- .sched_period = 10000000,195195- };196196- int ret;197197-198198- if (cppc_cpufreq_driver.get == hisi_cppc_cpufreq_get_rate)199199- return;200200-201201- if (fie_disabled)202202- return;203203-204204- kworker_fie = kthread_create_worker(0, "cppc_fie");205205- if (IS_ERR(kworker_fie))206206- return;207207-208208- ret = sched_setattr_nocheck(kworker_fie->task, &attr);209209- if (ret) {210210- pr_warn("%s: failed to set SCHED_DEADLINE: %d\n", __func__,211211- ret);212212- kthread_destroy_worker(kworker_fie);213213- return;214214- }215215-216216- /* Register for freq-invariance */217217- topology_set_scale_freq_source(&cppc_sftd, cpu_present_mask);218218-}219219-220220-static void cppc_freq_invariance_exit(void)221221-{222222- struct cppc_freq_invariance *cppc_fi;223223- int i;224224-225225- if (cppc_cpufreq_driver.get == hisi_cppc_cpufreq_get_rate)226226- return;227227-228228- if (fie_disabled)229229- return;230230-231231- topology_clear_scale_freq_source(SCALE_FREQ_SOURCE_CPPC, cpu_present_mask);232232-233233- for_each_possible_cpu(i) {234234- cppc_fi = &per_cpu(cppc_freq_inv, i);235235- irq_work_sync(&cppc_fi->irq_work);236236- }237237-238238- kthread_destroy_worker(kworker_fie);239239- kworker_fie = NULL;240240-}241241-242242-#else243243-static inline void244244-cppc_freq_invariance_policy_init(struct cpufreq_policy *policy,245245- struct cppc_cpudata *cpu_data)246246-{247247-}248248-249249-static inline void cppc_freq_invariance_init(void)250250-{251251-}252252-253253-static inline void cppc_freq_invariance_exit(void)254254-{255255-}256256-#endif /* CONFIG_ACPI_CPPC_CPUFREQ_FIE */2576325864/* Callback function used to retrieve the max frequency from DMI */25965static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private)···345547 cpu_data->perf_ctrls.desired_perf = caps->highest_perf;346548347549 ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);348348- if (ret) {550550+ if (ret)349551 pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",350552 caps->highest_perf, cpu, ret);351351- } else {352352- cppc_freq_invariance_policy_init(policy, cpu_data);353353- }354553355554 return ret;356555}···360565 return (u32)t1 - (u32)t0;361566}362567363363-static int cppc_perf_from_fbctrs(struct cppc_cpudata *cpu_data,364364- struct cppc_perf_fb_ctrs fb_ctrs_t0,365365- struct cppc_perf_fb_ctrs fb_ctrs_t1)568568+static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu_data,569569+ struct cppc_perf_fb_ctrs fb_ctrs_t0,570570+ struct cppc_perf_fb_ctrs fb_ctrs_t1)366571{367572 u64 delta_reference, delta_delivered;368368- u64 reference_perf;573573+ u64 reference_perf, delivered_perf;369574370575 reference_perf = fb_ctrs_t0.reference_perf;371576···374579 delta_delivered = get_delta(fb_ctrs_t1.delivered,375580 fb_ctrs_t0.delivered);376581377377- /* Check to avoid divide-by zero and invalid delivered_perf */378378- if (!delta_reference || !delta_delivered)379379- return cpu_data->perf_ctrls.desired_perf;380380-381381- return (reference_perf * delta_delivered) / delta_reference;382382-}383383-384384-static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu_data,385385- struct cppc_perf_fb_ctrs fb_ctrs_t0,386386- struct cppc_perf_fb_ctrs fb_ctrs_t1)387387-{388388- u64 delivered_perf;389389-390390- delivered_perf = cppc_perf_from_fbctrs(cpu_data, fb_ctrs_t0,391391- fb_ctrs_t1);582582+ /* Check to avoid divide-by zero */583583+ if (delta_reference || delta_delivered)584584+ delivered_perf = (reference_perf * delta_delivered) /585585+ delta_reference;586586+ else587587+ delivered_perf = cpu_data->perf_ctrls.desired_perf;392588393589 return cppc_cpufreq_perf_to_khz(cpu_data, delivered_perf);394590}···504718505719static int __init cppc_cpufreq_init(void)506720{507507- int ret;508508-509721 if ((acpi_disabled) || !acpi_cpc_valid())510722 return -ENODEV;511723···511727512728 cppc_check_hisi_workaround();513729514514- ret = cpufreq_register_driver(&cppc_cpufreq_driver);515515- if (!ret)516516- cppc_freq_invariance_init();517517-518518- return ret;730730+ return cpufreq_register_driver(&cppc_cpufreq_driver);519731}520732521733static inline void free_cpu_data(void)···528748529749static void __exit cppc_cpufreq_exit(void)530750{531531- cppc_freq_invariance_exit();532751 cpufreq_unregister_driver(&cppc_cpufreq_driver);533752534753 free_cpu_data();
+2
drivers/dma/Kconfig
···5959#devices6060config ALTERA_MSGDMA6161 tristate "Altera / Intel mSGDMA Engine"6262+ depends on HAS_IOMEM6263 select DMA_ENGINE6364 help6465 Enable support for Altera / Intel mSGDMA controller.···702701703702config XILINX_ZYNQMP_DPDMA704703 tristate "Xilinx DPDMA Engine"704704+ depends on HAS_IOMEM && OF705705 select DMA_ENGINE706706 select DMA_VIRTUAL_CHANNELS707707 help
+3
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
···332332 }333333334334 if (priv->dpdmai_attr.version.major > DPDMAI_VER_MAJOR) {335335+ err = -EINVAL;335336 dev_err(dev, "DPDMAI major version mismatch\n"336337 "Found %u.%u, supported version is %u.%u\n",337338 priv->dpdmai_attr.version.major,···342341 }343342344343 if (priv->dpdmai_attr.version.minor > DPDMAI_VER_MINOR) {344344+ err = -EINVAL;345345 dev_err(dev, "DPDMAI minor version mismatch\n"346346 "Found %u.%u, supported version is %u.%u\n",347347 priv->dpdmai_attr.version.major,···477475 ppriv->store =478476 dpaa2_io_store_create(DPAA2_QDMA_STORE_SIZE, dev);479477 if (!ppriv->store) {478478+ err = -ENOMEM;480479 dev_err(dev, "dpaa2_io_store_create() failed\n");481480 goto err_store;482481 }
···168168 return rc;169169}170170171171+static void idxd_cleanup_interrupts(struct idxd_device *idxd)172172+{173173+ struct pci_dev *pdev = idxd->pdev;174174+ struct idxd_irq_entry *irq_entry;175175+ int i, msixcnt;176176+177177+ msixcnt = pci_msix_vec_count(pdev);178178+ if (msixcnt <= 0)179179+ return;180180+181181+ irq_entry = &idxd->irq_entries[0];182182+ free_irq(irq_entry->vector, irq_entry);183183+184184+ for (i = 1; i < msixcnt; i++) {185185+186186+ irq_entry = &idxd->irq_entries[i];187187+ if (idxd->hw.cmd_cap & BIT(IDXD_CMD_RELEASE_INT_HANDLE))188188+ idxd_device_release_int_handle(idxd, idxd->int_handles[i],189189+ IDXD_IRQ_MSIX);190190+ free_irq(irq_entry->vector, irq_entry);191191+ }192192+193193+ idxd_mask_error_interrupts(idxd);194194+ pci_free_irq_vectors(pdev);195195+}196196+171197static int idxd_setup_wqs(struct idxd_device *idxd)172198{173199 struct device *dev = &idxd->pdev->dev;···268242 engine->idxd = idxd;269243 device_initialize(&engine->conf_dev);270244 engine->conf_dev.parent = &idxd->conf_dev;245245+ engine->conf_dev.bus = &dsa_bus_type;271246 engine->conf_dev.type = &idxd_engine_device_type;272247 rc = dev_set_name(&engine->conf_dev, "engine%d.%d", idxd->id, engine->id);273248 if (rc < 0) {···328301 while (--i >= 0)329302 put_device(&idxd->groups[i]->conf_dev);330303 return rc;304304+}305305+306306+static void idxd_cleanup_internals(struct idxd_device *idxd)307307+{308308+ int i;309309+310310+ for (i = 0; i < idxd->max_groups; i++)311311+ put_device(&idxd->groups[i]->conf_dev);312312+ for (i = 0; i < idxd->max_engines; i++)313313+ put_device(&idxd->engines[i]->conf_dev);314314+ for (i = 0; i < idxd->max_wqs; i++)315315+ put_device(&idxd->wqs[i]->conf_dev);316316+ destroy_workqueue(idxd->wq);331317}332318333319static int idxd_setup_internals(struct idxd_device *idxd)···571531 dev_dbg(dev, "Loading RO device config\n");572532 rc = idxd_device_load_config(idxd);573533 if (rc < 0)574574- goto err;534534+ goto err_config;575535 }576536577537 rc = idxd_setup_interrupts(idxd);578538 if (rc)579579- goto err;539539+ goto err_config;580540581541 dev_dbg(dev, "IDXD interrupt setup complete.\n");582542···589549 dev_dbg(dev, "IDXD device %d probed successfully\n", idxd->id);590550 return 0;591551552552+ err_config:553553+ idxd_cleanup_internals(idxd);592554 err:593555 if (device_pasid_enabled(idxd))594556 idxd_disable_system_pasid(idxd);595557 iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_SVA);596558 return rc;559559+}560560+561561+static void idxd_cleanup(struct idxd_device *idxd)562562+{563563+ struct device *dev = &idxd->pdev->dev;564564+565565+ perfmon_pmu_remove(idxd);566566+ idxd_cleanup_interrupts(idxd);567567+ idxd_cleanup_internals(idxd);568568+ if (device_pasid_enabled(idxd))569569+ idxd_disable_system_pasid(idxd);570570+ iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_SVA);597571}598572599573static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)···662608 rc = idxd_register_devices(idxd);663609 if (rc) {664610 dev_err(dev, "IDXD sysfs setup failed\n");665665- goto err;611611+ goto err_dev_register;666612 }667613668614 idxd->state = IDXD_DEV_CONF_READY;···672618673619 return 0;674620621621+ err_dev_register:622622+ idxd_cleanup(idxd);675623 err:676624 pci_iounmap(pdev, idxd->reg_base);677625 err_iomap:···843787844788static void __exit idxd_exit_module(void)845789{790790+ idxd_unregister_driver();846791 pci_unregister_driver(&idxd_pci_driver);847792 idxd_cdev_remove();848793 idxd_unregister_bus_type();
+1-1
drivers/dma/ipu/ipu_irq.c
···230230}231231232232/**233233- * ipu_irq_map() - map an IPU interrupt source to an IRQ number233233+ * ipu_irq_unmap() - unmap an IPU interrupt source234234 * @source: interrupt source bit position (see ipu_irq_map())235235 * @return: 0 or negative error code236236 */
···113113#define XILINX_DPDMA_CH_VDO 0x020114114#define XILINX_DPDMA_CH_PYLD_SZ 0x024115115#define XILINX_DPDMA_CH_DESC_ID 0x028116116+#define XILINX_DPDMA_CH_DESC_ID_MASK GENMASK(15, 0)116117117118/* DPDMA descriptor fields */118119#define XILINX_DPDMA_DESC_CONTROL_PREEMBLE 0xa5···867866 * will be used, but it should be enough.868867 */869868 list_for_each_entry(sw_desc, &desc->descriptors, node)870870- sw_desc->hw.desc_id = desc->vdesc.tx.cookie;869869+ sw_desc->hw.desc_id = desc->vdesc.tx.cookie870870+ & XILINX_DPDMA_CH_DESC_ID_MASK;871871872872 sw_desc = list_first_entry(&desc->descriptors,873873 struct xilinx_dpdma_sw_desc, node);···10881086 if (!chan->running || !pending)10891087 goto out;1090108810911091- desc_id = dpdma_read(chan->reg, XILINX_DPDMA_CH_DESC_ID);10891089+ desc_id = dpdma_read(chan->reg, XILINX_DPDMA_CH_DESC_ID)10901090+ & XILINX_DPDMA_CH_DESC_ID_MASK;1092109110931092 /* If the retrigger raced with vsync, retry at the next frame. */10941093 sw_desc = list_first_entry(&pending->descriptors,···14621459 */14631460static void xilinx_dpdma_disable_irq(struct xilinx_dpdma_device *xdev)14641461{14651465- dpdma_write(xdev->reg, XILINX_DPDMA_IDS, XILINX_DPDMA_INTR_ERR_ALL);14621462+ dpdma_write(xdev->reg, XILINX_DPDMA_IDS, XILINX_DPDMA_INTR_ALL);14661463 dpdma_write(xdev->reg, XILINX_DPDMA_EIDS, XILINX_DPDMA_EINTR_ALL);14671464}14681465···15991596 return dma_get_slave_channel(&xdev->chan[chan_id]->vchan.chan);16001597}1601159815991599+static void dpdma_hw_init(struct xilinx_dpdma_device *xdev)16001600+{16011601+ unsigned int i;16021602+ void __iomem *reg;16031603+16041604+ /* Disable all interrupts */16051605+ xilinx_dpdma_disable_irq(xdev);16061606+16071607+ /* Stop all channels */16081608+ for (i = 0; i < ARRAY_SIZE(xdev->chan); i++) {16091609+ reg = xdev->reg + XILINX_DPDMA_CH_BASE16101610+ + XILINX_DPDMA_CH_OFFSET * i;16111611+ dpdma_clr(reg, XILINX_DPDMA_CH_CNTL, XILINX_DPDMA_CH_CNTL_ENABLE);16121612+ }16131613+16141614+ /* Clear the interrupt status registers */16151615+ dpdma_write(xdev->reg, XILINX_DPDMA_ISR, XILINX_DPDMA_INTR_ALL);16161616+ dpdma_write(xdev->reg, XILINX_DPDMA_EISR, XILINX_DPDMA_EINTR_ALL);16171617+}16181618+16021619static int xilinx_dpdma_probe(struct platform_device *pdev)16031620{16041621 struct xilinx_dpdma_device *xdev;···16441621 xdev->reg = devm_platform_ioremap_resource(pdev, 0);16451622 if (IS_ERR(xdev->reg))16461623 return PTR_ERR(xdev->reg);16241624+16251625+ dpdma_hw_init(xdev);1647162616481627 xdev->irq = platform_get_irq(pdev, 0);16491628 if (xdev->irq < 0) {
+1-1
drivers/dma/xilinx/zynqmp_dma.c
···468468 struct zynqmp_dma_desc_sw *desc;469469 int i, ret;470470471471- ret = pm_runtime_get_sync(chan->dev);471471+ ret = pm_runtime_resume_and_get(chan->dev);472472 if (ret < 0)473473 return ret;474474
+5-1
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
···68716871 if (ring->use_doorbell) {68726872 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,68736873 (adev->doorbell_index.kiq * 2) << 2);68746874+ /* If GC has entered CGPG, ringing doorbell > first page doesn't68756875+ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround68766876+ * this issue.68776877+ */68746878 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,68756875- (adev->doorbell_index.userqueue_end * 2) << 2);68796879+ (adev->doorbell.size - 4));68766880 }6877688168786882 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
+5-1
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
···36733673 if (ring->use_doorbell) {36743674 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,36753675 (adev->doorbell_index.kiq * 2) << 2);36763676+ /* If GC has entered CGPG, ringing doorbell > first page doesn't36773677+ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround36783678+ * this issue.36793679+ */36763680 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,36773677- (adev->doorbell_index.userqueue_end * 2) << 2);36813681+ (adev->doorbell.size - 4));36783682 }3679368336803684 WREG32_SOC15_RLC(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
+35-1
drivers/irqchip/irq-gic-v3.c
···642642 nmi_exit();643643}644644645645+static u32 do_read_iar(struct pt_regs *regs)646646+{647647+ u32 iar;648648+649649+ if (gic_supports_nmi() && unlikely(!interrupts_enabled(regs))) {650650+ u64 pmr;651651+652652+ /*653653+ * We were in a context with IRQs disabled. However, the654654+ * entry code has set PMR to a value that allows any655655+ * interrupt to be acknowledged, and not just NMIs. This can656656+ * lead to surprising effects if the NMI has been retired in657657+ * the meantime, and that there is an IRQ pending. The IRQ658658+ * would then be taken in NMI context, something that nobody659659+ * wants to debug twice.660660+ *661661+ * Until we sort this, drop PMR again to a level that will662662+ * actually only allow NMIs before reading IAR, and then663663+ * restore it to what it was.664664+ */665665+ pmr = gic_read_pmr();666666+ gic_pmr_mask_irqs();667667+ isb();668668+669669+ iar = gic_read_iar();670670+671671+ gic_write_pmr(pmr);672672+ } else {673673+ iar = gic_read_iar();674674+ }675675+676676+ return iar;677677+}678678+645679static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)646680{647681 u32 irqnr;648682649649- irqnr = gic_read_iar();683683+ irqnr = do_read_iar(regs);650684651685 /* Check for special IDs first */652686 if ((irqnr >= 1020 && irqnr <= 1023))
+1
drivers/net/caif/caif_serial.c
···350350 rtnl_lock();351351 result = register_netdevice(dev);352352 if (result) {353353+ tty_kref_put(tty);353354 rtnl_unlock();354355 free_netdev(dev);355356 return -ENODEV;
+15-2
drivers/net/can/usb/mcba_usb.c
···8282 bool can_ka_first_pass;8383 bool can_speed_check;8484 atomic_t free_ctx_cnt;8585+ void *rxbuf[MCBA_MAX_RX_URBS];8686+ dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS];8587};86888789/* CAN frame */···635633 for (i = 0; i < MCBA_MAX_RX_URBS; i++) {636634 struct urb *urb = NULL;637635 u8 *buf;636636+ dma_addr_t buf_dma;638637639638 /* create a URB, and a buffer for it */640639 urb = usb_alloc_urb(0, GFP_KERNEL);···645642 }646643647644 buf = usb_alloc_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE,648648- GFP_KERNEL, &urb->transfer_dma);645645+ GFP_KERNEL, &buf_dma);649646 if (!buf) {650647 netdev_err(netdev, "No memory left for USB buffer\n");651648 usb_free_urb(urb);···664661 if (err) {665662 usb_unanchor_urb(urb);666663 usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE,667667- buf, urb->transfer_dma);664664+ buf, buf_dma);668665 usb_free_urb(urb);669666 break;670667 }668668+669669+ priv->rxbuf[i] = buf;670670+ priv->rxbuf_dma[i] = buf_dma;671671672672 /* Drop reference, USB core will take care of freeing it */673673 usb_free_urb(urb);···714708715709static void mcba_urb_unlink(struct mcba_priv *priv)716710{711711+ int i;712712+717713 usb_kill_anchored_urbs(&priv->rx_submitted);714714+715715+ for (i = 0; i < MCBA_MAX_RX_URBS; ++i)716716+ usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE,717717+ priv->rxbuf[i], priv->rxbuf_dma[i]);718718+718719 usb_kill_anchored_urbs(&priv->tx_submitted);719720}720721
···13371337 return ret;13381338 }1339133913401340- spin_lock_bh(&adap->win0_lock);13411341- ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size);13421342- spin_unlock_bh(&adap->win0_lock);13431343- if (ret)13441344- dev_err(adap->pdev_dev, "Failed to load PHY FW\n");13401340+ /* We have to RESET the chip/firmware because we need the13411341+ * chip in uninitialized state for loading new PHY image.13421342+ * Otherwise, the running firmware will only store the PHY13431343+ * image in local RAM which will be lost after next reset.13441344+ */13451345+ ret = t4_fw_reset(adap, adap->mbox, PIORSTMODE_F | PIORST_F);13461346+ if (ret < 0) {13471347+ dev_err(adap->pdev_dev,13481348+ "Set FW to RESET for flashing PHY FW failed. ret: %d\n",13491349+ ret);13501350+ return ret;13511351+ }1345135213461346- return ret;13531353+ ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size);13541354+ if (ret < 0) {13551355+ dev_err(adap->pdev_dev, "Failed to load PHY FW. ret: %d\n",13561356+ ret);13571357+ return ret;13581358+ }13591359+13601360+ return 0;13471361}1348136213491363static int cxgb4_ethtool_flash_fw(struct net_device *netdev,···16241610 u32 ftid)16251611{16261612 struct tid_info *t = &adap->tids;16271627- struct filter_entry *f;1628161316291629- if (ftid < t->nhpftids)16301630- f = &adap->tids.hpftid_tab[ftid];16311631- else if (ftid < t->nftids)16321632- f = &adap->tids.ftid_tab[ftid - t->nhpftids];16331633- else16341634- f = lookup_tid(&adap->tids, ftid);16141614+ if (ftid >= t->hpftid_base && ftid < t->hpftid_base + t->nhpftids)16151615+ return &t->hpftid_tab[ftid - t->hpftid_base];1635161616361636- return f;16171617+ if (ftid >= t->ftid_base && ftid < t->ftid_base + t->nftids)16181618+ return &t->ftid_tab[ftid - t->ftid_base];16191619+16201620+ return lookup_tid(t, ftid);16371621}1638162216391623static void cxgb4_fill_filter_rule(struct ethtool_rx_flow_spec *fs,···18381826 filter_id = filter_info->loc_array[cmd->fs.location];18391827 f = cxgb4_get_filter_entry(adapter, filter_id);1840182818291829+ if (f->fs.prio)18301830+ filter_id -= adapter->tids.hpftid_base;18311831+ else if (!f->fs.hash)18321832+ filter_id -= (adapter->tids.ftid_base - adapter->tids.nhpftids);18331833+18411834 ret = cxgb4_flow_rule_destroy(dev, f->fs.tc_prio, &f->fs, filter_id);18421835 if (ret)18431836 goto err;···19011884 goto free;1902188519031886 filter_info = &adapter->ethtool_filters->port[pi->port_id];18871887+18881888+ if (fs.prio)18891889+ tid += adapter->tids.hpftid_base;18901890+ else if (!fs.hash)18911891+ tid += (adapter->tids.ftid_base - adapter->tids.nhpftids);1904189219051893 filter_info->loc_array[cmd->fs.location] = tid;19061894 set_bit(cmd->fs.location, filter_info->bmap);
···4424442444254425 /* Load PHY Firmware onto adapter.44264426 */44274427- spin_lock_bh(&adap->win0_lock);44284427 ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version,44294428 (u8 *)phyf->data, phyf->size);44304430- spin_unlock_bh(&adap->win0_lock);44314429 if (ret < 0)44324430 dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n",44334431 -ret);
+29-17
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
···30603060 * @addr: the start address to write30613061 * @n: length of data to write in bytes30623062 * @data: the data to write30633063+ * @byte_oriented: whether to store data as bytes or as words30633064 *30643065 * Writes up to a page of data (256 bytes) to the serial flash starting30653066 * at the given address. All the data must be written to the same page.30673067+ * If @byte_oriented is set the write data is stored as byte stream30683068+ * (i.e. matches what on disk), otherwise in big-endian.30663069 */30673070static int t4_write_flash(struct adapter *adapter, unsigned int addr,30683068- unsigned int n, const u8 *data)30713071+ unsigned int n, const u8 *data, bool byte_oriented)30693072{30703070- int ret;30713071- u32 buf[64];30723073 unsigned int i, c, left, val, offset = addr & 0xff;30743074+ u32 buf[64];30753075+ int ret;3073307630743077 if (addr >= adapter->params.sf_size || offset + n > SF_PAGE_SIZE)30753078 return -EINVAL;···30833080 (ret = sf1_write(adapter, 4, 1, 1, val)) != 0)30843081 goto unlock;3085308230863086- for (left = n; left; left -= c) {30833083+ for (left = n; left; left -= c, data += c) {30873084 c = min(left, 4U);30883088- for (val = 0, i = 0; i < c; ++i)30893089- val = (val << 8) + *data++;30853085+ for (val = 0, i = 0; i < c; ++i) {30863086+ if (byte_oriented)30873087+ val = (val << 8) + data[i];30883088+ else30893089+ val = (val << 8) + data[c - i - 1];30903090+ }3090309130913092 ret = sf1_write(adapter, c, c != left, 1, val);30923093 if (ret)···31033096 t4_write_reg(adapter, SF_OP_A, 0); /* unlock SF */3104309731053098 /* Read the page to verify the write succeeded */31063106- ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, 1);30993099+ ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf,31003100+ byte_oriented);31073101 if (ret)31083102 return ret;31093103···37003692 */37013693 memcpy(first_page, fw_data, SF_PAGE_SIZE);37023694 ((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff);37033703- ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page);36953695+ ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page, true);37043696 if (ret)37053697 goto out;37063698···37083700 for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {37093701 addr += SF_PAGE_SIZE;37103702 fw_data += SF_PAGE_SIZE;37113711- ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data);37033703+ ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data, true);37123704 if (ret)37133705 goto out;37143706 }3715370737163716- ret = t4_write_flash(adap,37173717- fw_start + offsetof(struct fw_hdr, fw_ver),37183718- sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver);37083708+ ret = t4_write_flash(adap, fw_start + offsetof(struct fw_hdr, fw_ver),37093709+ sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver,37103710+ true);37193711out:37203712 if (ret)37213713 dev_err(adap->pdev_dev, "firmware download failed, error %d\n",···38203812 /* Copy the supplied PHY Firmware image to the adapter memory location38213813 * allocated by the adapter firmware.38223814 */38153815+ spin_lock_bh(&adap->win0_lock);38233816 ret = t4_memory_rw(adap, win, mtype, maddr,38243817 phy_fw_size, (__be32 *)phy_fw_data,38253818 T4_MEMORY_WRITE);38193819+ spin_unlock_bh(&adap->win0_lock);38263820 if (ret)38273821 return ret;38283822···1021810208 n = size - i;1021910209 else1022010210 n = SF_PAGE_SIZE;1022110221- ret = t4_write_flash(adap, addr, n, cfg_data);1021110211+ ret = t4_write_flash(adap, addr, n, cfg_data, true);1022210212 if (ret)1022310213 goto out;1022410214···1068710677 for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {1068810678 addr += SF_PAGE_SIZE;1068910679 boot_data += SF_PAGE_SIZE;1069010690- ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data);1068010680+ ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data,1068110681+ false);1069110682 if (ret)1069210683 goto out;1069310684 }10694106851069510686 ret = t4_write_flash(adap, boot_sector, SF_PAGE_SIZE,1069610696- (const u8 *)header);1068710687+ (const u8 *)header, false);10697106881069810689out:1069910690 if (ret)···1076910758 for (i = 0; i < size; i += SF_PAGE_SIZE) {1077010759 n = min_t(u32, size - i, SF_PAGE_SIZE);10771107601077210772- ret = t4_write_flash(adap, addr, n, cfg_data);1076110761+ ret = t4_write_flash(adap, addr, n, cfg_data, false);1077310762 if (ret)1077410763 goto out;1077510764···1078110770 for (i = 0; i < npad; i++) {1078210771 u8 data = 0;10783107721078410784- ret = t4_write_flash(adap, cfg_addr + size + i, 1, &data);1077310773+ ret = t4_write_flash(adap, cfg_addr + size + i, 1, &data,1077410774+ false);1078510775 if (ret)1078610776 goto out;1078710777 }
···17171717 * ice_vsi_cfg_txqs - Configure the VSI for Tx17181718 * @vsi: the VSI being configured17191719 * @rings: Tx ring array to be configured17201720+ * @count: number of Tx ring array elements17201721 *17211722 * Return 0 on success and a negative value on error17221723 * Configure the Tx VSI for operation.17231724 */17241725static int17251725-ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings)17261726+ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, u16 count)17261727{17271728 struct ice_aqc_add_tx_qgrp *qg_buf;17281729 u16 q_idx = 0;···1735173417361735 qg_buf->num_txqs = 1;1737173617381738- for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) {17371737+ for (q_idx = 0; q_idx < count; q_idx++) {17391738 err = ice_vsi_cfg_txq(vsi, rings[q_idx], qg_buf);17401739 if (err)17411740 goto err_cfg_txqs;···17551754 */17561755int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi)17571756{17581758- return ice_vsi_cfg_txqs(vsi, vsi->tx_rings);17571757+ return ice_vsi_cfg_txqs(vsi, vsi->tx_rings, vsi->num_txq);17591758}1760175917611760/**···17701769 int ret;17711770 int i;1772177117731773- ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings);17721772+ ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings, vsi->num_xdp_txq);17741773 if (ret)17751774 return ret;17761775···20102009 * @rst_src: reset source20112010 * @rel_vmvf_num: Relative ID of VF/VM20122011 * @rings: Tx ring array to be stopped20122012+ * @count: number of Tx ring array elements20132013 */20142014static int20152015ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,20162016- u16 rel_vmvf_num, struct ice_ring **rings)20162016+ u16 rel_vmvf_num, struct ice_ring **rings, u16 count)20172017{20182018 u16 q_idx;2019201920202020 if (vsi->num_txq > ICE_LAN_TXQ_MAX_QDIS)20212021 return -EINVAL;2022202220232023- for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) {20232023+ for (q_idx = 0; q_idx < count; q_idx++) {20242024 struct ice_txq_meta txq_meta = { };20252025 int status;20262026···20492047ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,20502048 u16 rel_vmvf_num)20512049{20522052- return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings);20502050+ return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings, vsi->num_txq);20532051}2054205220552053/**···20582056 */20592057int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi)20602058{20612061- return ice_vsi_stop_tx_rings(vsi, ICE_NO_RESET, 0, vsi->xdp_rings);20592059+ return ice_vsi_stop_tx_rings(vsi, ICE_NO_RESET, 0, vsi->xdp_rings, vsi->num_xdp_txq);20622060}2063206120642062/**
+15
drivers/net/ethernet/intel/ice/ice_main.c
···25562556}2557255725582558/**25592559+ * ice_xdp_safe_mode - XDP handler for safe mode25602560+ * @dev: netdevice25612561+ * @xdp: XDP command25622562+ */25632563+static int ice_xdp_safe_mode(struct net_device __always_unused *dev,25642564+ struct netdev_bpf *xdp)25652565+{25662566+ NL_SET_ERR_MSG_MOD(xdp->extack,25672567+ "Please provide working DDP firmware package in order to use XDP\n"25682568+ "Refer to Documentation/networking/device_drivers/ethernet/intel/ice.rst");25692569+ return -EOPNOTSUPP;25702570+}25712571+25722572+/**25592573 * ice_xdp - implements XDP handler25602574 * @dev: netdevice25612575 * @xdp: XDP command···69516937 .ndo_change_mtu = ice_change_mtu,69526938 .ndo_get_stats64 = ice_get_stats64,69536939 .ndo_tx_timeout = ice_tx_timeout,69406940+ .ndo_bpf = ice_xdp_safe_mode,69546941};6955694269566943static const struct net_device_ops ice_netdev_ops = {
+3-2
drivers/net/ethernet/lantiq_xrx200.c
···154154155155static int xrx200_alloc_skb(struct xrx200_chan *ch)156156{157157+ struct sk_buff *skb = ch->skb[ch->dma.desc];157158 dma_addr_t mapping;158159 int ret = 0;159160···169168 XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE);170169 if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) {171170 dev_kfree_skb_any(ch->skb[ch->dma.desc]);171171+ ch->skb[ch->dma.desc] = skb;172172 ret = -ENOMEM;173173 goto skip;174174 }···200198 ch->dma.desc %= LTQ_DESC_NUM;201199202200 if (ret) {203203- ch->skb[ch->dma.desc] = skb;204201 net_dev->stats.rx_dropped++;205202 netdev_err(net_dev, "failed to allocate new rx buffer\n");206203 return ret;···353352 struct xrx200_chan *ch = ptr;354353355354 if (napi_schedule_prep(&ch->napi)) {356356- __napi_schedule(&ch->napi);357355 ltq_dma_disable_irq(&ch->dma);356356+ __napi_schedule(&ch->napi);358357 }359358360359 ltq_dma_ack_irq(&ch->dma);
+19
drivers/net/ethernet/mellanox/mlx5/core/dev.c
···303303 int ret = 0, i;304304305305 mutex_lock(&mlx5_intf_mutex);306306+ priv->flags &= ~MLX5_PRIV_FLAGS_DETACH;306307 for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) {307308 if (!priv->adev[i]) {308309 bool is_supported = false;···321320 }322321 } else {323322 adev = &priv->adev[i]->adev;323323+324324+ /* Pay attention that this is not PCI driver that325325+ * mlx5_core_dev is connected, but auxiliary driver.326326+ *327327+ * Here we can race of module unload with devlink328328+ * reload, but we don't need to take extra lock because329329+ * we are holding global mlx5_intf_mutex.330330+ */331331+ if (!adev->dev.driver)332332+ continue;324333 adrv = to_auxiliary_drv(adev->dev.driver);325334326335 if (adrv->resume)···361350 continue;362351363352 adev = &priv->adev[i]->adev;353353+ /* Auxiliary driver was unbind manually through sysfs */354354+ if (!adev->dev.driver)355355+ goto skip_suspend;356356+364357 adrv = to_auxiliary_drv(adev->dev.driver);365358366359 if (adrv->suspend) {···372357 continue;373358 }374359360360+skip_suspend:375361 del_adev(&priv->adev[i]->adev);376362 priv->adev[i] = NULL;377363 }364364+ priv->flags |= MLX5_PRIV_FLAGS_DETACH;378365 mutex_unlock(&mlx5_intf_mutex);379366}380367···465448 struct mlx5_priv *priv = &dev->priv;466449467450 lockdep_assert_held(&mlx5_intf_mutex);451451+ if (priv->flags & MLX5_PRIV_FLAGS_DETACH)452452+ return 0;468453469454 delete_drivers(dev);470455 if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV)
···532532 struct mlx5_core_dev *mdev = priv->mdev;533533 struct net_device *netdev = priv->netdev;534534535535- if (!priv->ipsec)536536- return;537537-538535 if (!(mlx5_accel_ipsec_device_caps(mdev) & MLX5_ACCEL_IPSEC_CAP_ESP) ||539536 !MLX5_CAP_ETH(mdev, swp)) {540537 mlx5_core_dbg(mdev, "mlx5e: ESP and SWP offload not supported\n");
+1-1
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
···356356357357int mlx5e_arfs_create_tables(struct mlx5e_priv *priv)358358{359359- int err = 0;359359+ int err = -ENOMEM;360360 int i;361361362362 if (!(priv->netdev->hw_features & NETIF_F_NTUPLE))
···156156{157157 int err;158158159159+ if (!MLX5_CAP_GEN(dev, roce))160160+ return;161161+159162 err = mlx5_nic_vport_enable_roce(dev);160163 if (err) {161164 mlx5_core_err(dev, "Failed to enable RoCE: %d\n", err);
···694694 if (hw_action_sz / DR_STE_ACTION_DOUBLE_SZ < DR_STE_DECAP_L3_ACTION_NUM)695695 return -EINVAL;696696697697- memcpy(padded_data, data, data_sz);697697+ inline_data_sz =698698+ MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data);699699+700700+ /* Add an alignment padding */701701+ memcpy(padded_data + data_sz % inline_data_sz, data, data_sz);698702699703 /* Remove L2L3 outer headers */700704 MLX5_SET(ste_single_action_remove_header_v1, hw_action, action_id,···710706 hw_action += DR_STE_ACTION_DOUBLE_SZ;711707 used_actions++; /* Remove and NOP are a single double action */712708713713- inline_data_sz =714714- MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data);709709+ /* Point to the last dword of the header */710710+ data_ptr += (data_sz / inline_data_sz) * inline_data_sz;715711716716- /* Add the new header inline + 2 extra bytes */712712+ /* Add the new header using inline action 4Byte at a time, the header713713+ * is added in reversed order to the beginning of the packet to avoid714714+ * incorrect parsing by the HW. Since header is 14B or 18B an extra715715+ * two bytes are padded and later removed.716716+ */717717 for (i = 0; i < data_sz / inline_data_sz + 1; i++) {718718 void *addr_inline;719719720720 MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, action_id,721721 DR_STE_V1_ACTION_ID_INSERT_INLINE);722722 /* The hardware expects here offset to words (2 bytes) */723723- MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset,724724- i * 2);723723+ MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, 0);725724726725 /* Copy bytes one by one to avoid endianness problem */727726 addr_inline = MLX5_ADDR_OF(ste_double_action_insert_with_inline_v1,728727 hw_action, inline_data);729729- memcpy(addr_inline, data_ptr, inline_data_sz);728728+ memcpy(addr_inline, data_ptr - i * inline_data_sz, inline_data_sz);730729 hw_action += DR_STE_ACTION_DOUBLE_SZ;731731- data_ptr += inline_data_sz;732730 used_actions++;733731 }734732735735- /* Remove 2 extra bytes */733733+ /* Remove first 2 extra bytes */736734 MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, action_id,737735 DR_STE_V1_ACTION_ID_REMOVE_BY_SIZE);738738- MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, data_sz / 2);736736+ MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, 0);739737 /* The hardware expects here size in words (2 bytes) */740738 MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, remove_size, 1);741739 used_actions++;
···774774 stat = be32_to_cpu(cur_p->app0);775775776776 while (stat & STS_CTRL_APP0_CMPLT) {777777+ /* Make sure that the other fields are read after bd is778778+ * released by dma779779+ */780780+ rmb();777781 dma_unmap_single(ndev->dev.parent, be32_to_cpu(cur_p->phys),778782 be32_to_cpu(cur_p->len), DMA_TO_DEVICE);779783 skb = (struct sk_buff *)ptr_from_txbd(cur_p);780784 if (skb)781785 dev_consume_skb_irq(skb);782782- cur_p->app0 = 0;783786 cur_p->app1 = 0;784787 cur_p->app2 = 0;785788 cur_p->app3 = 0;···790787791788 ndev->stats.tx_packets++;792789 ndev->stats.tx_bytes += be32_to_cpu(cur_p->len);790790+791791+ /* app0 must be visible last, as it is used to flag792792+ * availability of the bd793793+ */794794+ smp_mb();795795+ cur_p->app0 = 0;793796794797 lp->tx_bd_ci++;795798 if (lp->tx_bd_ci >= lp->tx_bd_num)···822813 do {823814 if (cur_p->app0)824815 return NETDEV_TX_BUSY;816816+817817+ /* Make sure to read next bd app0 after this one */818818+ rmb();825819826820 tail++;827821 if (tail >= lp->tx_bd_num)···861849 smp_mb();862850863851 /* Space might have just been freed - check again */864864- if (temac_check_tx_bd_space(lp, num_frag))852852+ if (temac_check_tx_bd_space(lp, num_frag + 1))865853 return NETDEV_TX_BUSY;866854867855 netif_wake_queue(ndev);···888876 return NETDEV_TX_OK;889877 }890878 cur_p->phys = cpu_to_be32(skb_dma_addr);891891- ptr_to_txbd((void *)skb, cur_p);892879893880 for (ii = 0; ii < num_frag; ii++) {894881 if (++lp->tx_bd_tail >= lp->tx_bd_num)···926915 }927916 cur_p->app0 |= cpu_to_be32(STS_CTRL_APP0_EOP);928917918918+ /* Mark last fragment with skb address, so it can be consumed919919+ * in temac_start_xmit_done()920920+ */921921+ ptr_to_txbd((void *)skb, cur_p);922922+929923 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail;930924 lp->tx_bd_tail++;931925 if (lp->tx_bd_tail >= lp->tx_bd_num)···941925 /* Kick off the transfer */942926 wmb();943927 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */928928+929929+ if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {930930+ netdev_info(ndev, "%s -> netif_stop_queue\n", __func__);931931+ netif_stop_queue(ndev);932932+ }944933945934 return NETDEV_TX_OK;946935}
+1
drivers/net/hamradio/mkiss.c
···799799 ax->tty = NULL;800800801801 unregister_netdev(ax->dev);802802+ free_netdev(ax->dev);802803}803804804805/* Perform I/O control on an active ax25 channel. */
···826826{827827 int err;828828829829- err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET);829829+ err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART);830830 if (err < 0)831831 return err;832832833833 usleep_range(10, 20);834834835835- /* After reset FORCE_LINK_GOOD bit is set. Although the836836- * default value should be unset. Disable FORCE_LINK_GOOD837837- * for the phy to work properly.838838- */839835 return phy_modify(phydev, MII_DP83867_PHYCTRL,840836 DP83867_PHYCR_FORCE_LINK_GOOD, 0);841837}
···1183118311841184 dev->flags = IFF_MASTER | IFF_NOARP;1185118511861186- /* MTU is irrelevant for VRF device; set to 64k similar to lo */11871187- dev->mtu = 64 * 1024;11881188-11891186 /* similarly, oper state is irrelevant; set to up to avoid confusion */11901187 dev->operstate = IF_OPER_UP;11911188 netdev_lockdep_set_classes(dev);···16821685 * which breaks networking.16831686 */16841687 dev->min_mtu = IPV6_MIN_MTU;16851685- dev->max_mtu = ETH_MAX_MTU;16881688+ dev->max_mtu = IP6_MAX_MTU;16891689+ dev->mtu = dev->max_mtu;16861690}1687169116881692static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],
···514514 udelay(PIO_RETRY_DELAY);515515 }516516517517- dev_err(dev, "config read/write timed out\n");517517+ dev_err(dev, "PIO read/write transfer time out\n");518518 return -ETIMEDOUT;519519}520520···657657 return true;658658}659659660660+static bool advk_pcie_pio_is_running(struct advk_pcie *pcie)661661+{662662+ struct device *dev = &pcie->pdev->dev;663663+664664+ /*665665+ * Trying to start a new PIO transfer when previous has not completed666666+ * cause External Abort on CPU which results in kernel panic:667667+ *668668+ * SError Interrupt on CPU0, code 0xbf000002 -- SError669669+ * Kernel panic - not syncing: Asynchronous SError Interrupt670670+ *671671+ * Functions advk_pcie_rd_conf() and advk_pcie_wr_conf() are protected672672+ * by raw_spin_lock_irqsave() at pci_lock_config() level to prevent673673+ * concurrent calls at the same time. But because PIO transfer may take674674+ * about 1.5s when link is down or card is disconnected, it means that675675+ * advk_pcie_wait_pio() does not always have to wait for completion.676676+ *677677+ * Some versions of ARM Trusted Firmware handles this External Abort at678678+ * EL3 level and mask it to prevent kernel panic. Relevant TF-A commit:679679+ * https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50680680+ */681681+ if (advk_readl(pcie, PIO_START)) {682682+ dev_err(dev, "Previous PIO read/write transfer is still running\n");683683+ return true;684684+ }685685+686686+ return false;687687+}688688+660689static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,661690 int where, int size, u32 *val)662691{···702673 return pci_bridge_emul_conf_read(&pcie->bridge, where,703674 size, val);704675705705- /* Start PIO */706706- advk_writel(pcie, 0, PIO_START);707707- advk_writel(pcie, 1, PIO_ISR);676676+ if (advk_pcie_pio_is_running(pcie)) {677677+ *val = 0xffffffff;678678+ return PCIBIOS_SET_FAILED;679679+ }708680709681 /* Program the control register */710682 reg = advk_readl(pcie, PIO_CTRL);···724694 /* Program the data strobe */725695 advk_writel(pcie, 0xf, PIO_WR_DATA_STRB);726696727727- /* Start the transfer */697697+ /* Clear PIO DONE ISR and start the transfer */698698+ advk_writel(pcie, 1, PIO_ISR);728699 advk_writel(pcie, 1, PIO_START);729700730701 ret = advk_pcie_wait_pio(pcie);···765734 if (where % size)766735 return PCIBIOS_SET_FAILED;767736768768- /* Start PIO */769769- advk_writel(pcie, 0, PIO_START);770770- advk_writel(pcie, 1, PIO_ISR);737737+ if (advk_pcie_pio_is_running(pcie))738738+ return PCIBIOS_SET_FAILED;771739772740 /* Program the control register */773741 reg = advk_readl(pcie, PIO_CTRL);···793763 /* Program the data strobe */794764 advk_writel(pcie, data_strobe, PIO_WR_DATA_STRB);795765796796- /* Start the transfer */766766+ /* Clear PIO DONE ISR and start the transfer */767767+ advk_writel(pcie, 1, PIO_ISR);797768 advk_writel(pcie, 1, PIO_START);798769799770 ret = advk_pcie_wait_pio(pcie);
+2
drivers/pci/of.c
···353353 dev_warn(dev, "More than one I/O resource converted for %pOF. CPU base address for old range lost!\n",354354 dev_node);355355 *io_base = range.cpu_addr;356356+ } else if (resource_type(res) == IORESOURCE_MEM) {357357+ res->flags &= ~IORESOURCE_MEM_64;356358 }357359358360 pci_add_resource_offset(resources, res, res->start - range.pci_addr);
+92-1
drivers/pci/quirks.c
···35473547}3548354835493549/*35503550+ * Some NVIDIA GPU devices do not work with bus reset, SBR needs to be35513551+ * prevented for those affected devices.35523552+ */35533553+static void quirk_nvidia_no_bus_reset(struct pci_dev *dev)35543554+{35553555+ if ((dev->device & 0xffc0) == 0x2340)35563556+ quirk_no_bus_reset(dev);35573557+}35583558+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,35593559+ quirk_nvidia_no_bus_reset);35603560+35613561+/*35503562 * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset.35513563 * The device will throw a Link Down error on AER-capable systems and35523564 * regardless of AER, config space of the device is never accessible again···35773565 * accesses to the child may fail.35783566 */35793567DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CAVIUM, 0xa100, quirk_no_bus_reset);35683568+35693569+/*35703570+ * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS35713571+ * automatically disables LTSSM when Secondary Bus Reset is received and35723572+ * the device stops working. Prevent bus reset for these devices. With35733573+ * this change, the device can be assigned to VMs with VFIO, but it will35743574+ * leak state between VMs. Reference35753575+ * https://e2e.ti.com/support/processors/f/791/t/95438235763576+ */35773577+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0xb005, quirk_no_bus_reset);3580357835813579static void quirk_no_pm_reset(struct pci_dev *dev)35823580{···39233901 return 0;39243902}3925390339043904+#define PCI_DEVICE_ID_HINIC_VF 0x375E39053905+#define HINIC_VF_FLR_TYPE 0x100039063906+#define HINIC_VF_FLR_CAP_BIT (1UL << 30)39073907+#define HINIC_VF_OP 0xE8039083908+#define HINIC_VF_FLR_PROC_BIT (1UL << 18)39093909+#define HINIC_OPERATION_TIMEOUT 15000 /* 15 seconds */39103910+39113911+/* Device-specific reset method for Huawei Intelligent NIC virtual functions */39123912+static int reset_hinic_vf_dev(struct pci_dev *pdev, int probe)39133913+{39143914+ unsigned long timeout;39153915+ void __iomem *bar;39163916+ u32 val;39173917+39183918+ if (probe)39193919+ return 0;39203920+39213921+ bar = pci_iomap(pdev, 0, 0);39223922+ if (!bar)39233923+ return -ENOTTY;39243924+39253925+ /* Get and check firmware capabilities */39263926+ val = ioread32be(bar + HINIC_VF_FLR_TYPE);39273927+ if (!(val & HINIC_VF_FLR_CAP_BIT)) {39283928+ pci_iounmap(pdev, bar);39293929+ return -ENOTTY;39303930+ }39313931+39323932+ /* Set HINIC_VF_FLR_PROC_BIT for the start of FLR */39333933+ val = ioread32be(bar + HINIC_VF_OP);39343934+ val = val | HINIC_VF_FLR_PROC_BIT;39353935+ iowrite32be(val, bar + HINIC_VF_OP);39363936+39373937+ pcie_flr(pdev);39383938+39393939+ /*39403940+ * The device must recapture its Bus and Device Numbers after FLR39413941+ * in order generate Completions. Issue a config write to let the39423942+ * device capture this information.39433943+ */39443944+ pci_write_config_word(pdev, PCI_VENDOR_ID, 0);39453945+39463946+ /* Firmware clears HINIC_VF_FLR_PROC_BIT when reset is complete */39473947+ timeout = jiffies + msecs_to_jiffies(HINIC_OPERATION_TIMEOUT);39483948+ do {39493949+ val = ioread32be(bar + HINIC_VF_OP);39503950+ if (!(val & HINIC_VF_FLR_PROC_BIT))39513951+ goto reset_complete;39523952+ msleep(20);39533953+ } while (time_before(jiffies, timeout));39543954+39553955+ val = ioread32be(bar + HINIC_VF_OP);39563956+ if (!(val & HINIC_VF_FLR_PROC_BIT))39573957+ goto reset_complete;39583958+39593959+ pci_warn(pdev, "Reset dev timeout, FLR ack reg: %#010x\n", val);39603960+39613961+reset_complete:39623962+ pci_iounmap(pdev, bar);39633963+39643964+ return 0;39653965+}39663966+39263967static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {39273968 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF,39283969 reset_intel_82599_sfp_virtfn },···39983913 { PCI_VENDOR_ID_INTEL, 0x0a54, delay_250ms_after_flr },39993914 { PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,40003915 reset_chelsio_generic_dev },39163916+ { PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF,39173917+ reset_hinic_vf_dev },40013918 { 0 }40023919};40033920···48404753 { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs },48414754 { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs },48424755 { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs },47564756+ /* Broadcom multi-function device */47574757+ { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs },48434758 { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs },48444759 /* Amazon Annapurna Labs */48454760 { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs },···52435154static void quirk_amd_harvest_no_ats(struct pci_dev *pdev)52445155{52455156 if ((pdev->device == 0x7312 && pdev->revision != 0x00) ||52465246- (pdev->device == 0x7340 && pdev->revision != 0xc5))51575157+ (pdev->device == 0x7340 && pdev->revision != 0xc5) ||51585158+ (pdev->device == 0x7341 && pdev->revision != 0x00))52475159 return;5248516052495161 if (pdev->device == 0x15d8) {···52715181DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7312, quirk_amd_harvest_no_ats);52725182/* AMD Navi14 dGPU */52735183DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7340, quirk_amd_harvest_no_ats);51845184+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7341, quirk_amd_harvest_no_ats);52745185/* AMD Raven platform iGPU */52755186DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x15d8, quirk_amd_harvest_no_ats);52765187#endif /* CONFIG_PCI_ATS */
+3-3
drivers/ptp/ptp_clock.c
···6363 spin_unlock_irqrestore(&queue->lock, flags);6464}65656666-s32 scaled_ppm_to_ppb(long ppm)6666+long scaled_ppm_to_ppb(long ppm)6767{6868 /*6969 * The 'freq' field in the 'struct timex' is in parts per···8080 s64 ppb = 1 + ppm;8181 ppb *= 125;8282 ppb >>= 13;8383- return (s32) ppb;8383+ return (long) ppb;8484}8585EXPORT_SYMBOL(scaled_ppm_to_ppb);8686···138138 delta = ktime_to_ns(kt);139139 err = ops->adjtime(ops, delta);140140 } else if (tx->modes & ADJ_FREQUENCY) {141141- s32 ppb = scaled_ppm_to_ppb(tx->freq);141141+ long ppb = scaled_ppm_to_ppb(tx->freq);142142 if (ppb > ops->max_adj || ppb < -ops->max_adj)143143 return -ERANGE;144144 if (ops->adjfine)
+9-2
drivers/s390/crypto/ap_queue.c
···135135{136136 struct ap_queue_status status;137137 struct ap_message *ap_msg;138138+ bool found = false;138139139140 status = ap_dqap(aq->qid, &aq->reply->psmid,140141 aq->reply->msg, aq->reply->len);141142 switch (status.response_code) {142143 case AP_RESPONSE_NORMAL:143143- aq->queue_count--;144144+ aq->queue_count = max_t(int, 0, aq->queue_count - 1);144145 if (aq->queue_count > 0)145146 mod_timer(&aq->timeout,146147 jiffies + aq->request_timeout);···151150 list_del_init(&ap_msg->list);152151 aq->pendingq_count--;153152 ap_msg->receive(aq, ap_msg, aq->reply);153153+ found = true;154154 break;155155+ }156156+ if (!found) {157157+ AP_DBF_WARN("%s unassociated reply psmid=0x%016llx on 0x%02x.%04x\n",158158+ __func__, aq->reply->psmid,159159+ AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid));155160 }156161 fallthrough;157162 case AP_RESPONSE_NO_PENDING_REPLY:···239232 ap_msg->flags & AP_MSG_FLAG_SPECIAL);240233 switch (status.response_code) {241234 case AP_RESPONSE_NORMAL:242242- aq->queue_count++;235235+ aq->queue_count = max_t(int, 1, aq->queue_count + 1);243236 if (aq->queue_count == 1)244237 mod_timer(&aq->timeout, jiffies + aq->request_timeout);245238 list_move_tail(&ap_msg->list, &aq->pendingq);
+2-2
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
···22842284 mon_wdev->iftype = NL80211_IFTYPE_MONITOR;22852285 mon_ndev->ieee80211_ptr = mon_wdev;2286228622872287- ret = register_netdevice(mon_ndev);22872287+ ret = cfg80211_register_netdevice(mon_ndev);22882288 if (ret) {22892289 goto out;22902290 }···23602360 adapter = rtw_netdev_priv(ndev);23612361 pwdev_priv = adapter_wdev_data(adapter);2362236223632363- unregister_netdevice(ndev);23632363+ cfg80211_unregister_netdevice(ndev);2364236423652365 if (ndev == pwdev_priv->pmon_ndev) {23662366 pwdev_priv->pmon_ndev = NULL;
+14-2
drivers/usb/chipidea/usbmisc_imx.c
···686686 int val;687687 unsigned long flags;688688689689+ /* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */690690+ spin_lock_irqsave(&usbmisc->lock, flags);691691+ val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);692692+ val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0;693693+ writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2);694694+ spin_unlock_irqrestore(&usbmisc->lock, flags);695695+696696+ /* TVDMSRC_DIS */697697+ msleep(20);698698+689699 /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */690700 spin_lock_irqsave(&usbmisc->lock, flags);691701 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);···705695 usbmisc->base + MX7D_USB_OTG_PHY_CFG2);706696 spin_unlock_irqrestore(&usbmisc->lock, flags);707697708708- usleep_range(1000, 2000);698698+ /* TVDMSRC_ON */699699+ msleep(40);709700710701 /*711702 * Per BC 1.2, check voltage of D+:···809798 usbmisc->base + MX7D_USB_OTG_PHY_CFG2);810799 spin_unlock_irqrestore(&usbmisc->lock, flags);811800812812- usleep_range(1000, 2000);801801+ /* TVDPSRC_ON */802802+ msleep(40);813803814804 /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */815805 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);
···203203 goto error_fs;204204205205 afs_proc_symlink = proc_symlink("fs/afs", NULL, "../self/net/afs");206206- if (IS_ERR(afs_proc_symlink)) {207207- ret = PTR_ERR(afs_proc_symlink);206206+ if (!afs_proc_symlink) {207207+ ret = -ENOMEM;208208 goto error_proc;209209 }210210
+8-5
fs/afs/write.c
···837837 struct inode *inode = file_inode(file);838838 struct afs_vnode *vnode = AFS_FS_I(inode);839839 unsigned long priv;840840+ vm_fault_t ret = VM_FAULT_RETRY;840841841842 _enter("{{%llx:%llu}},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index);842843···849848#ifdef CONFIG_AFS_FSCACHE850849 if (PageFsCache(page) &&851850 wait_on_page_fscache_killable(page) < 0)852852- return VM_FAULT_RETRY;851851+ goto out;853852#endif854853855854 if (wait_on_page_writeback_killable(page))856856- return VM_FAULT_RETRY;855855+ goto out;857856858857 if (lock_page_killable(page) < 0)859859- return VM_FAULT_RETRY;858858+ goto out;860859861860 /* We mustn't change page->private until writeback is complete as that862861 * details the portion of the page we need to write back and we might···864863 */865864 if (wait_on_page_writeback_killable(page) < 0) {866865 unlock_page(page);867867- return VM_FAULT_RETRY;866866+ goto out;868867 }869868870869 priv = afs_page_dirty(page, 0, thp_size(page));···878877 }879878 file_update_time(file);880879880880+ ret = VM_FAULT_LOCKED;881881+out:881882 sb_end_pagefault(inode->i_sb);882882- return VM_FAULT_LOCKED;883883+ return ret;883884}884885885886/*
···17191719 struct address_space *check_mapping; /* Check page->mapping if set */17201720 pgoff_t first_index; /* Lowest page->index to unmap */17211721 pgoff_t last_index; /* Highest page->index to unmap */17221722+ struct page *single_page; /* Locked page to be unmapped */17221723};1723172417241725struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,···17671766extern int fixup_user_fault(struct mm_struct *mm,17681767 unsigned long address, unsigned int fault_flags,17691768 bool *unlocked);17691769+void unmap_mapping_page(struct page *page);17701770void unmap_mapping_pages(struct address_space *mapping,17711771 pgoff_t start, pgoff_t nr, bool even_cows);17721772void unmap_mapping_range(struct address_space *mapping,···17881786 BUG();17891787 return -EFAULT;17901788}17891789+static inline void unmap_mapping_page(struct page *page) { }17911790static inline void unmap_mapping_pages(struct address_space *mapping,17921791 pgoff_t start, pgoff_t nr, bool even_cows) { }17931792static inline void unmap_mapping_range(struct address_space *mapping,
+1-1
include/linux/ptp_clock_kernel.h
···235235 * @ppm: Parts per million, but with a 16 bit binary fractional field236236 */237237238238-extern s32 scaled_ppm_to_ppb(long ppm);238238+extern long scaled_ppm_to_ppb(long ppm);239239240240/**241241 * ptp_find_pin() - obtain the pin index of a given auxiliary function
+1
include/linux/rmap.h
···91919292 TTU_SPLIT_HUGE_PMD = 0x4, /* split huge PMD if any */9393 TTU_IGNORE_MLOCK = 0x8, /* ignore mlock */9494+ TTU_SYNC = 0x10, /* avoid racy checks with PVMW_SYNC */9495 TTU_IGNORE_HWPOISON = 0x20, /* corrupted page is recoverable */9596 TTU_BATCH_FLUSH = 0x40, /* Batch TLB flushes where possible9697 * and caller guarantees they will
-2
include/linux/socket.h
···438438 int __user *usockvec);439439extern int __sys_shutdown_sock(struct socket *sock, int how);440440extern int __sys_shutdown(int fd, int how);441441-442442-extern struct ns_common *get_net_ns(struct ns_common *ns);443441#endif /* _LINUX_SOCKET_H */
+11-4
include/linux/swapops.h
···2323#define SWP_TYPE_SHIFT (BITS_PER_XA_VALUE - MAX_SWAPFILES_SHIFT)2424#define SWP_OFFSET_MASK ((1UL << SWP_TYPE_SHIFT) - 1)25252626+/* Clear all flags but only keep swp_entry_t related information */2727+static inline pte_t pte_swp_clear_flags(pte_t pte)2828+{2929+ if (pte_swp_soft_dirty(pte))3030+ pte = pte_swp_clear_soft_dirty(pte);3131+ if (pte_swp_uffd_wp(pte))3232+ pte = pte_swp_clear_uffd_wp(pte);3333+ return pte;3434+}3535+2636/*2737 * Store a type+offset into a swp_entry_t in an arch-independent format2838 */···7666{7767 swp_entry_t arch_entry;78687979- if (pte_swp_soft_dirty(pte))8080- pte = pte_swp_clear_soft_dirty(pte);8181- if (pte_swp_uffd_wp(pte))8282- pte = pte_swp_clear_uffd_wp(pte);6969+ pte = pte_swp_clear_flags(pte);8370 arch_entry = __pte_to_swp_entry(pte);8471 return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));8572}
+7-2
include/net/mac80211.h
···55375537 *55385538 * This function iterates over the interfaces associated with a given55395539 * hardware that are currently active and calls the callback for them.55405540- * This version can only be used while holding the RTNL.55405540+ * This version can only be used while holding the wiphy mutex.55415541 *55425542 * @hw: the hardware struct of which the interfaces should be iterated over55435543 * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags···6392639263936393/**63946394 * ieee80211_parse_tx_radiotap - Sanity-check and parse the radiotap header63956395- * of injected frames63956395+ * of injected frames.63966396+ *63976397+ * To accurately parse and take into account rate and retransmission fields,63986398+ * you must initialize the chandef field in the ieee80211_tx_info structure63996399+ * of the skb before calling this function.64006400+ *63966401 * @skb: packet injected by userspace63976402 * @dev: the &struct device of this 802.11 device63986403 */
···1934193419351935static inline void sk_set_txhash(struct sock *sk)19361936{19371937- sk->sk_txhash = net_tx_rndhash();19371937+ /* This pairs with READ_ONCE() in skb_set_hash_from_sk() */19381938+ WRITE_ONCE(sk->sk_txhash, net_tx_rndhash());19381939}1939194019401941static inline bool sk_rethink_txhash(struct sock *sk)···2207220622082207static inline void skb_set_hash_from_sk(struct sk_buff *skb, struct sock *sk)22092208{22102210- if (sk->sk_txhash) {22092209+ /* This pairs with WRITE_ONCE() in sk_set_txhash() */22102210+ u32 txhash = READ_ONCE(sk->sk_txhash);22112211+22122212+ if (txhash) {22112213 skb->l4_hash = 1;22122212- skb->hash = sk->sk_txhash;22142214+ skb->hash = txhash;22132215 }22142216}22152217···22702266static inline int sock_error(struct sock *sk)22712267{22722268 int err;22732273- if (likely(!sk->sk_err))22692269+22702270+ /* Avoid an atomic operation for the common case.22712271+ * This is racy since another cpu/thread can change sk_err under us.22722272+ */22732273+ if (likely(data_race(!sk->sk_err)))22742274 return 0;22752275+22752276 err = xchg(&sk->sk_err, 0);22762277 return -err;22772278}
+1-2
include/uapi/asm-generic/unistd.h
···863863__SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2)864864#define __NR_mount_setattr 442865865__SYSCALL(__NR_mount_setattr, sys_mount_setattr)866866-#define __NR_quotactl_path 443867867-__SYSCALL(__NR_quotactl_path, sys_quotactl_path)866866+/* 443 is reserved for quotactl_path */868867869868#define __NR_landlock_create_ruleset 444870869__SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset)
+3
include/uapi/linux/in.h
···289289/* Address indicating an error return. */290290#define INADDR_NONE ((unsigned long int) 0xffffffff)291291292292+/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */293293+#define INADDR_DUMMY ((unsigned long int) 0xc0000008)294294+292295/* Network number for local host loopback. */293296#define IN_LOOPBACKNET 127294297
+61-7
kernel/bpf/verifier.c
···64836483 bool mask_to_left;64846484};6485648564866486+static struct bpf_verifier_state *64876487+sanitize_speculative_path(struct bpf_verifier_env *env,64886488+ const struct bpf_insn *insn,64896489+ u32 next_idx, u32 curr_idx)64906490+{64916491+ struct bpf_verifier_state *branch;64926492+ struct bpf_reg_state *regs;64936493+64946494+ branch = push_stack(env, next_idx, curr_idx, true);64956495+ if (branch && insn) {64966496+ regs = branch->frame[branch->curframe]->regs;64976497+ if (BPF_SRC(insn->code) == BPF_K) {64986498+ mark_reg_unknown(env, regs, insn->dst_reg);64996499+ } else if (BPF_SRC(insn->code) == BPF_X) {65006500+ mark_reg_unknown(env, regs, insn->dst_reg);65016501+ mark_reg_unknown(env, regs, insn->src_reg);65026502+ }65036503+ }65046504+ return branch;65056505+}65066506+64866507static int sanitize_ptr_alu(struct bpf_verifier_env *env,64876508 struct bpf_insn *insn,64886509 const struct bpf_reg_state *ptr_reg,···65876566 tmp = *dst_reg;65886567 *dst_reg = *ptr_reg;65896568 }65906590- ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true);65696569+ ret = sanitize_speculative_path(env, NULL, env->insn_idx + 1,65706570+ env->insn_idx);65916571 if (!ptr_is_dst_reg && ret)65926572 *dst_reg = tmp;65936573 return !ret ? REASON_STACK : 0;65746574+}65756575+65766576+static void sanitize_mark_insn_seen(struct bpf_verifier_env *env)65776577+{65786578+ struct bpf_verifier_state *vstate = env->cur_state;65796579+65806580+ /* If we simulate paths under speculation, we don't update the65816581+ * insn as 'seen' such that when we verify unreachable paths in65826582+ * the non-speculative domain, sanitize_dead_code() can still65836583+ * rewrite/sanitize them.65846584+ */65856585+ if (!vstate->speculative)65866586+ env->insn_aux_data[env->insn_idx].seen = env->pass_cnt;65946587}6595658865966589static int sanitize_err(struct bpf_verifier_env *env,···87858750 if (err)87868751 return err;87878752 }87538753+87888754 if (pred == 1) {87898789- /* only follow the goto, ignore fall-through */87558755+ /* Only follow the goto, ignore fall-through. If needed, push87568756+ * the fall-through branch for simulation under speculative87578757+ * execution.87588758+ */87598759+ if (!env->bypass_spec_v1 &&87608760+ !sanitize_speculative_path(env, insn, *insn_idx + 1,87618761+ *insn_idx))87628762+ return -EFAULT;87908763 *insn_idx += insn->off;87918764 return 0;87928765 } else if (pred == 0) {87938793- /* only follow fall-through branch, since87948794- * that's where the program will go87668766+ /* Only follow the fall-through branch, since that's where the87678767+ * program will go. If needed, push the goto branch for87688768+ * simulation under speculative execution.87958769 */87708770+ if (!env->bypass_spec_v1 &&87718771+ !sanitize_speculative_path(env, insn,87728772+ *insn_idx + insn->off + 1,87738773+ *insn_idx))87748774+ return -EFAULT;87968775 return 0;87978776 }87988777···1067910630 }10680106311068110632 regs = cur_regs(env);1068210682- env->insn_aux_data[env->insn_idx].seen = env->pass_cnt;1063310633+ sanitize_mark_insn_seen(env);1068310634 prev_insn_idx = env->insn_idx;10684106351068510636 if (class == BPF_ALU || class == BPF_ALU64) {···1090610857 return err;10907108581090810859 env->insn_idx++;1090910909- env->insn_aux_data[env->insn_idx].seen = env->pass_cnt;1086010860+ sanitize_mark_insn_seen(env);1091010861 } else {1091110862 verbose(env, "invalid BPF_LD mode\n");1091210863 return -EINVAL;···1141511366{1141611367 struct bpf_insn_aux_data *new_data, *old_data = env->insn_aux_data;1141711368 struct bpf_insn *insn = new_prog->insnsi;1136911369+ u32 old_seen = old_data[off].seen;1141811370 u32 prog_len;1141911371 int i;1142011372···1143611386 memcpy(new_data + off + cnt - 1, old_data + off,1143711387 sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));1143811388 for (i = off; i < off + cnt - 1; i++) {1143911439- new_data[i].seen = env->pass_cnt;1138911389+ /* Expand insni[off]'s seen count to the patched range. */1139011390+ new_data[i].seen = old_seen;1144011391 new_data[i].zext_dst = insn_has_def32(env, insn + i);1144111392 }1144211393 env->insn_aux_data = new_data;···1276112710 * insn_aux_data was touched. These variables are compared to clear temporary1276212711 * data from failed pass. For testing and experiments do_check_common() can be1276312712 * run multiple times even when prior attempt to verify is unsuccessful.1271312713+ *1271412714+ * Note that special handling is needed on !env->bypass_spec_v1 if this is1271512715+ * ever called outside of error path with subsequent program rejection.1276412716 */1276512717static void sanitize_insn_aux_data(struct bpf_verifier_env *env)1276612718{
···391391 /* No obstacles. */392392 return vprintk_default(fmt, args);393393}394394+EXPORT_SYMBOL(vprintk);394395395396void __init printk_safe_init(void)396397{···412411 /* Flush pending messages that did not have scheduled IRQ works. */413412 printk_safe_flush();414413}415415-EXPORT_SYMBOL(vprintk);
-1
kernel/sched/core.c
···63896389{63906390 return __sched_setscheduler(p, attr, false, true);63916391}63926392-EXPORT_SYMBOL_GPL(sched_setattr_nocheck);6393639263946393/**63956394 * sched_setscheduler_nocheck - change the scheduling policy and/or RT priority of a thread from kernelspace.
+25-19
kernel/sched/fair.c
···3298329832993299#ifdef CONFIG_SMP33003300#ifdef CONFIG_FAIR_GROUP_SCHED33013301+33023302+static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)33033303+{33043304+ if (cfs_rq->load.weight)33053305+ return false;33063306+33073307+ if (cfs_rq->avg.load_sum)33083308+ return false;33093309+33103310+ if (cfs_rq->avg.util_sum)33113311+ return false;33123312+33133313+ if (cfs_rq->avg.runnable_sum)33143314+ return false;33153315+33163316+ return true;33173317+}33183318+33013319/**33023320 * update_tg_load_avg - update the tg's load avg33033321 * @cfs_rq: the cfs_rq whose avg changed···4109409141104092#else /* CONFIG_SMP */4111409340944094+static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)40954095+{40964096+ return true;40974097+}40984098+41124099#define UPDATE_TG 0x041134100#define SKIP_AGE_LOAD 0x041144101#define DO_ATTACH 0x0···47724749 cfs_rq->throttled_clock_task_time += rq_clock_task(rq) -47734750 cfs_rq->throttled_clock_task;4774475147754775- /* Add cfs_rq with already running entity in the list */47764776- if (cfs_rq->nr_running >= 1)47524752+ /* Add cfs_rq with load or one or more already running entities to the list */47534753+ if (!cfs_rq_is_decayed(cfs_rq) || cfs_rq->nr_running)47774754 list_add_leaf_cfs_rq(cfs_rq);47784755 }47794756···80187995}8019799680207997#ifdef CONFIG_FAIR_GROUP_SCHED80218021-80228022-static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)80238023-{80248024- if (cfs_rq->load.weight)80258025- return false;80268026-80278027- if (cfs_rq->avg.load_sum)80288028- return false;80298029-80308030- if (cfs_rq->avg.util_sum)80318031- return false;80328032-80338033- if (cfs_rq->avg.runnable_sum)80348034- return false;80358035-80368036- return true;80378037-}8038799880397999static bool __update_blocked_fair(struct rq *rq, bool *done)80408000{
-11
kernel/trace/trace.c
···21982198};21992199static struct saved_cmdlines_buffer *savedcmd;2200220022012201-/* temporary disable recording */22022202-static atomic_t trace_record_taskinfo_disabled __read_mostly;22032203-22042201static inline char *get_saved_cmdlines(int idx)22052202{22062203 return &savedcmd->saved_cmdlines[idx * TASK_COMM_LEN];···24822485static bool tracing_record_taskinfo_skip(int flags)24832486{24842487 if (unlikely(!(flags & (TRACE_RECORD_CMDLINE | TRACE_RECORD_TGID))))24852485- return true;24862486- if (atomic_read(&trace_record_taskinfo_disabled) || !tracing_is_on())24872488 return true;24882489 if (!__this_cpu_read(trace_taskinfo_save))24892490 return true;···39933998 return ERR_PTR(-EBUSY);39943999#endif3995400039963996- if (!iter->snapshot)39973997- atomic_inc(&trace_record_taskinfo_disabled);39983998-39994001 if (*pos != iter->pos) {40004002 iter->ent = NULL;40014003 iter->cpu = 0;···40344042 if (iter->snapshot && iter->trace->use_max_tr)40354043 return;40364044#endif40374037-40384038- if (!iter->snapshot)40394039- atomic_dec(&trace_record_taskinfo_disabled);4040404540414046 trace_access_unlock(iter->cpu_file);40424047 trace_event_read_unlock();
+3-3
kernel/trace/trace_clock.c
···115115 prev_time = READ_ONCE(trace_clock_struct.prev_time);116116 now = sched_clock_cpu(this_cpu);117117118118- /* Make sure that now is always greater than prev_time */118118+ /* Make sure that now is always greater than or equal to prev_time */119119 if ((s64)(now - prev_time) < 0)120120- now = prev_time + 1;120120+ now = prev_time;121121122122 /*123123 * If in an NMI context then dont risk lockups and simply return···131131 /* Reread prev_time in case it was already updated */132132 prev_time = READ_ONCE(trace_clock_struct.prev_time);133133 if ((s64)(now - prev_time) < 0)134134- now = prev_time + 1;134134+ now = prev_time;135135136136 trace_clock_struct.prev_time = now;137137
+29-27
mm/huge_memory.c
···62626363static atomic_t huge_zero_refcount;6464struct page *huge_zero_page __read_mostly;6565+unsigned long huge_zero_pfn __read_mostly = ~0UL;65666667bool transparent_hugepage_enabled(struct vm_area_struct *vma)6768{···9998 __free_pages(zero_page, compound_order(zero_page));10099 goto retry;101100 }101101+ WRITE_ONCE(huge_zero_pfn, page_to_pfn(zero_page));102102103103 /* We take additional reference here. It will be put back by shrinker */104104 atomic_set(&huge_zero_refcount, 2);···149147 if (atomic_cmpxchg(&huge_zero_refcount, 1, 0) == 1) {150148 struct page *zero_page = xchg(&huge_zero_page, NULL);151149 BUG_ON(zero_page == NULL);150150+ WRITE_ONCE(huge_zero_pfn, ~0UL);152151 __free_pages(zero_page, compound_order(zero_page));153152 return HPAGE_PMD_NR;154153 }···20472044 count_vm_event(THP_SPLIT_PMD);2048204520492046 if (!vma_is_anonymous(vma)) {20502050- _pmd = pmdp_huge_clear_flush_notify(vma, haddr, pmd);20472047+ old_pmd = pmdp_huge_clear_flush_notify(vma, haddr, pmd);20512048 /*20522049 * We are going to unmap this huge page. So20532050 * just go ahead and zap it···20562053 zap_deposited_table(mm, pmd);20572054 if (vma_is_special_huge(vma))20582055 return;20592059- page = pmd_page(_pmd);20602060- if (!PageDirty(page) && pmd_dirty(_pmd))20612061- set_page_dirty(page);20622062- if (!PageReferenced(page) && pmd_young(_pmd))20632063- SetPageReferenced(page);20642064- page_remove_rmap(page, true);20652065- put_page(page);20562056+ if (unlikely(is_pmd_migration_entry(old_pmd))) {20572057+ swp_entry_t entry;20582058+20592059+ entry = pmd_to_swp_entry(old_pmd);20602060+ page = migration_entry_to_page(entry);20612061+ } else {20622062+ page = pmd_page(old_pmd);20632063+ if (!PageDirty(page) && pmd_dirty(old_pmd))20642064+ set_page_dirty(page);20652065+ if (!PageReferenced(page) && pmd_young(old_pmd))20662066+ SetPageReferenced(page);20672067+ page_remove_rmap(page, true);20682068+ put_page(page);20692069+ }20662070 add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR);20672071 return;20682068- } else if (pmd_trans_huge(*pmd) && is_huge_zero_pmd(*pmd)) {20722072+ }20732073+20742074+ if (is_huge_zero_pmd(*pmd)) {20692075 /*20702076 * FIXME: Do we want to invalidate secondary mmu by calling20712077 * mmu_notifier_invalidate_range() see comments below inside···2350233823512339static void unmap_page(struct page *page)23522340{23532353- enum ttu_flags ttu_flags = TTU_IGNORE_MLOCK |23412341+ enum ttu_flags ttu_flags = TTU_IGNORE_MLOCK | TTU_SYNC |23542342 TTU_RMAP_LOCKED | TTU_SPLIT_HUGE_PMD;23552355- bool unmap_success;2356234323572344 VM_BUG_ON_PAGE(!PageHead(page), page);2358234523592346 if (PageAnon(page))23602347 ttu_flags |= TTU_SPLIT_FREEZE;2361234823622362- unmap_success = try_to_unmap(page, ttu_flags);23632363- VM_BUG_ON_PAGE(!unmap_success, page);23492349+ try_to_unmap(page, ttu_flags);23502350+23512351+ VM_WARN_ON_ONCE_PAGE(page_mapped(page), page);23642352}2365235323662354static void remap_page(struct page *page, unsigned int nr)···26712659 struct deferred_split *ds_queue = get_deferred_split_queue(head);26722660 struct anon_vma *anon_vma = NULL;26732661 struct address_space *mapping = NULL;26742674- int count, mapcount, extra_pins, ret;26622662+ int extra_pins, ret;26752663 pgoff_t end;2676266426772665 VM_BUG_ON_PAGE(is_huge_zero_page(head), head);···27302718 }2731271927322720 unmap_page(head);27332733- VM_BUG_ON_PAGE(compound_mapcount(head), head);2734272127352722 /* block interrupt reentry in xa_lock and spinlock */27362723 local_irq_disable();···2747273627482737 /* Prevent deferred_split_scan() touching ->_refcount */27492738 spin_lock(&ds_queue->split_queue_lock);27502750- count = page_count(head);27512751- mapcount = total_mapcount(head);27522752- if (!mapcount && page_ref_freeze(head, 1 + extra_pins)) {27392739+ if (page_ref_freeze(head, 1 + extra_pins)) {27532740 if (!list_empty(page_deferred_list(head))) {27542741 ds_queue->split_queue_len--;27552742 list_del(page_deferred_list(head));···27672758 __split_huge_page(page, list, end);27682759 ret = 0;27692760 } else {27702770- if (IS_ENABLED(CONFIG_DEBUG_VM) && mapcount) {27712771- pr_alert("total_mapcount: %u, page_count(): %u\n",27722772- mapcount, count);27732773- if (PageTail(page))27742774- dump_page(head, NULL);27752775- dump_page(page, "total_mapcount(head) > 0");27762776- BUG();27772777- }27782761 spin_unlock(&ds_queue->split_queue_lock);27792779-fail: if (mapping)27622762+fail:27632763+ if (mapping)27802764 xa_unlock(&mapping->i_pages);27812765 local_irq_enable();27822766 remap_page(head, thp_nr_pages(head));
+116-27
mm/hugetlb.c
···21212121 * be restored when a newly allocated huge page must be freed. It is21222122 * to be called after calling vma_needs_reservation to determine if a21232123 * reservation exists.21242124+ *21252125+ * vma_del_reservation is used in error paths where an entry in the reserve21262126+ * map was created during huge page allocation and must be removed. It is to21272127+ * be called after calling vma_needs_reservation to determine if a reservation21282128+ * exists.21242129 */21252130enum vma_resv_mode {21262131 VMA_NEEDS_RESV,21272132 VMA_COMMIT_RESV,21282133 VMA_END_RESV,21292134 VMA_ADD_RESV,21352135+ VMA_DEL_RESV,21302136};21312137static long __vma_reservation_common(struct hstate *h,21322138 struct vm_area_struct *vma, unsigned long addr,···21762170 ret = region_del(resv, idx, idx + 1);21772171 }21782172 break;21732173+ case VMA_DEL_RESV:21742174+ if (vma->vm_flags & VM_MAYSHARE) {21752175+ region_abort(resv, idx, idx + 1, 1);21762176+ ret = region_del(resv, idx, idx + 1);21772177+ } else {21782178+ ret = region_add(resv, idx, idx + 1, 1, NULL, NULL);21792179+ /* region_add calls of range 1 should never fail. */21802180+ VM_BUG_ON(ret < 0);21812181+ }21822182+ break;21792183 default:21802184 BUG();21812185 }2182218621832183- if (vma->vm_flags & VM_MAYSHARE)21872187+ if (vma->vm_flags & VM_MAYSHARE || mode == VMA_DEL_RESV)21842188 return ret;21852189 /*21862190 * We know private mapping must have HPAGE_RESV_OWNER set.···22382222 return __vma_reservation_common(h, vma, addr, VMA_ADD_RESV);22392223}2240222422412241-/*22422242- * This routine is called to restore a reservation on error paths. In the22432243- * specific error paths, a huge page was allocated (via alloc_huge_page)22442244- * and is about to be freed. If a reservation for the page existed,22452245- * alloc_huge_page would have consumed the reservation and set22462246- * HPageRestoreReserve in the newly allocated page. When the page is freed22472247- * via free_huge_page, the global reservation count will be incremented if22482248- * HPageRestoreReserve is set. However, free_huge_page can not adjust the22492249- * reserve map. Adjust the reserve map here to be consistent with global22502250- * reserve count adjustments to be made by free_huge_page.22512251- */22522252-static void restore_reserve_on_error(struct hstate *h,22532253- struct vm_area_struct *vma, unsigned long address,22542254- struct page *page)22252225+static long vma_del_reservation(struct hstate *h,22262226+ struct vm_area_struct *vma, unsigned long addr)22552227{22562256- if (unlikely(HPageRestoreReserve(page))) {22572257- long rc = vma_needs_reservation(h, vma, address);22282228+ return __vma_reservation_common(h, vma, addr, VMA_DEL_RESV);22292229+}2258223022592259- if (unlikely(rc < 0)) {22312231+/*22322232+ * This routine is called to restore reservation information on error paths.22332233+ * It should ONLY be called for pages allocated via alloc_huge_page(), and22342234+ * the hugetlb mutex should remain held when calling this routine.22352235+ *22362236+ * It handles two specific cases:22372237+ * 1) A reservation was in place and the page consumed the reservation.22382238+ * HPageRestoreReserve is set in the page.22392239+ * 2) No reservation was in place for the page, so HPageRestoreReserve is22402240+ * not set. However, alloc_huge_page always updates the reserve map.22412241+ *22422242+ * In case 1, free_huge_page later in the error path will increment the22432243+ * global reserve count. But, free_huge_page does not have enough context22442244+ * to adjust the reservation map. This case deals primarily with private22452245+ * mappings. Adjust the reserve map here to be consistent with global22462246+ * reserve count adjustments to be made by free_huge_page. Make sure the22472247+ * reserve map indicates there is a reservation present.22482248+ *22492249+ * In case 2, simply undo reserve map modifications done by alloc_huge_page.22502250+ */22512251+void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,22522252+ unsigned long address, struct page *page)22532253+{22542254+ long rc = vma_needs_reservation(h, vma, address);22552255+22562256+ if (HPageRestoreReserve(page)) {22572257+ if (unlikely(rc < 0))22602258 /*22612259 * Rare out of memory condition in reserve map22622260 * manipulation. Clear HPageRestoreReserve so that···22832253 * accounting of reserve counts.22842254 */22852255 ClearHPageRestoreReserve(page);22862286- } else if (rc) {22872287- rc = vma_add_reservation(h, vma, address);22882288- if (unlikely(rc < 0))22892289- /*22902290- * See above comment about rare out of22912291- * memory condition.22922292- */22932293- ClearHPageRestoreReserve(page);22942294- } else22562256+ else if (rc)22572257+ (void)vma_add_reservation(h, vma, address);22582258+ else22952259 vma_end_reservation(h, vma, address);22602260+ } else {22612261+ if (!rc) {22622262+ /*22632263+ * This indicates there is an entry in the reserve map22642264+ * added by alloc_huge_page. We know it was added22652265+ * before the alloc_huge_page call, otherwise22662266+ * HPageRestoreReserve would be set on the page.22672267+ * Remove the entry so that a subsequent allocation22682268+ * does not consume a reservation.22692269+ */22702270+ rc = vma_del_reservation(h, vma, address);22712271+ if (rc < 0)22722272+ /*22732273+ * VERY rare out of memory condition. Since22742274+ * we can not delete the entry, set22752275+ * HPageRestoreReserve so that the reserve22762276+ * count will be incremented when the page22772277+ * is freed. This reserve will be consumed22782278+ * on a subsequent allocation.22792279+ */22802280+ SetHPageRestoreReserve(page);22812281+ } else if (rc < 0) {22822282+ /*22832283+ * Rare out of memory condition from22842284+ * vma_needs_reservation call. Memory allocation is22852285+ * only attempted if a new entry is needed. Therefore,22862286+ * this implies there is not an entry in the22872287+ * reserve map.22882288+ *22892289+ * For shared mappings, no entry in the map indicates22902290+ * no reservation. We are done.22912291+ */22922292+ if (!(vma->vm_flags & VM_MAYSHARE))22932293+ /*22942294+ * For private mappings, no entry indicates22952295+ * a reservation is present. Since we can22962296+ * not add an entry, set SetHPageRestoreReserve22972297+ * on the page so reserve count will be22982298+ * incremented when freed. This reserve will22992299+ * be consumed on a subsequent allocation.23002300+ */23012301+ SetHPageRestoreReserve(page);23022302+ } else23032303+ /*23042304+ * No reservation present, do nothing23052305+ */23062306+ vma_end_reservation(h, vma, address);22962307 }22972308}22982309···41084037 spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);41094038 entry = huge_ptep_get(src_pte);41104039 if (!pte_same(src_pte_old, entry)) {40404040+ restore_reserve_on_error(h, vma, addr,40414041+ new);41114042 put_page(new);41124043 /* dst_entry won't change as in child */41134044 goto again;···50795006 if (vm_shared || is_continue)50805007 unlock_page(page);50815008out_release_nounlock:50095009+ restore_reserve_on_error(h, dst_vma, dst_addr, page);50825010 put_page(page);50835011 goto out;50845012}···59275853 ClearHPageMigratable(page);59285854 list_move_tail(&page->lru, list);59295855unlock:58565856+ spin_unlock_irq(&hugetlb_lock);58575857+ return ret;58585858+}58595859+58605860+int get_hwpoison_huge_page(struct page *page, bool *hugetlb)58615861+{58625862+ int ret = 0;58635863+58645864+ *hugetlb = false;58655865+ spin_lock_irq(&hugetlb_lock);58665866+ if (PageHeadHuge(page)) {58675867+ *hugetlb = true;58685868+ if (HPageFreed(page) || HPageMigratable(page))58695869+ ret = get_page_unless_zero(page);58705870+ }59305871 spin_unlock_irq(&hugetlb_lock);59315872 return ret;59325873}
+39-14
mm/internal.h
···384384extern pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);385385386386/*387387- * At what user virtual address is page expected in @vma?387387+ * At what user virtual address is page expected in vma?388388+ * Returns -EFAULT if all of the page is outside the range of vma.389389+ * If page is a compound head, the entire compound page is considered.388390 */389389-static inline unsigned long390390-__vma_address(struct page *page, struct vm_area_struct *vma)391391-{392392- pgoff_t pgoff = page_to_pgoff(page);393393- return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);394394-}395395-396391static inline unsigned long397392vma_address(struct page *page, struct vm_area_struct *vma)398393{399399- unsigned long start, end;394394+ pgoff_t pgoff;395395+ unsigned long address;400396401401- start = __vma_address(page, vma);402402- end = start + thp_size(page) - PAGE_SIZE;397397+ VM_BUG_ON_PAGE(PageKsm(page), page); /* KSM page->index unusable */398398+ pgoff = page_to_pgoff(page);399399+ if (pgoff >= vma->vm_pgoff) {400400+ address = vma->vm_start +401401+ ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);402402+ /* Check for address beyond vma (or wrapped through 0?) */403403+ if (address < vma->vm_start || address >= vma->vm_end)404404+ address = -EFAULT;405405+ } else if (PageHead(page) &&406406+ pgoff + compound_nr(page) - 1 >= vma->vm_pgoff) {407407+ /* Test above avoids possibility of wrap to 0 on 32-bit */408408+ address = vma->vm_start;409409+ } else {410410+ address = -EFAULT;411411+ }412412+ return address;413413+}403414404404- /* page should be within @vma mapping range */405405- VM_BUG_ON_VMA(end < vma->vm_start || start >= vma->vm_end, vma);415415+/*416416+ * Then at what user virtual address will none of the page be found in vma?417417+ * Assumes that vma_address() already returned a good starting address.418418+ * If page is a compound head, the entire compound page is considered.419419+ */420420+static inline unsigned long421421+vma_address_end(struct page *page, struct vm_area_struct *vma)422422+{423423+ pgoff_t pgoff;424424+ unsigned long address;406425407407- return max(start, vma->vm_start);426426+ VM_BUG_ON_PAGE(PageKsm(page), page); /* KSM page->index unusable */427427+ pgoff = page_to_pgoff(page) + compound_nr(page);428428+ address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);429429+ /* Check for address beyond vma (or wrapped through 0?) */430430+ if (address < vma->vm_start || address > vma->vm_end)431431+ address = vma->vm_end;432432+ return address;408433}409434410435static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
+33-3
mm/memory-failure.c
···949949 return (result == MF_RECOVERED || result == MF_DELAYED) ? 0 : -EBUSY;950950}951951952952+/*953953+ * Return true if a page type of a given page is supported by hwpoison954954+ * mechanism (while handling could fail), otherwise false. This function955955+ * does not return true for hugetlb or device memory pages, so it's assumed956956+ * to be called only in the context where we never have such pages.957957+ */958958+static inline bool HWPoisonHandlable(struct page *page)959959+{960960+ return PageLRU(page) || __PageMovable(page);961961+}962962+952963/**953964 * __get_hwpoison_page() - Get refcount for memory error handling:954965 * @page: raw error page (hit by memory error)···970959static int __get_hwpoison_page(struct page *page)971960{972961 struct page *head = compound_head(page);962962+ int ret = 0;963963+ bool hugetlb = false;973964974974- if (!PageHuge(head) && PageTransHuge(head)) {965965+ ret = get_hwpoison_huge_page(head, &hugetlb);966966+ if (hugetlb)967967+ return ret;968968+969969+ /*970970+ * This check prevents from calling get_hwpoison_unless_zero()971971+ * for any unsupported type of page in order to reduce the risk of972972+ * unexpected races caused by taking a page refcount.973973+ */974974+ if (!HWPoisonHandlable(head))975975+ return 0;976976+977977+ if (PageTransHuge(head)) {975978 /*976979 * Non anonymous thp exists only in allocation/free time. We977980 * can't handle such a case correctly, so let's give it up.···10421017 ret = -EIO;10431018 }10441019 } else {10451045- if (PageHuge(p) || PageLRU(p) || __PageMovable(p)) {10201020+ if (PageHuge(p) || HWPoisonHandlable(p)) {10461021 ret = 1;10471022 } else {10481023 /*···15521527 return 0;15531528 }1554152915551555- if (!PageTransTail(p) && !PageLRU(p))15301530+ /*15311531+ * __munlock_pagevec may clear a writeback page's LRU flag without15321532+ * page_lock. We need wait writeback completion for this page or it15331533+ * may trigger vfs BUG while evict inode.15341534+ */15351535+ if (!PageTransTail(p) && !PageLRU(p) && !PageWriteback(p))15561536 goto identify_page_state;1557153715581538 /*
+41
mm/memory.c
···13611361 else if (zap_huge_pmd(tlb, vma, pmd, addr))13621362 goto next;13631363 /* fall through */13641364+ } else if (details && details->single_page &&13651365+ PageTransCompound(details->single_page) &&13661366+ next - addr == HPAGE_PMD_SIZE && pmd_none(*pmd)) {13671367+ spinlock_t *ptl = pmd_lock(tlb->mm, pmd);13681368+ /*13691369+ * Take and drop THP pmd lock so that we cannot return13701370+ * prematurely, while zap_huge_pmd() has cleared *pmd,13711371+ * but not yet decremented compound_mapcount().13721372+ */13731373+ spin_unlock(ptl);13641374 }13751375+13651376 /*13661377 * Here there can be other concurrent MADV_DONTNEED or13671378 * trans huge page faults running, and if the pmd is···32453234 ((zea - vba + 1) << PAGE_SHIFT) + vma->vm_start,32463235 details);32473236 }32373237+}32383238+32393239+/**32403240+ * unmap_mapping_page() - Unmap single page from processes.32413241+ * @page: The locked page to be unmapped.32423242+ *32433243+ * Unmap this page from any userspace process which still has it mmaped.32443244+ * Typically, for efficiency, the range of nearby pages has already been32453245+ * unmapped by unmap_mapping_pages() or unmap_mapping_range(). But once32463246+ * truncation or invalidation holds the lock on a page, it may find that32473247+ * the page has been remapped again: and then uses unmap_mapping_page()32483248+ * to unmap it finally.32493249+ */32503250+void unmap_mapping_page(struct page *page)32513251+{32523252+ struct address_space *mapping = page->mapping;32533253+ struct zap_details details = { };32543254+32553255+ VM_BUG_ON(!PageLocked(page));32563256+ VM_BUG_ON(PageTail(page));32573257+32583258+ details.check_mapping = mapping;32593259+ details.first_index = page->index;32603260+ details.last_index = page->index + thp_nr_pages(page) - 1;32613261+ details.single_page = page;32623262+32633263+ i_mmap_lock_write(mapping);32643264+ if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))32653265+ unmap_mapping_range_tree(&mapping->i_mmap, &details);32663266+ i_mmap_unlock_write(mapping);32483267}3249326832503269/**
+1
mm/migrate.c
···295295 goto out;296296297297 page = migration_entry_to_page(entry);298298+ page = compound_head(page);298299299300 /*300301 * Once page cache replacement of page migration started, page_count
+17-10
mm/page_vma_mapped.c
···212212 pvmw->ptl = NULL;213213 }214214 } else if (!pmd_present(pmde)) {215215+ /*216216+ * If PVMW_SYNC, take and drop THP pmd lock so that we217217+ * cannot return prematurely, while zap_huge_pmd() has218218+ * cleared *pmd but not decremented compound_mapcount().219219+ */220220+ if ((pvmw->flags & PVMW_SYNC) &&221221+ PageTransCompound(pvmw->page)) {222222+ spinlock_t *ptl = pmd_lock(mm, pvmw->pmd);223223+224224+ spin_unlock(ptl);225225+ }215226 return false;216227 }217228 if (!map_pte(pvmw))218229 goto next_pte;219230 while (1) {231231+ unsigned long end;232232+220233 if (check_pte(pvmw))221234 return true;222235next_pte:223236 /* Seek to next pte only makes sense for THP */224237 if (!PageTransHuge(pvmw->page) || PageHuge(pvmw->page))225238 return not_found(pvmw);239239+ end = vma_address_end(pvmw->page, pvmw->vma);226240 do {227241 pvmw->address += PAGE_SIZE;228228- if (pvmw->address >= pvmw->vma->vm_end ||229229- pvmw->address >=230230- __vma_address(pvmw->page, pvmw->vma) +231231- thp_size(pvmw->page))242242+ if (pvmw->address >= end)232243 return not_found(pvmw);233244 /* Did we cross page table boundary? */234245 if (pvmw->address % PMD_SIZE == 0) {···277266 .vma = vma,278267 .flags = PVMW_SYNC,279268 };280280- unsigned long start, end;281269282282- start = __vma_address(page, vma);283283- end = start + thp_size(page) - PAGE_SIZE;284284-285285- if (unlikely(end < vma->vm_start || start >= vma->vm_end))270270+ pvmw.address = vma_address(page, vma);271271+ if (pvmw.address == -EFAULT)286272 return 0;287287- pvmw.address = max(start, vma->vm_start);288273 if (!page_vma_mapped_walk(&pvmw))289274 return 0;290275 page_vma_mapped_walk_done(&pvmw);
···707707 */708708unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)709709{710710- unsigned long address;711710 if (PageAnon(page)) {712711 struct anon_vma *page__anon_vma = page_anon_vma(page);713712 /*···716717 if (!vma->anon_vma || !page__anon_vma ||717718 vma->anon_vma->root != page__anon_vma->root)718719 return -EFAULT;719719- } else if (page->mapping) {720720- if (!vma->vm_file || vma->vm_file->f_mapping != page->mapping)721721- return -EFAULT;722722- } else720720+ } else if (!vma->vm_file) {723721 return -EFAULT;724724- address = __vma_address(page, vma);725725- if (unlikely(address < vma->vm_start || address >= vma->vm_end))722722+ } else if (vma->vm_file->f_mapping != compound_head(page)->mapping) {726723 return -EFAULT;727727- return address;724724+ }725725+726726+ return vma_address(page, vma);728727}729728730729pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address)···916919 */917920 mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_PAGE,918921 0, vma, vma->vm_mm, address,919919- min(vma->vm_end, address + page_size(page)));922922+ vma_address_end(page, vma));920923 mmu_notifier_invalidate_range_start(&range);921924922925 while (page_vma_mapped_walk(&pvmw)) {···14021405 struct mmu_notifier_range range;14031406 enum ttu_flags flags = (enum ttu_flags)(long)arg;1404140714081408+ /*14091409+ * When racing against e.g. zap_pte_range() on another cpu,14101410+ * in between its ptep_get_and_clear_full() and page_remove_rmap(),14111411+ * try_to_unmap() may return false when it is about to become true,14121412+ * if page table locking is skipped: use TTU_SYNC to wait for that.14131413+ */14141414+ if (flags & TTU_SYNC)14151415+ pvmw.flags = PVMW_SYNC;14161416+14051417 /* munlock has nothing to gain from examining un-locked vmas */14061418 if ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED))14071419 return true;···14321426 * Note that the page can not be free in this function as call of14331427 * try_to_unmap() must hold a reference on the page.14341428 */14291429+ range.end = PageKsm(page) ?14301430+ address + PAGE_SIZE : vma_address_end(page, vma);14351431 mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,14361436- address,14371437- min(vma->vm_end, address + page_size(page)));14321432+ address, range.end);14381433 if (PageHuge(page)) {14391434 /*14401435 * If sharing is possible, start and end will be adjusted···17841777 else17851778 rmap_walk(page, &rwc);1786177917871787- return !page_mapcount(page) ? true : false;17801780+ /*17811781+ * When racing against e.g. zap_pte_range() on another cpu,17821782+ * in between its ptep_get_and_clear_full() and page_remove_rmap(),17831783+ * try_to_unmap() may return false when it is about to become true,17841784+ * if page table locking is skipped: use TTU_SYNC to wait for that.17851785+ */17861786+ return !page_mapcount(page);17881787}1789178817901789/**···18871874 struct vm_area_struct *vma = avc->vma;18881875 unsigned long address = vma_address(page, vma);1889187618771877+ VM_BUG_ON_VMA(address == -EFAULT, vma);18901878 cond_resched();1891187918921880 if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg))···19421928 pgoff_start, pgoff_end) {19431929 unsigned long address = vma_address(page, vma);1944193019311931+ VM_BUG_ON_VMA(address == -EFAULT, vma);19451932 cond_resched();1946193319471934 if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg))
+1-2
mm/slab_common.c
···9797#ifdef CONFIG_DEBUG_VM9898static int kmem_cache_sanity_check(const char *name, unsigned int size)9999{100100- if (!name || in_interrupt() || size < sizeof(void *) ||101101- size > KMALLOC_MAX_SIZE) {100100+ if (!name || in_interrupt() || size > KMALLOC_MAX_SIZE) {102101 pr_err("kmem_cache_create(%s) integrity check failed\n", name);103102 return -EINVAL;104103 }
+16-21
mm/slub.c
···1515#include <linux/module.h>1616#include <linux/bit_spinlock.h>1717#include <linux/interrupt.h>1818+#include <linux/swab.h>1819#include <linux/bitops.h>1920#include <linux/slab.h>2021#include "slab.h"···713712 p, p - addr, get_freepointer(s, p));714713715714 if (s->flags & SLAB_RED_ZONE)716716- print_section(KERN_ERR, "Redzone ", p - s->red_left_pad,715715+ print_section(KERN_ERR, "Redzone ", p - s->red_left_pad,717716 s->red_left_pad);718717 else if (p > addr + 16)719718 print_section(KERN_ERR, "Bytes b4 ", p - 16, 16);720719721721- print_section(KERN_ERR, "Object ", p,720720+ print_section(KERN_ERR, "Object ", p,722721 min_t(unsigned int, s->object_size, PAGE_SIZE));723722 if (s->flags & SLAB_RED_ZONE)724724- print_section(KERN_ERR, "Redzone ", p + s->object_size,723723+ print_section(KERN_ERR, "Redzone ", p + s->object_size,725724 s->inuse - s->object_size);726725727726 off = get_info_end(s);···733732734733 if (off != size_from_object(s))735734 /* Beginning of the filler is the free pointer */736736- print_section(KERN_ERR, "Padding ", p + off,735735+ print_section(KERN_ERR, "Padding ", p + off,737736 size_from_object(s) - off);738737739738 dump_stack();···910909 u8 *endobject = object + s->object_size;911910912911 if (s->flags & SLAB_RED_ZONE) {913913- if (!check_bytes_and_report(s, page, object, "Redzone",912912+ if (!check_bytes_and_report(s, page, object, "Left Redzone",914913 object - s->red_left_pad, val, s->red_left_pad))915914 return 0;916915917917- if (!check_bytes_and_report(s, page, object, "Redzone",916916+ if (!check_bytes_and_report(s, page, object, "Right Redzone",918917 endobject, val, s->inuse - s->object_size))919918 return 0;920919 } else {···929928 if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) &&930929 (!check_bytes_and_report(s, page, p, "Poison", p,931930 POISON_FREE, s->object_size - 1) ||932932- !check_bytes_and_report(s, page, p, "Poison",931931+ !check_bytes_and_report(s, page, p, "End Poison",933932 p + s->object_size - 1, POISON_END, 1)))934933 return 0;935934 /*···36903689{36913690 slab_flags_t flags = s->flags;36923691 unsigned int size = s->object_size;36933693- unsigned int freepointer_area;36943692 unsigned int order;3695369336963694 /*···36983698 * the possible location of the free pointer.36993699 */37003700 size = ALIGN(size, sizeof(void *));37013701- /*37023702- * This is the area of the object where a freepointer can be37033703- * safely written. If redzoning adds more to the inuse size, we37043704- * can't use that portion for writing the freepointer, so37053705- * s->offset must be limited within this for the general case.37063706- */37073707- freepointer_area = size;3708370137093702#ifdef CONFIG_SLUB_DEBUG37103703 /*···3723373037243731 /*37253732 * With that we have determined the number of bytes in actual use37263726- * by the object. This is the potential offset to the free pointer.37333733+ * by the object and redzoning.37273734 */37283735 s->inuse = size;3729373637303730- if (((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) ||37313731- s->ctor)) {37373737+ if ((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) ||37383738+ ((flags & SLAB_RED_ZONE) && s->object_size < sizeof(void *)) ||37393739+ s->ctor) {37323740 /*37333741 * Relocate free pointer after the object if it is not37343742 * permitted to overwrite the first word of the object on37353743 * kmem_cache_free.37363744 *37373745 * This is the case if we do RCU, have a constructor or37383738- * destructor or are poisoning the objects.37463746+ * destructor, are poisoning the objects, or are37473747+ * redzoning an object smaller than sizeof(void *).37393748 *37403749 * The assumption that s->offset >= s->inuse means free37413750 * pointer is outside of the object is used in the···37463751 */37473752 s->offset = size;37483753 size += sizeof(void *);37493749- } else if (freepointer_area > sizeof(void *)) {37543754+ } else {37503755 /*37513756 * Store freelist pointer near middle of object to keep37523757 * it away from the edges of the object to avoid small37533758 * sized over/underflows from neighboring allocations.37543759 */37553755- s->offset = ALIGN(freepointer_area / 2, sizeof(void *));37603760+ s->offset = ALIGN_DOWN(s->object_size / 2, sizeof(void *));37563761 }3757376237583763#ifdef CONFIG_SLUB_DEBUG
+11-2
mm/sparse.c
···344344 return sizeof(struct mem_section_usage) + usemap_size();345345}346346347347+static inline phys_addr_t pgdat_to_phys(struct pglist_data *pgdat)348348+{349349+#ifndef CONFIG_NEED_MULTIPLE_NODES350350+ return __pa_symbol(pgdat);351351+#else352352+ return __pa(pgdat);353353+#endif354354+}355355+347356#ifdef CONFIG_MEMORY_HOTREMOVE348357static struct mem_section_usage * __init349358sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,···371362 * from the same section as the pgdat where possible to avoid372363 * this problem.373364 */374374- goal = __pa(pgdat) & (PAGE_SECTION_MASK << PAGE_SHIFT);365365+ goal = pgdat_to_phys(pgdat) & (PAGE_SECTION_MASK << PAGE_SHIFT);375366 limit = goal + (1UL << PA_SECTION_SHIFT);376367 nid = early_pfn_to_nid(goal >> PAGE_SHIFT);377368again:···399390 }400391401392 usemap_snr = pfn_to_section_nr(__pa(usage) >> PAGE_SHIFT);402402- pgdat_snr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);393393+ pgdat_snr = pfn_to_section_nr(pgdat_to_phys(pgdat) >> PAGE_SHIFT);403394 if (usemap_snr == pgdat_snr)404395 return;405396
···167167 * its lock, b) when a concurrent invalidate_mapping_pages got there first and168168 * c) when tmpfs swizzles a page between a tmpfs inode and swapper_space.169169 */170170-static void171171-truncate_cleanup_page(struct address_space *mapping, struct page *page)170170+static void truncate_cleanup_page(struct page *page)172171{173173- if (page_mapped(page)) {174174- unsigned int nr = thp_nr_pages(page);175175- unmap_mapping_pages(mapping, page->index, nr, false);176176- }172172+ if (page_mapped(page))173173+ unmap_mapping_page(page);177174178175 if (page_has_private(page))179176 do_invalidatepage(page, 0, thp_size(page));···215218 if (page->mapping != mapping)216219 return -EIO;217220218218- truncate_cleanup_page(mapping, page);221221+ truncate_cleanup_page(page);219222 delete_from_page_cache(page);220223 return 0;221224}···322325 index = indices[pagevec_count(&pvec) - 1] + 1;323326 truncate_exceptional_pvec_entries(mapping, &pvec, indices);324327 for (i = 0; i < pagevec_count(&pvec); i++)325325- truncate_cleanup_page(mapping, pvec.pages[i]);328328+ truncate_cleanup_page(pvec.pages[i]);326329 delete_from_page_cache_batch(mapping, &pvec);327330 for (i = 0; i < pagevec_count(&pvec); i++)328331 unlock_page(pvec.pages[i]);···636639 continue;637640 }638641642642+ if (!did_range_unmap && page_mapped(page)) {643643+ /*644644+ * If page is mapped, before taking its lock,645645+ * zap the rest of the file in one hit.646646+ */647647+ unmap_mapping_pages(mapping, index,648648+ (1 + end - index), false);649649+ did_range_unmap = 1;650650+ }651651+639652 lock_page(page);640653 WARN_ON(page_to_index(page) != index);641654 if (page->mapping != mapping) {···653646 continue;654647 }655648 wait_on_page_writeback(page);656656- if (page_mapped(page)) {657657- if (!did_range_unmap) {658658- /*659659- * Zap the rest of the file in one hit.660660- */661661- unmap_mapping_pages(mapping, index,662662- (1 + end - index), false);663663- did_range_unmap = 1;664664- } else {665665- /*666666- * Just zap this page667667- */668668- unmap_mapping_pages(mapping, index,669669- 1, false);670670- }671671- }649649+650650+ if (page_mapped(page))651651+ unmap_mapping_page(page);672652 BUG_ON(page_mapped(page));653653+673654 ret2 = do_launder_page(mapping, page);674655 if (ret2 == 0) {675656 if (!invalidate_complete_page2(mapping, page))
+1-1
net/appletalk/aarp.c
···768768 if (a && a->status & ATIF_PROBE) {769769 a->status |= ATIF_PROBE_FAIL;770770 /*771771- * we do not respond to probe or request packets for771771+ * we do not respond to probe or request packets of772772 * this address while we are probing this address773773 */774774 goto unlock;
+3-1
net/batman-adv/bat_iv_ogm.c
···409409 if (WARN_ON(!forw_packet->if_outgoing))410410 return;411411412412- if (WARN_ON(forw_packet->if_outgoing->soft_iface != soft_iface))412412+ if (forw_packet->if_outgoing->soft_iface != soft_iface) {413413+ pr_warn("%s: soft interface switch for queued OGM\n", __func__);413414 return;415415+ }414416415417 if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE)416418 return;
···641641}642642EXPORT_SYMBOL_GPL(__put_net);643643644644+/**645645+ * get_net_ns - increment the refcount of the network namespace646646+ * @ns: common namespace (net)647647+ *648648+ * Returns the net's common namespace.649649+ */650650+struct ns_common *get_net_ns(struct ns_common *ns)651651+{652652+ return &get_net(container_of(ns, struct net, ns))->ns;653653+}654654+EXPORT_SYMBOL_GPL(get_net_ns);655655+644656struct net *get_net_ns_by_fd(int fd)645657{646658 struct file *file;···672660 fput(file);673661 return net;674662}675675-676676-#else677677-struct net *get_net_ns_by_fd(int fd)678678-{679679- return ERR_PTR(-EINVAL);680680-}681681-#endif682663EXPORT_SYMBOL_GPL(get_net_ns_by_fd);664664+#endif683665684666struct net *get_net_ns_by_pid(pid_t pid)685667{
+5-3
net/core/rtnetlink.c
···48424842 if (err < 0)48434843 goto errout;4844484448454845- if (!skb->len) {48464846- err = -EINVAL;48454845+ /* Notification info is only filled for bridge ports, not the bridge48464846+ * device itself. Therefore, a zero notification length is valid and48474847+ * should not result in an error.48484848+ */48494849+ if (!skb->len)48474850 goto errout;48484848- }4849485148504852 rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);48514853 return 0;
+3-1
net/core/skbuff.c
···12531253 struct sock *sk = skb->sk;12541254 struct sk_buff_head *q;12551255 unsigned long flags;12561256+ bool is_zerocopy;12561257 u32 lo, hi;12571258 u16 len;12581259···12681267 len = uarg->len;12691268 lo = uarg->id;12701269 hi = uarg->id + len - 1;12701270+ is_zerocopy = uarg->zerocopy;1271127112721272 serr = SKB_EXT_ERR(skb);12731273 memset(serr, 0, sizeof(*serr));···12761274 serr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY;12771275 serr->ee.ee_data = hi;12781276 serr->ee.ee_info = lo;12791279- if (!uarg->zerocopy)12771277+ if (!is_zerocopy)12801278 serr->ee.ee_code |= SO_EE_CODE_ZEROCOPY_COPIED;1281127912821280 q = &sk->sk_error_queue;
+1-1
net/ethtool/eeprom.c
···9595 if (dev->sfp_bus)9696 return sfp_get_module_eeprom_by_page(dev->sfp_bus, page_data, extack);97979898- if (ops->get_module_info)9898+ if (ops->get_module_eeprom_by_page)9999 return ops->get_module_eeprom_by_page(dev, page_data, extack);100100101101 return -EOPNOTSUPP;
+5-5
net/ethtool/ioctl.c
···14211421 if (eeprom.offset + eeprom.len > total_len)14221422 return -EINVAL;1423142314241424- data = kmalloc(PAGE_SIZE, GFP_USER);14241424+ data = kzalloc(PAGE_SIZE, GFP_USER);14251425 if (!data)14261426 return -ENOMEM;14271427···14861486 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))14871487 return -EINVAL;1488148814891489- data = kmalloc(PAGE_SIZE, GFP_USER);14891489+ data = kzalloc(PAGE_SIZE, GFP_USER);14901490 if (!data)14911491 return -ENOMEM;14921492···17651765 return -EFAULT;1766176617671767 test.len = test_len;17681768- data = kmalloc_array(test_len, sizeof(u64), GFP_USER);17681768+ data = kcalloc(test_len, sizeof(u64), GFP_USER);17691769 if (!data)17701770 return -ENOMEM;17711771···22932293 ret = ethtool_tunable_valid(&tuna);22942294 if (ret)22952295 return ret;22962296- data = kmalloc(tuna.len, GFP_USER);22962296+ data = kzalloc(tuna.len, GFP_USER);22972297 if (!data)22982298 return -ENOMEM;22992299 ret = ops->get_tunable(dev, &tuna, data);···24852485 ret = ethtool_phy_tunable_valid(&tuna);24862486 if (ret)24872487 return ret;24882488- data = kmalloc(tuna.len, GFP_USER);24882488+ data = kzalloc(tuna.len, GFP_USER);24892489 if (!data)24902490 return -ENOMEM;24912491 if (phy_drv_tunable) {
+2
net/ethtool/strset.c
···353353 int len = 0;354354 int ret;355355356356+ len += nla_total_size(0); /* ETHTOOL_A_STRSET_STRINGSETS */357357+356358 for (i = 0; i < ETH_SS_COUNT; i++) {357359 const struct strset_info *set_info = &data->sets[i];358360
+2-2
net/ipv4/af_inet.c
···575575 return err;576576 }577577578578- if (!inet_sk(sk)->inet_num && inet_autobind(sk))578578+ if (data_race(!inet_sk(sk)->inet_num) && inet_autobind(sk))579579 return -EAGAIN;580580 return sk->sk_prot->connect(sk, uaddr, addr_len);581581}···803803 sock_rps_record_flow(sk);804804805805 /* We may need to bind the socket. */806806- if (!inet_sk(sk)->inet_num && !sk->sk_prot->no_autobind &&806806+ if (data_race(!inet_sk(sk)->inet_num) && !sk->sk_prot->no_autobind &&807807 inet_autobind(sk))808808 return -EAGAIN;809809
···19891989 return -EAFNOSUPPORT;1990199019911991 if (nla_parse_nested_deprecated(tb, IFLA_INET_MAX, nla, NULL, NULL) < 0)19921992- BUG();19921992+ return -EINVAL;1993199319941994 if (tb[IFLA_INET_CONF]) {19951995 nla_for_each_nested(a, tb[IFLA_INET_CONF], rem)
+7
net/ipv4/icmp.c
···759759 icmp_param.data_len = room;760760 icmp_param.head_len = sizeof(struct icmphdr);761761762762+ /* if we don't have a source address at this point, fall back to the763763+ * dummy address instead of sending out a packet with a source address764764+ * of 0.0.0.0765765+ */766766+ if (!fl4.saddr)767767+ fl4.saddr = htonl(INADDR_DUMMY);768768+762769 icmp_push_reply(&icmp_param, &fl4, &ipc, &rt);763770ende:764771 ip_rt_put(rt);
···954954 struct sock *sk;955955 struct net *net = dev_net(skb->dev);956956 struct icmphdr *icmph = icmp_hdr(skb);957957+ bool rc = false;957958958959 /* We assume the packet has already been checked by icmp_rcv */959960···969968 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);970969971970 pr_debug("rcv on socket %p\n", sk);972972- if (skb2)973973- ping_queue_rcv_skb(sk, skb2);971971+ if (skb2 && !ping_queue_rcv_skb(sk, skb2))972972+ rc = true;974973 sock_put(sk);975975- return true;976974 }977977- pr_debug("no socket, dropping\n");978975979979- return false;976976+ if (!rc)977977+ pr_debug("no socket, dropping\n");978978+979979+ return rc;980980}981981EXPORT_SYMBOL_GPL(ping_rcv);982982
+14-1
net/ipv4/route.c
···20562056 return err;20572057}2058205820592059+/* get device for dst_alloc with local routes */20602060+static struct net_device *ip_rt_get_dev(struct net *net,20612061+ const struct fib_result *res)20622062+{20632063+ struct fib_nh_common *nhc = res->fi ? res->nhc : NULL;20642064+ struct net_device *dev = NULL;20652065+20662066+ if (nhc)20672067+ dev = l3mdev_master_dev_rcu(nhc->nhc_dev);20682068+20692069+ return dev ? : net->loopback_dev;20702070+}20712071+20592072/*20602073 * NOTE. We drop all the packets that has local source20612074 * addresses, because every properly looped back packet···22252212 }22262213 }2227221422282228- rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,22152215+ rth = rt_dst_alloc(ip_rt_get_dev(net, res),22292216 flags | RTCF_LOCAL, res->type,22302217 IN_DEV_ORCONF(in_dev, NOPOLICY), false);22312218 if (!rth)
+10
net/ipv4/udp.c
···26072607{26082608 struct udp_sock *up = udp_sk(sk);26092609 bool slow = lock_sock_fast(sk);26102610+26112611+ /* protects from races with udp_abort() */26122612+ sock_set_flag(sk, SOCK_DEAD);26102613 udp_flush_pending_frames(sk);26112614 unlock_sock_fast(sk, slow);26122615 if (static_branch_unlikely(&udp_encap_needed_key)) {···28602857{28612858 lock_sock(sk);2862285928602860+ /* udp{v6}_destroy_sock() sets it under the sk lock, avoid racing28612861+ * with close()28622862+ */28632863+ if (sock_flag(sk, SOCK_DEAD))28642864+ goto out;28652865+28632866 sk->sk_err = err;28642867 sk->sk_error_report(sk);28652868 __udp_disconnect(sk, 0);2866286928702870+out:28672871 release_sock(sk);2868287228692873 return 0;
···14421442 rcu_read_lock();14431443 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);1444144414451445- if (WARN_ON_ONCE(!chanctx_conf)) {14451445+ if (!chanctx_conf) {14461446 rcu_read_unlock();14471447 return NULL;14481448 }
+12-7
net/mac80211/iface.c
···476476 GFP_KERNEL);477477 }478478479479- /* APs need special treatment */480479 if (sdata->vif.type == NL80211_IFTYPE_AP) {481481- struct ieee80211_sub_if_data *vlan, *tmpsdata;482482-483483- /* down all dependent devices, that is VLANs */484484- list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,485485- u.vlan.list)486486- dev_close(vlan->dev);487480 WARN_ON(!list_empty(&sdata->u.ap.vlans));488481 } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {489482 /* remove all packets in parent bc_buf pointing to this dev */···633640static int ieee80211_stop(struct net_device *dev)634641{635642 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);643643+644644+ /* close all dependent VLAN interfaces before locking wiphy */645645+ if (sdata->vif.type == NL80211_IFTYPE_AP) {646646+ struct ieee80211_sub_if_data *vlan, *tmpsdata;647647+648648+ list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,649649+ u.vlan.list)650650+ dev_close(vlan->dev);651651+ }636652637653 wiphy_lock(sdata->local->hw.wiphy);638654 ieee80211_do_stop(sdata, true);···1593159115941592 switch (sdata->vif.type) {15951593 case NL80211_IFTYPE_AP:15941594+ if (!list_empty(&sdata->u.ap.vlans))15951595+ return -EBUSY;15961596+ break;15961597 case NL80211_IFTYPE_STATION:15971598 case NL80211_IFTYPE_ADHOC:15981599 case NL80211_IFTYPE_OCB:
+6-1
net/mac80211/main.c
···252252 struct ieee80211_local *local =253253 container_of(work, struct ieee80211_local, restart_work);254254 struct ieee80211_sub_if_data *sdata;255255+ int ret;255256256257 /* wait for scan work complete */257258 flush_workqueue(local->workqueue);···302301 /* wait for all packet processing to be done */303302 synchronize_net();304303305305- ieee80211_reconfig(local);304304+ ret = ieee80211_reconfig(local);306305 wiphy_unlock(local->hw.wiphy);306306+307307+ if (ret)308308+ cfg80211_shutdown_all_interfaces(local->hw.wiphy);309309+307310 rtnl_unlock();308311}309312
···280280281281 /* try to fetch required memory from subflow */282282 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {283283- if (ssk->sk_forward_alloc < skb->truesize)283283+ int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT;284284+285285+ if (ssk->sk_forward_alloc < amount)284286 goto drop;285285- __sk_mem_reclaim(ssk, skb->truesize);286286- if (!sk_rmem_schedule(sk, skb, skb->truesize))287287- goto drop;287287+288288+ ssk->sk_forward_alloc -= amount;289289+ sk->sk_forward_alloc += amount;288290 }289291290292 /* the skb map_seq accounts for the skb offset:···670668/* In most cases we will be able to lock the mptcp socket. If its already671669 * owned, we need to defer to the work queue to avoid ABBA deadlock.672670 */673673-static void move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk)671671+static bool move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk)674672{675673 struct sock *sk = (struct sock *)msk;676674 unsigned int moved = 0;677675678676 if (inet_sk_state_load(sk) == TCP_CLOSE)679679- return;680680-681681- mptcp_data_lock(sk);677677+ return false;682678683679 __mptcp_move_skbs_from_subflow(msk, ssk, &moved);684680 __mptcp_ofo_queue(msk);681681+ if (unlikely(ssk->sk_err)) {682682+ if (!sock_owned_by_user(sk))683683+ __mptcp_error_report(sk);684684+ else685685+ set_bit(MPTCP_ERROR_REPORT, &msk->flags);686686+ }685687686688 /* If the moves have caught up with the DATA_FIN sequence number687689 * it's time to ack the DATA_FIN and change socket state, but···694688 */695689 if (mptcp_pending_data_fin(sk, NULL))696690 mptcp_schedule_work(sk);697697- mptcp_data_unlock(sk);691691+ return moved > 0;698692}699693700694void mptcp_data_ready(struct sock *sk, struct sock *ssk)···702696 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);703697 struct mptcp_sock *msk = mptcp_sk(sk);704698 int sk_rbuf, ssk_rbuf;705705- bool wake;706699707700 /* The peer can send data while we are shutting down this708701 * subflow at msk destruction time, but we must avoid enqueuing···710705 if (unlikely(subflow->disposable))711706 return;712707713713- /* move_skbs_to_msk below can legitly clear the data_avail flag,714714- * but we will need later to properly woke the reader, cache its715715- * value716716- */717717- wake = subflow->data_avail == MPTCP_SUBFLOW_DATA_AVAIL;718718- if (wake)719719- set_bit(MPTCP_DATA_READY, &msk->flags);720720-721708 ssk_rbuf = READ_ONCE(ssk->sk_rcvbuf);722709 sk_rbuf = READ_ONCE(sk->sk_rcvbuf);723710 if (unlikely(ssk_rbuf > sk_rbuf))724711 sk_rbuf = ssk_rbuf;725712726726- /* over limit? can't append more skbs to msk */713713+ /* over limit? can't append more skbs to msk, Also, no need to wake-up*/727714 if (atomic_read(&sk->sk_rmem_alloc) > sk_rbuf)728728- goto wake;715715+ return;729716730730- move_skbs_to_msk(msk, ssk);731731-732732-wake:733733- if (wake)717717+ /* Wake-up the reader only for in-sequence data */718718+ mptcp_data_lock(sk);719719+ if (move_skbs_to_msk(msk, ssk)) {720720+ set_bit(MPTCP_DATA_READY, &msk->flags);734721 sk->sk_data_ready(sk);722722+ }723723+ mptcp_data_unlock(sk);735724}736725737726static bool mptcp_do_flush_join_list(struct mptcp_sock *msk)···857858 sock_owned_by_me(sk);858859859860 mptcp_for_each_subflow(msk, subflow) {860860- if (subflow->data_avail)861861+ if (READ_ONCE(subflow->data_avail))861862 return mptcp_subflow_tcp_sock(subflow);862863 }863864···19541955 done = __mptcp_move_skbs_from_subflow(msk, ssk, &moved);19551956 mptcp_data_unlock(sk);19561957 tcp_cleanup_rbuf(ssk, moved);19581958+19591959+ if (unlikely(ssk->sk_err))19601960+ __mptcp_error_report(sk);19571961 unlock_sock_fast(ssk, slowpath);19581962 } while (!done);19591963
···943943 }944944945945 tcph = skb_header_pointer(skb, offset, sizeof(_tcph), &_tcph);946946- if (!tcph)946946+ if (!tcph || tcph->doff < 5)947947 return NULL;948948949949 return skb_header_pointer(skb, offset,···967967 length--;968968 continue;969969 }970970+ if (length < 2)971971+ break;970972 opsize = *ptr++;971973 if (opsize < 2 || opsize > length)972974 break;···11061104 length--;11071105 continue;11081106 }11071107+ if (length < 2)11081108+ break;11091109 opsize = *ptr++;11101110 if (opsize < 2 || opsize > length)11111111 break;···2342233823432339/* List of known Diffserv codepoints:23442340 *23452345- * Least Effort (CS1)23412341+ * Least Effort (CS1, LE)23462342 * Best Effort (CS0)23472343 * Max Reliability & LLT "Lo" (TOS1)23482344 * Max Throughput (TOS2)···23642360 * Total 25 codepoints.23652361 */2366236223672367-/* List of traffic classes in RFC 4594:23632363+/* List of traffic classes in RFC 4594, updated by RFC 8622:23682364 * (roughly descending order of contended priority)23692365 * (roughly ascending order of uncontended throughput)23702366 *···23792375 * Ops, Admin, Management (CS2,TOS1) - eg. ssh23802376 * Standard Service (CS0 & unrecognised codepoints)23812377 * High Throughput Data (AF1x,TOS2) - eg. web traffic23822382- * Low Priority Data (CS1) - eg. BitTorrent23782378+ * Low Priority Data (CS1,LE) - eg. BitTorrent2383237923842380 * Total 12 traffic classes.23852381 */···23952391 * Video Streaming (AF4x, AF3x, CS3)23962392 * Bog Standard (CS0 etc.)23972393 * High Throughput (AF1x, TOS2)23982398- * Background Traffic (CS1)23942394+ * Background Traffic (CS1, LE)23992395 *24002396 * Total 8 traffic classes.24012397 */···24392435 * Latency Sensitive (CS7, CS6, EF, VA, CS5, CS4)24402436 * Streaming Media (AF4x, AF3x, CS3, AF2x, TOS4, CS2, TOS1)24412437 * Best Effort (CS0, AF1x, TOS2, and those not specified)24422442- * Background Traffic (CS1)24382438+ * Background Traffic (CS1, LE)24432439 *24442440 * Total 4 traffic classes.24452441 */···24772473static int cake_config_diffserv3(struct Qdisc *sch)24782474{24792475/* Simplified Diffserv structure with 3 tins.24802480- * Low Priority (CS1)24762476+ * Low Priority (CS1, LE)24812477 * Best Effort24822478 * Latency Sensitive (TOS4, VA, EF, CS6, CS7)24832479 */
-13
net/socket.c
···10721072 * what to do with it - that's up to the protocol still.10731073 */1074107410751075-/**10761076- * get_net_ns - increment the refcount of the network namespace10771077- * @ns: common namespace (net)10781078- *10791079- * Returns the net's common namespace.10801080- */10811081-10821082-struct ns_common *get_net_ns(struct ns_common *ns)10831083-{10841084- return &get_net(container_of(ns, struct net, ns))->ns;10851085-}10861086-EXPORT_SYMBOL_GPL(get_net_ns);10871087-10881075static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)10891076{10901077 struct socket *sock;
+4-3
net/unix/af_unix.c
···535535 u->path.mnt = NULL;536536 state = sk->sk_state;537537 sk->sk_state = TCP_CLOSE;538538+539539+ skpair = unix_peer(sk);540540+ unix_peer(sk) = NULL;541541+538542 unix_state_unlock(sk);539543540544 wake_up_interruptible_all(&u->peer_wait);541541-542542- skpair = unix_peer(sk);543545544546 if (skpair != NULL) {545547 if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {···557555558556 unix_dgram_peer_wake_disconnect(sk, skpair);559557 sock_put(skpair); /* It may now die */560560- unix_peer(sk) = NULL;561558 }562559563560 /* Try to flush out this socket. Throw out buffers at least */
···13401340 rdev->devlist_generation++;13411341 wdev->registered = true;1342134213431343+ if (wdev->netdev &&13441344+ sysfs_create_link(&wdev->netdev->dev.kobj, &rdev->wiphy.dev.kobj,13451345+ "phy80211"))13461346+ pr_err("failed to add phy80211 symlink to netdev!\n");13471347+13431348 nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE);13441349}13451350···13691364 ret = register_netdevice(dev);13701365 if (ret)13711366 goto out;13721372-13731373- if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,13741374- "phy80211")) {13751375- pr_err("failed to add phy80211 symlink to netdev!\n");13761376- unregister_netdevice(dev);13771377- ret = -EINVAL;13781378- goto out;13791379- }1380136713811368 cfg80211_register_wdev(rdev, wdev);13821369 ret = 0;
+14-2
net/wireless/pmsr.c
···334334 gfp_t gfp)335335{336336 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);337337+ struct cfg80211_pmsr_request *tmp, *prev, *to_free = NULL;337338 struct sk_buff *msg;338339 void *hdr;339340···365364 nlmsg_free(msg);366365free_request:367366 spin_lock_bh(&wdev->pmsr_lock);368368- list_del(&req->list);367367+ /*368368+ * cfg80211_pmsr_process_abort() may have already moved this request369369+ * to the free list, and will free it later. In this case, don't free370370+ * it here.371371+ */372372+ list_for_each_entry_safe(tmp, prev, &wdev->pmsr_list, list) {373373+ if (tmp == req) {374374+ list_del(&req->list);375375+ to_free = req;376376+ break;377377+ }378378+ }369379 spin_unlock_bh(&wdev->pmsr_lock);370370- kfree(req);380380+ kfree(to_free);371381}372382EXPORT_SYMBOL_GPL(cfg80211_pmsr_complete);373383
+4
net/wireless/sysfs.c
···133133 if (rdev->wiphy.registered && rdev->ops->resume)134134 ret = rdev_resume(rdev);135135 wiphy_unlock(&rdev->wiphy);136136+137137+ if (ret)138138+ cfg80211_shutdown_all_interfaces(&rdev->wiphy);139139+136140 rtnl_unlock();137141138142 return ret;
···192192 Elf32_Word const *symtab_shndx)193193{194194 unsigned long offset;195195+ unsigned short shndx = w2(sym->st_shndx);195196 int index;196197197197- if (sym->st_shndx != SHN_XINDEX)198198- return w2(sym->st_shndx);198198+ if (shndx > SHN_UNDEF && shndx < SHN_LORESERVE)199199+ return shndx;199200200200- offset = (unsigned long)sym - (unsigned long)symtab;201201- index = offset / sizeof(*sym);201201+ if (shndx == SHN_XINDEX) {202202+ offset = (unsigned long)sym - (unsigned long)symtab;203203+ index = offset / sizeof(*sym);202204203203- return w(symtab_shndx[index]);205205+ return w(symtab_shndx[index]);206206+ }207207+208208+ return 0;204209}205210206211static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0)
+1-2
tools/include/uapi/asm-generic/unistd.h
···863863__SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2)864864#define __NR_mount_setattr 442865865__SYSCALL(__NR_mount_setattr, sys_mount_setattr)866866-#define __NR_quotactl_path 443867867-__SYSCALL(__NR_quotactl_path, sys_quotactl_path)866866+/* 443 is reserved for quotactl_path */868867869868#define __NR_landlock_create_ruleset 444870869__SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset)
+3
tools/include/uapi/linux/in.h
···289289/* Address indicating an error return. */290290#define INADDR_NONE ((unsigned long int) 0xffffffff)291291292292+/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */293293+#define INADDR_DUMMY ((unsigned long int) 0xc0000008)294294+292295/* Network number for local host loopback. */293296#define IN_LOOPBACKNET 127294297
···1111 second_num=$212121313 # upper bound is first_num * 110%1414- upper=$(( $first_num + $first_num / 10 ))1414+ upper=$(expr $first_num + $first_num / 10 )1515 # lower bound is first_num * 90%1616- lower=$(( $first_num - $first_num / 10 ))1616+ lower=$(expr $first_num - $first_num / 10 )17171818 if [ $second_num -gt $upper ] || [ $second_num -lt $lower ]; then1919 echo "The difference between $first_num and $second_num are greater than 10%."
-2
tools/perf/trace/beauty/include/linux/socket.h
···438438 int __user *usockvec);439439extern int __sys_shutdown_sock(struct socket *sock, int how);440440extern int __sys_shutdown(int fd, int how);441441-442442-extern struct ns_common *get_net_ns(struct ns_common *ns);443441#endif /* _LINUX_SOCKET_H */
···13841384 ipv4_rt_replace_mpath13851385}1386138613871387+# checks that cached input route on VRF port is deleted13881388+# when VRF is deleted13891389+ipv4_local_rt_cache()13901390+{13911391+ run_cmd "ip addr add 10.0.0.1/32 dev lo"13921392+ run_cmd "ip netns add test-ns"13931393+ run_cmd "ip link add veth-outside type veth peer name veth-inside"13941394+ run_cmd "ip link add vrf-100 type vrf table 1100"13951395+ run_cmd "ip link set veth-outside master vrf-100"13961396+ run_cmd "ip link set veth-inside netns test-ns"13971397+ run_cmd "ip link set veth-outside up"13981398+ run_cmd "ip link set vrf-100 up"13991399+ run_cmd "ip route add 10.1.1.1/32 dev veth-outside table 1100"14001400+ run_cmd "ip netns exec test-ns ip link set veth-inside up"14011401+ run_cmd "ip netns exec test-ns ip addr add 10.1.1.1/32 dev veth-inside"14021402+ run_cmd "ip netns exec test-ns ip route add 10.0.0.1/32 dev veth-inside"14031403+ run_cmd "ip netns exec test-ns ip route add default via 10.0.0.1"14041404+ run_cmd "ip netns exec test-ns ping 10.0.0.1 -c 1 -i 1"14051405+ run_cmd "ip link delete vrf-100"14061406+14071407+ # if we do not hang test is a success14081408+ log_test $? 0 "Cached route removed from VRF port device"14091409+}14101410+13871411ipv4_route_test()13881412{13891413 route_setup1390141413911415 ipv4_rt_add13921416 ipv4_rt_replace14171417+ ipv4_local_rt_cache1393141813941419 route_cleanup13951420}
+74
tools/testing/selftests/net/icmp.sh
···11+#!/bin/bash22+# SPDX-License-Identifier: GPL-2.033+44+# Test for checking ICMP response with dummy address instead of 0.0.0.0.55+# Sets up two namespaces like:66+# +----------------------+ +--------------------+77+# | ns1 | v4-via-v6 routes: | ns2 |88+# | | ' | |99+# | +--------+ -> 172.16.1.0/24 -> +--------+ |1010+# | | veth0 +--------------------------+ veth0 | |1111+# | +--------+ <- 172.16.0.0/24 <- +--------+ |1212+# | 172.16.0.1 | | 2001:db8:1::2/64 |1313+# | 2001:db8:1::2/64 | | |1414+# +----------------------+ +--------------------+1515+#1616+# And then tries to ping 172.16.1.1 from ns1. This results in a "net1717+# unreachable" message being sent from ns2, but there is no IPv4 address set in1818+# that address space, so the kernel should substitute the dummy address1919+# 192.0.0.8 defined in RFC7600.2020+2121+NS1=ns12222+NS2=ns22323+H1_IP=172.16.0.1/322424+H1_IP6=2001:db8:1::12525+RT1=172.16.1.0/242626+PINGADDR=172.16.1.12727+RT2=172.16.0.0/242828+H2_IP6=2001:db8:1::22929+3030+TMPFILE=$(mktemp)3131+3232+cleanup()3333+{3434+ rm -f "$TMPFILE"3535+ ip netns del $NS13636+ ip netns del $NS23737+}3838+3939+trap cleanup EXIT4040+4141+# Namespaces4242+ip netns add $NS14343+ip netns add $NS24444+4545+# Connectivity4646+ip -netns $NS1 link add veth0 type veth peer name veth0 netns $NS24747+ip -netns $NS1 link set dev veth0 up4848+ip -netns $NS2 link set dev veth0 up4949+ip -netns $NS1 addr add $H1_IP dev veth05050+ip -netns $NS1 addr add $H1_IP6/64 dev veth0 nodad5151+ip -netns $NS2 addr add $H2_IP6/64 dev veth0 nodad5252+ip -netns $NS1 route add $RT1 via inet6 $H2_IP65353+ip -netns $NS2 route add $RT2 via inet6 $H1_IP65454+5555+# Make sure ns2 will respond with ICMP unreachable5656+ip netns exec $NS2 sysctl -qw net.ipv4.icmp_ratelimit=0 net.ipv4.ip_forward=15757+5858+# Run the test - a ping runs in the background, and we capture ICMP responses5959+# with tcpdump; -c 1 means it should exit on the first ping, but add a timeout6060+# in case something goes wrong6161+ip netns exec $NS1 ping -w 3 -i 0.5 $PINGADDR >/dev/null &6262+ip netns exec $NS1 timeout 10 tcpdump -tpni veth0 -c 1 'icmp and icmp[icmptype] != icmp-echo' > $TMPFILE 2>/dev/null6363+6464+# Parse response and check for dummy address6565+# tcpdump output looks like:6666+# IP 192.0.0.8 > 172.16.0.1: ICMP net 172.16.1.1 unreachable, length 926767+RESP_IP=$(awk '{print $2}' < $TMPFILE)6868+if [[ "$RESP_IP" != "192.0.0.8" ]]; then6969+ echo "FAIL - got ICMP response from $RESP_IP, should be 192.0.0.8"7070+ exit 17171+else7272+ echo "OK"7373+ exit 07474+fi
···197197ip -net "$ns4" route add default via 10.0.3.2198198ip -net "$ns4" route add default via dead:beef:3::2199199200200-# use TCP syn cookies, even if no flooding was detected.201201-ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2202202-203200set_ethtool_flags() {204201 local ns="$1"205202 local dev="$2"···732735 if [ $ret -ne 0 ] ;then733736 echo "FAIL: Could not even run loopback v6 test" 2>&1734737 exit $ret738738+ fi739739+740740+ # ns1<->ns2 is not subject to reordering/tc delays. Use it to test741741+ # mptcp syncookie support.742742+ if [ $sender = $ns1 ]; then743743+ ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2744744+ else745745+ ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=1735746 fi736747737748 run_tests "$ns2" $sender 10.0.1.2