]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: Remove redundant state variables from struct kvm_s2_fault
authorFuad Tabba <tabba@google.com>
Fri, 6 Mar 2026 14:02:27 +0000 (14:02 +0000)
committerMarc Zyngier <maz@kernel.org>
Sat, 28 Mar 2026 11:29:40 +0000 (11:29 +0000)
Remove redundant variables vma_shift and vfio_allow_any_uc from struct
kvm_s2_fault as they are easily derived or checked when needed.

Signed-off-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/mmu.c

index 1d423bc29e6c06a81eca5a5e80def261db0e17aa..ee653dd4eb27cb50faa5e93e685680e1e614f1d3 100644 (file)
@@ -1721,10 +1721,8 @@ struct kvm_s2_fault {
        bool mte_allowed;
        bool is_vma_cacheable;
        bool s2_force_noncacheable;
-       bool vfio_allow_any_uc;
        unsigned long mmu_seq;
        phys_addr_t ipa;
-       short vma_shift;
        gfn_t gfn;
        kvm_pfn_t pfn;
        bool logging_active;
@@ -1749,9 +1747,9 @@ static int kvm_s2_fault_get_vma_info(struct kvm_s2_fault *fault)
                return -EFAULT;
        }
 
-       fault->vma_shift = kvm_s2_resolve_vma_size(vma, fault->hva, fault->memslot, fault->nested,
-                                                  &fault->force_pte, &fault->ipa);
-       fault->vma_pagesize = 1UL << fault->vma_shift;
+       fault->vma_pagesize = 1UL << kvm_s2_resolve_vma_size(vma, fault->hva, fault->memslot,
+                                                            fault->nested, &fault->force_pte,
+                                                            &fault->ipa);
 
        /*
         * Both the canonical IPA and fault IPA must be aligned to the
@@ -1764,8 +1762,6 @@ static int kvm_s2_fault_get_vma_info(struct kvm_s2_fault *fault)
        fault->gfn = fault->ipa >> PAGE_SHIFT;
        fault->mte_allowed = kvm_vma_mte_allowed(vma);
 
-       fault->vfio_allow_any_uc = vma->vm_flags & VM_ALLOW_ANY_UNCACHED;
-
        fault->vm_flags = vma->vm_flags;
 
        fault->is_vma_cacheable = kvm_vma_is_cacheable(vma);
@@ -1796,7 +1792,7 @@ static int kvm_s2_fault_pin_pfn(struct kvm_s2_fault *fault)
                                       fault->write_fault ? FOLL_WRITE : 0,
                                       &fault->writable, &fault->page);
        if (fault->pfn == KVM_PFN_ERR_HWPOISON) {
-               kvm_send_hwpoison_signal(fault->hva, fault->vma_shift);
+               kvm_send_hwpoison_signal(fault->hva, __ffs(fault->vma_pagesize));
                return 0;
        }
        if (is_error_noslot_pfn(fault->pfn))
@@ -1874,7 +1870,7 @@ static int kvm_s2_fault_compute_prot(struct kvm_s2_fault *fault)
                fault->prot |= KVM_PGTABLE_PROT_X;
 
        if (fault->s2_force_noncacheable) {
-               if (fault->vfio_allow_any_uc)
+               if (fault->vm_flags & VM_ALLOW_ANY_UNCACHED)
                        fault->prot |= KVM_PGTABLE_PROT_NORMAL_NC;
                else
                        fault->prot |= KVM_PGTABLE_PROT_DEVICE;
@@ -1978,7 +1974,6 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                .logging_active = memslot_is_logging(memslot),
                .force_pte = memslot_is_logging(memslot),
                .s2_force_noncacheable = false,
-               .vfio_allow_any_uc = false,
                .prot = KVM_PGTABLE_PROT_R,
        };
        struct kvm_s2_fault *fault = &fault_data;