Skip to content

Commit e63474d

Browse files
committed
KVM: arm64: Rename the device variable to s2_force_noncacheable
JIRA: https://issues.redhat.com/browse/RHEL-73607 Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git commit 8cc9dc1 Author: Ankit Agrawal <ankita@nvidia.com> Date: Sat Jul 5 07:17:12 2025 +0000 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> Signed-off-by: Donald Dutile <ddutile@redhat.com>
1 parent 644e7d3 commit e63474d

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
@@ -1474,7 +1474,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
14741474
int ret = 0;
14751475
bool write_fault, writable, force_pte = false;
14761476
bool exec_fault, mte_allowed;
1477-
bool device = false, vfio_allow_any_uc = false;
1477+
bool s2_force_noncacheable = false, vfio_allow_any_uc = false;
14781478
unsigned long mmu_seq;
14791479
phys_addr_t ipa = fault_ipa;
14801480
struct kvm *kvm = vcpu->kvm;
@@ -1649,7 +1649,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16491649
* In both cases, we don't let transparent_hugepage_adjust()
16501650
* change things at the last minute.
16511651
*/
1652-
device = true;
1652+
s2_force_noncacheable = true;
16531653
} else if (logging_active && !write_fault) {
16541654
/*
16551655
* Only actually map the page as writable if this was a write
@@ -1658,7 +1658,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16581658
writable = false;
16591659
}
16601660

1661-
if (exec_fault && device)
1661+
if (exec_fault && s2_force_noncacheable)
16621662
return -ENOEXEC;
16631663

16641664
/*
@@ -1691,7 +1691,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16911691
* If we are not forced to use page mapping, check if we are
16921692
* backed by a THP and thus use block mapping if possible.
16931693
*/
1694-
if (vma_pagesize == PAGE_SIZE && !(force_pte || device)) {
1694+
if (vma_pagesize == PAGE_SIZE && !(force_pte || s2_force_noncacheable)) {
16951695
if (fault_is_perm && fault_granule > PAGE_SIZE)
16961696
vma_pagesize = fault_granule;
16971697
else
@@ -1705,7 +1705,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17051705
}
17061706
}
17071707

1708-
if (!fault_is_perm && !device && kvm_has_mte(kvm)) {
1708+
if (!fault_is_perm && !s2_force_noncacheable && kvm_has_mte(kvm)) {
17091709
/* Check the VMM hasn't introduced a new disallowed VMA */
17101710
if (mte_allowed) {
17111711
sanitise_mte_tags(kvm, pfn, vma_pagesize);
@@ -1721,7 +1721,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17211721
if (exec_fault)
17221722
prot |= KVM_PGTABLE_PROT_X;
17231723

1724-
if (device) {
1724+
if (s2_force_noncacheable) {
17251725
if (vfio_allow_any_uc)
17261726
prot |= KVM_PGTABLE_PROT_NORMAL_NC;
17271727
else

0 commit comments

Comments
 (0)