mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brijesh Singh <brijesh.singh@amd.com>
Subject: Re: [PATCH 1/3] KVM: SVM: Unconditionally sync GPRs to GHCB on VMRUN of SEV-ES guest
Date: Mon, 25 Jan 2021 09:05:16 -0600	[thread overview]
Message-ID: <9d92a765-fef3-dded-7478-443f25370661@amd.com> (raw)
In-Reply-To: <20210122235049.3107620-2-seanjc@google.com>

On 1/22/21 5:50 PM, Sean Christopherson wrote:
> Drop the per-GPR dirty checks when synchronizing GPRs to the GHCB, the
> GRPs' dirty bits are set from time zero and never cleared, i.e. will

Ah, missed that, bad assumption on my part.

> always be seen as dirty.  The obvious alternative would be to clear
> the dirty bits when appropriate, but removing the dirty checks is
> desirable as it allows reverting GPR dirty+available tracking, which
> adds overhead to all flavors of x86 VMs.
> 
> Note, unconditionally writing the GPRs in the GHCB is tacitly allowed
> by the GHCB spec, which allows the hypervisor (or guest) to provide
> unnecessary info; it's the guest's responsibility to consume only what
> it needs (the hypervisor is untrusted after all).
> 
>   The guest and hypervisor can supply additional state if desired but
>   must not rely on that additional state being provided.

Yes, that's true.

I'm ok with removing the tracking if that's desired. Otherwise, we can add
a vcpu->arch.regs_dirty = 0 in sev_es_sync_from_ghcb().

Thanks,
Tom

> 
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Fixes: 291bd20d5d88 ("KVM: SVM: Add initial support for a VMGEXIT VMEXIT")
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  arch/x86/kvm/svm/sev.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index c8ffdbc81709..ac652bc476ae 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1415,16 +1415,13 @@ static void sev_es_sync_to_ghcb(struct vcpu_svm *svm)
>  	 * to be returned:
>  	 *   GPRs RAX, RBX, RCX, RDX
>  	 *
> -	 * Copy their values to the GHCB if they are dirty.
> +	 * Copy their values, even if they may not have been written during the
> +	 * VM-Exit.  It's the guest's responsibility to not consume random data.
>  	 */
> -	if (kvm_register_is_dirty(vcpu, VCPU_REGS_RAX))
> -		ghcb_set_rax(ghcb, vcpu->arch.regs[VCPU_REGS_RAX]);
> -	if (kvm_register_is_dirty(vcpu, VCPU_REGS_RBX))
> -		ghcb_set_rbx(ghcb, vcpu->arch.regs[VCPU_REGS_RBX]);
> -	if (kvm_register_is_dirty(vcpu, VCPU_REGS_RCX))
> -		ghcb_set_rcx(ghcb, vcpu->arch.regs[VCPU_REGS_RCX]);
> -	if (kvm_register_is_dirty(vcpu, VCPU_REGS_RDX))
> -		ghcb_set_rdx(ghcb, vcpu->arch.regs[VCPU_REGS_RDX]);
> +	ghcb_set_rax(ghcb, vcpu->arch.regs[VCPU_REGS_RAX]);
> +	ghcb_set_rbx(ghcb, vcpu->arch.regs[VCPU_REGS_RBX]);
> +	ghcb_set_rcx(ghcb, vcpu->arch.regs[VCPU_REGS_RCX]);
> +	ghcb_set_rdx(ghcb, vcpu->arch.regs[VCPU_REGS_RDX]);
>  }
>  
>  static void sev_es_sync_from_ghcb(struct vcpu_svm *svm)
> 

  reply	other threads:[~2021-01-26  7:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 23:50 [PATCH 0/3] KVM: x86: Revert dirty tracking for GPRs Sean Christopherson
2021-01-22 23:50 ` [PATCH 1/3] KVM: SVM: Unconditionally sync GPRs to GHCB on VMRUN of SEV-ES guest Sean Christopherson
2021-01-25 15:05   ` Tom Lendacky [this message]
2021-01-22 23:50 ` [PATCH 2/3] KVM: x86: Revert "KVM: x86: Mark GPRs dirty when written" Sean Christopherson
2021-01-22 23:50 ` [PATCH 3/3] KVM: SVM: Sync GPRs to the GHCB only after VMGEXIT Sean Christopherson
2021-01-23  0:09   ` Tom Lendacky
2021-01-23  0:29     ` Sean Christopherson
2021-01-25 17:22 ` [PATCH 0/3] KVM: x86: Revert dirty tracking for GPRs 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=9d92a765-fef3-dded-7478-443f25370661@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=brijesh.singh@amd.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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

all inboxes | Powered by JetHome®