From ce7f5b1c5027d73aa7c30820ef2b23ef4d72d20d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 16 Sep 2021 17:53:57 +0200 Subject: hvf: Introduce hvf_arch_init() callback We will need to install a migration helper for the ARM hvf backend. Let's introduce an arch callback for the overall hvf init chain to do so. Signed-off-by: Alexander Graf Reviewed-by: Peter Maydell Message-id: 20210916155404.86958-4-agraf@csgraf.de Signed-off-by: Peter Maydell --- include/sysemu/hvf_int.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h index 8b66a4e..0466106 100644 --- a/include/sysemu/hvf_int.h +++ b/include/sysemu/hvf_int.h @@ -48,6 +48,7 @@ struct hvf_vcpu_state { }; void assert_hvf_ok(hv_return_t ret); +int hvf_arch_init(void); int hvf_arch_init_vcpu(CPUState *cpu); void hvf_arch_vcpu_destroy(CPUState *cpu); int hvf_vcpu_exec(CPUState *); -- cgit v1.1 From a1477da3ddeb1b76adb71af7b5c46a18120dc952 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 16 Sep 2021 17:53:58 +0200 Subject: hvf: Add Apple Silicon support With Apple Silicon available to the masses, it's a good time to add support for driving its virtualization extensions from QEMU. This patch adds all necessary architecture specific code to get basic VMs working, including save/restore. Known limitations: - WFI handling is missing (follows in later patch) - No watchpoint/breakpoint support Signed-off-by: Alexander Graf Reviewed-by: Roman Bolshakov Reviewed-by: Sergio Lopez Reviewed-by: Peter Maydell Message-id: 20210916155404.86958-5-agraf@csgraf.de [PMM: added missing #include] Signed-off-by: Peter Maydell --- include/sysemu/hvf_int.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h index 0466106..7c245c7 100644 --- a/include/sysemu/hvf_int.h +++ b/include/sysemu/hvf_int.h @@ -11,7 +11,11 @@ #ifndef HVF_INT_H #define HVF_INT_H +#ifdef __aarch64__ +#include +#else #include +#endif /* hvf_slot flags */ #define HVF_SLOT_LOG (1 << 0) @@ -40,11 +44,14 @@ struct HVFState { int num_slots; hvf_vcpu_caps *hvf_caps; + uint64_t vtimer_offset; }; extern HVFState *hvf_state; struct hvf_vcpu_state { - int fd; + uint64_t fd; + void *exit; + bool vtimer_masked; }; void assert_hvf_ok(hv_return_t ret); @@ -55,5 +62,6 @@ int hvf_vcpu_exec(CPUState *); hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); int hvf_put_registers(CPUState *); int hvf_get_registers(CPUState *); +void hvf_kick_vcpu_thread(CPUState *cpu); #endif -- cgit v1.1 From 219c101fa7f9c528458cd6a491af371f01e20cba Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 16 Sep 2021 17:53:59 +0200 Subject: arm/hvf: Add a WFI handler Sleep on WFI until the VTIMER is due but allow ourselves to be woken up on IPI. In this implementation IPI is blocked on the CPU thread at startup and pselect() is used to atomically unblock the signal and begin sleeping. The signal is sent unconditionally so there's no need to worry about races between actually sleeping and the "we think we're sleeping" state. It may lead to an extra wakeup but that's better than missing it entirely. Signed-off-by: Peter Collingbourne Signed-off-by: Alexander Graf Acked-by: Roman Bolshakov Reviewed-by: Sergio Lopez Message-id: 20210916155404.86958-6-agraf@csgraf.de [agraf: Remove unused 'set' variable, always advance PC on WFX trap, support vm stop / continue operations and cntv offsets] Signed-off-by: Alexander Graf Acked-by: Roman Bolshakov Reviewed-by: Sergio Lopez Signed-off-by: Peter Maydell --- include/sysemu/hvf_int.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h index 7c245c7..6545f7c 100644 --- a/include/sysemu/hvf_int.h +++ b/include/sysemu/hvf_int.h @@ -52,6 +52,7 @@ struct hvf_vcpu_state { uint64_t fd; void *exit; bool vtimer_masked; + sigset_t unblock_ipi_mask; }; void assert_hvf_ok(hv_return_t ret); -- cgit v1.1