Thread (48 messages) 48 messages, 5 authors, 2026-05-30

Re: [PATCH 06/17] KVM: arm64: Kill write_fault from kvm_s2_fault

From: Fuad Tabba <tabba@google.com>
Date: 2026-03-17 11:21:44
Also in: kvmarm

On Mon, 16 Mar 2026 at 17:55, Marc Zyngier [off-list ref] wrote:
quoted hunk ↗ jump to hunk
We already have kvm_is_write_fault() as a predicate indicating
a S2 fault on a write, and we're better off just using that instead
of duplicating the state.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/mmu.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 12c2f0aeaae4c..86950acbd7e6b 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1711,7 +1711,6 @@ static short kvm_s2_resolve_vma_size(const struct kvm_s2_fault_desc *s2fd,
 }

 struct kvm_s2_fault {
-       bool write_fault;
        bool exec_fault;
        bool writable;
        bool topup_memcache;
@@ -1799,7 +1798,7 @@ static int kvm_s2_fault_pin_pfn(const struct kvm_s2_fault_desc *s2fd,
                return ret;

        fault->pfn = __kvm_faultin_pfn(s2fd->memslot, get_canonical_gfn(s2fd, fault),
-                                      fault->write_fault ? FOLL_WRITE : 0,
+                                      kvm_is_write_fault(s2fd->vcpu) ? FOLL_WRITE : 0,
                                       &fault->writable, &fault->page);
        if (unlikely(is_error_noslot_pfn(fault->pfn))) {
                if (fault->pfn == KVM_PFN_ERR_HWPOISON) {
@@ -1850,7 +1849,7 @@ static int kvm_s2_fault_compute_prot(const struct kvm_s2_fault_desc *s2fd,
                         */
                        fault->s2_force_noncacheable = true;
                }
-       } else if (fault->logging_active && !fault->write_fault) {
+       } else if (fault->logging_active && !kvm_is_write_fault(s2fd->vcpu)) {
                /*
                 * Only actually map the page as writable if this was a write
                 * fault.
@@ -1980,21 +1979,17 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd,
 static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd)
 {
        bool perm_fault = kvm_vcpu_trap_is_permission_fault(s2fd->vcpu);
-       bool write_fault = kvm_is_write_fault(s2fd->vcpu);
        bool logging_active = memslot_is_logging(s2fd->memslot);
        struct kvm_s2_fault fault = {
                .logging_active = logging_active,
                .force_pte = logging_active,
                .prot = KVM_PGTABLE_PROT_R,
-               .write_fault = write_fault,
                .exec_fault = kvm_vcpu_trap_is_exec_fault(s2fd->vcpu),
-               .topup_memcache = !perm_fault || (logging_active && write_fault),
+               .topup_memcache = !perm_fault || (logging_active && kvm_is_write_fault(s2fd->vcpu)),
        };
        void *memcache;
        int ret;

-       VM_WARN_ON_ONCE(fault.write_fault && fault.exec_fault);
-
We can't hit this warning anyway.

Reviewed-by: Fuad Tabba <tabba@google.com>

Cheers,
/fuad
        /*
         * Permission faults just need to update the existing leaf entry,
         * and so normally don't require allocations from the memcache. The
--
2.47.3
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help