KVM: arm64: Do not let a L1 hypervisor access the *32_EL2 sysregs
Marc Zyngier
maintainerPATCH 1/1 KVM: arm64: Do not let a L1 hypervisor access the *32_EL2 sysregs
DBGVCR32_EL2, DACR32_EL2, IFSR32_EL2 and FPEXC32_EL2 are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.
Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
--- arch/arm64/kvm/sys_regs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/kvm/sys_regs.c +4 -4
@@ -1961,7 +1961,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {// DBGDTR[TR]X_EL0 share the same encoding { SYS_DESC(SYS_DBGDTRTX_EL0), trap_raz_wi }, - { SYS_DESC(SYS_DBGVCR32_EL2), NULL, reset_val, DBGVCR32_EL2, 0 }, + { SYS_DESC(SYS_DBGVCR32_EL2), trap_undef, reset_val, DBGVCR32_EL2, 0 }, { SYS_DESC(SYS_MPIDR_EL1), NULL, reset_mpidr, MPIDR_EL1 },
@@ -2380,18 +2380,18 @@ static const struct sys_reg_desc sys_reg_descs[] = {EL2_REG (VTTBR_EL2 , access_rw, reset_val,0 ),EL2_REG (VTCR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_DACR32_EL2), NULL, reset_unknown, DACR32_EL2 }, + { SYS_DESC(SYS_DACR32_EL2), trap_undef, reset_unknown, DACR32_EL2 },EL2_REG (HDFGRTR_EL2 , access_rw, reset_val,0 ),EL2_REG (HDFGWTR_EL2 , access_rw, reset_val,0 ),EL2_REG (SPSR_EL2 , access_rw, reset_val,0 ),EL2_REG (ELR_EL2 , access_rw, reset_val,0 ), { SYS_DESC(SYS_SP_EL1), access_sp_el1}, - { SYS_DESC(SYS_IFSR32_EL2), NULL, reset_unknown, IFSR32_EL2 }, + { SYS_DESC(SYS_IFSR32_EL2), trap_undef, reset_unknown, IFSR32_EL2 },EL2_REG (AFSR0_EL2 , access_rw, reset_val,0 ),EL2_REG (AFSR1_EL2 , access_rw, reset_val,0 ),EL2_REG (ESR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x700 }, + { SYS_DESC(SYS_FPEXC32_EL2), trap_undef, reset_val, FPEXC32_EL2, 0x700 },EL2_REG (FAR_EL2 , access_rw, reset_val,0 ), EL2_REG(HPFAR_EL2, access_rw, reset_val, 0),
Signature · 1 line
2.34.1
Quoted 8 lines · Marc Zyngier
DBGVCR32_EL2,DACR32_EL2,IFSR32_EL2andFPEXC32_EL2are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
Signed-off-by Marc Zyngier <[email protected]>
If you intend to send this as a fix for 6.6:
Otherwise it is on the stack of patches I'll pick up for 6.7
Signature · 2 lines
Thanks, Oliver
Marc Zyngier
maintainerQuoted 9 lines · Oliver Upton
Quoted 7 lines · Marc Zyngier
DBGVCR32_EL2,DACR32_EL2,IFSR32_EL2andFPEXC32_EL2are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
Quoted 7 lines
Quoted 1 line
Signed-off-by Marc Zyngier <[email protected]>If you intend to send this as a fix for 6.6:
Reviewed-by Oliver Upton <[email protected]>Otherwise it is on the stack of patches I'll pick up for 6.7
Thanks.
I've queued it as a fix for now, together with Miguel's NV fix series.
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Hi Marc,
Quoted 37 lines · Marc Zyngier
DBGVCR32_EL2,DACR32_EL2,IFSR32_EL2andFPEXC32_EL2are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
Signed-off-by Marc Zyngier <[email protected]>---
arch/arm64/kvm/sys_regs.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)arch/arm64/kvm/sys_regs.c +2
-2@@ -1961,7 +1961,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {// DBGDTR[TR]X_EL0 share the same encoding { SYS_DESC(SYS_DBGDTRTX_EL0), trap_raz_wi }, - { SYS_DESC(SYS_DBGVCR32_EL2), NULL, reset_val, DBGVCR32_EL2, 0 }, + { SYS_DESC(SYS_DBGVCR32_EL2), trap_undef, reset_val, DBGVCR32_EL2, 0 }, { SYS_DESC(SYS_MPIDR_EL1), NULL, reset_mpidr, MPIDR_EL1 },@@ -2380,18 +2380,18 @@ static const struct sys_reg_desc sys_reg_descs[] = {EL2_REG (VTTBR_EL2 , access_rw, reset_val,0 ),EL2_REG (VTCR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_DACR32_EL2), NULL, reset_unknown, DACR32_EL2 }, + { SYS_DESC(SYS_DACR32_EL2), trap_undef, reset_unknown, DACR32_EL2 },EL2_REG (HDFGRTR_EL2 , access_rw, reset_val,0 ),EL2_REG (HDFGWTR_EL2 , access_rw, reset_val,0 ),EL2_REG (SPSR_EL2 , access_rw, reset_val,0 ), EL2_REG(ELR_EL2, access_rw, reset_val, 0),
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc sys_reg_descs[] = { · line 2395
Quoted 10 lines
arch/arm64/kvm/sys_regs.c +2
-2{ SYS_DESC(SYS_SP_EL1), access_sp_el1}, - { SYS_DESC(SYS_IFSR32_EL2), NULL, reset_unknown, IFSR32_EL2 }, + { SYS_DESC(SYS_IFSR32_EL2), trap_undef, reset_unknown, IFSR32_EL2 },EL2_REG (AFSR0_EL2 , access_rw, reset_val,0 ),EL2_REG (AFSR1_EL2 , access_rw, reset_val,0 ),EL2_REG (ESR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x700 }, + { SYS_DESC(SYS_FPEXC32_EL2), trap_undef, reset_val, FPEXC32_EL2, 0x700 },
Should SDER32_EL2 be considered to this same list?
Thanks,
Miguel
Quoted 6 lines
arch/arm64/kvm/sys_regs.c +0
-0EL2_REG (FAR_EL2 , access_rw, reset_val,0 ), EL2_REG(HPFAR_EL2, access_rw, reset_val, 0),Signature · 1 line
2.34.1
Marc Zyngier
maintainerQuoted 41 lines · Miguel Luis
Hi Marc,
Quoted 39 lines · Marc Zyngier
DBGVCR32_EL2,DACR32_EL2,IFSR32_EL2andFPEXC32_EL2are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
Signed-off-by Marc Zyngier <[email protected]>---
arch/arm64/kvm/sys_regs.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)arch/arm64/kvm/sys_regs.c +2
-2@@ -1961,7 +1961,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {// DBGDTR[TR]X_EL0 share the same encoding { SYS_DESC(SYS_DBGDTRTX_EL0), trap_raz_wi }, - { SYS_DESC(SYS_DBGVCR32_EL2), NULL, reset_val, DBGVCR32_EL2, 0 }, + { SYS_DESC(SYS_DBGVCR32_EL2), trap_undef, reset_val, DBGVCR32_EL2, 0 }, { SYS_DESC(SYS_MPIDR_EL1), NULL, reset_mpidr, MPIDR_EL1 },@@ -2380,18 +2380,18 @@ static const struct sys_reg_desc sys_reg_descs[] = {EL2_REG (VTTBR_EL2 , access_rw, reset_val,0 ),EL2_REG (VTCR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_DACR32_EL2), NULL, reset_unknown, DACR32_EL2 }, + { SYS_DESC(SYS_DACR32_EL2), trap_undef, reset_unknown, DACR32_EL2 },EL2_REG (HDFGRTR_EL2 , access_rw, reset_val,0 ),EL2_REG (HDFGWTR_EL2 , access_rw, reset_val,0 ),EL2_REG (SPSR_EL2 , access_rw, reset_val,0 ),EL2_REG (ELR_EL2 , access_rw, reset_val,0 ), { SYS_DESC(SYS_SP_EL1), access_sp_el1},
Quoted 11 lines
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc sys_reg_descs[] = { · line 2395
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +2
-2- { SYS_DESC(SYS_IFSR32_EL2), NULL, reset_unknown, IFSR32_EL2 }, + { SYS_DESC(SYS_IFSR32_EL2), trap_undef, reset_unknown, IFSR32_EL2 },EL2_REG (AFSR0_EL2 , access_rw, reset_val,0 ),EL2_REG (AFSR1_EL2 , access_rw, reset_val,0 ),EL2_REG (ESR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x700 }, + { SYS_DESC(SYS_FPEXC32_EL2), trap_undef, reset_val, FPEXC32_EL2, 0x700 },Should
SDER32_EL2be considered to this same list?
This wouldn't make much sense.
This register is only available when running in secure mode, and KVM is firmly non-secure.
Thanks,
M.
Jazz is not dead, it just smells funny
Hi Marc,
Quoted 58 lines · Marc Zyngier
Quoted 41 lines · Miguel Luis
Hi Marc,
Quoted 39 lines · Marc Zyngier
DBGVCR32_EL2,DACR32_EL2,IFSR32_EL2andFPEXC32_EL2are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
Signed-off-by Marc Zyngier <[email protected]>---
arch/arm64/kvm/sys_regs.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)arch/arm64/kvm/sys_regs.c +2
-2@@ -1961,7 +1961,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {// DBGDTR[TR]X_EL0 share the same encoding { SYS_DESC(SYS_DBGDTRTX_EL0), trap_raz_wi }, - { SYS_DESC(SYS_DBGVCR32_EL2), NULL, reset_val, DBGVCR32_EL2, 0 }, + { SYS_DESC(SYS_DBGVCR32_EL2), trap_undef, reset_val, DBGVCR32_EL2, 0 }, { SYS_DESC(SYS_MPIDR_EL1), NULL, reset_mpidr, MPIDR_EL1 },@@ -2380,18 +2380,18 @@ static const struct sys_reg_desc sys_reg_descs[] = {EL2_REG (VTTBR_EL2 , access_rw, reset_val,0 ),EL2_REG (VTCR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_DACR32_EL2), NULL, reset_unknown, DACR32_EL2 }, + { SYS_DESC(SYS_DACR32_EL2), trap_undef, reset_unknown, DACR32_EL2 },EL2_REG (HDFGRTR_EL2 , access_rw, reset_val,0 ),EL2_REG (HDFGWTR_EL2 , access_rw, reset_val,0 ),EL2_REG (SPSR_EL2 , access_rw, reset_val,0 ),EL2_REG (ELR_EL2 , access_rw, reset_val,0 ), { SYS_DESC(SYS_SP_EL1), access_sp_el1},Quoted 11 lines
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc sys_reg_descs[] = { · line 2395
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +2
-2- { SYS_DESC(SYS_IFSR32_EL2), NULL, reset_unknown, IFSR32_EL2 }, + { SYS_DESC(SYS_IFSR32_EL2), trap_undef, reset_unknown, IFSR32_EL2 },EL2_REG (AFSR0_EL2 , access_rw, reset_val,0 ),EL2_REG (AFSR1_EL2 , access_rw, reset_val,0 ),EL2_REG (ESR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x700 }, + { SYS_DESC(SYS_FPEXC32_EL2), trap_undef, reset_val, FPEXC32_EL2, 0x700 },Should
SDER32_EL2be considered to this same list?
Quoted 4 lines
This wouldn't make much sense.
This register is only available when running in secure mode, and KVM is firmly non-secure.
Thanks for clarifying.
Miguel
Quoted 5 lines
Thanks,
M.Jazz is not dead, it just smells funny
Hi Marc,
Quoted 8 lines · Marc Zyngier
DBGVCR32_EL2,DACR32_EL2,IFSR32_EL2andFPEXC32_EL2are required to UNDEF when AArch32 isn't implemented, which is definitely the case when running NV.Given that this is the only case where these registers can trap, unconditionally inject an UNDEF exception.
Signed-off-by Marc Zyngier <[email protected]>
Eric
Quoted 39 lines
--- arch/arm64/kvm/sys_regs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/arm64/kvm/sys_regs.c +4
-4@@ -1961,7 +1961,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {// DBGDTR[TR]X_EL0 share the same encoding { SYS_DESC(SYS_DBGDTRTX_EL0), trap_raz_wi }, - { SYS_DESC(SYS_DBGVCR32_EL2), NULL, reset_val, DBGVCR32_EL2, 0 }, + { SYS_DESC(SYS_DBGVCR32_EL2), trap_undef, reset_val, DBGVCR32_EL2, 0 }, { SYS_DESC(SYS_MPIDR_EL1), NULL, reset_mpidr, MPIDR_EL1 },@@ -2380,18 +2380,18 @@ static const struct sys_reg_desc sys_reg_descs[] = {EL2_REG (VTTBR_EL2 , access_rw, reset_val,0 ),EL2_REG (VTCR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_DACR32_EL2), NULL, reset_unknown, DACR32_EL2 }, + { SYS_DESC(SYS_DACR32_EL2), trap_undef, reset_unknown, DACR32_EL2 },EL2_REG (HDFGRTR_EL2 , access_rw, reset_val,0 ),EL2_REG (HDFGWTR_EL2 , access_rw, reset_val,0 ),EL2_REG (SPSR_EL2 , access_rw, reset_val,0 ),EL2_REG (ELR_EL2 , access_rw, reset_val,0 ), { SYS_DESC(SYS_SP_EL1), access_sp_el1}, - { SYS_DESC(SYS_IFSR32_EL2), NULL, reset_unknown, IFSR32_EL2 }, + { SYS_DESC(SYS_IFSR32_EL2), trap_undef, reset_unknown, IFSR32_EL2 },EL2_REG (AFSR0_EL2 , access_rw, reset_val,0 ),EL2_REG (AFSR1_EL2 , access_rw, reset_val,0 ),EL2_REG (ESR_EL2 , access_rw, reset_val,0 ), - { SYS_DESC(SYS_FPEXC32_EL2), NULL, reset_val, FPEXC32_EL2, 0x700 }, + { SYS_DESC(SYS_FPEXC32_EL2), trap_undef, reset_val, FPEXC32_EL2, 0x700 },EL2_REG (FAR_EL2 , access_rw, reset_val,0 ), EL2_REG(HPFAR_EL2, access_rw, reset_val, 0),