hvf: arm: Add support for GICv3
PATCH v2 1/1 hvf: arm: Add support for GICv3
We currently only support GICv2 emulation. To also support GICv3, we will need to pass a few system registers into their respective handler functions.
This patch adds support for HVF to call into the TCG callbacks for GICv3 system register handlers. This is safe because the GICv3 TCG code is generic as long as we limit ourselves to EL0 and EL1 - which are the only modes supported by HVF.
To make sure nobody trips over that, we also annotate callbacks that don't work in HVF mode, such as EL state change hooks.
With GICv3 support in place, we can run with more than 8 vCPUs.
---
v1 -> v2:
- assert when guest has EL2/EL3 and uses non-TCG GICv3
- use defines for sysreg masks
--- hw/intc/arm_gicv3_cpuif.c | 15 +++- target/arm/hvf/hvf.c | 151 ++++++++++++++++++++++++++++++++++++ target/arm/hvf/trace-events | 2 + 3 files changed, 167 insertions(+), 1 deletion(-)
hw/intc/arm_gicv3_cpuif.c +14 -1
@@ -21,6 +21,7 @@#include "hw/irq.h" #include "cpu.h" #include "target/arm/cpregs.h" +#include "sysemu/tcg.h" /* * Special case return value from hppvi_index(); must be larger than
@@ -2810,6 +2811,8 @@ void gicv3_init_cpuif(GICv3State *s)* which case we'd get the wrong value. * So instead we define the regs with no ri->opaque info, and * get back to the GICv3CPUState from the CPUARMState. +* +* These CP regs callbacks can be called from either TCG or HVF code. */ define_arm_cp_regs (cpu, gicv3_cpuif_reginfo);
@@ -2905,6 +2908,16 @@ void gicv3_init_cpuif(GICv3State *s)define_arm_cp_regs (cpu, gicv3_cpuif_ich_apxr23_reginfo); } } -arm_register_el_change_hook (cpu, gicv3_cpuif_el_change_hook, cs); +if (tcg_enabled ()) { +/* +* We can only trap EL changes with TCG. However the GIC interrupt +* state only changes on EL changes involving EL2 or EL3, so for +* the non-TCG case this is OK, as EL2 and EL3 can't exist. +*/ +arm_register_el_change_hook (cpu, gicv3_cpuif_el_change_hook, cs); + }else { +assert (!arm_feature (&cpu->env,ARM_FEATURE_EL2 )); +assert (!arm_feature (&cpu->env,ARM_FEATURE_EL3 )); + } } }
target/arm/hvf/hvf.c +151 -0
181 lines not on this page · raw message
target/arm/hvf/trace-events +2 -0
@@ -9,3 +9,5 @@ hvf_unknown_hvc(uint64_t x0) "unknown HVC! 0x%016"PRIx64 hvf_unknown_smc(uint64_t x0) "unknown SMC! 0x%016"PRIx64 hvf_exit(uint64_t syndrome, uint32_t ec, uint64_t pc) "exit: 0x%"PRIx64" [ec=0x%x pc=0x%"PRIx64"]" hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=0x%016"PRIx64" x1=0x%016"PRIx64" x2=0x%016"PRIx64" x3=0x%016"PRIx64" cpu=0x%x" +hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]" +hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]"
Signature · 1 line
2.37.1 (Apple Git-137.1)
Peter Maydell
AppliedQuoted 9 lines · Alexander Graf
We currently only support GICv2 emulation. To also support GICv3, we will need to pass a few system registers into their respective handler functions.
This patch adds support for HVF to call into the TCG callbacks for GICv3 system register handlers. This is safe because the GICv3 TCG code is generic as long as we limit ourselves to EL0 and EL1 - which are the only modes supported by HVF.
Quoted 8 lines
To make sure nobody trips over that, we also annotate callbacks that don't work in HVF mode, such as EL state change hooks.
With GICv3 support in place, we can run with more than 8 vCPUs.
Signed-off-by Alexander Graf <[email protected]>---
Applied to target-arm.next, thanks.
-- PMM
Quoted 16 lines · Peter Maydell
Quoted 14 lines · Alexander Graf
We currently only support GICv2 emulation. To also support GICv3, we will need to pass a few system registers into their respective handler functions.
This patch adds support for HVF to call into the TCG callbacks for GICv3 system register handlers. This is safe because the GICv3 TCG code is generic as long as we limit ourselves to EL0 and EL1 - which are the only modes supported by HVF.
To make sure nobody trips over that, we also annotate callbacks that don't work in HVF mode, such as EL state change hooks.
With GICv3 support in place, we can run with more than 8 vCPUs.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Alexander Graf <[email protected]>---
Applied to target-arm.next, thanks.
This one *also* fails 'make check'. Please can you test your patches before sending them?
The fix is not difficult (another missing qtest_enabled() check), so I've squashed it in.
thanks
-- PMM
Hey Peter,
Quoted 20 lines · Peter Maydell
Quoted 19 lines · Peter Maydell
Quoted 16 lines · Alexander Graf
We currently only support GICv2 emulation. To also support GICv3, we will need to pass a few system registers into their respective handler functions.
This patch adds support for HVF to call into the TCG callbacks for GICv3 system register handlers. This is safe because the GICv3 TCG code is generic as long as we limit ourselves to EL0 and EL1 - which are the only modes supported by HVF.
To make sure nobody trips over that, we also annotate callbacks that don't work in HVF mode, such as EL state change hooks.
With GICv3 support in place, we can run with more than 8 vCPUs.
Signed-off-by Alexander Graf <[email protected]>---
Quoted 6 lines
Quoted 1 line
Applied to target-arm.next, thanks.
This one *also* fails 'make check'. Please can you test your patches before sending them?
The fix is not difficult (another missing
qtest_enabled()check), so I've squashed it in.
Sorry for the mess :(. I usually do test TCG and HVF when submitting these patches with various VMs, but keep forgetting about "make check". I'll try hard to remember next time.
Thanks,
Alex