Skip to content

Commit be0135b

Browse files
author
Marc Zyngier
committed
KVM: arm64: nv: Add basic emulation of AT S1E1{R,W}P
Building on top of our primitive AT S1E{0,1}{R,W} emulation, add minimal support for the FEAT_PAN2 instructions, momentary context-switching PSTATE.PAN so that it takes effect in the context of the guest. Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 477e89c commit be0135b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

arch/arm64/kvm/at.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ static void __mmu_config_restore(struct mmu_config *config)
4949
write_sysreg(config->vtcr, vtcr_el2);
5050
}
5151

52+
static bool at_s1e1p_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
53+
{
54+
u64 host_pan;
55+
bool fail;
56+
57+
host_pan = read_sysreg_s(SYS_PSTATE_PAN);
58+
write_sysreg_s(*vcpu_cpsr(vcpu) & PSTATE_PAN, SYS_PSTATE_PAN);
59+
60+
switch (op) {
61+
case OP_AT_S1E1RP:
62+
fail = __kvm_at(OP_AT_S1E1RP, vaddr);
63+
break;
64+
case OP_AT_S1E1WP:
65+
fail = __kvm_at(OP_AT_S1E1WP, vaddr);
66+
break;
67+
}
68+
69+
write_sysreg_s(host_pan, SYS_PSTATE_PAN);
70+
71+
return fail;
72+
}
73+
5274
/*
5375
* Return the PAR_EL1 value as the result of a valid translation.
5476
*
@@ -105,6 +127,10 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
105127
isb();
106128

107129
switch (op) {
130+
case OP_AT_S1E1RP:
131+
case OP_AT_S1E1WP:
132+
fail = at_s1e1p_fast(vcpu, op, vaddr);
133+
break;
108134
case OP_AT_S1E1R:
109135
fail = __kvm_at(OP_AT_S1E1R, vaddr);
110136
break;

0 commit comments

Comments
 (0)