[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c924ef5-2ff9-c9a8-f28c-8bedaf8b1af6@redhat.com>
Date: Thu, 11 Nov 2021 08:06:31 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>,
Ben Gardon <bgardon@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Peter Xu <peterx@...hat.com>, Peter Shier <pshier@...gle.com>,
David Matlack <dmatlack@...gle.com>,
Mingwei Zhang <mizhang@...gle.com>,
Yulei Zhang <yulei.kernel@...il.com>,
Wanpeng Li <kernellwp@...il.com>,
Xiao Guangrong <xiaoguangrong.eric@...il.com>,
Kai Huang <kai.huang@...el.com>,
Keqian Zhu <zhukeqian1@...wei.com>,
David Hildenbrand <david@...hat.com>
Subject: Re: [RFC 11/19] KVM: x86/mmu: Factor shadow_zero_check out of
make_spte
On 11/11/21 02:18, Sean Christopherson wrote:
> But what would you actually move? Even shadow_zero_check barely squeaks by,
> e.g. if NX is ever used to for NPT, then maybe it stops being a per-VM setting.
Hmm, I think it would still be per-VM, just like 32-bit shadow page tables
are always built for EFER.NXE=CR4.PAE=1. Anyway, the rough sketch is to have
three structs:
* struct kvm_mmu_kind has the function pointers and the state that is
needed to operate on page tables
* struct kvm_mmu has the function pointers and the state that is
needed while the vCPU runs, including the role
* struct kvm_paging_context has the stuff related to emulation;
shadow page tables of course needs it but EPT/NPT do not (with
either the old or the new MMU)
So you'd have a "struct kvm_mmu_kind direct_mmu" in struct kvm_arch (for
either legacy EPT/NPT or the new MMU), and
struct kvm_mmu_kind shadow_mmu;
struct kvm_mmu root_mmu; /* either TDP or shadow */
struct kvm_mmu tdp12_mmu; /* always shadow */
struct kvm_mmu *mmu; /* either &kvm->direct_mmu or &vcpu->shadow_mmu */
struct kvm_paging_context root_walk; /* maybe unified with walk01 below? dunno yet */
struct kvm_paging_context walk01;
struct kvm_paging_context walk12;
struct kvm_paging_context *walk; /* either &vcpu->root_walk or &vcpu->walk12 */
in struct kvm_vcpu_arch. struct kvm_mmu* has a pointer to
struct kvm_mmu_kind*; however, if an spte.c function does not need
the data in struct kvm_mmu_state*, it can take a struct kvm_mmu_kind*
and it won't need a vCPU. Likewise the TDP MMU knows its kvm_mmu_kind
is always in &kvm->direct_mmu so it can take a struct kvm* if the struct
kvm_mmu_state* is not needed.
The first part of the refactoring would be to kill the nested_mmu
and walk_mmu, replacing them by &vcpu->walk12 and vcpu->walk
respectively. The half-useless nested_mmu has always bothered me,
I was going to play with it anyway because I want to remove the
kvm_mmu_reset_context from CR0.WP writes, I'll see if I get
something useful out of it.
Paolo
Powered by blists - more mailing lists