mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniil Tatianin <d-tatianin@yandex-team.ru>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm/x86: actually verify that reading MSR_IA32_UCODE_REV succeeds
Date: Thu, 16 Mar 2023 08:51:15 +0300	[thread overview]
Message-ID: <69f0d161-e473-37dc-13a9-c81ec9145de2@yandex-team.ru> (raw)
In-Reply-To: <ZBInlO18ZlClLbHp@google.com>

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!

      reply	other threads:[~2023-03-16  5:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 19:51 Daniil Tatianin
2023-03-15 20:16 ` Sean Christopherson
2023-03-16  5:51   ` Daniil Tatianin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69f0d161-e473-37dc-13a9-c81ec9145de2@yandex-team.ru \
    --to=d-tatianin@yandex-team.ru \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®