Let user-space handle HvGetVpRegisters and HvSetVpRegisters as they are VTL aware hypercalls used solely in the context of VSM. Additionally, expose the cpuid bit. Signed-off-by: Nicolas Saenz Julienne <nsaenz@xxxxxxxxxx> --- Documentation/virt/kvm/api.rst | 10 ++++++++++ arch/x86/kvm/hyperv.c | 15 +++++++++++++++ include/asm-generic/hyperv-tlfs.h | 1 + 3 files changed, 26 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index e664c54a13b04..05b01b00a395c 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -8931,3 +8931,13 @@ CPUIDs map to KVM functionality. This CPUID indicates that KVM supports retuning data to the guest in response to a hypercall using the XMM registers. It also extends ``struct kvm_hyperv_exit`` to allow passing the XMM data from userspace. + +10.2 HV_ACCESS_VP_REGISTERS +--------------------------- + +:Location: CPUID.40000003H:EBX[bit 17] + +This CPUID indicates that KVM supports HvGetVpRegisters and HvSetVpRegisters. +Currently, it is only used in conjunction with HV_ACCESS_VSM, and immediately +exits to userspace with KVM_EXIT_HYPERV_HCALL as the reason. Userspace is +expected to complete the hypercall before resuming execution. diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index d00baf3ffb165..d0edc2bec5a4f 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -2425,6 +2425,11 @@ static void kvm_hv_write_xmm(struct kvm_hyperv_xmm_reg *xmm) static bool kvm_hv_is_xmm_output_hcall(u16 code) { + switch (code) { + case HVCALL_GET_VP_REGISTERS: + return true; + } + return false; } @@ -2505,6 +2510,8 @@ static bool is_xmm_fast_hypercall(struct kvm_hv_hcall *hc) case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX: case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX: case HVCALL_SEND_IPI_EX: + case HVCALL_GET_VP_REGISTERS: + case HVCALL_SET_VP_REGISTERS: return true; } @@ -2543,6 +2550,10 @@ static bool hv_check_hypercall_access(struct kvm_vcpu_hv *hv_vcpu, u16 code) */ return !kvm_hv_is_syndbg_enabled(hv_vcpu->vcpu) || hv_vcpu->cpuid_cache.features_ebx & HV_DEBUGGING; + case HVCALL_GET_VP_REGISTERS: + case HVCALL_SET_VP_REGISTERS: + return hv_vcpu->cpuid_cache.features_ebx & + HV_ACCESS_VP_REGISTERS; case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX: case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX: if (!(hv_vcpu->cpuid_cache.enlightenments_eax & @@ -2727,6 +2738,9 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) break; } goto hypercall_userspace_exit; + case HVCALL_GET_VP_REGISTERS: + case HVCALL_SET_VP_REGISTERS: + goto hypercall_userspace_exit; default: ret = HV_STATUS_INVALID_HYPERCALL_CODE; break; @@ -2898,6 +2912,7 @@ int kvm_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid, ent->ebx |= HV_POST_MESSAGES; ent->ebx |= HV_SIGNAL_EVENTS; ent->ebx |= HV_ENABLE_EXTENDED_HYPERCALLS; + ent->ebx |= HV_ACCESS_VP_REGISTERS; ent->edx |= HV_X64_HYPERCALL_XMM_INPUT_AVAILABLE; ent->edx |= HV_X64_HYPERCALL_XMM_OUTPUT_AVAILABLE; diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h index 28cde641b5474..9e909f0834598 100644 --- a/include/asm-generic/hyperv-tlfs.h +++ b/include/asm-generic/hyperv-tlfs.h @@ -90,6 +90,7 @@ #define HV_DEBUGGING BIT(11) #define HV_CPU_MANAGEMENT BIT(12) #define HV_ACCESS_VSM BIT(16) +#define HV_ACCESS_VP_REGISTERS BIT(17) #define HV_ENABLE_EXTENDED_HYPERCALLS BIT(20) #define HV_ISOLATION BIT(22) -- 2.40.1