KVM: arm64: Kill the copro array
Subsystems (4)
Marc Zyngier
maintainerPATCH v2 1/9 KVM: arm64: Introduce handling of AArch32 TTBCR2 traps
In reply to Marc ZyngierARMv8.2 introduced TTBCR2, which shares TCR_EL1 with TTBCR. Gracefully handle traps to this register when HCR_EL2.TVM is set.
--- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/sys_regs.c | 1 + 2 files changed, 2 insertions(+)
arch/arm64/include/asm/kvm_host.h +1 -0
@@ -212,6 +212,7 @@ enum vcpu_sysreg {#define c2_TTBR1 (TTBR1_EL1 * 2)/* Translation Table Base Register 1 */ #define c2_TTBR1_high (c2_TTBR1 + 1)/* TTBR1 top 32 bits */ #define c2_TTBCR (TCR_EL1 * 2)/* Translation Table Base Control R. */ +#define c2_TTBCR2 (c2_TTBCR + 1)/* Translation Table Base Control R. 2 */ #define c3_DACR (DACR32_EL2 * 2)/* Domain Access Control Register */ #define c5_DFSR (ESR_EL1 * 2)/* Data Fault Status Register */ #define c5_IFSR (IFSR32_EL2 * 2)/* Instruction Fault Status Register */
arch/arm64/kvm/sys_regs.c +1 -0
@@ -1925,6 +1925,7 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1( 0), CRn( 2), CRm( 0), Op2( 0), access_vm_reg, NULL, c2_TTBR0 }, { Op1( 0), CRn( 2), CRm( 0), Op2( 1), access_vm_reg, NULL, c2_TTBR1 }, { Op1( 0), CRn( 2), CRm( 0), Op2( 2), access_vm_reg, NULL, c2_TTBCR }, + { Op1( 0), CRn( 2), CRm( 0), Op2( 3), access_vm_reg, NULL, c2_TTBCR2 }, { Op1( 0), CRn( 3), CRm( 0), Op2( 0), access_vm_reg, NULL, c3_DACR }, { Op1( 0), CRn( 5), CRm( 0), Op2( 0), access_vm_reg, NULL, c5_DFSR }, { Op1( 0), CRn( 5), CRm( 0), Op2( 1), access_vm_reg, NULL, c5_IFSR },
Signature · 1 line
2.28.0
Marc Zyngier
maintainerv2 cover KVM: arm64: Kill the copro array
Since the very beginning of KVM/arm64, we represented the system register file using a dual view: on one side the AArch64 state, on the other a bizarre mapping of the AArch32 state onto the Aarch64 registers.
It was nice at the time as it allowed us to share some code with the 32bit port, and to come up with some creative bugs. But is was always a hack, and we are now in a position to simplify the whole thing.
This series goes through the whole of the AArch32 cp14/15 register file, and point each of them directly at their 64bit equivalent. For the few cases where two 32bit registers share a 64bit counterpart, we define which half of the register they map.
Finally, we drop a large number of definitions and state that have become useless.
This series applies on top of the exception injection rework previously posted [2].
* From v1 [1]:
- Added initial patch to deal with TTBCR2
- Fixed TCR_EL1 handling in inject_abt32()
- Optimise for 64bit handling of sysreg access
- Make most 32bit cp14 registers access the full 64bit register
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
Marc Zyngier (9):
KVM: arm64: Introduce handling of AArch32 TTBCR2 traps
KVM: arm64: Move AArch32 exceptions over to AArch64 sysregs
KVM: arm64: Add AArch32 mapping annotation
KVM: arm64: Map AArch32 cp15 register to AArch64 sysregs
KVM: arm64: Map AArch32 cp14 register to AArch64 sysregs
KVM: arm64: Drop is_32bit trap attribute
KVM: arm64: Drop is_aarch32 trap attribute
KVM: arm64: Drop legacy copro shadow register
KVM: arm64: Drop kvm_coproc.h
arch/arm64/include/asm/kvm_coproc.h | 38 ----- arch/arm64/include/asm/kvm_host.h | 73 +++------ arch/arm64/kvm/arm.c | 3 +- arch/arm64/kvm/guest.c | 1 - arch/arm64/kvm/handle_exit.c | 1 - arch/arm64/kvm/inject_fault.c | 62 +++----- arch/arm64/kvm/reset.c | 1 - arch/arm64/kvm/sys_regs.c | 233 +++++++++++++--------------- arch/arm64/kvm/sys_regs.h | 9 +- arch/arm64/kvm/vgic-sys-reg-v3.c | 4 - 10 files changed, 151 insertions(+), 274 deletions(-) delete mode 100644 arch/arm64/include/asm/kvm_coproc.h
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 2/9 KVM: arm64: Move AArch32 exceptions over to AArch64 sysregs
The use of the AArch32-specific accessors have always been a bit annoying on 64bit, and it is time for a change.
Let's move the AArch32 exception injection over to the AArch64 encoding, which requires us to split the two halves of FAR_EL1 into DFAR and IFAR. This enables us to drop the preempt_disable() games on VHE, and to kill the last user of the vcpu_cp15() macro.
--- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/inject_fault.c | 62 ++++++++++--------------------- 2 files changed, 20 insertions(+), 43 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -1
@@ -562,7 +562,6 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg)#define CPx_BIAS IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)#define vcpu_cp14 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS]) -#define vcpu_cp15 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])struct kvm_vm_stat {ulong remote_tlb_flush;
arch/arm64/kvm/inject_fault.c +20 -42
85 lines not on this page · raw message
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 3/9 KVM: arm64: Add AArch32 mapping annotation
In reply to Marc ZyngierIn order to deal with the few AArch32 system registers that map to only a particular half of their AArch64 counterpart (such as DFAR and IFAR being colocated in FAR_EL1), let's add an optional annotation to the sysreg descriptor structure, indicating whether a register maps to the upper or lower 32bits of a register.
Nothing is using these annotation yet.
--- arch/arm64/kvm/sys_regs.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kvm/sys_regs.h +7 -0
@@ -27,6 +27,12 @@ struct sys_reg_desc {/* Sysreg string for debug */ const char *name; +enum { +AA32_ZEROHIGH , +AA32_LO , +AA32_HI , + } aarch32_map; +/* MRS/MSR instruction which accesses it. */ u8 Op0;u8 Op1;
@@ -153,6 +159,7 @@ const struct sys_reg_desc *find_reg_by_id(u64 id,const struct sys_reg_desc table[], unsigned int num); +#define AA32 (_x) .aarch32_map = AA32_##_x#define Op0 (_x) .Op0 = _x#define Op1 (_x) .Op1 = _x#define CRn (_x) .CRn = _x
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 6/9 KVM: arm64: Drop is_32bit trap attribute
In reply to Marc ZyngierThe is_32bit attribute is now completely unused, drop it.
--- arch/arm64/kvm/sys_regs.c | 3 --- arch/arm64/kvm/sys_regs.h | 1 - arch/arm64/kvm/vgic-sys-reg-v3.c | 2 -- 3 files changed, 6 deletions(-)
arch/arm64/kvm/sys_regs.c +0 -3
@@ -2176,7 +2176,6 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu,int Rt2 = (esr >>10 ) &0x1f ; params.is_aarch32 = true; - params.is_32bit = false; params.CRm = (esr >>1 ) &0xf ; params.is_write = ((esr &1 ) ==0 );
@@ -2227,7 +2226,6 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu,int Rt =kvm_vcpu_sys_get_rt (vcpu); params.is_aarch32 = true; - params.is_32bit = true; params.CRm = (esr >>1 ) &0xf ; params.regval =vcpu_get_reg (vcpu, Rt); params.is_write = ((esr &1 ) ==0 );
@@ -2322,7 +2320,6 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu)trace_kvm_handle_sys_reg (esr); params.is_aarch32 = false; - params.is_32bit = false; params.Op0 = (esr >>20 ) &3 ; params.Op1 = (esr >>14 ) &0x7 ; params.CRn = (esr >>10 ) &0xf ;
arch/arm64/kvm/sys_regs.h +0 -1
@@ -20,7 +20,6 @@ struct sys_reg_params {u64 regval;bool is_write;bool is_aarch32; -bool is_32bit;/* Only valid if is_aarch32 is true */ };struct sys_reg_desc {
arch/arm64/kvm/vgic-sys-reg-v3.c +0 -2
@@ -269,7 +269,6 @@ int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, bool is_write, u64 id, params.regval = *reg; params.is_write = is_write; params.is_aarch32 = false; - params.is_32bit = false;if (find_reg_by_id (sysreg, ¶ms, gic_v3_icc_reg_descs,ARRAY_SIZE (gic_v3_icc_reg_descs)))
@@ -289,7 +288,6 @@ int vgic_v3_cpu_sysregs_uaccess(struct kvm_vcpu *vcpu, bool is_write, u64 id, params.regval = *reg; params.is_write = is_write; params.is_aarch32 = false; - params.is_32bit = false; r =find_reg_by_id (sysreg, ¶ms, gic_v3_icc_reg_descs,ARRAY_SIZE (gic_v3_icc_reg_descs));
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 5/9 KVM: arm64: Map AArch32 cp14 register to AArch64 sysregs
In reply to Marc ZyngierSimilarly to what has been done on the cp15 front, repaint the debug registers to use their AArch64 counterparts. This results in some simplification as we can remove the 32bit-specific accessors.
--- arch/arm64/include/asm/kvm_host.h | 8 --- arch/arm64/kvm/sys_regs.c | 109 ++++++++++-------------------- 2 files changed, 37 insertions(+), 80 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -8
@@ -555,14 +555,6 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg)return true; } -/* -* CP14 and CP15 live in the same array, as they are backed by the -* same system registers. -*/ -#define CPx_BIAS IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) - -#define vcpu_cp14 (v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS]) -struct kvm_vm_stat {ulong remote_tlb_flush; };
arch/arm64/kvm/sys_regs.c +37 -72
181 lines not on this page · raw message
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 4/9 KVM: arm64: Map AArch32 cp15 register to AArch64 sysregs
In reply to Marc ZyngierMove all the cp15 registers over to their AArch64 counterpart. This requires the annotation of a few of them (such as the usual DFAR/IFAR vs FAR_EL1), and a new helper that generates mask/shift pairs for the various configurations.
--- arch/arm64/kvm/sys_regs.c | 114 ++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 48 deletions(-)
arch/arm64/kvm/sys_regs.c +66 -48
@@ -128,6 +128,24 @@ static bool access_dcsw(struct kvm_vcpu *vcpu,return true; } +static void get_access_mask (const struct sys_reg_desc *r,u64 *mask,u64 *shift) +{ +switch (r->aarch32_map) { +case AA32_LO : + *mask =GENMASK_ULL (31 ,0 ); + *shift =0 ; +break ; +case AA32_HI : + *mask =GENMASK_ULL (63 ,32 ); + *shift =32 ; +break ; +default : + *mask =GENMASK_ULL (63 ,0 ); + *shift =0 ; +break ; + } +} +/* * Generic accessor for VM registers. Only called as long as HCR_TVM * is set. If the guest enables the MMU, we stop trapping the VM
@@ -138,26 +156,21 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) {bool was_enabled =vcpu_has_cache_enabled (vcpu); -u64 val; -int reg = r->reg; +u64 val, mask, shift;BUG_ON (!p->is_write); -/* See the 32bit mapping in kvm_host.h */ -if (p->is_aarch32) - reg = r->reg /2 ; +get_access_mask (r, &mask, &shift); -if (!p->is_aarch32 || !p->is_32bit) { - val = p->regval; +if (~mask) { + val =vcpu_read_sys_reg (vcpu, r->reg); + val &= ~mask; }else { - val =vcpu_read_sys_reg (vcpu, reg); -if (r->reg %2 ) - val = (p->regval <<32 ) | (u64 )lower_32_bits (val); -else - val = ((u64 )upper_32_bits (val) <<32 ) | -lower_32_bits (p->regval); + val =0 ; } -vcpu_write_sys_reg (vcpu, val, reg); + + val |= (p->regval & (mask >> shift)) << shift; +vcpu_write_sys_reg (vcpu, val, r->reg);kvm_toggle_cache (vcpu, was_enabled);return true;
@@ -167,17 +180,13 @@ static bool access_actlr(struct kvm_vcpu *vcpu,struct sys_reg_params *p, const struct sys_reg_desc *r) { + u64 mask, shift; +if (p->is_write)return ignore_write (vcpu, p); - p->regval =vcpu_read_sys_reg (vcpu,ACTLR_EL1 ); - -if (p->is_aarch32) { -if (r->Op2 &2 ) - p->regval =upper_32_bits (p->regval); -else - p->regval =lower_32_bits (p->regval); - } +get_access_mask (r, &mask, &shift); + p->regval = (vcpu_read_sys_reg (vcpu, r->reg) & mask) >> shift;return true; }
@@ -1264,10 +1273,6 @@ static bool access_csselr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, {int reg = r->reg; -/* See the 32bit mapping in kvm_host.h */ -if (p->is_aarch32) - reg = r->reg /2 ; -if (p->is_write)vcpu_write_sys_reg (vcpu, p->regval, reg);else
@@ -1919,20 +1924,29 @@ static const struct sys_reg_desc cp14_64_regs[] = {*/ static const struct sys_reg_desc cp15_regs[] = { {Op1 (0 ),CRn (0 ),CRm (0 ),Op2 (1 ), access_ctr }, - {Op1 (0 ),CRn (1 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL , c1_SCTLR }, - {Op1 (0 ),CRn (1 ),CRm (0 ),Op2 (1 ), access_actlr }, - {Op1 (0 ),CRn (1 ),CRm (0 ),Op2 (3 ), access_actlr }, - {Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL , c2_TTBR0 }, - {Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (1 ), access_vm_reg,NULL , c2_TTBR1 }, - {Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (2 ), access_vm_reg,NULL , c2_TTBCR }, - {Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (3 ), access_vm_reg,NULL , c2_TTBCR2 }, - {Op1 (0 ),CRn (3 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL , c3_DACR }, - {Op1 (0 ),CRn (5 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL , c5_DFSR }, - {Op1 (0 ),CRn (5 ),CRm (0 ),Op2 (1 ), access_vm_reg,NULL , c5_IFSR }, - {Op1 (0 ),CRn (5 ),CRm (1 ),Op2 (0 ), access_vm_reg,NULL , c5_ADFSR }, - {Op1 (0 ),CRn (5 ),CRm (1 ),Op2 (1 ), access_vm_reg,NULL , c5_AIFSR }, - {Op1 (0 ),CRn (6 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL , c6_DFAR }, - {Op1 (0 ),CRn (6 ),CRm (0 ),Op2 (2 ), access_vm_reg,NULL , c6_IFAR }, + {Op1 (0 ),CRn (1 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL ,SCTLR_EL1 }, +/* ACTLR */ + {AA32 (LO ),Op1 (0 ),CRn (1 ),CRm (0 ),Op2 (1 ), access_actlr,NULL ,ACTLR_EL1 }, +/* ACTLR2 */ + {AA32 (HI ),Op1 (0 ),CRn (1 ),CRm (0 ),Op2 (3 ), access_actlr,NULL ,ACTLR_EL1 }, + {Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL ,TTBR0_EL1 }, + {Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (1 ), access_vm_reg,NULL ,TTBR1_EL1 }, +/* TTBCR */ + {AA32 (LO ),Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (2 ), access_vm_reg,NULL ,TCR_EL1 }, +/* TTBCR2 */ + {AA32 (HI ),Op1 (0 ),CRn (2 ),CRm (0 ),Op2 (3 ), access_vm_reg,NULL ,TCR_EL1 }, + {Op1 (0 ),CRn (3 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL ,DACR32_EL2 }, +/* DFSR */ + {Op1 (0 ),CRn (5 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL ,ESR_EL1 }, + {Op1 (0 ),CRn (5 ),CRm (0 ),Op2 (1 ), access_vm_reg,NULL ,IFSR32_EL2 }, +/* ADFSR */ + {Op1 (0 ),CRn (5 ),CRm (1 ),Op2 (0 ), access_vm_reg,NULL ,AFSR0_EL1 }, +/* AIFSR */ + {Op1 (0 ),CRn (5 ),CRm (1 ),Op2 (1 ), access_vm_reg,NULL ,AFSR1_EL1 }, +/* DFAR */ + {AA32 (LO ),Op1 (0 ),CRn (6 ),CRm (0 ),Op2 (0 ), access_vm_reg,NULL ,FAR_EL1 }, +/* IFAR */ + {AA32 (HI ),Op1 (0 ),CRn (6 ),CRm (0 ),Op2 (2 ), access_vm_reg,NULL ,FAR_EL1 },/* * DC{C,I,CI}SW operations:
@@ -1958,15 +1972,19 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1( 0), CRn( 9), CRm(14), Op2( 2), access_pminten }, { Op1( 0), CRn( 9), CRm(14), Op2( 3), access_pmovs }, - { Op1( 0), CRn(10), CRm( 2), Op2( 0), access_vm_reg, NULL, c10_PRRR }, - { Op1( 0), CRn(10), CRm( 2), Op2( 1), access_vm_reg, NULL, c10_NMRR }, - { Op1( 0), CRn(10), CRm( 3), Op2( 0), access_vm_reg, NULL, c10_AMAIR0 }, - { Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, c10_AMAIR1 }, +/* PRRR/MAIR0 */ + { AA32(LO), Op1( 0), CRn(10), CRm( 2), Op2( 0), access_vm_reg, NULL, MAIR_EL1 }, +/* NMRR/MAIR1 */ + { AA32(HI), Op1( 0), CRn(10), CRm( 2), Op2( 1), access_vm_reg, NULL, MAIR_EL1 }, +/* AMAIR0 */ + { AA32(LO), Op1( 0), CRn(10), CRm( 3), Op2( 0), access_vm_reg, NULL, AMAIR_EL1 }, +/* AMAIR1 */ + { AA32(HI), Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, AMAIR_EL1 },/* ICC_SRE */ { Op1( 0), CRn(12), CRm(12), Op2( 5), access_gic_sre }, - { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, c13_CID }, + { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, CONTEXTIDR_EL1 },/* Arch Tmers */ { SYS_DESC(SYS_AARCH32_CNTP_TVAL), access_arch_timer },
@@ -2041,14 +2059,14 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1(1), CRn( 0), CRm( 0), Op2(0), access_ccsidr }, { Op1(1), CRn( 0), CRm( 0), Op2(1), access_clidr }, - { Op1(2), CRn( 0), CRm( 0), Op2(0), access_csselr, NULL, c0_CSSELR }, + { Op1(2), CRn( 0), CRm( 0), Op2(0), access_csselr, NULL, CSSELR_EL1 }, };static const struct sys_reg_desc cp15_64_regs[] = { - {Op1 (0 ),CRn (0 ),CRm (2 ),Op2 (0 ), access_vm_reg,NULL , c2_TTBR0 }, + {Op1 (0 ),CRn (0 ),CRm (2 ),Op2 (0 ), access_vm_reg,NULL ,TTBR0_EL1 }, {Op1 (0 ),CRn (0 ),CRm (9 ),Op2 (0 ), access_pmu_evcntr }, {Op1 (0 ),CRn (0 ),CRm (12 ),Op2 (0 ), access_gic_sgi },/* ICC_SGI1R */ - {Op1 (1 ),CRn (0 ),CRm (2 ),Op2 (0 ), access_vm_reg,NULL , c2_TTBR1 }, + {Op1 (1 ),CRn (0 ),CRm (2 ),Op2 (0 ), access_vm_reg,NULL ,TTBR1_EL1 }, {Op1 (1 ),CRn (0 ),CRm (12 ),Op2 (0 ), access_gic_sgi },/* ICC_ASGI1R */ {Op1 (2 ),CRn (0 ),CRm (12 ),Op2 (0 ), access_gic_sgi },/* ICC_SGI0R */ { SYS_DESC(SYS_AARCH32_CNTP_CVAL), access_arch_timer },
Signature · 6 lines
2.28.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH v2 8/9 KVM: arm64: Drop legacy copro shadow register
In reply to Marc ZyngierFinally remove one of the biggest 32bit legacy: the copro shadow mapping. We won't missit.
--- arch/arm64/include/asm/kvm_host.h | 48 +------------------------------ 1 file changed, 1 insertion(+), 47 deletions(-)
arch/arm64/include/asm/kvm_host.h +1 -47
@@ -201,49 +201,6 @@ enum vcpu_sysreg {NR_SYS_REGS /* Nothing after this line! */ }; -/* 32bit mapping */ -#define c0_MPIDR (MPIDR_EL1 * 2)/* MultiProcessor ID Register */ -#define c0_CSSELR (CSSELR_EL1 * 2)/* Cache Size Selection Register */ -#define c1_SCTLR (SCTLR_EL1 * 2)/* System Control Register */ -#define c1_ACTLR (ACTLR_EL1 * 2)/* Auxiliary Control Register */ -#define c1_CPACR (CPACR_EL1 * 2)/* Coprocessor Access Control */ -#define c2_TTBR0 (TTBR0_EL1 * 2)/* Translation Table Base Register 0 */ -#define c2_TTBR0_high (c2_TTBR0 + 1)/* TTBR0 top 32 bits */ -#define c2_TTBR1 (TTBR1_EL1 * 2)/* Translation Table Base Register 1 */ -#define c2_TTBR1_high (c2_TTBR1 + 1)/* TTBR1 top 32 bits */ -#define c2_TTBCR (TCR_EL1 * 2)/* Translation Table Base Control R. */ -#define c2_TTBCR2 (c2_TTBCR + 1)/* Translation Table Base Control R. 2 */ -#define c3_DACR (DACR32_EL2 * 2)/* Domain Access Control Register */ -#define c5_DFSR (ESR_EL1 * 2)/* Data Fault Status Register */ -#define c5_IFSR (IFSR32_EL2 * 2)/* Instruction Fault Status Register */ -#define c5_ADFSR (AFSR0_EL1 * 2)/* Auxiliary Data Fault Status R */ -#define c5_AIFSR (AFSR1_EL1 * 2)/* Auxiliary Instr Fault Status R */ -#define c6_DFAR (FAR_EL1 * 2)/* Data Fault Address Register */ -#define c6_IFAR (c6_DFAR + 1)/* Instruction Fault Address Register */ -#define c7_PAR (PAR_EL1 * 2)/* Physical Address Register */ -#define c7_PAR_high (c7_PAR + 1)/* PAR top 32 bits */ -#define c10_PRRR (MAIR_EL1 * 2)/* Primary Region Remap Register */ -#define c10_NMRR (c10_PRRR + 1)/* Normal Memory Remap Register */ -#define c12_VBAR (VBAR_EL1 * 2)/* Vector Base Address Register */ -#define c13_CID (CONTEXTIDR_EL1 * 2)/* Context ID Register */ -#define c13_TID_URW (TPIDR_EL0 * 2)/* Thread ID, User R/W */ -#define c13_TID_URO (TPIDRRO_EL0 * 2)/* Thread ID, User R/O */ -#define c13_TID_PRIV (TPIDR_EL1 * 2)/* Thread ID, Privileged */ -#define c10_AMAIR0 (AMAIR_EL1 * 2)/* Aux Memory Attr Indirection Reg */ -#define c10_AMAIR1 (c10_AMAIR0 + 1)/* Aux Memory Attr Indirection Reg */ -#define c14_CNTKCTL (CNTKCTL_EL1 * 2)/* Timer Control Register (PL1) */ - -#define cp14_DBGDSCRext (MDSCR_EL1 * 2) -#define cp14_DBGBCR0 (DBGBCR0_EL1 * 2) -#define cp14_DBGBVR0 (DBGBVR0_EL1 * 2) -#define cp14_DBGBXVR0 (cp14_DBGBVR0 + 1) -#define cp14_DBGWCR0 (DBGWCR0_EL1 * 2) -#define cp14_DBGWVR0 (DBGWVR0_EL1 * 2) -#define cp14_DBGDCCINT (MDCCINT_EL1 * 2) -#define cp14_DBGVCR (DBGVCR32_EL2 * 2) - -#define NR_COPRO_REGS (NR_SYS_REGS * 2) -struct kvm_cpu_context {struct user_pt_regs regs;/* sp = sp_el0 */
@@ -254,10 +211,7 @@ struct kvm_cpu_context {struct user_fpsimd_state fp_regs; -union { -u64 sys_regs[NR_SYS_REGS ]; -u32 copro[NR_COPRO_REGS ]; - }; +u64 sys_regs[NR_SYS_REGS ];struct kvm_vcpu *__hyp_running_vcpu; };
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 7/9 KVM: arm64: Drop is_aarch32 trap attribute
In reply to Marc Zyngieris_aarch32 is only used once, and can be trivially replaced by testing Op0 instead. Drop it.
--- arch/arm64/kvm/sys_regs.c | 7 ++----- arch/arm64/kvm/sys_regs.h | 1 - arch/arm64/kvm/vgic-sys-reg-v3.c | 2 -- 3 files changed, 2 insertions(+), 8 deletions(-)
arch/arm64/kvm/sys_regs.c +2 -5
@@ -213,7 +213,7 @@ static bool access_gic_sgi(struct kvm_vcpu *vcpu,* equivalent to ICC_SGI0R_EL1, as there is no "alternative" secure * group. */ -if (p->is_aarch32) { +if (p->Op0 ==0 ) {/* AArch32 */ switch (p->Op1) {default :/* Keep GCC quiet */ case 0 :/* ICC_SGI1R */
@@ -224,7 +224,7 @@ static bool access_gic_sgi(struct kvm_vcpu *vcpu, g1 = false;break ; } - }else { + }else {/* AArch64 */ switch (p->Op2) {default :/* Keep GCC quiet */ case 5 :/* ICC_SGI1R_EL1 */
@@ -2175,7 +2175,6 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu,int Rt =kvm_vcpu_sys_get_rt (vcpu);int Rt2 = (esr >>10 ) &0x1f ; - params.is_aarch32 = true; params.CRm = (esr >>1 ) &0xf ; params.is_write = ((esr &1 ) ==0 );
@@ -2225,7 +2224,6 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu,u32 esr =kvm_vcpu_get_esr (vcpu);int Rt =kvm_vcpu_sys_get_rt (vcpu); - params.is_aarch32 = true; params.CRm = (esr >>1 ) &0xf ; params.regval =vcpu_get_reg (vcpu, Rt); params.is_write = ((esr &1 ) ==0 );
@@ -2319,7 +2317,6 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu)trace_kvm_handle_sys_reg (esr); - params.is_aarch32 = false; params.Op0 = (esr >>20 ) &3 ; params.Op1 = (esr >>14 ) &0x7 ; params.CRn = (esr >>10 ) &0xf ;
arch/arm64/kvm/sys_regs.h +0 -1
@@ -19,7 +19,6 @@ struct sys_reg_params {u8 Op2;u64 regval;bool is_write; -bool is_aarch32; };struct sys_reg_desc {
arch/arm64/kvm/vgic-sys-reg-v3.c +0 -2
@@ -268,7 +268,6 @@ int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, bool is_write, u64 id, params.regval = *reg; params.is_write = is_write; - params.is_aarch32 = false;if (find_reg_by_id (sysreg, ¶ms, gic_v3_icc_reg_descs,ARRAY_SIZE (gic_v3_icc_reg_descs)))
@@ -287,7 +286,6 @@ int vgic_v3_cpu_sysregs_uaccess(struct kvm_vcpu *vcpu, bool is_write, u64 id,if (is_write) params.regval = *reg; params.is_write = is_write; - params.is_aarch32 = false; r =find_reg_by_id (sysreg, ¶ms, gic_v3_icc_reg_descs,ARRAY_SIZE (gic_v3_icc_reg_descs));
Signature · 1 line
2.28.0
Marc Zyngier
maintainerPATCH v2 9/9 KVM: arm64: Drop kvm_coproc.h
In reply to Marc Zyngierkvm_coproc.h used to serve as a compatibility layer for the files shared between the 32 and 64 bit ports.
Another one bites the dust...
--- arch/arm64/include/asm/kvm_coproc.h | 38 ----------------------------- arch/arm64/include/asm/kvm_host.h | 17 +++++++++++++ arch/arm64/kvm/arm.c | 3 +-- arch/arm64/kvm/guest.c | 1 - arch/arm64/kvm/handle_exit.c | 1 - arch/arm64/kvm/reset.c | 1 - arch/arm64/kvm/sys_regs.c | 1 - 7 files changed, 18 insertions(+), 44 deletions(-) delete mode 100644 arch/arm64/include/asm/kvm_coproc.h
arch/arm64/include/asm/kvm_coproc.h deleted +0 -38
@@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (C) 2012,2013 - ARM Ltd -* Author: Marc Zyngier <[email protected]> -* -* Derived from arch/arm/include/asm/kvm_coproc.h -* Copyright (C) 2012 Rusty Russell IBM Corporation -*/ - -#ifndef __ARM64_KVM_COPROC_H__ -#define __ARM64_KVM_COPROC_H__ - -#include <linux/kvm_host.h> - -void kvm_reset_sys_regs (struct kvm_vcpu *vcpu); - -struct kvm_sys_reg_table { -const struct sys_reg_desc *table; -size_t num; -}; - -int kvm_handle_cp14_load_store (struct kvm_vcpu *vcpu); -int kvm_handle_cp14_32 (struct kvm_vcpu *vcpu); -int kvm_handle_cp14_64 (struct kvm_vcpu *vcpu); -int kvm_handle_cp15_32 (struct kvm_vcpu *vcpu); -int kvm_handle_cp15_64 (struct kvm_vcpu *vcpu); -int kvm_handle_sys_reg (struct kvm_vcpu *vcpu); - -#define kvm_coproc_table_init kvm_sys_reg_table_init -void kvm_sys_reg_table_init (void ); - -struct kvm_one_reg ; -int kvm_arm_copy_sys_reg_indices (struct kvm_vcpu *vcpu,u64 __user *uindices); -int kvm_arm_sys_reg_get_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *); -int kvm_arm_sys_reg_set_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *); -unsigned long kvm_arm_num_sys_reg_descs (struct kvm_vcpu *vcpu); - -#endif /* __ARM64_KVM_COPROC_H__ */
arch/arm64/include/asm/kvm_host.h +17 -0
@@ -533,6 +533,12 @@ unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);int kvm_arm_copy_reg_indices (struct kvm_vcpu *vcpu,u64 __user *indices);int kvm_arm_get_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *reg);int kvm_arm_set_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *reg); + +unsigned long kvm_arm_num_sys_reg_descs (struct kvm_vcpu *vcpu); +int kvm_arm_copy_sys_reg_indices (struct kvm_vcpu *vcpu,u64 __user *uindices); +int kvm_arm_sys_reg_get_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *); +int kvm_arm_sys_reg_set_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *); +int __kvm_arm_vcpu_get_events (struct kvm_vcpu *vcpu,struct kvm_vcpu_events *events);
@@ -595,6 +601,17 @@ void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);int handle_exit (struct kvm_vcpu *vcpu,int exception_index);void handle_exit_early (struct kvm_vcpu *vcpu,int exception_index); +int kvm_handle_cp14_load_store (struct kvm_vcpu *vcpu); +int kvm_handle_cp14_32 (struct kvm_vcpu *vcpu); +int kvm_handle_cp14_64 (struct kvm_vcpu *vcpu); +int kvm_handle_cp15_32 (struct kvm_vcpu *vcpu); +int kvm_handle_cp15_64 (struct kvm_vcpu *vcpu); +int kvm_handle_sys_reg (struct kvm_vcpu *vcpu); + +void kvm_reset_sys_regs (struct kvm_vcpu *vcpu); + +void kvm_sys_reg_table_init (void ); +/* MMIO helpers */ void kvm_mmio_write_buf (void *buf,unsigned int len,unsigned long data);unsigned long kvm_mmio_read_buf (const void *buf,unsigned int len);
arch/arm64/kvm/arm.c +1 -2
@@ -35,7 +35,6 @@#include <asm/kvm_asm.h> #include <asm/kvm_mmu.h> #include <asm/kvm_emulate.h> -#include <asm/kvm_coproc.h> #include <asm/sections.h> #include <kvm/arm_hypercalls.h>
@@ -1525,7 +1524,7 @@ static int init_subsystems(void) goto out;kvm_perf_init (); -kvm_coproc_table_init (); +kvm_sys_reg_table_init (); out:on_each_cpu (_kvm_arch_hardware_disable,NULL ,1 );
arch/arm64/kvm/guest.c +0 -1
@@ -24,7 +24,6 @@#include <asm/fpsimd.h> #include <asm/kvm.h> #include <asm/kvm_emulate.h> -#include <asm/kvm_coproc.h> #include <asm/sigcontext.h> #include "trace.h"
arch/arm64/kvm/handle_exit.c +0 -1
@@ -14,7 +14,6 @@#include <asm/esr.h> #include <asm/exception.h> #include <asm/kvm_asm.h> -#include <asm/kvm_coproc.h> #include <asm/kvm_emulate.h> #include <asm/kvm_mmu.h> #include <asm/debug-monitors.h>
arch/arm64/kvm/reset.c +0 -1
@@ -25,7 +25,6 @@#include <asm/ptrace.h> #include <asm/kvm_arm.h> #include <asm/kvm_asm.h> -#include <asm/kvm_coproc.h> #include <asm/kvm_emulate.h> #include <asm/kvm_mmu.h> #include <asm/virt.h>
arch/arm64/kvm/sys_regs.c +0 -1
@@ -20,7 +20,6 @@#include <asm/debug-monitors.h> #include <asm/esr.h> #include <asm/kvm_arm.h> -#include <asm/kvm_coproc.h> #include <asm/kvm_emulate.h> #include <asm/kvm_hyp.h> #include <asm/kvm_mmu.h>
Signature · 1 line
2.28.0