All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"Joerg Roedel" <joro@8bytes.org>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 0/3] KVM: x86: Drop "caching" of always-available GPRs
Date: Tue, 30 Apr 2019 13:19:43 -0700	[thread overview]
Message-ID: <20190430201943.GA4868@linux.intel.com> (raw)
In-Reply-To: <e61c4c2f-867a-131d-b59e-0e54970b2f90@redhat.com>

On Tue, Apr 30, 2019 at 10:03:59PM +0200, Paolo Bonzini wrote:
> On 30/04/19 19:36, Sean Christopherson wrote:
> > KVM's GPR caching logic is unconditionally emitted for all GPR accesses
> > (that go through the accessors), even when the register being accessed
> > is fixed and always available.  This bloats KVM due to the instructions
> > needed to test and set the available/dirty bitmaps, and to conditionally
> > invoke the .cache_reg() callback.  The latter is especially painful when
> > compiling with retpolines.
> > 
> > Eliminate the unnecessary overhead by:
> > 
> >  - Adding dedicated accessors for every GPR
> >  - Omitting the caching logic for GPRs that are always available
> >  - Preventing use of the unoptimized versions for fixed accesses
> > 
> > The last patch is an opportunistic clean up of VMX, which has gradually
> > acquired a bad habit of sprinkling in direct access to GPRs.
> 
> Another related cleanup is to replace these with the direct accessors:
> 
> arch/x86/kvm/vmx/nested.c:	vmcs12->guest_rsp = kvm_register_read(vcpu, VCPU_REGS_RSP);
> arch/x86/kvm/vmx/nested.c:	vmcs12->guest_rip = kvm_register_read(vcpu, VCPU_REGS_RIP);
> arch/x86/kvm/x86.c:	regs->rsp = kvm_register_read(vcpu, VCPU_REGS_RSP);
> arch/x86/kvm/svm.c:	kvm_register_write(&svm->vcpu, VCPU_REGS_RSP, hsave->save.rsp);
> arch/x86/kvm/svm.c:	kvm_register_write(&svm->vcpu, VCPU_REGS_RIP, hsave->save.rip);
> arch/x86/kvm/svm.c:	kvm_register_write(&svm->vcpu, VCPU_REGS_RSP, nested_vmcb->save.rsp);
> arch/x86/kvm/svm.c:	kvm_register_write(&svm->vcpu, VCPU_REGS_RIP, nested_vmcb->save.rip);
> arch/x86/kvm/vmx/nested.c:	kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->guest_rsp);
> arch/x86/kvm/vmx/nested.c:	kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->guest_rip);
> arch/x86/kvm/vmx/nested.c:	kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->host_rsp);
> arch/x86/kvm/vmx/nested.c:	kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->host_rip);
> arch/x86/kvm/x86.c:	kvm_register_write(vcpu, VCPU_REGS_RSP, regs->rsp);
> 
> I can take care of this.  I have applied patches 1 and 3.  I didn't apply
> patch 2 for the reasons I mentioned in my reply, and because I am not sure
> if it works properly---it should have flagged the above occurrences,
> shouldn't it?

I squeezed the cleanup into patch 2.  I should have called that out in the
changelog but didn't for whatever reason.  Probably would have been even
better to do the refactor in a separate patch.  Sorry :(

      reply	other threads:[~2019-04-30 20:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30 17:36 [PATCH 0/3] KVM: x86: Drop "caching" of always-available GPRs Sean Christopherson
2019-04-30 17:36 ` [PATCH 1/3] KVM: x86: Omit caching logic for " Sean Christopherson
2019-04-30 17:36 ` [PATCH 2/3] KVM: x86: Prevent use of kvm_register_{read,write}() with known GPRs Sean Christopherson
2019-04-30 20:34   ` Paolo Bonzini
2019-04-30 20:44     ` Sean Christopherson
2019-04-30 17:36 ` [PATCH 3/3] KVM: VMX: Use accessors for GPRs outside of dedicated caching logic Sean Christopherson
2019-04-30 20:03 ` [PATCH 0/3] KVM: x86: Drop "caching" of always-available GPRs Paolo Bonzini
2019-04-30 20:19   ` Sean Christopherson [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=20190430201943.GA4868@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.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 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.