From: Sasha Levin Date: Tue, 10 May 2022 00:57:01 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v4.9.313~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1563b1138d92d9ae76529703f1ed9ebcd899683;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/hwmon-adt7470-fix-warning-on-module-removal.patch-15216 b/queue-5.4/hwmon-adt7470-fix-warning-on-module-removal.patch-15216 new file mode 100644 index 00000000000..a76985ba626 --- /dev/null +++ b/queue-5.4/hwmon-adt7470-fix-warning-on-module-removal.patch-15216 @@ -0,0 +1,49 @@ +From 4fdf6634d79999d99d828650e324f5a7fc705635 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 7 Apr 2022 12:13:12 +0200 +Subject: hwmon: (adt7470) Fix warning on module removal + +From: Armin Wolf + +[ Upstream commit 7b2666ce445c700b8dcee994da44ddcf050a0842 ] + +When removing the adt7470 module, a warning might be printed: + +do not call blocking ops when !TASK_RUNNING; state=1 +set at [] adt7470_update_thread+0x7b/0x130 [adt7470] + +This happens because adt7470_update_thread() can leave the kthread in +TASK_INTERRUPTIBLE state when the kthread is being stopped before +the call of set_current_state(). Since kthread_exit() might sleep in +exit_signals(), the warning is printed. +Fix that by using schedule_timeout_interruptible() and removing +the call of set_current_state(). +This causes TASK_INTERRUPTIBLE to be set after kthread_should_stop() +which might cause the kthread to exit. + +Reported-by: Zheyu Ma +Fixes: 93cacfd41f82 (hwmon: (adt7470) Allow faster removal) +Signed-off-by: Armin Wolf +Tested-by: Zheyu Ma +Link: https://lore.kernel.org/r/20220407101312.13331-1-W_Armin@gmx.de +Signed-off-by: Guenter Roeck +Signed-off-by: Sasha Levin +--- + drivers/hwmon/adt7470.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c +index 95e06886991d..1f82a0ee0397 100644 +--- a/drivers/hwmon/adt7470.c ++++ b/drivers/hwmon/adt7470.c +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.35.1 + diff --git a/queue-5.4/kvm-lapic-enable-timer-posted-interrupt-only-when-mw.patch b/queue-5.4/kvm-lapic-enable-timer-posted-interrupt-only-when-mw.patch new file mode 100644 index 00000000000..c974e788aaa --- /dev/null +++ b/queue-5.4/kvm-lapic-enable-timer-posted-interrupt-only-when-mw.patch @@ -0,0 +1,54 @@ +From a94ed7387b4bb4905a00a3199829e3038a4e6d61 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 25 Jan 2022 04:08:58 -0800 +Subject: KVM: LAPIC: Enable timer posted-interrupt only when mwait/hlt is + advertised + +From: Wanpeng Li + +[ Upstream commit 1714a4eb6fb0cb79f182873cd011a8ed60ac65e8 ] + +As commit 0c5f81dad46 ("KVM: LAPIC: Inject timer interrupt via posted +interrupt") mentioned that the host admin should well tune the guest +setup, so that vCPUs are placed on isolated pCPUs, and with several pCPUs +surplus for *busy* housekeeping. In this setup, it is preferrable to +disable mwait/hlt/pause vmexits to keep the vCPUs in non-root mode. + +However, if only some guests isolated and others not, they would not +have any benefit from posted timer interrupts, and at the same time lose +VMX preemption timer fast paths because kvm_can_post_timer_interrupt() +returns true and therefore forces kvm_can_use_hv_timer() to false. + +By guaranteeing that posted-interrupt timer is only used if MWAIT or +HLT are done without vmexit, KVM can make a better choice and use the +VMX preemption timer and the corresponding fast paths. + +Reported-by: Aili Yao +Reviewed-by: Sean Christopherson +Cc: Aili Yao +Cc: Sean Christopherson +Signed-off-by: Wanpeng Li +Message-Id: <1643112538-36743-1-git-send-email-wanpengli@tencent.com> +Signed-off-by: Paolo Bonzini +Signed-off-by: Sasha Levin +--- + arch/x86/kvm/lapic.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c +index afe3b8e61514..3696b4de9d99 100644 +--- a/arch/x86/kvm/lapic.c ++++ b/arch/x86/kvm/lapic.c +@@ -118,7 +118,8 @@ static inline u32 kvm_x2apic_id(struct kvm_lapic *apic) + + bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu) + { +- return pi_inject_timer && kvm_vcpu_apicv_active(vcpu); ++ return pi_inject_timer && kvm_vcpu_apicv_active(vcpu) && ++ (kvm_mwait_in_guest(vcpu->kvm) || kvm_hlt_in_guest(vcpu->kvm)); + } + EXPORT_SYMBOL_GPL(kvm_can_post_timer_interrupt); + +-- +2.35.1 + diff --git a/queue-5.4/kvm-x86-cpuid-only-provide-cpuid-leaf-0xa-if-host-ha.patch b/queue-5.4/kvm-x86-cpuid-only-provide-cpuid-leaf-0xa-if-host-ha.patch new file mode 100644 index 00000000000..a9cb1257c36 --- /dev/null +++ b/queue-5.4/kvm-x86-cpuid-only-provide-cpuid-leaf-0xa-if-host-ha.patch @@ -0,0 +1,54 @@ +From 0f2da91a0c674b43912040d6a77225d2d2879e27 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 27 Apr 2022 17:01:49 +0530 +Subject: kvm: x86/cpuid: Only provide CPUID leaf 0xA if host has architectural + PMU + +From: Sandipan Das + +[ Upstream commit 5a1bde46f98b893cda6122b00e94c0c40a6ead3c ] + +On some x86 processors, CPUID leaf 0xA provides information +on Architectural Performance Monitoring features. It +advertises a PMU version which Qemu uses to determine the +availability of additional MSRs to manage the PMCs. + +Upon receiving a KVM_GET_SUPPORTED_CPUID ioctl request for +the same, the kernel constructs return values based on the +x86_pmu_capability irrespective of the vendor. + +This leaf and the additional MSRs are not supported on AMD +and Hygon processors. If AMD PerfMonV2 is detected, the PMU +version is set to 2 and guest startup breaks because of an +attempt to access a non-existent MSR. Return zeros to avoid +this. + +Fixes: a6c06ed1a60a ("KVM: Expose the architectural performance monitoring CPUID leaf") +Reported-by: Vasant Hegde +Signed-off-by: Sandipan Das +Message-Id: <3fef83d9c2b2f7516e8ff50d60851f29a4bcb716.1651058600.git.sandipan.das@amd.com> +Signed-off-by: Paolo Bonzini +Signed-off-by: Sasha Levin +--- + arch/x86/kvm/cpuid.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c +index 6a8db8eb0e94..62c7f771a7cf 100644 +--- a/arch/x86/kvm/cpuid.c ++++ b/arch/x86/kvm/cpuid.c +@@ -592,6 +592,11 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function, + union cpuid10_eax eax; + union cpuid10_edx edx; + ++ if (!static_cpu_has(X86_FEATURE_ARCH_PERFMON)) { ++ entry->eax = entry->ebx = entry->ecx = entry->edx = 0; ++ break; ++ } ++ + perf_get_x86_pmu_capability(&cap); + + /* +-- +2.35.1 + diff --git a/queue-5.4/nfc-netlink-fix-sleep-in-atomic-bug-when-firmware-do.patch b/queue-5.4/nfc-netlink-fix-sleep-in-atomic-bug-when-firmware-do.patch new file mode 100644 index 00000000000..96128641fe6 --- /dev/null +++ b/queue-5.4/nfc-netlink-fix-sleep-in-atomic-bug-when-firmware-do.patch @@ -0,0 +1,70 @@ +From eb97b9f8bfb9bed63c50821b17f83e052dfb0a86 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 May 2022 13:58:47 +0800 +Subject: NFC: netlink: fix sleep in atomic bug when firmware download timeout + +From: Duoming Zhou + +[ Upstream commit 4071bf121d59944d5cd2238de0642f3d7995a997 ] + +There are sleep in atomic bug that could cause kernel panic during +firmware download process. The root cause is that nlmsg_new with +GFP_KERNEL parameter is called in fw_dnld_timeout which is a timer +handler. The call trace is shown below: + +BUG: sleeping function called from invalid context at include/linux/sched/mm.h:265 +Call Trace: +kmem_cache_alloc_node +__alloc_skb +nfc_genl_fw_download_done +call_timer_fn +__run_timers.part.0 +run_timer_softirq +__do_softirq +... + +The nlmsg_new with GFP_KERNEL parameter may sleep during memory +allocation process, and the timer handler is run as the result of +a "software interrupt" that should not call any other function +that could sleep. + +This patch changes allocation mode of netlink message from GFP_KERNEL +to GFP_ATOMIC in order to prevent sleep in atomic bug. The GFP_ATOMIC +flag makes memory allocation operation could be used in atomic context. + +Fixes: 9674da8759df ("NFC: Add firmware upload netlink command") +Fixes: 9ea7187c53f6 ("NFC: netlink: Rename CMD_FW_UPLOAD to CMD_FW_DOWNLOAD") +Signed-off-by: Duoming Zhou +Reviewed-by: Krzysztof Kozlowski +Link: https://lore.kernel.org/r/20220504055847.38026-1-duoming@zju.edu.cn +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + net/nfc/netlink.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c +index 9e94f732e717..a5d8f87c3763 100644 +--- a/net/nfc/netlink.c ++++ b/net/nfc/netlink.c +@@ -542,7 +542,7 @@ int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx) + struct sk_buff *msg; + void *hdr; + +- msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); ++ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); + if (!msg) + return -ENOMEM; + +@@ -562,7 +562,7 @@ int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx) + + genlmsg_end(msg, hdr); + +- genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL); ++ genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC); + + return 0; + +-- +2.35.1 + diff --git a/queue-5.4/nfsv4-don-t-invalidate-inode-attributes-on-delegatio.patch b/queue-5.4/nfsv4-don-t-invalidate-inode-attributes-on-delegatio.patch new file mode 100644 index 00000000000..27857e98dea --- /dev/null +++ b/queue-5.4/nfsv4-don-t-invalidate-inode-attributes-on-delegatio.patch @@ -0,0 +1,56 @@ +From f9af82a9d9390d725a6bf40332037e3dd24250fa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Apr 2022 18:04:27 -0400 +Subject: NFSv4: Don't invalidate inode attributes on delegation return + +From: Trond Myklebust + +[ Upstream commit 00c94ebec5925593c0377b941289224469e72ac7 ] + +There is no need to declare attributes such as the ctime, mtime and +block size invalid when we're just returning a delegation, so it is +inappropriate to call nfs_post_op_update_inode_force_wcc(). +Instead, just call nfs_refresh_inode() after faking up the change +attribute. We know that the GETATTR op occurs before the DELEGRETURN, so +we are safe when doing this. + +Fixes: 0bc2c9b4dca9 ("NFSv4: Don't discard the attributes returned by asynchronous DELEGRETURN") +Signed-off-by: Trond Myklebust +Signed-off-by: Sasha Levin +--- + fs/nfs/nfs4proc.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index 76baf7b441f3..cf3b00751ff6 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -359,6 +359,14 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent + kunmap_atomic(start); + } + ++static void nfs4_fattr_set_prechange(struct nfs_fattr *fattr, u64 version) ++{ ++ if (!(fattr->valid & NFS_ATTR_FATTR_PRECHANGE)) { ++ fattr->pre_change_attr = version; ++ fattr->valid |= NFS_ATTR_FATTR_PRECHANGE; ++ } ++} ++ + static void nfs4_test_and_free_stateid(struct nfs_server *server, + nfs4_stateid *stateid, + const struct cred *cred) +@@ -6307,7 +6315,9 @@ static void nfs4_delegreturn_release(void *calldata) + pnfs_roc_release(&data->lr.arg, &data->lr.res, + data->res.lr_ret); + if (inode) { +- nfs_post_op_update_inode_force_wcc(inode, &data->fattr); ++ nfs4_fattr_set_prechange(&data->fattr, ++ inode_peek_iversion_raw(inode)); ++ nfs_refresh_inode(inode, &data->fattr); + nfs_iput_and_deactive(inode); + } + kfree(calldata); +-- +2.35.1 + diff --git a/queue-5.4/series b/queue-5.4/series index 41ab5308e88..a27fb4509a8 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -32,3 +32,9 @@ smsc911x-allow-using-irq0.patch btrfs-always-log-symlinks-in-full-mode.patch net-igmp-respect-rcu-rules-in-ip_mc_source-and-ip_mc_msfilter.patch drm-amdkfd-use-drm_priv-to-pass-vm-from-kfd-to-amdgpu.patch +hwmon-adt7470-fix-warning-on-module-removal.patch-15216 +nfsv4-don-t-invalidate-inode-attributes-on-delegatio.patch +kvm-x86-cpuid-only-provide-cpuid-leaf-0xa-if-host-ha.patch +nfc-netlink-fix-sleep-in-atomic-bug-when-firmware-do.patch +x86-kvm-preserve-bsp-msr_kvm_poll_control-across-sus.patch +kvm-lapic-enable-timer-posted-interrupt-only-when-mw.patch diff --git a/queue-5.4/x86-kvm-preserve-bsp-msr_kvm_poll_control-across-sus.patch b/queue-5.4/x86-kvm-preserve-bsp-msr_kvm_poll_control-across-sus.patch new file mode 100644 index 00000000000..d3b143fa7c6 --- /dev/null +++ b/queue-5.4/x86-kvm-preserve-bsp-msr_kvm_poll_control-across-sus.patch @@ -0,0 +1,71 @@ +From 17652e8a748924071cb74511c93a1c0e2ff4477b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 18 Apr 2022 00:42:32 -0700 +Subject: x86/kvm: Preserve BSP MSR_KVM_POLL_CONTROL across suspend/resume + +From: Wanpeng Li + +[ Upstream commit 0361bdfddca20c8855ea3bdbbbc9c999912b10ff ] + +MSR_KVM_POLL_CONTROL is cleared on reset, thus reverting guests to +host-side polling after suspend/resume. Non-bootstrap CPUs are +restored correctly by the haltpoll driver because they are hot-unplugged +during suspend and hot-plugged during resume; however, the BSP +is not hotpluggable and remains in host-sde polling mode after +the guest resume. The makes the guest pay for the cost of vmexits +every time the guest enters idle. + +Fix it by recording BSP's haltpoll state and resuming it during guest +resume. + +Cc: Marcelo Tosatti +Signed-off-by: Wanpeng Li +Message-Id: <1650267752-46796-1-git-send-email-wanpengli@tencent.com> +Signed-off-by: Paolo Bonzini +Signed-off-by: Sasha Levin +--- + arch/x86/kernel/kvm.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c +index 408b51aba293..f582dda8dd34 100644 +--- a/arch/x86/kernel/kvm.c ++++ b/arch/x86/kernel/kvm.c +@@ -59,6 +59,7 @@ static DEFINE_PER_CPU_DECRYPTED(struct kvm_vcpu_pv_apf_data, apf_reason) __align + DEFINE_PER_CPU_DECRYPTED(struct kvm_steal_time, steal_time) __aligned(64) __visible; + static int has_steal_clock = 0; + ++static int has_guest_poll = 0; + /* + * No need for any "IO delay" on KVM + */ +@@ -584,14 +585,26 @@ static int kvm_cpu_down_prepare(unsigned int cpu) + + static int kvm_suspend(void) + { ++ u64 val = 0; ++ + kvm_guest_cpu_offline(false); + ++#ifdef CONFIG_ARCH_CPUIDLE_HALTPOLL ++ if (kvm_para_has_feature(KVM_FEATURE_POLL_CONTROL)) ++ rdmsrl(MSR_KVM_POLL_CONTROL, val); ++ has_guest_poll = !(val & 1); ++#endif + return 0; + } + + static void kvm_resume(void) + { + kvm_cpu_online(raw_smp_processor_id()); ++ ++#ifdef CONFIG_ARCH_CPUIDLE_HALTPOLL ++ if (kvm_para_has_feature(KVM_FEATURE_POLL_CONTROL) && has_guest_poll) ++ wrmsrl(MSR_KVM_POLL_CONTROL, 0); ++#endif + } + + static struct syscore_ops kvm_syscore_ops = { +-- +2.35.1 +