Skip to contentSkip to conversation

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

PATCH In review [email protected] 2 participants 5 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.12-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.12.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 '2026072033-wrinkle-closure-7d3c@gregkh' --subject-prefix 'PATCH 6.12.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)
(cherry picked from commit f35e314d4512480316454d3e963c513faa68decf)
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/pgtable.c +1 -1
index deabc21caae37..70274579cd412 100644
@@ -1314,7 +1314,7 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 				   enum kvm_pgtable_prot prot)
 {
 	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)
(cherry picked from commit 42dfd119dce06db36d3127ec48e12b0eeb7e8545)
---
 arch/arm64/kvm/hyp/pgtable.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/pgtable.c +3 -2
index 70274579cd412..dca66f7571bea 100644
@@ -1314,7 +1314,7 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 				   enum kvm_pgtable_prot prot)
 {
 	int ret;
-	s8 level = TLBI_TTL_UNKNOWN;
+	s8 level;
 	kvm_pte_t set = 0, clr = 0;
 
 	if (prot & KVM_PTE_LEAF_ATTR_HI_SW)
@@ -1333,7 +1333,8 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
 				       KVM_PGTABLE_WALK_HANDLE_FAULT |
 				       KVM_PGTABLE_WALK_SHARED);
 	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
author maintainer
#3 lore raw

Re: [PATCH 6.12.y 1/2] KVM: arm64: Ensure level is always initialized when relaxing perms

In reply to Marc Zyngier
Quoted 10 lines · Marc Zyngier

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.

Quoted 9 lines
Fixes be097997a273 ("KVM: arm64: Always invalidate TLB for stage-2 permission faults")
(cherry picked from commit 100baf0184896f859290a684f864b8200d8ac872)
(cherry picked from commit f35e314d4512480316454d3e963c513faa68decf)

This id isn't in the tree, something went wrong?

I'll just drop it and use the real one here.

thanks,

greg k-h

maintainer
#4 lore raw

Re: [PATCH 6.12.y 1/2] KVM: arm64: Ensure level is always initialized when relaxing perms

Quoted 22 lines · Greg KH
Quoted 10 lines · Marc Zyngier

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.

Quoted 9 lines
Fixes be097997a273 ("KVM: arm64: Always invalidate TLB for stage-2 permission faults")
(cherry picked from commit 100baf0184896f859290a684f864b8200d8ac872)
(cherry picked from commit f35e314d4512480316454d3e963c513faa68decf)
Quoted 1 line

This id isn't in the tree, something went wrong?

Crap. No idea how I managed to have *two* of those. Probably a cherry-pick -xs between stable trees... :-/

Sorry for the mess.

Quoted 1 line

I'll just drop it and use the real one here.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.