Skip to content

Commit 9e27085

Browse files
author
Oliver Upton
committed
KVM: arm64: nv: Respect stage-2 write permssion when setting stage-1 AF
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: bff8aa2 ("KVM: arm64: Implement HW access flag management in stage-1 SW PTW") Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://msgid.link/20260108204230.677172-1-oupton@kernel.org Signed-off-by: Oliver Upton <oupton@kernel.org>
1 parent 9cb2c20 commit 9e27085

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

arch/arm64/kvm/at.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
403403
struct s1_walk_result *wr, u64 va)
404404
{
405405
u64 va_top, va_bottom, baddr, desc, new_desc, ipa;
406+
struct kvm_s2_trans s2_trans = {};
406407
int level, stride, ret;
407408

408409
level = wi->sl;
@@ -420,8 +421,6 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
420421
ipa = baddr | index;
421422

422423
if (wi->s2) {
423-
struct kvm_s2_trans s2_trans = {};
424-
425424
ret = kvm_walk_nested_s2(vcpu, ipa, &s2_trans);
426425
if (ret) {
427426
fail_s1_walk(wr,
@@ -515,6 +514,11 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
515514
new_desc |= PTE_AF;
516515

517516
if (new_desc != desc) {
517+
if (wi->s2 && !kvm_s2_trans_writable(&s2_trans)) {
518+
fail_s1_walk(wr, ESR_ELx_FSC_PERM_L(level), true);
519+
return -EPERM;
520+
}
521+
518522
ret = kvm_swap_s1_desc(vcpu, ipa, desc, new_desc, wi);
519523
if (ret)
520524
return ret;

0 commit comments

Comments
 (0)