2016-04-07 11:48:09

by Paolo Bonzini

[permalink] [raw]
Subject: [PATCH] KVM: x86: mask CPUID(0xD,0x1).EAX against host value

This ensures that the guest doesn't see XSAVE extensions
(e.g. xgetbv1 or xsavec) that the host lacks.

Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
---
arch/x86/kvm/cpuid.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 8efb839948e5..bbbaa802d13e 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -534,6 +534,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
do_cpuid_1_ent(&entry[i], function, idx);
if (idx == 1) {
entry[i].eax &= kvm_cpuid_D_1_eax_x86_features;
+ cpuid_mask(&entry[i].eax, CPUID_D_1_EAX);
entry[i].ebx = 0;
if (entry[i].eax & (F(XSAVES)|F(XSAVEC)))
entry[i].ebx =
--
1.8.3.1


2016-04-07 14:40:58

by Radim Krčmář

[permalink] [raw]
Subject: Re: [PATCH] KVM: x86: mask CPUID(0xD,0x1).EAX against host value

2016-04-07 13:47+0200, Paolo Bonzini:
> This ensures that the guest doesn't see XSAVE extensions
> (e.g. xgetbv1 or xsavec) that the host lacks.
>
> Cc: [email protected]
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---

Reviewed-by: Radim Krčmář <[email protected]>