From: Marc Zyngier Date: Mon, 9 Mar 2026 11:22:59 +0000 (+0000) Subject: KVM: arm64: Kill write_fault from kvm_s2_fault X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49902d7e010614888253a90252f4704edb2fe3e3;p=thirdparty%2Flinux.git KVM: arm64: Kill write_fault from kvm_s2_fault 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 Reviewed-by: Fuad Tabba Reviewed-by: Suzuki K Poulose Signed-off-by: Marc Zyngier --- diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 981c04a74ab7a..7dab0c3faa5bf 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 @@ 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