mbox series

[V2,0/5] KVM: X86: permission_fault() for SMAP

Message ID 20220311070346.45023-1-jiangshanlai@gmail.com (mailing list archive)
Headers show
Series KVM: X86: permission_fault() for SMAP | expand

Message

Lai Jiangshan March 11, 2022, 7:03 a.m. UTC
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

Some change in permission_fault() for SMAP.  It also reduces
calls two callbacks to get CPL and RFLAGS in come cases, but it
has not any measurable performance change in tests (kernel build
in guest).

Changed from 1:
	gross implicit access into @access as Sean suggested.

	Use my official email address (Ant Group).  The work is backed
	by my company and I was incorrectly misunderstood that
	XXX@linux.alibaba.com is the only portal for opensource work
	in the corporate group.

[V1]: https://lore.kernel.org/kvm/20211207095039.53166-1-jiangshanlai@gmail.com/

Lai Jiangshan (6):
  KVM: X86: Change the type of access u32 to u64
  KVM: X86: Fix comments in update_permission_bitmask
  KVM: X86: Rename variable smap to not_smap in permission_fault()
  KVM: X86: Handle implicit supervisor access with SMAP
  KVM: X86: Only get rflags when needed in permission_fault()
  KVM: X86: Propagate the nested page fault info to the guest

 arch/x86/include/asm/kvm_host.h |  6 +++-
 arch/x86/kvm/kvm_emulate.h      |  3 +-
 arch/x86/kvm/mmu.h              | 54 ++++++++++++++++++++++-----------
 arch/x86/kvm/mmu/mmu.c          | 10 +++---
 arch/x86/kvm/mmu/paging_tmpl.h  | 16 ++++++----
 arch/x86/kvm/svm/nested.c       | 10 ++----
 arch/x86/kvm/vmx/nested.c       | 11 +++++++
 arch/x86/kvm/x86.c              | 32 ++++++++++---------
 8 files changed, 89 insertions(+), 53 deletions(-)

Comments

Paolo Bonzini March 15, 2022, 9:06 p.m. UTC | #1
On 3/11/22 08:03, Lai Jiangshan wrote:
> From: Lai Jiangshan<jiangshan.ljs@antgroup.com>
> 
> Some change in permission_fault() for SMAP.  It also reduces
> calls two callbacks to get CPL and RFLAGS in come cases, but it
> has not any measurable performance change in tests (kernel build
> in guest).

I am going to queue patches 1-4.  The last one shouldn't really have any 
performance impact with static calls.

Paolo
Lai Jiangshan March 16, 2022, 2:38 a.m. UTC | #2
On Wed, Mar 16, 2022 at 5:06 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 3/11/22 08:03, Lai Jiangshan wrote:
> > From: Lai Jiangshan<jiangshan.ljs@antgroup.com>
> >
> > Some change in permission_fault() for SMAP.  It also reduces
> > calls two callbacks to get CPL and RFLAGS in come cases, but it
> > has not any measurable performance change in tests (kernel build
> > in guest).
>
> I am going to queue patches 1-4.  The last one shouldn't really have any
> performance impact with static calls.
>

It is not about performance, it is about "less surprise".

The patchset was made due to it surprised me that "what the hell
is it when L0 is using L2's rflags when building shadow EPT/NPT for L1".

After some investigation, I knew the L2's rflags is "ignored" in a very
hidden and complicated way which relies on code in several other places.

I think some additional comment is necessary if that patch is not applied.