public inbox for kvmarm@lists.cs.columbia.edu
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF
@ 2026-01-08 20:42 Oliver Upton
  2026-01-09 11:31 ` Marc Zyngier
  2026-01-10 10:22 ` Oliver Upton
  0 siblings, 2 replies; 3+ messages in thread
From: Oliver Upton @ 2026-01-08 20:42 UTC (permalink / raw)
  To: kvmarm; +Cc: Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
	Oliver Upton

Naturally, updating the Access Flag in a stage-1 descriptor requires
write permission at stage-2, although this isn't actually enforced in
KVM's software PTW.

Generate a stage-2 permission fault if the stage-1 walk attempts to
update the descriptor and its corresponding stage-2 translation lacks
write permission.

Fixes: bff8aa213dee ("KVM: arm64: Implement HW access flag management in stage-1 SW PTW")
Signed-off-by: Oliver Upton <oupton@kernel.org>
---
 arch/arm64/kvm/at.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c
index 53bf70126f81..808d26bed182 100644
--- a/arch/arm64/kvm/at.c
+++ b/arch/arm64/kvm/at.c
@@ -403,6 +403,7 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
 		   struct s1_walk_result *wr, u64 va)
 {
 	u64 va_top, va_bottom, baddr, desc, new_desc, ipa;
+	struct kvm_s2_trans s2_trans = {};
 	int level, stride, ret;
 
 	level = wi->sl;
@@ -420,8 +421,6 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
 		ipa = baddr | index;
 
 		if (wi->s2) {
-			struct kvm_s2_trans s2_trans = {};
-
 			ret = kvm_walk_nested_s2(vcpu, ipa, &s2_trans);
 			if (ret) {
 				fail_s1_walk(wr,
@@ -515,6 +514,11 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
 		new_desc |= PTE_AF;
 
 	if (new_desc != desc) {
+		if (wi->s2 && !kvm_s2_trans_writable(&s2_trans)) {
+			fail_s1_walk(wr, ESR_ELx_FSC_PERM_L(level), true);
+			return -EPERM;
+		}
+
 		ret = kvm_swap_s1_desc(vcpu, ipa, desc, new_desc, wi);
 		if (ret)
 			return ret;

base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF
  2026-01-08 20:42 [PATCH] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF Oliver Upton
@ 2026-01-09 11:31 ` Marc Zyngier
  2026-01-10 10:22 ` Oliver Upton
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2026-01-09 11:31 UTC (permalink / raw)
  To: Oliver Upton; +Cc: kvmarm, Joey Gouly, Suzuki K Poulose, Zenghui Yu

On Thu, 08 Jan 2026 20:42:30 +0000,
Oliver Upton <oupton@kernel.org> wrote:
> 
> Naturally, updating the Access Flag in a stage-1 descriptor requires
> write permission at stage-2, although this isn't actually enforced in
> KVM's software PTW.
> 
> Generate a stage-2 permission fault if the stage-1 walk attempts to
> update the descriptor and its corresponding stage-2 translation lacks
> write permission.
> 
> Fixes: bff8aa213dee ("KVM: arm64: Implement HW access flag management in stage-1 SW PTW")
> Signed-off-by: Oliver Upton <oupton@kernel.org>

Reviewed-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF
  2026-01-08 20:42 [PATCH] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF Oliver Upton
  2026-01-09 11:31 ` Marc Zyngier
@ 2026-01-10 10:22 ` Oliver Upton
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2026-01-10 10:22 UTC (permalink / raw)
  To: kvmarm, Oliver Upton
  Cc: Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu

On Thu, 08 Jan 2026 12:42:30 -0800, Oliver Upton wrote:
> Naturally, updating the Access Flag in a stage-1 descriptor requires
> write permission at stage-2, although this isn't actually enforced in
> KVM's software PTW.
> 
> Generate a stage-2 permission fault if the stage-1 walk attempts to
> update the descriptor and its corresponding stage-2 translation lacks
> write permission.
> 
> [...]

Applied to fixes, thanks!

[1/1] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF
      https://git.kernel.org/kvmarm/kvmarm/c/9e27085c33cc

--
Best,
Oliver

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-10 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 20:42 [PATCH] KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF Oliver Upton
2026-01-09 11:31 ` Marc Zyngier
2026-01-10 10:22 ` Oliver Upton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox