public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Daniil Tatianin <d-tatianin@yandex-team.ru>
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: Wed, 15 Mar 2023 13:16:20 -0700	[thread overview]
Message-ID: <ZBInlO18ZlClLbHp@google.com> (raw)
In-Reply-To: <20230315195109.580333-1-d-tatianin@yandex-team.ru>

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.

  reply	other threads:[~2023-03-15 20:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-03-16  5:51   ` Daniil Tatianin

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=ZBInlO18ZlClLbHp@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=d-tatianin@yandex-team.ru \
    --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=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