* [PATCH] KVM: x86: Supplement __cr4_reserved_bits() with X86_FEATURE_PCID check
@ 2021-02-01 14:28 Vitaly Kuznetsov
2021-02-01 14:43 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Vitaly Kuznetsov @ 2021-02-01 14:28 UTC (permalink / raw)
To: kvm, Paolo Bonzini; +Cc: Sean Christopherson, Wanpeng Li, Jim Mattson
Commit 7a873e455567 ("KVM: selftests: Verify supported CR4 bits can be set
before KVM_SET_CPUID2") reveals that KVM allows to set X86_CR4_PCIDE even
when PCID support is missing:
==== Test Assertion Failure ====
x86_64/set_sregs_test.c:41: rc
pid=6956 tid=6956 - Invalid argument
1 0x000000000040177d: test_cr4_feature_bit at set_sregs_test.c:41
2 0x00000000004014fc: main at set_sregs_test.c:119
3 0x00007f2d9346d041: ?? ??:0
4 0x000000000040164d: _start at ??:?
KVM allowed unsupported CR4 bit (0x20000)
Add X86_FEATURE_PCID feature check to __cr4_reserved_bits() to make
kvm_is_valid_cr4() fail.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
arch/x86/kvm/x86.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index c5ee0f5ce0f1..0f727b50bd3d 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -425,6 +425,8 @@ bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
__reserved_bits |= X86_CR4_UMIP; \
if (!__cpu_has(__c, X86_FEATURE_VMX)) \
__reserved_bits |= X86_CR4_VMXE; \
+ if (!__cpu_has(__c, X86_FEATURE_PCID)) \
+ __reserved_bits |= X86_CR4_PCIDE; \
__reserved_bits; \
})
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86: Supplement __cr4_reserved_bits() with X86_FEATURE_PCID check
2021-02-01 14:28 [PATCH] KVM: x86: Supplement __cr4_reserved_bits() with X86_FEATURE_PCID check Vitaly Kuznetsov
@ 2021-02-01 14:43 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2021-02-01 14:43 UTC (permalink / raw)
To: Vitaly Kuznetsov, kvm; +Cc: Sean Christopherson, Wanpeng Li, Jim Mattson
On 01/02/21 15:28, Vitaly Kuznetsov wrote:
> Commit 7a873e455567 ("KVM: selftests: Verify supported CR4 bits can be set
> before KVM_SET_CPUID2") reveals that KVM allows to set X86_CR4_PCIDE even
> when PCID support is missing:
>
> ==== Test Assertion Failure ====
> x86_64/set_sregs_test.c:41: rc
> pid=6956 tid=6956 - Invalid argument
> 1 0x000000000040177d: test_cr4_feature_bit at set_sregs_test.c:41
> 2 0x00000000004014fc: main at set_sregs_test.c:119
> 3 0x00007f2d9346d041: ?? ??:0
> 4 0x000000000040164d: _start at ??:?
> KVM allowed unsupported CR4 bit (0x20000)
>
> Add X86_FEATURE_PCID feature check to __cr4_reserved_bits() to make
> kvm_is_valid_cr4() fail.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> arch/x86/kvm/x86.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index c5ee0f5ce0f1..0f727b50bd3d 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -425,6 +425,8 @@ bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
> __reserved_bits |= X86_CR4_UMIP; \
> if (!__cpu_has(__c, X86_FEATURE_VMX)) \
> __reserved_bits |= X86_CR4_VMXE; \
> + if (!__cpu_has(__c, X86_FEATURE_PCID)) \
> + __reserved_bits |= X86_CR4_PCIDE; \
> __reserved_bits; \
> })
>
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-01 14:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 14:28 [PATCH] KVM: x86: Supplement __cr4_reserved_bits() with X86_FEATURE_PCID check Vitaly Kuznetsov
2021-02-01 14:43 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).