]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: Kill write_fault from kvm_s2_fault
authorMarc Zyngier <maz@kernel.org>
Mon, 9 Mar 2026 11:22:59 +0000 (11:22 +0000)
committerMarc Zyngier <maz@kernel.org>
Sat, 28 Mar 2026 11:29:41 +0000 (11:29 +0000)
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.

Tested-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/mmu.c

index 981c04a74ab7a60c24bdf28676f40db52ed72174..7dab0c3faa5bfe41cb420ab8935db79f45754b67 100644 (file)
@@ -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 @@ out_unlock:
 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);
-
        /*
         * Permission faults just need to update the existing leaf entry,
         * and so normally don't require allocations from the memcache. The