[PATCH v3 02/15] KVM: arm64: Add "struct kvm_page_fault" to gather common fault variables
Sean Christopherson
seanjc at google.com
Wed Jun 18 14:17:43 PDT 2025
On Wed, Jun 18, 2025, Oliver Upton wrote:
> On Wed, Jun 18, 2025 at 04:24:11AM +0000, James Houghton wrote:
> > From: Sean Christopherson <seanjc at google.com>
> >
> > Introduce "struct kvm_page_fault" and use it in user_mem_abort() in lieu
> > of a collection of local variables. Providing "struct kvm_page_fault"
> > will allow common KVM to provide APIs to take in said structure, e.g. when
> > preparing memory fault exits.
> >
> > No functional change intended.
> >
> > Signed-off-by: Sean Christopherson <seanjc at google.com>
> > Signed-off-by: James Houghton <jthoughton at google.com>
> > ---
> > arch/arm64/include/asm/kvm_host.h | 9 +++++++++
> > arch/arm64/kvm/mmu.c | 32 +++++++++++++++++--------------
> > 2 files changed, 27 insertions(+), 14 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> > index 6ce2c51734820..ae83d95d11b74 100644
> > --- a/arch/arm64/include/asm/kvm_host.h
> > +++ b/arch/arm64/include/asm/kvm_host.h
> > @@ -413,6 +413,15 @@ struct kvm_vcpu_fault_info {
> > u64 disr_el1; /* Deferred [SError] Status Register */
> > };
> >
> > +struct kvm_page_fault {
> > + const bool exec;
> > + const bool write;
> > + const bool is_private;
> > +
> > + gfn_t gfn;
> > + struct kvm_memory_slot *slot;
> > +};
> > +
>
> So this seems to cherry-pick "interesting" values into the structure but
s/interesting/necessary. I literally grabbed only the fields that were needed
to handle the userfault :-)
> leaves the rest of the abort context scattered about in locals. If we're
> going to do something like this I'd rather have a wholesale refactoring
> than just the bits to intersect with x86 (more on that later...)
Definitely no objection from me. How about I send a standalone patch so that we
can iterate on just that without James having to respin the entire series (for
changes that have no meaningful impact)? I'm anticipating we'll need a few rounds
to strike the right balance between what was done here and "throw everything into
kvm_page_fault". E.g. we probably don't want "vma" in kvm_page_fault.
Hmm, yeah, and I suspect/hope that moving more things into kvm_page_fault will
allow for encapsulating the mmap_read_lock() section in a helper without having
a bajillion boolean flags being passed around. That would obviate the need to
nullify vma, because it would simply go out of scope.
More information about the linux-arm-kernel
mailing list