linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
	Alexander Graf <graf@amazon.com>
Subject: Re: [PATCH 2/3] KVM: x86: use kvm_complete_insn_gp in emulating RDMSR/WRMSR
Date: Mon, 14 Dec 2020 14:52:09 -0600	[thread overview]
Message-ID: <bc04f9a7-cc26-2347-58ae-bcbc024d996d@amd.com> (raw)
In-Reply-To: <20201214183250.1034541-3-pbonzini@redhat.com>

On 12/14/20 12:32 PM, Paolo Bonzini wrote:
> Simplify the four functions that handle {kernel,user} {rd,wr}msr, there
> is still some repetition between the two instances of rdmsr but the
> whole business of calling kvm_inject_gp and kvm_skip_emulated_instruction
> can be unified nicely.
> 
> Because complete_emulated_wrmsr now becomes essentially a call to
> kvm_complete_insn_gp, remove complete_emulated_msr.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Just two minor nits below.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index a3fdc16cfd6f..2f1bc52e70c0 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1634,27 +1634,20 @@ int kvm_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data)
>  }
>  EXPORT_SYMBOL_GPL(kvm_set_msr);
>  
>  
>  	/* MSR read failed? Inject a #GP */

This comment isn't accurate any more, maybe just delete it?

> -	if (r) {
> +	if (!r) {
> +		trace_kvm_msr_read(ecx, data);
> +
> +		kvm_rax_write(vcpu, data & -1u);
> +		kvm_rdx_write(vcpu, (data >> 32) & -1u);
> +	} else {
>  		trace_kvm_msr_read_ex(ecx);
> -		kvm_inject_gp(vcpu, 0);
> -		return 1;
>  	}
>  
> -	trace_kvm_msr_read(ecx, data);
> -
> -	kvm_rax_write(vcpu, data & -1u);
> -	kvm_rdx_write(vcpu, (data >> 32) & -1u);
> -	return kvm_skip_emulated_instruction(vcpu);
> +	return kvm_complete_insn_gp(vcpu, r);
>  }
>  EXPORT_SYMBOL_GPL(kvm_emulate_rdmsr);
>  
> @@ -1750,14 +1742,12 @@ int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu)
>  		return r;
>  
>  	/* MSR write failed? Inject a #GP */

Ditto on this comment.

Thanks,
Tom

> -	if (r > 0) {
> +	if (!r)
> +		trace_kvm_msr_write(ecx, data);
> +	else
>  		trace_kvm_msr_write_ex(ecx, data);
> -		kvm_inject_gp(vcpu, 0);
> -		return 1;
> -	}
>  
> -	trace_kvm_msr_write(ecx, data);
> -	return kvm_skip_emulated_instruction(vcpu);
> +	return kvm_complete_insn_gp(vcpu, r);
>  }
>  EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr);
>  
> 

  reply	other threads:[~2020-12-14 20:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 18:32 [PATCH 0/3] KVM: x86: MSR completion refactoring for SEV-ES Paolo Bonzini
2020-12-14 18:32 ` [PATCH 1/3] KVM: x86: remove bogus #GP injection Paolo Bonzini
2020-12-14 20:50   ` Tom Lendacky
2020-12-14 18:32 ` [PATCH 2/3] KVM: x86: use kvm_complete_insn_gp in emulating RDMSR/WRMSR Paolo Bonzini
2020-12-14 20:52   ` Tom Lendacky [this message]
2020-12-14 18:32 ` [PATCH 3/3] KVM: x86: introduce complete_emulated_msr callback Paolo Bonzini
2020-12-14 20:55   ` Tom Lendacky
2020-12-15 10:23     ` Paolo Bonzini

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=bc04f9a7-cc26-2347-58ae-bcbc024d996d@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=graf@amazon.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).