* [PATCH] kvm/x86: actually verify that reading MSR_IA32_UCODE_REV succeeds
@ 2023-03-15 19:51 Daniil Tatianin
2023-03-15 20:16 ` Sean Christopherson
0 siblings, 1 reply; 3+ messages in thread
From: Daniil Tatianin @ 2023-03-15 19:51 UTC (permalink / raw)
To: Sean Christopherson
Cc: Daniil Tatianin, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, kvm,
linux-kernel
...and return KVM_MSR_RET_INVALID otherwise.
Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
Fixes: cd28325249a1 ("KVM: VMX: support MSR_IA32_ARCH_CAPABILITIES as a feature MSR")
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
arch/x86/kvm/x86.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7713420abab0..7de6939fc371 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1661,7 +1661,8 @@ static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
msr->data = kvm_caps.supported_perf_cap;
break;
case MSR_IA32_UCODE_REV:
- rdmsrl_safe(msr->index, &msr->data);
+ if (rdmsrl_safe(msr->index, &msr->data))
+ return KVM_MSR_RET_INVALID;
break;
default:
return static_call(kvm_x86_get_msr_feature)(msr);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm/x86: actually verify that reading MSR_IA32_UCODE_REV succeeds
2023-03-15 19:51 [PATCH] kvm/x86: actually verify that reading MSR_IA32_UCODE_REV succeeds Daniil Tatianin
@ 2023-03-15 20:16 ` Sean Christopherson
2023-03-16 5:51 ` Daniil Tatianin
0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2023-03-15 20:16 UTC (permalink / raw)
To: Daniil Tatianin
Cc: Paolo Bonzini, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, kvm, linux-kernel
On Wed, Mar 15, 2023, Daniil Tatianin wrote:
> ...and return KVM_MSR_RET_INVALID otherwise.
>
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
>
> Fixes: cd28325249a1 ("KVM: VMX: support MSR_IA32_ARCH_CAPABILITIES as a feature MSR")
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> ---
> arch/x86/kvm/x86.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 7713420abab0..7de6939fc371 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1661,7 +1661,8 @@ static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
> msr->data = kvm_caps.supported_perf_cap;
> break;
> case MSR_IA32_UCODE_REV:
> - rdmsrl_safe(msr->index, &msr->data);
> + if (rdmsrl_safe(msr->index, &msr->data))
> + return KVM_MSR_RET_INVALID;
This is unnecessary and would arguably break KVM's ABI. KVM unconditionally emulates
MSR_IA32_UCODE_REV in software and rdmsrl_safe() zeros the result on a fault (see
ex_handler_msr()). '0' is a legitimate ucode revid and a reasonable fallback for
a theoretical (virtual) CPU that doesn't support the MSR.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm/x86: actually verify that reading MSR_IA32_UCODE_REV succeeds
2023-03-15 20:16 ` Sean Christopherson
@ 2023-03-16 5:51 ` Daniil Tatianin
0 siblings, 0 replies; 3+ messages in thread
From: Daniil Tatianin @ 2023-03-16 5:51 UTC (permalink / raw)
To: Sean Christopherson
Cc: Paolo Bonzini, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, kvm, linux-kernel
On 3/15/23 11:16 PM, Sean Christopherson wrote:
> On Wed, Mar 15, 2023, Daniil Tatianin wrote:
>> ...and return KVM_MSR_RET_INVALID otherwise.
>>
>> Found by Linux Verification Center (linuxtesting.org) with the SVACE
>> static analysis tool.
>>
>> Fixes: cd28325249a1 ("KVM: VMX: support MSR_IA32_ARCH_CAPABILITIES as a feature MSR")
>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
>> ---
>> arch/x86/kvm/x86.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index 7713420abab0..7de6939fc371 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -1661,7 +1661,8 @@ static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
>> msr->data = kvm_caps.supported_perf_cap;
>> break;
>> case MSR_IA32_UCODE_REV:
>> - rdmsrl_safe(msr->index, &msr->data);
>> + if (rdmsrl_safe(msr->index, &msr->data))
>> + return KVM_MSR_RET_INVALID;
>
> This is unnecessary and would arguably break KVM's ABI. KVM unconditionally emulates
> MSR_IA32_UCODE_REV in software and rdmsrl_safe() zeros the result on a fault (see
> ex_handler_msr()). '0' is a legitimate ucode revid and a reasonable fallback for
> a theoretical (virtual) CPU that doesn't support the MSR.
I see, thanks for the explanation!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-16 5:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 19:51 [PATCH] kvm/x86: actually verify that reading MSR_IA32_UCODE_REV succeeds Daniil Tatianin
2023-03-15 20:16 ` Sean Christopherson
2023-03-16 5:51 ` Daniil Tatianin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.