Skip to content

Commit 4e62aa9

Browse files
vittyvkbonzini
authored andcommitted
KVM: x86: hyper-v: Check if guest is allowed to use XMM registers for hypercall input
TLFS states that "Availability of the XMM fast hypercall interface is indicated via the “Hypervisor Feature Identification” CPUID Leaf (0x40000003, see section 2.4.4) ... Any attempt to use this interface when the hypervisor does not indicate availability will result in a #UD fault." Implement the check for 'strict' mode (KVM_CAP_HYPERV_ENFORCE_CPUID). Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Siddharth Chandrasekaran <sidcha@amazon.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20210730122625.112848-4-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent f5714bb commit 4e62aa9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

arch/x86/kvm/hyperv.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,7 @@ static bool hv_check_hypercall_access(struct kvm_vcpu_hv *hv_vcpu, u16 code)
21402140

21412141
int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
21422142
{
2143+
struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
21432144
struct kvm_hv_hcall hc;
21442145
u64 ret = HV_STATUS_SUCCESS;
21452146

@@ -2177,13 +2178,21 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
21772178
trace_kvm_hv_hypercall(hc.code, hc.fast, hc.rep_cnt, hc.rep_idx,
21782179
hc.ingpa, hc.outgpa);
21792180

2180-
if (unlikely(!hv_check_hypercall_access(to_hv_vcpu(vcpu), hc.code))) {
2181+
if (unlikely(!hv_check_hypercall_access(hv_vcpu, hc.code))) {
21812182
ret = HV_STATUS_ACCESS_DENIED;
21822183
goto hypercall_complete;
21832184
}
21842185

2185-
if (hc.fast && is_xmm_fast_hypercall(&hc))
2186+
if (hc.fast && is_xmm_fast_hypercall(&hc)) {
2187+
if (unlikely(hv_vcpu->enforce_cpuid &&
2188+
!(hv_vcpu->cpuid_cache.features_edx &
2189+
HV_X64_HYPERCALL_XMM_INPUT_AVAILABLE))) {
2190+
kvm_queue_exception(vcpu, UD_VECTOR);
2191+
return 1;
2192+
}
2193+
21862194
kvm_hv_hypercall_read_xmm(&hc);
2195+
}
21872196

21882197
switch (hc.code) {
21892198
case HVCALL_NOTIFY_LONG_SPIN_WAIT:

0 commit comments

Comments
 (0)