Skip to contentSkip to conversation

FAILED: patch "[PATCH] KVM: arm64: Ensure level is always initialized when relaxing" failed to apply to 6.18-stable tree

PATCH New [email protected] 2 participants 3 messages Jul 20 – Jul 21

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 100baf0184896f859290a684f864b8200d8ac872
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072032-musty-tightly-d28e@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 100baf0184896f859290a684f864b8200d8ac872 Mon Sep 17 00:00:00 2001
From: Oliver Upton <[email protected]>
Date: Wed, 1 Jul 2026 16:16:19 -0700
Subject: [PATCH] KVM: arm64: Ensure level is always initialized when relaxing
perms

stage2_update_leaf_attrs() returns early before writing to @level if the table walker returned an error. At the same time, kvm_pgtable_stage2_relax_perms() uses the level as a TLBI TTL hint when the error was EAGAIN, indicating the vCPU raced with a table update and the TLB entry it hit is now stale.

Fall back to an unknown TTL if none was provided by the walk.

Fixes be097997a273 ("KVM: arm64: Always invalidate TLB for stage-2 permission faults")
arch/arm64/kvm/hyp/pgtable.c +1 -1
index 0c1defa5fb0f..386a7468136a 100644
@@ -1356,7 +1356,7 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 				   enum kvm_pgtable_prot prot, enum kvm_pgtable_walk_flags flags)
 {
 	kvm_pte_t xn = 0, set = 0, clr = 0;
-	s8 level;
+	s8 level = TLBI_TTL_UNKNOWN;
 	int ret;
 
 	if (prot & KVM_PTE_LEAF_ATTR_HI_SW)
maintainer
#1 lore raw

PATCH 1/2 KVM: arm64: Ensure level is always initialized when relaxing perms

From: Oliver Upton <[email protected]>

stage2_update_leaf_attrs() returns early before writing to @level if the table walker returned an error. At the same time, kvm_pgtable_stage2_relax_perms() uses the level as a TLBI TTL hint when the error was EAGAIN, indicating the vCPU raced with a table update and the TLB entry it hit is now stale.

Fall back to an unknown TTL if none was provided by the walk.

Fixes be097997a273 ("KVM: arm64: Always invalidate TLB for stage-2 permission faults")
(cherry picked from commit 100baf0184896f859290a684f864b8200d8ac872)
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/pgtable.c +1 -1
index cbf8cd2e16735..3e056afea0722 100644
@@ -1291,7 +1291,7 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 				   enum kvm_pgtable_prot prot, enum kvm_pgtable_walk_flags flags)
 {
 	int ret;
-	s8 level;
+	s8 level = TLBI_TTL_UNKNOWN;
 	kvm_pte_t set = 0, clr = 0;
 
 	if (prot & KVM_PTE_LEAF_ATTR_HI_SW)
Signature · 1 line
2.47.3
maintainer
#2 lore raw

PATCH 2/2 KVM: arm64: Fix propagation of TLBI level in kvm_pgtable_stage2_relax_perms()

Assigning the invalidation level (an s8 value) with TLBI_TTL_UNKNOWN (a 32bit signed value) is not ideal, to say the least. Instead of this, only pass TLBI_TTL_UNKNOWN to __kvm_tlb_flush_vmid_ipa_nsh() when we know for sure that we don't have a provided level.

Fixes 100baf0184896 ("KVM: arm64: Ensure level is always initialized when relaxing perms")
(cherry picked from commit 8d187d4b33c262c0f3e44842553521151d8629e8)
---
 arch/arm64/kvm/hyp/pgtable.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/pgtable.c +3 -2
index 3e056afea0722..3a088c5713674 100644
@@ -1291,7 +1291,7 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 				   enum kvm_pgtable_prot prot, enum kvm_pgtable_walk_flags flags)
 {
 	int ret;
-	s8 level = TLBI_TTL_UNKNOWN;
+	s8 level;
 	kvm_pte_t set = 0, clr = 0;
 
 	if (prot & KVM_PTE_LEAF_ATTR_HI_SW)
@@ -1308,7 +1308,8 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 
 	ret = stage2_update_leaf_attrs(pgt, addr, 1, set, clr, NULL, &level, flags);
 	if (!ret || ret == -EAGAIN)
-		kvm_call_hyp(__kvm_tlb_flush_vmid_ipa_nsh, pgt->mmu, addr, level);
+		kvm_call_hyp(__kvm_tlb_flush_vmid_ipa_nsh, pgt->mmu, addr,
+			     (ret == -EAGAIN) ? TLBI_TTL_UNKNOWN : level);
 	return ret;
 }
 
Signature · 1 line
2.47.3