Patch "powerpc: Fix is_kvm_guest() / kvm_para_available()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    powerpc: Fix is_kvm_guest() / kvm_para_available()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     powerpc-fix-is_kvm_guest-kvm_para_available.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b30386b044afd2b1a612a9906f5dc057aeedc409
Author: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Date:   Wed Jun 23 23:05:14 2021 +1000

    powerpc: Fix is_kvm_guest() / kvm_para_available()
    
    [ Upstream commit 95839225639ba7c3d8d7231b542728dcf222bf2d ]
    
    Commit a21d1becaa3f ("powerpc: Reintroduce is_kvm_guest() as a fast-path
    check") added is_kvm_guest() and changed kvm_para_available() to use it.
    
    is_kvm_guest() checks a static key, kvm_guest, and that static key is
    set in check_kvm_guest().
    
    The problem is check_kvm_guest() is only called on pseries, and even
    then only in some configurations. That means is_kvm_guest() always
    returns false on all non-pseries and some pseries depending on
    configuration. That's a bug.
    
    For PR KVM guests this is noticable because they no longer do live
    patching of themselves, which can be detected by the omission of a
    message in dmesg such as:
    
      KVM: Live patching for a fast VM worked
    
    To fix it make check_kvm_guest() an initcall, to ensure it's always
    called at boot. It needs to be core so that it runs before
    kvm_guest_init() which is postcore. To be an initcall it needs to return
    int, where 0 means success, so update that.
    
    We still call it manually in pSeries_smp_probe(), because that runs
    before init calls are run.
    
    Fixes: a21d1becaa3f ("powerpc: Reintroduce is_kvm_guest() as a fast-path check")
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210623130514.2543232-1-mpe@xxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/include/asm/kvm_guest.h b/arch/powerpc/include/asm/kvm_guest.h
index 2fca299f7e192..c63105d2c9e7c 100644
--- a/arch/powerpc/include/asm/kvm_guest.h
+++ b/arch/powerpc/include/asm/kvm_guest.h
@@ -16,10 +16,10 @@ static inline bool is_kvm_guest(void)
 	return static_branch_unlikely(&kvm_guest);
 }
 
-bool check_kvm_guest(void);
+int check_kvm_guest(void);
 #else
 static inline bool is_kvm_guest(void) { return false; }
-static inline bool check_kvm_guest(void) { return false; }
+static inline int check_kvm_guest(void) { return 0; }
 #endif
 
 #endif /* _ASM_POWERPC_KVM_GUEST_H_ */
diff --git a/arch/powerpc/kernel/firmware.c b/arch/powerpc/kernel/firmware.c
index c9e2819b095ab..c7022c41cc314 100644
--- a/arch/powerpc/kernel/firmware.c
+++ b/arch/powerpc/kernel/firmware.c
@@ -23,18 +23,20 @@ EXPORT_SYMBOL_GPL(powerpc_firmware_features);
 
 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_GUEST)
 DEFINE_STATIC_KEY_FALSE(kvm_guest);
-bool check_kvm_guest(void)
+int __init check_kvm_guest(void)
 {
 	struct device_node *hyper_node;
 
 	hyper_node = of_find_node_by_path("/hypervisor");
 	if (!hyper_node)
-		return false;
+		return 0;
 
 	if (!of_device_is_compatible(hyper_node, "linux,kvm"))
-		return false;
+		return 0;
 
 	static_branch_enable(&kvm_guest);
-	return true;
+
+	return 0;
 }
+core_initcall(check_kvm_guest); // before kvm_guest_init()
 #endif
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 9d596b41ec675..f47429323eee9 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -208,7 +208,9 @@ static __init void pSeries_smp_probe(void)
 	if (!cpu_has_feature(CPU_FTR_SMT))
 		return;
 
-	if (check_kvm_guest()) {
+	check_kvm_guest();
+
+	if (is_kvm_guest()) {
 		/*
 		 * KVM emulates doorbells by disabling FSCR[MSGP] so msgsndp
 		 * faults to the hypervisor which then reads the instruction



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux