From: Jintack Lim <jintack.lim@xxxxxxxxxx> This introduces a function prototype to determine if we need to forward system instruction traps to the virtual EL2. The implementation of forward_trap functions for each system instruction will be added in later patches. Signed-off-by: Jintack Lim <jintack.lim@xxxxxxxxxx> Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> --- arch/arm64/kvm/sys_regs.c | 9 +++++++++ arch/arm64/kvm/sys_regs.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 364020afc17c..fae3f4a70eeb 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -25,6 +25,7 @@ #include <asm/kvm_host.h> #include <asm/kvm_hyp.h> #include <asm/kvm_mmu.h> +#include <asm/kvm_nested.h> #include <asm/perf_event.h> #include <asm/sysreg.h> @@ -2491,6 +2492,14 @@ static void perform_access(struct kvm_vcpu *vcpu, */ BUG_ON(!r->access); + /* + * Forward this trap to the virtual EL2 if the guest hypervisor has + * configured to trap the current instruction. + */ + if (nested_virt_in_use(vcpu) && r->forward_trap + && unlikely(r->forward_trap(vcpu))) + return; + /* Skip instruction if instructed so */ if (likely(r->access(vcpu, params, r))) kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h index 5a6fc30f5989..65e736f7103a 100644 --- a/arch/arm64/kvm/sys_regs.h +++ b/arch/arm64/kvm/sys_regs.h @@ -54,6 +54,12 @@ struct sys_reg_desc { int (*set_user)(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, const struct kvm_one_reg *reg, void __user *uaddr); + /* + * Forward the trap to the virtual EL2 if the guest hypervisor has + * configured to trap the current instruction. + */ + bool (*forward_trap)(struct kvm_vcpu *vcpu); + /* Return mask of REG_* runtime visibility overrides */ unsigned int (*visibility)(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd); -- 2.20.1 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm