GNU Linux-libre 6.8.7-gnu
[releases.git] / arch / powerpc / kernel / firmware.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
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
10  */
11
12 #include <linux/export.h>
13 #include <linux/cache.h>
14 #include <linux/of.h>
15
16 #include <asm/firmware.h>
17 #include <asm/kvm_guest.h>
18
19 #ifdef CONFIG_PPC64
20 unsigned long powerpc_firmware_features __read_mostly;
21 EXPORT_SYMBOL_GPL(powerpc_firmware_features);
22 #endif
23
24 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_GUEST)
25 DEFINE_STATIC_KEY_FALSE(kvm_guest);
26 EXPORT_SYMBOL_GPL(kvm_guest);
27
28 int __init check_kvm_guest(void)
29 {
30         struct device_node *hyper_node;
31
32         hyper_node = of_find_node_by_path("/hypervisor");
33         if (!hyper_node)
34                 return 0;
35
36         if (of_device_is_compatible(hyper_node, "linux,kvm"))
37                 static_branch_enable(&kvm_guest);
38
39         of_node_put(hyper_node);
40         return 0;
41 }
42 core_initcall(check_kvm_guest); // before kvm_guest_init()
43 #endif