firmware.c 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include <linux/export.h>
  12. #include <linux/cache.h>
  13. #include <linux/of.h>
  14. #include <asm/firmware.h>
  15. #include <asm/kvm_guest.h>
  16. #ifdef CONFIG_PPC64
  17. unsigned long powerpc_firmware_features __read_mostly;
  18. EXPORT_SYMBOL_GPL(powerpc_firmware_features);
  19. #endif
  20. #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_GUEST)
  21. DEFINE_STATIC_KEY_FALSE(kvm_guest);
  22. int __init check_kvm_guest(void)
  23. {
  24. struct device_node *hyper_node;
  25. hyper_node = of_find_node_by_path("/hypervisor");
  26. if (!hyper_node)
  27. return 0;
  28. if (of_device_is_compatible(hyper_node, "linux,kvm"))
  29. static_branch_enable(&kvm_guest);
  30. of_node_put(hyper_node);
  31. return 0;
  32. }
  33. core_initcall(check_kvm_guest); // before kvm_guest_init()
  34. #endif