various aarch64 fixes for running Hyper-V on TCG
PATCH 3/3 target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
In reply to Evgeny IakovlevARM trusted firmware, when built with FEAT_HCX support, sets SCR_EL3.HXEn bit to allow EL2 to modify HCRX_EL2 register without trapping it in EL3. Qemu uses a valid mask to clear unsupported SCR_EL3 bits when emulating SCR_EL3 write, and that mask doesn't include SCR_EL3.HXEn bit even if FEAT_HCX is enabled and exposed to the guest. As a result EL3 writes of that bit are ignored.
--- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)
target/arm/helper.c +3 -0
@@ -1844,6 +1844,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)if (cpu_isar_feature (aa64_sme, cpu)) { valid_mask |=SCR_ENTP2 ; } +if (cpu_isar_feature (aa64_hcx, cpu)) { + valid_mask |=SCR_HXEN ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST );if (cpu_isar_feature (aa32_ras, cpu)) {
Signature · 1 line
2.34.1
PATCH 1/3 target/arm: implement DBGCLAIM registers
In reply to Evgeny IakovlevThe architecture does not define any functionality for the CLAIM tag bits. So we will just keep the raw bits, as per spec.
Helps Hyper-V boot on aarch64-tcg because it context-switches DBGCLAIM on EL2 entry/exit.
--- target/arm/cpu.h | 1 + target/arm/debug_helper.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)
target/arm/cpu.h +1 -0
@@ -494,6 +494,7 @@ typedef struct CPUArchState {uint64_t dbgbcr[16 ];/* breakpoint control registers */ uint64_t dbgwvr[16 ];/* watchpoint value registers */ uint64_t dbgwcr[16 ];/* watchpoint control registers */ +uint64_t dbgclaim;/* DBGCLAIM bits */ uint64_t mdscr_el1;uint64_t oslsr_el1;/* OS Lock Status */ uint64_t osdlr_el1;/* OS DoubleLock status */
target/arm/debug_helper.c +27 -0
@@ -629,6 +629,18 @@ static void osdlr_write(CPUARMState *env, const ARMCPRegInfo *ri, } } +static void dbgclaimset_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ + env->cp15.dbgclaim |= (value &0xFF ); +} + +static void dbgclaimclr_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ + env->cp15.dbgclaim &= ~(value &0xFF ); +} +static const ARMCPRegInfo debug_cp_reginfo[] = {/* * DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped
@@ -712,6 +724,21 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, .access = PL1_RW, .accessfn = access_tda, .type = ARM_CP_NOP }, +/* +* Dummy DBGCLAIM registers. +* "The architecture does not define any functionality for the CLAIM tag bits.", +* so we only keep the raw bits +*/ + { .name = "DBGCLAIMSET_EL1", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6, + .access = PL1_RW, .accessfn = access_tda, + .writefn = dbgclaimset_write, + .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) }, + { .name = "DBGCLAIMCLR_EL1", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 6, + .access = PL1_RW, .accessfn = access_tda, + .writefn = dbgclaimclr_write, + .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) }, }; static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {
Signature · 1 line
2.34.1
cover various aarch64 fixes for running Hyper-V on TCG
Small series of changes to aarch64 emulation to better support running Hyper-V as a TCG guest wtih EL3 firmware.
Evgeny Iakovlev (3):
target/arm: implement DBGCLAIM registers
target/arm: provide RAZ/WI stubs for more DCC registers target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
target/arm/cpu.h | 1 + target/arm/debug_helper.c | 39 +++++++++++++++++++++++++++++++++++++++ target/arm/helper.c | 3 +++ 3 files changed, 43 insertions(+)
Signature · 1 line
2.34.1
PATCH 2/3 target/arm: provide RAZ/WI stubs for more DCC registers
Qemu doesn't implement Debug Communication Channel, however when running Microsoft Hyper-V in software-emulated ARM64 as a guest, it tries to access some of the DCM registers during an EL2 context switch.
Provide RAZ/WI stubs for OSDTRRX_EL1, OSDTRTX_EL1 and OSECCR_EL1 registers in the same way the rest of DCM is currently done. Do account for access traps though with access_tda.
--- target/arm/debug_helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
target/arm/debug_helper.c +12 -0
@@ -673,6 +673,18 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0, .access = PL0_R, .accessfn = access_tda, .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2, + .access = PL1_RW, .accessfn = access_tda, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "OSDTRTX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, + .access = PL1_RW, .accessfn = access_tda, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "OSECCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, + .access = PL1_RW, .accessfn = access_tda, + .type = ARM_CP_CONST, .resetvalue = 0 },/* * DBGDSCRint[15,12,5:2] map to MDSCR_EL1[15,12,5:2]. Map all bits as * it is unlikely a guest will care.
Signature · 1 line
2.34.1
Re: [PATCH 1/3] target/arm: implement DBGCLAIM registers
In reply to Evgeny IakovlevQuoted 52 lines · Evgeny Iakovlev
The architecture does not define any functionality for the CLAIM tag bits. So we will just keep the raw bits, as per spec.
Helps Hyper-V boot on aarch64-tcg because it context-switches DBGCLAIM on EL2 entry/exit.
Signed-off-by Evgeny Iakovlev <[email protected]>--- target/arm/cpu.h | 1 + target/arm/debug_helper.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)target/arm/cpu.h +1
-0@@ -494,6 +494,7 @@ typedef struct CPUArchState {uint64_t dbgbcr[16 ];/* breakpoint control registers */ uint64_t dbgwvr[16 ];/* watchpoint value registers */ uint64_t dbgwcr[16 ];/* watchpoint control registers */ +uint64_t dbgclaim;/* DBGCLAIM bits */ uint64_t mdscr_el1;uint64_t oslsr_el1;/* OS Lock Status */ uint64_t osdlr_el1;/* OS DoubleLock status */ target/arm/debug_helper.c +12
-0@@ -629,6 +629,18 @@ static void osdlr_write(CPUARMState *env, const ARMCPRegInfo *ri, } } +static void dbgclaimset_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ + env->cp15.dbgclaim |= (value &0xFF ); +} + +static void dbgclaimclr_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ + env->cp15.dbgclaim &= ~(value &0xFF ); +} +static const ARMCPRegInfo debug_cp_reginfo[] = {/* * DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped @@ -712,6 +724,21 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, .access = PL1_RW, .accessfn = access_tda, .type = ARM_CP_NOP },
target/arm/debug_helper.c static const ARMCPRegInfo debug_cp_reginfo[] = { · line 736
Quoted 10 lines
target/arm/debug_helper.c +10
-0+/* +* Dummy DBGCLAIM registers. +* "The architecture does not define any functionality for the CLAIM tag bits.", +* so we only keep the raw bits +*/ + { .name = "DBGCLAIMSET_EL1", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6, + .access = PL1_RW, .accessfn = access_tda, + .writefn = dbgclaimset_write, + .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) },
DBGCLAIMSET_EL1 CLAIM bits are supposed to RAO. (In v7 this was done so software could identify how many claim bits are implemented by writing all-1s and then reading back.) So we need a readfn that just returns 0xff, and can skip the .fieldoffset.
We should mark DBGCLAIMSET_EL1 as ARM_CP_ALIAS, because the actual state is handled by DBGCLAIMCLR_EL1.
target/arm/debug_helper.c static const ARMCPRegInfo debug_cp_reginfo[] = { · line 741
Quoted 5 lines
target/arm/debug_helper.c +5
-0+ { .name = "DBGCLAIMCLR_EL1", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 6, + .access = PL1_RW, .accessfn = access_tda, + .writefn = dbgclaimclr_write, + .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) },
This also needs .raw_writefn = raw_write,
so that on migration restore we can write the value in and not have it go via the "clear these bits" writefn.
thanks
-- PMM
Re: [PATCH 2/3] target/arm: provide RAZ/WI stubs for more DCC registers
In reply to Evgeny IakovlevQuoted 4 lines · Evgeny Iakovlev
Qemu doesn't implement Debug Communication Channel, however when running Microsoft Hyper-V in software-emulated ARM64 as a guest, it tries to access some of the DCM registers during an EL2 context switch.
I've occasionally thought about implementing the DCC as something the QEMU user could connect to a QEMU chardev. But that would be a lot of faff for no very obvious benefit, so making these registers RAZ makes sense for now.
Quoted 3 lines
Provide RAZ/WI stubs for
OSDTRRX_EL1,OSDTRTX_EL1andOSECCR_EL1registers in the same way the rest of DCM is currently done. Do account for access traps though withaccess_tda.
OSECCR_EL1 isn't part of DCC; it's a different bit of the external debug interface.
Quoted 15 lines
Signed-off-by Evgeny Iakovlev <[email protected]>--- target/arm/debug_helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)target/arm/debug_helper.c +2
-0@@ -673,6 +673,18 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0, .access = PL0_R, .accessfn = access_tda, .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2,
target/arm/debug_helper.c static const ARMCPRegInfo debug_cp_reginfo[] = { · line 687
Quoted 10 lines
target/arm/debug_helper.c +10
-0+ .access = PL1_RW, .accessfn = access_tda, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "OSDTRTX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, + .access = PL1_RW, .accessfn = access_tda, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "OSECCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, + .access = PL1_RW, .accessfn = access_tda, + .type = ARM_CP_CONST, .resetvalue = 0 },
A brief comment or two here would be nice.
Otherwise
thanks
-- PMM
Re: [PATCH 3/3] target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
In reply to Evgeny IakovlevQuoted 18 lines · Evgeny Iakovlev
ARM trusted firmware, when built with
FEAT_HCXsupport, sets SCR_EL3.HXEn bit to allow EL2 to modifyHCRX_EL2register without trapping it in EL3. Qemu uses a valid mask to clear unsupportedSCR_EL3bits when emulatingSCR_EL3write, and that mask doesn't include SCR_EL3.HXEn bit even ifFEAT_HCXis enabled and exposed to the guest. As a result EL3 writes of that bit are ignored.Signed-off-by Evgeny Iakovlev <[email protected]>--- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)target/arm/helper.c +0
-0
target/arm/helper.c static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
Quoted 10 lines
target/arm/helper.c +3
-1@@ -1844,6 +1844,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)if (cpu_isar_feature (aa64_sme, cpu)) { valid_mask |=SCR_ENTP2 ; } +if (cpu_isar_feature (aa64_hcx, cpu)) { + valid_mask |=SCR_HXEN ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST );if (cpu_isar_feature (aa32_ras, cpu)) { --
Oops. This is worth
Cc: [email protected]
I think.
I'll take this 3rd patch into target-arm.next now; I've left review comments for the other 2.
thanks
-- PMM
Re: [PATCH 3/3] target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
Quoted 34 lines · Peter Maydell
Quoted 17 lines · Evgeny Iakovlev
ARM trusted firmware, when built with
FEAT_HCXsupport, sets SCR_EL3.HXEn bit to allow EL2 to modifyHCRX_EL2register without trapping it in EL3. Qemu uses a valid mask to clear unsupportedSCR_EL3bits when emulatingSCR_EL3write, and that mask doesn't include SCR_EL3.HXEn bit even ifFEAT_HCXis enabled and exposed to the guest. As a result EL3 writes of that bit are ignored.Signed-off-by Evgeny Iakovlev <[email protected]>--- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)target/arm/helper.c +0
-0target/arm/helper.c static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
Quoted 10 lines
target/arm/helper.c +3
-1@@ -1844,6 +1844,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)if (cpu_isar_feature (aa64_sme, cpu)) { valid_mask |=SCR_ENTP2 ; } +if (cpu_isar_feature (aa64_hcx, cpu)) { + valid_mask |=SCR_HXEN ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST );if (cpu_isar_feature (aa32_ras, cpu)) { --Oops. This is worth
Cc: [email protected]I think.
Quoted 7 lines
Reviewed-by Peter Maydell <[email protected]>I'll take this 3rd patch into target-arm.next now; I've left review comments for the other 2.
thanks
-- PMM
Thanks, Peter! I'll be addressing the comments today and post a v2 with changes for the first 2.