[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZWYVw93lixTmlCqD@google.com>
Date: Tue, 28 Nov 2023 08:31:18 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Maxim Levitsky <mlevitsk@...hat.com>
Cc: Nicolas Saenz Julienne <nsaenz@...zon.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hyperv@...r.kernel.org,
pbonzini@...hat.com, vkuznets@...hat.com, anelkz@...zon.com,
graf@...zon.com, dwmw@...zon.co.uk, jgowans@...zon.com,
corbert@....net, kys@...rosoft.com, haiyangz@...rosoft.com,
decui@...rosoft.com, x86@...nel.org, linux-doc@...r.kernel.org
Subject: Re: [RFC 16/33] KVM: x86/mmu: Expose R/W/X flags during memory fault exits
On Tue, Nov 28, 2023, Maxim Levitsky wrote:
> On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote:
> > Include the fault's read, write and execute status when exiting to
> > user-space.
> >
> > Signed-off-by: Nicolas Saenz Julienne <nsaenz@...zon.com>
> > ---
> > arch/x86/kvm/mmu/mmu.c | 4 ++--
> > include/linux/kvm_host.h | 9 +++++++--
> > include/uapi/linux/kvm.h | 6 ++++++
> > 3 files changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index 4e02d506cc25..feca077c0210 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -4300,8 +4300,8 @@ static inline u8 kvm_max_level_for_order(int order)
> > static void kvm_mmu_prepare_memory_fault_exit(struct kvm_vcpu *vcpu,
> > struct kvm_page_fault *fault)
> > {
> > - kvm_prepare_memory_fault_exit(vcpu, fault->gfn << PAGE_SHIFT,
> > - PAGE_SIZE, fault->write, fault->exec,
> > + kvm_prepare_memory_fault_exit(vcpu, fault->gfn << PAGE_SHIFT, PAGE_SIZE,
> > + fault->write, fault->exec, fault->user,
> > fault->is_private);
> > }
> >
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > index 71e1e8cf8936..631fd532c97a 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -2367,14 +2367,19 @@ static inline void kvm_account_pgtable_pages(void *virt, int nr)
> > static inline void kvm_prepare_memory_fault_exit(struct kvm_vcpu *vcpu,
> > gpa_t gpa, gpa_t size,
> > bool is_write, bool is_exec,
> > - bool is_private)
> > + bool is_read, bool is_private)
>
> It almost feels like there is a need for a struct to hold all of those parameters.
The most obvious solution would be to make "struct kvm_page_fault" common, e.g.
ARM's user_mem_abort() fills RWX booleans just like x86 fills kvm_page_fault.
But I think it's best to wait to do something like that until after Anish's series
lands[*]. That way the conversion can be more of a pure refactoring.
[*] https://lore.kernel.org/all/20231109210325.3806151-1-amoorthy@google.com
Powered by blists - more mailing lists