Skip to content

Commit c190762

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/nv-trap-forwarding into kvmarm-master/next
* kvm-arm64/nv-trap-forwarding: (30 commits) : . : This implements the so called "trap forwarding" infrastructure, which : gets used when we take a trap from an L2 guest and that the L1 guest : wants to see the trap for itself. : . KVM: arm64: nv: Add trap description for SPSR_EL2 and ELR_EL2 KVM: arm64: nv: Select XARRAY_MULTI to fix build error KVM: arm64: nv: Add support for HCRX_EL2 KVM: arm64: Move HCRX_EL2 switch to load/put on VHE systems KVM: arm64: nv: Expose FGT to nested guests KVM: arm64: nv: Add switching support for HFGxTR/HDFGxTR KVM: arm64: nv: Expand ERET trap forwarding to handle FGT KVM: arm64: nv: Add SVC trap forwarding KVM: arm64: nv: Add trap forwarding for HDFGxTR_EL2 KVM: arm64: nv: Add trap forwarding for HFGITR_EL2 KVM: arm64: nv: Add trap forwarding for HFGxTR_EL2 KVM: arm64: nv: Add fine grained trap forwarding infrastructure KVM: arm64: nv: Add trap forwarding for CNTHCTL_EL2 KVM: arm64: nv: Add trap forwarding for MDCR_EL2 KVM: arm64: nv: Expose FEAT_EVT to nested guests KVM: arm64: nv: Add trap forwarding for HCR_EL2 KVM: arm64: nv: Add trap forwarding infrastructure KVM: arm64: Restructure FGT register switching KVM: arm64: nv: Add FGT registers KVM: arm64: Add missing HCR_EL2 trap bits ... Signed-off-by: Marc Zyngier <maz@kernel.org>
2 parents 319d1a9 + c948a0a commit c190762

File tree

15 files changed

+2488
-41
lines changed

15 files changed

+2488
-41
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@
1818
#define HCR_DCT (UL(1) << 57)
1919
#define HCR_ATA_SHIFT 56
2020
#define HCR_ATA (UL(1) << HCR_ATA_SHIFT)
21+
#define HCR_TTLBOS (UL(1) << 55)
22+
#define HCR_TTLBIS (UL(1) << 54)
23+
#define HCR_ENSCXT (UL(1) << 53)
24+
#define HCR_TOCU (UL(1) << 52)
2125
#define HCR_AMVOFFEN (UL(1) << 51)
26+
#define HCR_TICAB (UL(1) << 50)
2227
#define HCR_TID4 (UL(1) << 49)
2328
#define HCR_FIEN (UL(1) << 47)
2429
#define HCR_FWB (UL(1) << 46)
30+
#define HCR_NV2 (UL(1) << 45)
31+
#define HCR_AT (UL(1) << 44)
32+
#define HCR_NV1 (UL(1) << 43)
33+
#define HCR_NV (UL(1) << 42)
2534
#define HCR_API (UL(1) << 41)
2635
#define HCR_APK (UL(1) << 40)
2736
#define HCR_TEA (UL(1) << 37)
@@ -324,6 +333,47 @@
324333
BIT(18) | \
325334
GENMASK(16, 15))
326335

336+
/*
337+
* FGT register definitions
338+
*
339+
* RES0 and polarity masks as of DDI0487J.a, to be updated as needed.
340+
* We're not using the generated masks as they are usually ahead of
341+
* the published ARM ARM, which we use as a reference.
342+
*
343+
* Once we get to a point where the two describe the same thing, we'll
344+
* merge the definitions. One day.
345+
*/
346+
#define __HFGRTR_EL2_RES0 (GENMASK(63, 56) | GENMASK(53, 51))
347+
#define __HFGRTR_EL2_MASK GENMASK(49, 0)
348+
#define __HFGRTR_EL2_nMASK (GENMASK(55, 54) | BIT(50))
349+
350+
#define __HFGWTR_EL2_RES0 (GENMASK(63, 56) | GENMASK(53, 51) | \
351+
BIT(46) | BIT(42) | BIT(40) | BIT(28) | \
352+
GENMASK(26, 25) | BIT(21) | BIT(18) | \
353+
GENMASK(15, 14) | GENMASK(10, 9) | BIT(2))
354+
#define __HFGWTR_EL2_MASK GENMASK(49, 0)
355+
#define __HFGWTR_EL2_nMASK (GENMASK(55, 54) | BIT(50))
356+
357+
#define __HFGITR_EL2_RES0 GENMASK(63, 57)
358+
#define __HFGITR_EL2_MASK GENMASK(54, 0)
359+
#define __HFGITR_EL2_nMASK GENMASK(56, 55)
360+
361+
#define __HDFGRTR_EL2_RES0 (BIT(49) | BIT(42) | GENMASK(39, 38) | \
362+
GENMASK(21, 20) | BIT(8))
363+
#define __HDFGRTR_EL2_MASK ~__HDFGRTR_EL2_nMASK
364+
#define __HDFGRTR_EL2_nMASK GENMASK(62, 59)
365+
366+
#define __HDFGWTR_EL2_RES0 (BIT(63) | GENMASK(59, 58) | BIT(51) | BIT(47) | \
367+
BIT(43) | GENMASK(40, 38) | BIT(34) | BIT(30) | \
368+
BIT(22) | BIT(9) | BIT(6))
369+
#define __HDFGWTR_EL2_MASK ~__HDFGWTR_EL2_nMASK
370+
#define __HDFGWTR_EL2_nMASK GENMASK(62, 60)
371+
372+
/* Similar definitions for HCRX_EL2 */
373+
#define __HCRX_EL2_RES0 (GENMASK(63, 16) | GENMASK(13, 12))
374+
#define __HCRX_EL2_MASK (0)
375+
#define __HCRX_EL2_nMASK (GENMASK(15, 14) | GENMASK(4, 0))
376+
327377
/* Hyp Prefetch Fault Address Register (HPFAR/HDFAR) */
328378
#define HPFAR_MASK (~UL(0xf))
329379
/*

arch/arm64/include/asm/kvm_host.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ enum vcpu_sysreg {
380380
CPTR_EL2, /* Architectural Feature Trap Register (EL2) */
381381
HSTR_EL2, /* Hypervisor System Trap Register */
382382
HACR_EL2, /* Hypervisor Auxiliary Control Register */
383+
HCRX_EL2, /* Extended Hypervisor Configuration Register */
383384
TTBR0_EL2, /* Translation Table Base Register 0 (EL2) */
384385
TTBR1_EL2, /* Translation Table Base Register 1 (EL2) */
385386
TCR_EL2, /* Translation Control Register (EL2) */
@@ -400,6 +401,11 @@ enum vcpu_sysreg {
400401
TPIDR_EL2, /* EL2 Software Thread ID Register */
401402
CNTHCTL_EL2, /* Counter-timer Hypervisor Control register */
402403
SP_EL2, /* EL2 Stack Pointer */
404+
HFGRTR_EL2,
405+
HFGWTR_EL2,
406+
HFGITR_EL2,
407+
HDFGRTR_EL2,
408+
HDFGWTR_EL2,
403409
CNTHP_CTL_EL2,
404410
CNTHP_CVAL_EL2,
405411
CNTHV_CTL_EL2,
@@ -983,6 +989,7 @@ int kvm_handle_cp10_id(struct kvm_vcpu *vcpu);
983989
void kvm_reset_sys_regs(struct kvm_vcpu *vcpu);
984990

985991
int __init kvm_sys_reg_table_init(void);
992+
int __init populate_nv_trap_config(void);
986993

987994
bool lock_all_vcpus(struct kvm *kvm);
988995
void unlock_all_vcpus(struct kvm *kvm);

arch/arm64/include/asm/kvm_nested.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ static inline bool vcpu_has_nv(const struct kvm_vcpu *vcpu)
1111
test_bit(KVM_ARM_VCPU_HAS_EL2, vcpu->arch.features));
1212
}
1313

14+
extern bool __check_nv_sr_forward(struct kvm_vcpu *vcpu);
15+
1416
struct sys_reg_params;
1517
struct sys_reg_desc;
1618

0 commit comments

Comments
 (0)