mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
![Michael Ellerman](/assets/img/avatar_default.png)
Commita21d1becaa
("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:a21d1becaa
("powerpc: Reintroduce is_kvm_guest() as a fast-path check") Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210623130514.2543232-1-mpe@ellerman.id.au
42 lines
999 B
C
42 lines
999 B
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Extracted from cputable.c
|
|
*
|
|
* Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
|
|
*
|
|
* Modifications for ppc64:
|
|
* Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
|
|
* Copyright (C) 2005 Stephen Rothwell, IBM Corporation
|
|
*/
|
|
|
|
#include <linux/export.h>
|
|
#include <linux/cache.h>
|
|
#include <linux/of.h>
|
|
|
|
#include <asm/firmware.h>
|
|
#include <asm/kvm_guest.h>
|
|
|
|
#ifdef CONFIG_PPC64
|
|
unsigned long powerpc_firmware_features __read_mostly;
|
|
EXPORT_SYMBOL_GPL(powerpc_firmware_features);
|
|
#endif
|
|
|
|
#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_GUEST)
|
|
DEFINE_STATIC_KEY_FALSE(kvm_guest);
|
|
int __init check_kvm_guest(void)
|
|
{
|
|
struct device_node *hyper_node;
|
|
|
|
hyper_node = of_find_node_by_path("/hypervisor");
|
|
if (!hyper_node)
|
|
return 0;
|
|
|
|
if (!of_device_is_compatible(hyper_node, "linux,kvm"))
|
|
return 0;
|
|
|
|
static_branch_enable(&kvm_guest);
|
|
|
|
return 0;
|
|
}
|
|
core_initcall(check_kvm_guest); // before kvm_guest_init()
|
|
#endif
|