Skip to content

Commit 8cc9dc1

Browse files
ankita-nvoupton
authored andcommitted
KVM: arm64: Rename the device variable to s2_force_noncacheable
To perform cache maintenance on a region of memory, KVM/arm64 relies on that region having a cacheable alias in the kernel's address space which can be used with CMO instructions. The 'device' variable is somewhat of a misnomer, as it actually indicates whether or not the stage-2 alias is allowed to have cacheable memory attributes. The resulting stage-2 memory attributes are further modified by VM_ALLOW_ANY_UNCACHED, selecting between Normal-NC or Device-nGnRE depending on what the endpoint supports. Rename the to s2_force_noncacheable such that its purpose is a bit more obvious. CC: Catalin Marinas <catalin.marinas@arm.com> Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: David Hildenbrand <david@redhat.com> Tested-by: Donald Dutile <ddutile@redhat.com> Signed-off-by: Ankit Agrawal <ankita@nvidia.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20250705071717.5062-2-ankita@nvidia.com [ Oliver: addressed typos, wound up rewriting changelog ] Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 86731a2 commit 8cc9dc1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
14781478
int ret = 0;
14791479
bool write_fault, writable, force_pte = false;
14801480
bool exec_fault, mte_allowed;
1481-
bool device = false, vfio_allow_any_uc = false;
1481+
bool s2_force_noncacheable = false, vfio_allow_any_uc = false;
14821482
unsigned long mmu_seq;
14831483
phys_addr_t ipa = fault_ipa;
14841484
struct kvm *kvm = vcpu->kvm;
@@ -1653,7 +1653,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16531653
* In both cases, we don't let transparent_hugepage_adjust()
16541654
* change things at the last minute.
16551655
*/
1656-
device = true;
1656+
s2_force_noncacheable = true;
16571657
} else if (logging_active && !write_fault) {
16581658
/*
16591659
* Only actually map the page as writable if this was a write
@@ -1662,7 +1662,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16621662
writable = false;
16631663
}
16641664

1665-
if (exec_fault && device)
1665+
if (exec_fault && s2_force_noncacheable)
16661666
return -ENOEXEC;
16671667

16681668
/*
@@ -1695,7 +1695,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16951695
* If we are not forced to use page mapping, check if we are
16961696
* backed by a THP and thus use block mapping if possible.
16971697
*/
1698-
if (vma_pagesize == PAGE_SIZE && !(force_pte || device)) {
1698+
if (vma_pagesize == PAGE_SIZE && !(force_pte || s2_force_noncacheable)) {
16991699
if (fault_is_perm && fault_granule > PAGE_SIZE)
17001700
vma_pagesize = fault_granule;
17011701
else
@@ -1709,7 +1709,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17091709
}
17101710
}
17111711

1712-
if (!fault_is_perm && !device && kvm_has_mte(kvm)) {
1712+
if (!fault_is_perm && !s2_force_noncacheable && kvm_has_mte(kvm)) {
17131713
/* Check the VMM hasn't introduced a new disallowed VMA */
17141714
if (mte_allowed) {
17151715
sanitise_mte_tags(kvm, pfn, vma_pagesize);
@@ -1725,7 +1725,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17251725
if (exec_fault)
17261726
prot |= KVM_PGTABLE_PROT_X;
17271727

1728-
if (device) {
1728+
if (s2_force_noncacheable) {
17291729
if (vfio_allow_any_uc)
17301730
prot |= KVM_PGTABLE_PROT_NORMAL_NC;
17311731
else

0 commit comments

Comments
 (0)