hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/powerpc/kernel/firmware.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Extracted from cputable.c
34 *
....@@ -6,17 +7,35 @@
67 * Modifications for ppc64:
78 * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
89 * Copyright (C) 2005 Stephen Rothwell, IBM Corporation
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License
12
- * as published by the Free Software Foundation; either version
13
- * 2 of the License, or (at your option) any later version.
1410 */
1511
1612 #include <linux/export.h>
1713 #include <linux/cache.h>
14
+#include <linux/of.h>
1815
1916 #include <asm/firmware.h>
17
+#include <asm/kvm_guest.h>
2018
19
+#ifdef CONFIG_PPC64
2120 unsigned long powerpc_firmware_features __read_mostly;
2221 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
+int __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
+}
40
+core_initcall(check_kvm_guest); // before kvm_guest_init()
41
+#endif