blob: 20328f72f9f2ba2965da1f3148ff4f533f4564cd [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-or-later
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Extracted from cputable.c
4 *
5 * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
6 *
7 * Modifications for ppc64:
8 * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
9 * Copyright (C) 2005 Stephen Rothwell, IBM Corporation
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000010 */
11
12#include <linux/export.h>
13#include <linux/cache.h>
Olivier Deprez157378f2022-04-04 15:47:50 +020014#include <linux/of.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000015
16#include <asm/firmware.h>
Olivier Deprez157378f2022-04-04 15:47:50 +020017#include <asm/kvm_guest.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000018
Olivier Deprez157378f2022-04-04 15:47:50 +020019#ifdef CONFIG_PPC64
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000020unsigned long powerpc_firmware_features __read_mostly;
21EXPORT_SYMBOL_GPL(powerpc_firmware_features);
Olivier Deprez157378f2022-04-04 15:47:50 +020022#endif
23
24#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_GUEST)
25DEFINE_STATIC_KEY_FALSE(kvm_guest);
26int __init check_kvm_guest(void)
27{
28 struct device_node *hyper_node;
29
30 hyper_node = of_find_node_by_path("/hypervisor");
31 if (!hyper_node)
32 return 0;
33
34 if (of_device_is_compatible(hyper_node, "linux,kvm"))
35 static_branch_enable(&kvm_guest);
36
37 of_node_put(hyper_node);
38 return 0;
39}
40core_initcall(check_kvm_guest); // before kvm_guest_init()
41#endif