@@ -1081,6 +1081,17 @@ config PARAVIRT_TIME_ACCOUNTING
If in doubt, say N here.
+config KVM_GUEST
+ bool "KVM Guest Support"
+ depends on PARAVIRT
+ default y
+ help
+ This option enables various optimizations for running under the KVM
+ hypervisor. Overhead for the kernel when not running inside KVM should
+ be minimal.
+
+ In case of doubt, say Y
+
config KEXEC
depends on PM_SLEEP_SMP
select KEXEC_CORE
@@ -3,6 +3,8 @@
#define _ASM_ARM_KVM_PARA_H
#include <uapi/asm/kvm_para.h>
+#include <linux/of.h>
+#include <asm/hypervisor.h>
static inline bool kvm_check_and_clear_guest_paused(void)
{
@@ -11,7 +13,12 @@ static inline bool kvm_check_and_clear_guest_paused(void)
static inline unsigned int kvm_arch_para_features(void)
{
- return 0;
+ unsigned int features = 0;
+
+ if (kvm_arm_hyp_service_available(ARM_SMCCC_KVM_FUNC_ASYNC_PF))
+ features |= (1 << KVM_FEATURE_ASYNC_PF);
+
+ return features;
}
static inline unsigned int kvm_arch_para_hints(void)
@@ -21,6 +28,9 @@ static inline unsigned int kvm_arch_para_hints(void)
static inline bool kvm_para_available(void)
{
+ if (IS_ENABLED(CONFIG_KVM_GUEST))
+ return true;
+
return false;
}
@@ -4,6 +4,8 @@
#include <linux/types.h>
+#define KVM_FEATURE_ASYNC_PF 0
+
/* Async PF */
#define KVM_ASYNC_PF_ENABLED (1 << 0)
#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1)
This implements kvm_para_available() to check if para-virtualization features are available or not. Besides, kvm_para_has_feature() is enhanced to detect the asynchronous page fault para-virtualization feature. These two functions are going to be used by guest kernel to enable the asynchronous page fault. This also adds kernel option (CONFIG_KVM_GUEST), which is the umbrella for the optimizations related to KVM para-virtualization. Signed-off-by: Gavin Shan <gshan@redhat.com> --- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/kvm_para.h | 12 +++++++++++- arch/arm64/include/uapi/asm/kvm_para.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-)