hvf: Implement Apple Silicon Support
v5 cover hvf: Implement Apple Silicon Support
Now that Apple Silicon is widely available, people are obviously excited to try and run virtualized workloads on them, such as Linux and Windows.
This patch set implements a fully functional version to get the ball going on that. With this applied, I can successfully run both Linux and Windows as guests. I am not aware of any limitations specific to Hypervisor.framework apart from:
- Live migration / savevm
- gdbstub debugging (SP register)
Enjoy!
Alex
v1 -> v2:
- New patch: hvf: Actually set SIG_IPI mask
- New patch: hvf: Introduce hvf vcpu struct
- New patch: hvf: arm: Mark CPU as dirty on reset
- Removed patch: hw/arm/virt: Disable highmem when on hypervisor.framework
- Removed patch: arm: Synchronize CPU on PSCI on
- Fix build on 32bit arm
- Merge vcpu kick function patch into ARM enablement
- Implement WFI handling (allows vCPUs to sleep)
- Synchronize system registers (fixes OVMF crashes and reboot)
- Don't always call cpu_synchronize_state()
- Use more fine grained iothread locking
- Populate aa64mmfr0 from hardware
- Make safe to ctrl-C entitlement application
v2 -> v3:
- Removed patch: hvf: Actually set SIG_IPI mask
- New patch: hvf: arm: Add support for GICv3
- New patch: hvf: arm: Implement -cpu host
- Advance PC on SMC
- Use cp list interface for sysreg syncs
- Do not set current_cpu
- Fix sysreg isread mask
- Move sysreg handling to functions
- Remove WFI logic again
- Revert to global iothread locking
v3 -> v4:
- Removed patch: hvf: arm: Mark CPU as dirty on reset
- New patch: hvf: Simplify post reset/init/loadvm hooks
- Remove i386-softmmu target (meson.build for hvf target)
- Combine both if statements (PSCI)
- Use hv.h instead of Hypervisor.h for 10.15 compat
- Remove manual inclusion of Hypervisor.h in common .c files
- No longer include Hypervisor.h in arm hvf .c files
- Remove unused exe_full variable
- Reuse exe_name variable
v4 -> v5:
- Use g_free() on destroy
Alexander Graf (10):
hvf: Add hypervisor entitlement to output binaries
hvf: x86: Remove unused definitions
hvf: Move common code out
hvf: Introduce hvf vcpu struct
arm: Set PSCI to 0.2 for HVF
hvf: Simplify post reset/init/loadvm hooks
hvf: Add Apple Silicon support
arm: Add Hypervisor.framework build target
hvf: arm: Add support for GICv3
hvf: arm: Implement -cpu host
Peter Collingbourne (1):
arm/hvf: Add a WFI handler
MAINTAINERS | 14 +- accel/hvf/entitlements.plist | 8 + accel/hvf/hvf-all.c | 54 +++ accel/hvf/hvf-cpus.c | 466 +++++++++++++++++++ accel/hvf/meson.build | 7 + accel/meson.build | 1 + include/hw/core/cpu.h | 3 +- include/sysemu/hvf.h | 2 + include/sysemu/hvf_int.h | 66 +++ meson.build | 40 +- scripts/entitlement.sh | 13 + target/arm/cpu.c | 13 +- target/arm/cpu.h | 2 + target/arm/hvf/hvf.c | 856 +++++++++++++++++++++++++++++++++++ target/arm/hvf/meson.build | 3 + target/arm/kvm_arm.h | 2 - target/arm/meson.build | 2 + target/i386/hvf/hvf-cpus.c | 131 ------ target/i386/hvf/hvf-cpus.h | 25 - target/i386/hvf/hvf-i386.h | 49 +- target/i386/hvf/hvf.c | 462 +++---------------- target/i386/hvf/meson.build | 1 - target/i386/hvf/vmx.h | 24 +- target/i386/hvf/x86.c | 28 +- target/i386/hvf/x86_descr.c | 26 +- target/i386/hvf/x86_emu.c | 62 +-- target/i386/hvf/x86_mmu.c | 4 +- target/i386/hvf/x86_task.c | 12 +- target/i386/hvf/x86hvf.c | 224 ++++----- target/i386/hvf/x86hvf.h | 2 - 30 files changed, 1786 insertions(+), 816 deletions(-) create mode 100644 accel/hvf/entitlements.plist create mode 100644 accel/hvf/hvf-all.c create mode 100644 accel/hvf/hvf-cpus.c create mode 100644 accel/hvf/meson.build create mode 100644 include/sysemu/hvf_int.h create mode 100755 scripts/entitlement.sh create mode 100644 target/arm/hvf/hvf.c create mode 100644 target/arm/hvf/meson.build delete mode 100644 target/i386/hvf/hvf-cpus.c delete mode 100644 target/i386/hvf/hvf-cpus.h
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 1/11 hvf: Add hypervisor entitlement to output binaries
In macOS 11, QEMU only gets access to Hypervisor.framework if it has the respective entitlement. Add an entitlement template and automatically self sign and apply the entitlement in the build.
---
v1 -> v2:
- Make safe to ctrl-C
v3 -> v4:
- Remove unused exe_full variable
- Reuse exe_name variable
--- accel/hvf/entitlements.plist | 8 ++++++++ meson.build | 29 +++++++++++++++++++++++++---- scripts/entitlement.sh | 13 +++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 accel/hvf/entitlements.plist create mode 100755 scripts/entitlement.sh
accel/hvf/entitlements.plist new file +8 -0
@@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.security.hypervisor</key> + <true/> +</dict> +</plist>
meson.build +25 -4
@@ -1849,9 +1849,14 @@ foreach target : target_dirs }] endif foreach exe: execs - emulators += {exe['name']: - executable(exe['name'], exe['sources'], - install: true, + exe_name = exe['name'] + exe_sign = 'CONFIG_HVF' in config_target + if exe_sign + exe_name += '-unsigned' + endif + + emulator = executable(exe_name, exe['sources'], + install: not exe_sign, c_args: c_args, dependencies: arch_deps + deps + exe['dependencies'], objects: lib.extract_all_objects(recursive: true),
@@ -1859,7 +1864,23 @@ foreach target : target_dirs link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []), link_args: link_args, gui_app: exe['gui']) - } + + if exe_sign + emulators += {exe['name'] : custom_target(exe['name'], + install: true, + install_dir: get_option('bindir'), + depends: emulator, + output: exe['name'], + command: [ + meson.current_source_dir() / 'scripts/entitlement.sh', + meson.current_build_dir() / exe_name, + meson.current_build_dir() / exe['name'], + meson.current_source_dir() / 'accel/hvf/entitlements.plist' + ]) + } + else + emulators += {exe['name']: emulator} + endif if 'CONFIG_TRACE_SYSTEMTAP' in config_host foreach stp: [
scripts/entitlement.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh -e +# +# Helper script for the build process to apply entitlements + +SRC="$1" +DST="$2" +ENTITLEMENT="$3" + +trap 'rm "$DST.tmp"' exit +cp -af "$SRC" "$DST.tmp" +codesign --entitlements "$ENTITLEMENT" --force -s - "$DST.tmp" +mv "$DST.tmp" "$DST" +trap '' exit
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 2/11 hvf: x86: Remove unused definitions
In reply to Alexander GrafThe hvf i386 has a few struct and cpp definitions that are never used. Remove them.
--- target/i386/hvf/hvf-i386.h | 16 ---------------- 1 file changed, 16 deletions(-)
target/i386/hvf/hvf-i386.h +0 -16
@@ -21,21 +21,6 @@#include "cpu.h" #include "x86.h" -#define HVF_MAX_VCPU 0x10 - -extern struct hvf_state hvf_global; - -struct hvf_vm { -int id; -struct hvf_vcpu_state *vcpus[HVF_MAX_VCPU ]; -}; - -struct hvf_state { -uint32_t version; -struct hvf_vm *vm; -uint64_t mem_quota; -}; -/* hvf_slot flags */ #define HVF_SLOT_LOG (1 << 0)
@@ -75,7 +60,6 @@ hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);/* Host specific functions */ int hvf_inject_interrupt (CPUArchState *env,int vector); -int hvf_vcpu_run (struct hvf_vcpu_state *vcpu);#endif #endif
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 3/11 hvf: Move common code out
In reply to Alexander GrafUntil now, Hypervisor.framework has only been available on x86_64 systems. With Apple Silicon shipping now, it extends its reach to aarch64. To prepare for support for multiple architectures, let's move common code out into its own accel directory.
---
v3 -> v4:
- Use hv.h instead of Hypervisor.h for 10.15 compat
- Remove manual inclusion of Hypervisor.h in common .c files
--- MAINTAINERS | 9 +- accel/hvf/hvf-all.c | 54 +++++ accel/hvf/hvf-cpus.c | 462 ++++++++++++++++++++++++++++++++++++ accel/hvf/meson.build | 7 + accel/meson.build | 1 + include/sysemu/hvf_int.h | 54 +++++ target/i386/hvf/hvf-cpus.c | 131 ---------- target/i386/hvf/hvf-cpus.h | 25 -- target/i386/hvf/hvf-i386.h | 33 +-- target/i386/hvf/hvf.c | 360 +--------------------------- target/i386/hvf/meson.build | 1 - target/i386/hvf/x86hvf.c | 11 +- target/i386/hvf/x86hvf.h | 2 - 13 files changed, 596 insertions(+), 554 deletions(-) create mode 100644 accel/hvf/hvf-all.c create mode 100644 accel/hvf/hvf-cpus.c create mode 100644 accel/hvf/meson.build create mode 100644 include/sysemu/hvf_int.h delete mode 100644 target/i386/hvf/hvf-cpus.c delete mode 100644 target/i386/hvf/hvf-cpus.h
MAINTAINERS +8 -1
@@ -444,9 +444,16 @@ M: Cameron Esfahani <[email protected]> M: Roman Bolshakov <[email protected]> W: https://wiki.qemu.org/Features/HVF S: Maintained -F: accel/stubs/hvf-stub.c F: target/i386/hvf/ + +HVF +M: Cameron Esfahani <[email protected]> +M: Roman Bolshakov <[email protected]> +W: https://wiki.qemu.org/Features/HVF +S: Maintained +F: accel/hvf/ F: include/sysemu/hvf.h +F: include/sysemu/hvf_int.h WHPX CPUs M: Sunil Muthuswamy <[email protected]>
accel/hvf/hvf-all.c new file +54 -0
54 lines not on this page · raw message
accel/hvf/hvf-cpus.c new file +462 -0
462 lines not on this page · raw message
accel/hvf/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +hvf_ss = ss.source_set() +hvf_ss.add(files( + 'hvf-all.c', + 'hvf-cpus.c', +)) + +specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss)
accel/meson.build +1 -0
@@ -1,5 +1,6 @@ softmmu_ss.add(files('accel.c')) +subdir('hvf') subdir('qtest') subdir('kvm') subdir('tcg')
include/sysemu/hvf_int.h new file +54 -0
54 lines not on this page · raw message
target/i386/hvf/hvf-cpus.c deleted +0 -131
131 lines not on this page · raw message
target/i386/hvf/hvf-cpus.h deleted +0 -25
@@ -1,25 +0,0 @@ -/* -* Accelerator CPUS Interface -* -* Copyright 2020 SUSE LLC -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef HVF_CPUS_H -#define HVF_CPUS_H - -#include "sysemu/cpus.h" - -extern const CpusAccel hvf_cpus; - -int hvf_init_vcpu (CPUState *); -int hvf_vcpu_exec (CPUState *); -void hvf_cpu_synchronize_state (CPUState *); -void hvf_cpu_synchronize_post_reset (CPUState *); -void hvf_cpu_synchronize_post_init (CPUState *); -void hvf_cpu_synchronize_pre_loadvm (CPUState *); -void hvf_vcpu_destroy (CPUState *); - -#endif /* HVF_CPUS_H */
target/i386/hvf/hvf-i386.h +1 -32
@@ -18,42 +18,11 @@#include "sysemu/accel.h" #include "sysemu/hvf.h" +#include "sysemu/hvf_int.h" #include "cpu.h" #include "x86.h" -/* hvf_slot flags */ -#define HVF_SLOT_LOG (1 << 0) - -typedef struct hvf_slot { -uint64_t start; -uint64_t size; -uint8_t *mem; -int slot_id; -uint32_t flags; -MemoryRegion *region; -}hvf_slot ; - -typedef struct hvf_vcpu_caps { -uint64_t vmx_cap_pinbased; -uint64_t vmx_cap_procbased; -uint64_t vmx_cap_procbased2; -uint64_t vmx_cap_entry; -uint64_t vmx_cap_exit; -uint64_t vmx_cap_preemption_timer; -}hvf_vcpu_caps ; - -struct HVFState { -AccelState parent; -hvf_slot slots[32 ]; -int num_slots; - -hvf_vcpu_caps *hvf_caps; -}; -extern HVFState *hvf_state; - -void hvf_set_phys_mem (MemoryRegionSection *,bool );void hvf_handle_io (CPUArchState *,uint16_t ,void *,int ,int ,int ); -hvf_slot *hvf_find_overlap_slot (uint64_t ,uint64_t );#ifdef NEED_CPU_H /* Functions exported to host specific mode */
target/i386/hvf/hvf.c +3 -357
404 lines not on this page · raw message
target/i386/hvf/meson.build +0 -1
@@ -1,6 +1,5 @@ i386_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( 'hvf.c', - 'hvf-cpus.c', 'x86.c', 'x86_cpuid.c', 'x86_decode.c',
target/i386/hvf/x86hvf.c +6 -5
@@ -20,6 +20,9 @@#include "qemu/osdep.h" #include "qemu-common.h" +#include "sysemu/hvf.h" +#include "sysemu/hvf_int.h" +#include "sysemu/hw_accel.h" #include "x86hvf.h" #include "vmx.h" #include "vmcs.h"
@@ -32,8 +35,6 @@#include <Hypervisor/hv.h> #include <Hypervisor/hv_vmx.h> -#include "hvf-cpus.h" -void hvf_set_segment (struct CPUState *cpu,struct vmx_segment *vmx_seg,SegmentCache *qseg,bool is_tr) {
@@ -437,7 +438,7 @@ int hvf_process_events(CPUState *cpu_state) env->eflags =rreg (cpu_state->hvf_fd,HV_X86_RFLAGS );if (cpu_state->interrupt_request &CPU_INTERRUPT_INIT ) { -hvf_cpu_synchronize_state (cpu_state); +cpu_synchronize_state (cpu_state);do_cpu_init (cpu); }
@@ -451,12 +452,12 @@ int hvf_process_events(CPUState *cpu_state) cpu_state->halted =0 ; }if (cpu_state->interrupt_request &CPU_INTERRUPT_SIPI ) { -hvf_cpu_synchronize_state (cpu_state); +cpu_synchronize_state (cpu_state);do_cpu_sipi (cpu); }if (cpu_state->interrupt_request &CPU_INTERRUPT_TPR ) { cpu_state->interrupt_request &= ~CPU_INTERRUPT_TPR ; -hvf_cpu_synchronize_state (cpu_state); +cpu_synchronize_state (cpu_state);apic_handle_tpr_access_report (cpu->apic_state, env->eip, env->tpr_access_type); }
target/i386/hvf/x86hvf.h +0 -2
@@ -21,8 +21,6 @@#include "x86_descr.h" int hvf_process_events (CPUState *); -int hvf_put_registers (CPUState *); -int hvf_get_registers (CPUState *);bool hvf_inject_interrupts (CPUState *);void hvf_set_segment (struct CPUState *cpu,struct vmx_segment *vmx_seg,SegmentCache *qseg,bool is_tr);
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 4/11 hvf: Introduce hvf vcpu struct
In reply to Alexander GrafWe will need more than a single field for hvf going forward. To keep the global vcpu struct uncluttered, let's allocate a special hvf vcpu struct, similar to how hax does it.
---
v4 -> v5:
- Use g_free() on destroy
--- accel/hvf/hvf-cpus.c | 8 +- include/hw/core/cpu.h | 3 +- include/sysemu/hvf_int.h | 4 + target/i386/hvf/hvf.c | 102 +++++++++--------- target/i386/hvf/vmx.h | 24 +++-- target/i386/hvf/x86.c | 28 ++--- target/i386/hvf/x86_descr.c | 26 ++--- target/i386/hvf/x86_emu.c | 62 +++++------ target/i386/hvf/x86_mmu.c | 4 +- target/i386/hvf/x86_task.c | 12 +-- target/i386/hvf/x86hvf.c | 210 ++++++++++++++++++------------------ 11 files changed, 247 insertions(+), 236 deletions(-)
accel/hvf/hvf-cpus.c +6 -2
@@ -312,10 +312,12 @@ static void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu)static void hvf_vcpu_destroy (CPUState *cpu) { -hv_return_t ret =hv_vcpu_destroy (cpu->hvf_fd); +hv_return_t ret =hv_vcpu_destroy (cpu->hvf->fd);assert_hvf_ok (ret);hvf_arch_vcpu_destroy (cpu); +g_free (cpu->hvf); + cpu->hvf =NULL ; }static void dummy_signal (int sig)
@@ -326,6 +328,8 @@ static int hvf_init_vcpu(CPUState *cpu) {int r; + cpu->hvf =g_malloc0 (sizeof (*cpu->hvf)); +/* init cpu signals */ sigset_t set;struct sigaction sigact;
@@ -337,7 +341,7 @@ static int hvf_init_vcpu(CPUState *cpu)pthread_sigmask (SIG_BLOCK ,NULL , &set);sigdelset (&set,SIG_IPI ); - r =hv_vcpu_create ((hv_vcpuid_t *)&cpu->hvf_fd,HV_VCPU_DEFAULT ); + r =hv_vcpu_create ((hv_vcpuid_t *)&cpu->hvf->fd,HV_VCPU_DEFAULT ); cpu->vcpu_dirty =1 ;assert_hvf_ok (r);
include/hw/core/cpu.h +2 -1
@@ -280,6 +280,7 @@ struct KVMState;struct kvm_run ;struct hax_vcpu_state ; +struct hvf_vcpu_state ;#define TB_JMP_CACHE_BITS 12#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
@@ -463,7 +464,7 @@ struct CPUState {struct hax_vcpu_state *hax_vcpu; -int hvf_fd; +struct hvf_vcpu_state *hvf;/* track IOMMUs whose translations we've cached in the TCG TLB */ GArray *iommu_notifiers;
include/sysemu/hvf_int.h +4 -0
@@ -43,6 +43,10 @@ struct HVFState { };extern HVFState *hvf_state; +struct hvf_vcpu_state { +int fd; +}; +void assert_hvf_ok (hv_return_t ret);int hvf_get_registers (CPUState *cpu);int hvf_put_registers (CPUState *cpu);
target/i386/hvf/hvf.c +51 -51
221 lines not on this page · raw message
target/i386/hvf/vmx.h +13 -11
@@ -30,6 +30,8 @@#include "vmcs.h" #include "cpu.h" #include "x86.h" +#include "sysemu/hvf.h" +#include "sysemu/hvf_int.h" #include "exec/address-spaces.h"
@@ -179,15 +181,15 @@ static inline void macvm_set_rip(CPUState *cpu, uint64_t rip)uint64_t val;/* BUG, should take considering overlap.. */ -wreg (cpu->hvf_fd,HV_X86_RIP , rip); +wreg (cpu->hvf->fd,HV_X86_RIP , rip); env->eip = rip;/* after moving forward in rip, we need to clean INTERRUPTABILITY */ - val =rvmcs (cpu->hvf_fd,VMCS_GUEST_INTERRUPTIBILITY ); + val =rvmcs (cpu->hvf->fd,VMCS_GUEST_INTERRUPTIBILITY );if (val & (VMCS_INTERRUPTIBILITY_STI_BLOCKING |VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING )) { env->hflags &= ~HF_INHIBIT_IRQ_MASK ; -wvmcs (cpu->hvf_fd,VMCS_GUEST_INTERRUPTIBILITY , +wvmcs (cpu->hvf->fd,VMCS_GUEST_INTERRUPTIBILITY , val & ~(VMCS_INTERRUPTIBILITY_STI_BLOCKING |VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING )); }
@@ -199,9 +201,9 @@ static inline void vmx_clear_nmi_blocking(CPUState *cpu)CPUX86State *env = &x86_cpu->env; env->hflags2 &= ~HF2_NMI_MASK ; -uint32_t gi = (uint32_t )rvmcs (cpu->hvf_fd,VMCS_GUEST_INTERRUPTIBILITY ); +uint32_t gi = (uint32_t )rvmcs (cpu->hvf->fd,VMCS_GUEST_INTERRUPTIBILITY ); gi &= ~VMCS_INTERRUPTIBILITY_NMI_BLOCKING ; -wvmcs (cpu->hvf_fd,VMCS_GUEST_INTERRUPTIBILITY , gi); +wvmcs (cpu->hvf->fd,VMCS_GUEST_INTERRUPTIBILITY , gi); }static inline void vmx_set_nmi_blocking (CPUState *cpu)
@@ -210,16 +212,16 @@ static inline void vmx_set_nmi_blocking(CPUState *cpu)CPUX86State *env = &x86_cpu->env; env->hflags2 |=HF2_NMI_MASK ; -uint32_t gi = (uint32_t )rvmcs (cpu->hvf_fd,VMCS_GUEST_INTERRUPTIBILITY ); +uint32_t gi = (uint32_t )rvmcs (cpu->hvf->fd,VMCS_GUEST_INTERRUPTIBILITY ); gi |=VMCS_INTERRUPTIBILITY_NMI_BLOCKING ; -wvmcs (cpu->hvf_fd,VMCS_GUEST_INTERRUPTIBILITY , gi); +wvmcs (cpu->hvf->fd,VMCS_GUEST_INTERRUPTIBILITY , gi); }static inline void vmx_set_nmi_window_exiting (CPUState *cpu) {uint64_t val; - val =rvmcs (cpu->hvf_fd,VMCS_PRI_PROC_BASED_CTLS ); -wvmcs (cpu->hvf_fd,VMCS_PRI_PROC_BASED_CTLS , val | + val =rvmcs (cpu->hvf->fd,VMCS_PRI_PROC_BASED_CTLS ); +wvmcs (cpu->hvf->fd,VMCS_PRI_PROC_BASED_CTLS , val |VMCS_PRI_PROC_BASED_CTLS_NMI_WINDOW_EXITING ); }
@@ -228,8 +230,8 @@ static inline void vmx_clear_nmi_window_exiting(CPUState *cpu) {uint64_t val; - val =rvmcs (cpu->hvf_fd,VMCS_PRI_PROC_BASED_CTLS ); -wvmcs (cpu->hvf_fd,VMCS_PRI_PROC_BASED_CTLS , val & + val =rvmcs (cpu->hvf->fd,VMCS_PRI_PROC_BASED_CTLS ); +wvmcs (cpu->hvf->fd,VMCS_PRI_PROC_BASED_CTLS , val & ~VMCS_PRI_PROC_BASED_CTLS_NMI_WINDOW_EXITING ); }
target/i386/hvf/x86.c +14 -14
@@ -62,11 +62,11 @@ bool x86_read_segment_descriptor(struct CPUState *cpu, }if (GDT_SEL == sel.ti) { - base =rvmcs (cpu->hvf_fd,VMCS_GUEST_GDTR_BASE ); - limit =rvmcs (cpu->hvf_fd,VMCS_GUEST_GDTR_LIMIT ); + base =rvmcs (cpu->hvf->fd,VMCS_GUEST_GDTR_BASE ); + limit =rvmcs (cpu->hvf->fd,VMCS_GUEST_GDTR_LIMIT ); }else { - base =rvmcs (cpu->hvf_fd,VMCS_GUEST_LDTR_BASE ); - limit =rvmcs (cpu->hvf_fd,VMCS_GUEST_LDTR_LIMIT ); + base =rvmcs (cpu->hvf->fd,VMCS_GUEST_LDTR_BASE ); + limit =rvmcs (cpu->hvf->fd,VMCS_GUEST_LDTR_LIMIT ); }if (sel.index *8 >= limit) {
@@ -85,11 +85,11 @@ bool x86_write_segment_descriptor(struct CPUState *cpu,uint32_t limit;if (GDT_SEL == sel.ti) { - base =rvmcs (cpu->hvf_fd,VMCS_GUEST_GDTR_BASE ); - limit =rvmcs (cpu->hvf_fd,VMCS_GUEST_GDTR_LIMIT ); + base =rvmcs (cpu->hvf->fd,VMCS_GUEST_GDTR_BASE ); + limit =rvmcs (cpu->hvf->fd,VMCS_GUEST_GDTR_LIMIT ); }else { - base =rvmcs (cpu->hvf_fd,VMCS_GUEST_LDTR_BASE ); - limit =rvmcs (cpu->hvf_fd,VMCS_GUEST_LDTR_LIMIT ); + base =rvmcs (cpu->hvf->fd,VMCS_GUEST_LDTR_BASE ); + limit =rvmcs (cpu->hvf->fd,VMCS_GUEST_LDTR_LIMIT ); }if (sel.index *8 >= limit) {
@@ -103,8 +103,8 @@ bool x86_write_segment_descriptor(struct CPUState *cpu,bool x86_read_call_gate (struct CPUState *cpu,struct x86_call_gate *idt_desc,int gate) { -target_ulong base =rvmcs (cpu->hvf_fd,VMCS_GUEST_IDTR_BASE ); -uint32_t limit =rvmcs (cpu->hvf_fd,VMCS_GUEST_IDTR_LIMIT ); +target_ulong base =rvmcs (cpu->hvf->fd,VMCS_GUEST_IDTR_BASE ); +uint32_t limit =rvmcs (cpu->hvf->fd,VMCS_GUEST_IDTR_LIMIT );memset (idt_desc,0 ,sizeof (*idt_desc));if (gate *8 >= limit) {
@@ -118,7 +118,7 @@ bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc,bool x86_is_protected (struct CPUState *cpu) { -uint64_t cr0 =rvmcs (cpu->hvf_fd,VMCS_GUEST_CR0 ); +uint64_t cr0 =rvmcs (cpu->hvf->fd,VMCS_GUEST_CR0 );return cr0 &CR0_PE ; }
@@ -136,7 +136,7 @@ bool x86_is_v8086(struct CPUState *cpu)bool x86_is_long_mode (struct CPUState *cpu) { -return rvmcs (cpu->hvf_fd,VMCS_GUEST_IA32_EFER ) &MSR_EFER_LMA ; +return rvmcs (cpu->hvf->fd,VMCS_GUEST_IA32_EFER ) &MSR_EFER_LMA ; }bool x86_is_long64_mode (struct CPUState *cpu)
@@ -149,13 +149,13 @@ bool x86_is_long64_mode(struct CPUState *cpu)bool x86_is_paging_mode (struct CPUState *cpu) { -uint64_t cr0 =rvmcs (cpu->hvf_fd,VMCS_GUEST_CR0 ); +uint64_t cr0 =rvmcs (cpu->hvf->fd,VMCS_GUEST_CR0 );return cr0 &CR0_PG ; }bool x86_is_pae_enabled (struct CPUState *cpu) { -uint64_t cr4 =rvmcs (cpu->hvf_fd,VMCS_GUEST_CR4 ); +uint64_t cr4 =rvmcs (cpu->hvf->fd,VMCS_GUEST_CR4 );return cr4 &CR4_PAE ; }
target/i386/hvf/x86_descr.c +13 -13
@@ -48,47 +48,47 @@ static const struct vmx_segment_field {uint32_t vmx_read_segment_limit (CPUState *cpu,X86Seg seg) { -return (uint32_t )rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].limit); +return (uint32_t )rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].limit); }uint32_t vmx_read_segment_ar (CPUState *cpu,X86Seg seg) { -return (uint32_t )rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].ar_bytes); +return (uint32_t )rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].ar_bytes); }uint64_t vmx_read_segment_base (CPUState *cpu,X86Seg seg) { -return rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].base); +return rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].base); }x68_segment_selector vmx_read_segment_selector (CPUState *cpu,X86Seg seg) {x68_segment_selector sel; - sel.sel =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].selector); + sel.sel =rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].selector);return sel; }void vmx_write_segment_selector (struct CPUState *cpu,x68_segment_selector selector,X86Seg seg) { -wvmcs (cpu->hvf_fd, vmx_segment_fields[seg].selector, selector.sel); +wvmcs (cpu->hvf->fd, vmx_segment_fields[seg].selector, selector.sel); }void vmx_read_segment_descriptor (struct CPUState *cpu,struct vmx_segment *desc,X86Seg seg) { - desc->sel =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].selector); - desc->base =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].base); - desc->limit =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].limit); - desc->ar =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].ar_bytes); + desc->sel =rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].selector); + desc->base =rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].base); + desc->limit =rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].limit); + desc->ar =rvmcs (cpu->hvf->fd, vmx_segment_fields[seg].ar_bytes); }void vmx_write_segment_descriptor (CPUState *cpu,struct vmx_segment *desc,X86Seg seg) {const struct vmx_segment_field *sf = &vmx_segment_fields[seg]; -wvmcs (cpu->hvf_fd, sf->base, desc->base); -wvmcs (cpu->hvf_fd, sf->limit, desc->limit); -wvmcs (cpu->hvf_fd, sf->selector, desc->sel); -wvmcs (cpu->hvf_fd, sf->ar_bytes, desc->ar); +wvmcs (cpu->hvf->fd, sf->base, desc->base); +wvmcs (cpu->hvf->fd, sf->limit, desc->limit); +wvmcs (cpu->hvf->fd, sf->selector, desc->sel); +wvmcs (cpu->hvf->fd, sf->ar_bytes, desc->ar); }void x86_segment_descriptor_to_vmx (struct CPUState *cpu,x68_segment_selector selector,struct x86_segment_descriptor *desc,struct vmx_segment *vmx_desc)
target/i386/hvf/x86_emu.c +31 -31
117 lines not on this page · raw message
target/i386/hvf/x86_mmu.c +2 -2
@@ -128,7 +128,7 @@ static bool test_pt_entry(struct CPUState *cpu, struct gpt_translation *pt, pt->err_code |=MMU_PAGE_PT ; } -uint32_t cr0 =rvmcs (cpu->hvf_fd,VMCS_GUEST_CR0 ); +uint32_t cr0 =rvmcs (cpu->hvf->fd,VMCS_GUEST_CR0 );/* check protection */ if (cr0 &CR0_WP ) {if (pt->write_access && !pte_write_access (pte)) {
@@ -173,7 +173,7 @@ static bool walk_gpt(struct CPUState *cpu, target_ulong addr, int err_code, {int top_level, level;bool is_large = false; -target_ulong cr3 =rvmcs (cpu->hvf_fd,VMCS_GUEST_CR3 ); +target_ulong cr3 =rvmcs (cpu->hvf->fd,VMCS_GUEST_CR3 );uint64_t page_mask = pae ?PAE_PTE_PAGE_MASK :LEGACY_PTE_PAGE_MASK ;memset (pt,0 ,sizeof (*pt));
target/i386/hvf/x86_task.c +6 -6
@@ -62,7 +62,7 @@ static void load_state_from_tss32(CPUState *cpu, struct x86_tss_segment32 *tss)X86CPU *x86_cpu =X86_CPU (cpu);CPUX86State *env = &x86_cpu->env; -wvmcs (cpu->hvf_fd,VMCS_GUEST_CR3 , tss->cr3); +wvmcs (cpu->hvf->fd,VMCS_GUEST_CR3 , tss->cr3); env->eip = tss->eip; env->eflags = tss->eflags |2 ;
@@ -111,11 +111,11 @@ static int task_switch_32(CPUState *cpu, x68_segment_selector tss_sel, x68_segmevoid vmx_handle_task_switch (CPUState *cpu,x68_segment_selector tss_sel,int reason,bool gate_valid,uint8_t gate,uint64_t gate_type) { -uint64_t rip =rreg (cpu->hvf_fd,HV_X86_RIP ); +uint64_t rip =rreg (cpu->hvf->fd,HV_X86_RIP );if (!gate_valid || (gate_type !=VMCS_INTR_T_HWEXCEPTION && gate_type !=VMCS_INTR_T_HWINTR && gate_type !=VMCS_INTR_T_NMI )) { -int ins_len =rvmcs (cpu->hvf_fd,VMCS_EXIT_INSTRUCTION_LENGTH ); +int ins_len =rvmcs (cpu->hvf->fd,VMCS_EXIT_INSTRUCTION_LENGTH );macvm_set_rip (cpu, rip + ins_len);return ; }
@@ -174,12 +174,12 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea//ret = task_switch_16(cpu, tss_sel, old_tss_sel, old_tss_base, &next_tss_desc); VM_PANIC ("task_switch_16" ); -macvm_set_cr0 (cpu->hvf_fd,rvmcs (cpu->hvf_fd,VMCS_GUEST_CR0 ) |CR0_TS ); +macvm_set_cr0 (cpu->hvf->fd,rvmcs (cpu->hvf->fd,VMCS_GUEST_CR0 ) |CR0_TS );x86_segment_descriptor_to_vmx (cpu, tss_sel, &next_tss_desc, &vmx_seg);vmx_write_segment_descriptor (cpu, &vmx_seg,R_TR );store_regs (cpu); -hv_vcpu_invalidate_tlb (cpu->hvf_fd); -hv_vcpu_flush (cpu->hvf_fd); +hv_vcpu_invalidate_tlb (cpu->hvf->fd); +hv_vcpu_flush (cpu->hvf->fd); }
target/i386/hvf/x86hvf.c +105 -105
354 lines not on this page · raw message
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 5/11 arm: Set PSCI to 0.2 for HVF
In reply to Alexander GrafIn Hypervisor.framework, we just pass PSCI calls straight on to the QEMU emulation of it. That means, if TCG is compatible with PSCI 0.2, so are we. Let's transpose that fact in code too.
---
v3 -> v4:
- Combine both if statements
--- target/arm/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/cpu.c +2 -2
@@ -1062,8 +1062,8 @@ static void arm_cpu_initfn(Object *obj) cpu->psci_version =1 ;/* By default assume PSCI v0.1 */ cpu->kvm_target =QEMU_KVM_ARM_TARGET_NONE ; -if (tcg_enabled ()) { - cpu->psci_version =2 ;/* TCG implements PSCI 0.2 */ +if (tcg_enabled () ||hvf_enabled ()) { + cpu->psci_version =2 ;/* TCG and HVF implement PSCI 0.2 */ } }
Signature · 1 line
2.24.3 (Apple Git-128)
Re: [PATCH v5 05/11] arm: Set PSCI to 0.2 for HVF
Quoted 6 lines · Alexander Graf
In Hypervisor.framework, we just pass PSCI calls straight on to the QEMU emulation of it. That means, if TCG is compatible with PSCI 0.2, so are we. Let's transpose that fact in code too.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Roman Bolshakov <[email protected]>
r~
PATCH v5 6/11 hvf: Simplify post reset/init/loadvm hooks
In reply to Alexander GrafThe hooks we have that call us after reset, init and loadvm really all just want to say "The reference of all register state is in the QEMU vcpu struct, please push it".
We already have a working pushing mechanism though called cpu->vcpu_dirty, so we can just reuse that for all of the above, syncing state properly the next time we actually execute a vCPU.
This fixes PSCI resets on ARM, as they modify CPU state even after the post init call has completed, but before we execute the vCPU again.
To also make the scheme work for x86, we have to make sure we don't move stale eflags into our env when the vcpu state is dirty.
--- accel/hvf/hvf-cpus.c | 27 +++++++-------------------- target/i386/hvf/x86hvf.c | 5 ++++- 2 files changed, 11 insertions(+), 21 deletions(-)
accel/hvf/hvf-cpus.c +7 -20
@@ -275,39 +275,26 @@ static void hvf_cpu_synchronize_state(CPUState *cpu) } } -static void do_hvf_cpu_synchronize_post_reset (CPUState *cpu, -run_on_cpu_data arg) +static void do_hvf_cpu_synchronize_set_dirty (CPUState *cpu, +run_on_cpu_data arg) { -hvf_put_registers (cpu); - cpu->vcpu_dirty = false; +/* QEMU state is the reference, push it to HVF now and on next entry */ + cpu->vcpu_dirty = true; }static void hvf_cpu_synchronize_post_reset (CPUState *cpu) { -run_on_cpu (cpu, do_hvf_cpu_synchronize_post_reset,RUN_ON_CPU_NULL ); -} - -static void do_hvf_cpu_synchronize_post_init (CPUState *cpu, -run_on_cpu_data arg) -{ -hvf_put_registers (cpu); - cpu->vcpu_dirty = false; +run_on_cpu (cpu, do_hvf_cpu_synchronize_set_dirty,RUN_ON_CPU_NULL ); }static void hvf_cpu_synchronize_post_init (CPUState *cpu) { -run_on_cpu (cpu, do_hvf_cpu_synchronize_post_init,RUN_ON_CPU_NULL ); -} - -static void do_hvf_cpu_synchronize_pre_loadvm (CPUState *cpu, -run_on_cpu_data arg) -{ - cpu->vcpu_dirty = true; +run_on_cpu (cpu, do_hvf_cpu_synchronize_set_dirty,RUN_ON_CPU_NULL ); }static void hvf_cpu_synchronize_pre_loadvm (CPUState *cpu) { -run_on_cpu (cpu, do_hvf_cpu_synchronize_pre_loadvm,RUN_ON_CPU_NULL ); +run_on_cpu (cpu, do_hvf_cpu_synchronize_set_dirty,RUN_ON_CPU_NULL ); }static void hvf_vcpu_destroy (CPUState *cpu)
target/i386/hvf/x86hvf.c +4 -1
@@ -435,7 +435,10 @@ int hvf_process_events(CPUState *cpu_state)X86CPU *cpu =X86_CPU (cpu_state);CPUX86State *env = &cpu->env; - env->eflags =rreg (cpu_state->hvf->fd,HV_X86_RFLAGS ); +if (!cpu_state->vcpu_dirty) { +/* light weight sync for CPU_INTERRUPT_HARD and IF_MASK */ + env->eflags =rreg (cpu_state->hvf->fd,HV_X86_RFLAGS ); + }if (cpu_state->interrupt_request &CPU_INTERRUPT_INIT ) {cpu_synchronize_state (cpu_state);
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 7/11 hvf: Add Apple Silicon support
In reply to Alexander GrafWith 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. It's still pretty raw, but definitely functional.
Known limitations:
- Vtimer acknowledgement is hacky
- Should implement more sysregs and fault on invalid ones then
- WFI handling is missing, need to marry it with vtimer
---
v1 -> v2:
- Merge vcpu kick function patch
- Implement WFI handling (allows vCPUs to sleep)
- Synchronize system registers (fixes OVMF crashes and reboot)
- Don't always call cpu_synchronize_state()
- Use more fine grained iothread locking
- Populate aa64mmfr0 from hardware
v2 -> v3:
- Advance PC on SMC
- Use cp list interface for sysreg syncs
- Do not set current_cpu
- Fix sysreg isread mask
- Move sysreg handling to functions
- Remove WFI logic again
- Revert to global iothread locking
- Use Hypervisor.h on arm, hv.h does not contain aarch64 definitions
v3 -> v4:
- No longer include Hypervisor.h
--- MAINTAINERS | 5 + accel/hvf/hvf-cpus.c | 14 + include/sysemu/hvf_int.h | 9 +- target/arm/hvf/hvf.c | 618 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 645 insertions(+), 1 deletion(-) create mode 100644 target/arm/hvf/hvf.c
MAINTAINERS +5 -0
@@ -439,6 +439,11 @@ F: accel/accel.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs +Apple Silicon HVF CPUs +M: Alexander Graf <[email protected]> +S: Maintained +F: target/arm/hvf/ + X86 HVF CPUs M: Cameron Esfahani <[email protected]> M: Roman Bolshakov <[email protected]>
accel/hvf/hvf-cpus.c +14 -0
@@ -58,6 +58,10 @@#include "sysemu/runstate.h" #include "qemu/guest-random.h" +#ifdef __aarch64__ +#define HV_VM_DEFAULT NULL +#endif +/* Memory slots */ struct mac_slot {
@@ -328,7 +332,11 @@ static int hvf_init_vcpu(CPUState *cpu)pthread_sigmask (SIG_BLOCK ,NULL , &set);sigdelset (&set,SIG_IPI ); +#ifdef __aarch64__ + r =hv_vcpu_create (&cpu->hvf->fd, (hv_vcpu_exit_t **)&cpu->hvf->exit,NULL ); +#else r =hv_vcpu_create ((hv_vcpuid_t *)&cpu->hvf->fd,HV_VCPU_DEFAULT ); +#endif cpu->vcpu_dirty =1 ;assert_hvf_ok (r);
@@ -399,8 +407,14 @@ static void hvf_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } +__attribute__((weak))void hvf_kick_vcpu_thread (CPUState *cpu) +{ +cpus_kick_thread (cpu); +} +static const CpusAccel hvf_cpus = { .create_vcpu_thread = hvf_start_vcpu_thread, + .kick_vcpu_thread = hvf_kick_vcpu_thread, .synchronize_post_reset = hvf_cpu_synchronize_post_reset, .synchronize_post_init = hvf_cpu_synchronize_post_init,
include/sysemu/hvf_int.h +8 -1
@@ -11,7 +11,12 @@#ifndef HVF_INT_H #define HVF_INT_H +#include "qemu/osdep.h" +#ifdef __aarch64__ +#include <Hypervisor/Hypervisor.h> +#else #include <Hypervisor/hv.h> +#endif /* hvf_slot flags */ #define HVF_SLOT_LOG (1 << 0)
@@ -44,7 +49,8 @@ struct HVFState {extern HVFState *hvf_state;struct hvf_vcpu_state { -int fd; +uint64_t fd; +void *exit; };void assert_hvf_ok (hv_return_t ret);
@@ -54,5 +60,6 @@ int hvf_arch_init_vcpu(CPUState *cpu);void hvf_arch_vcpu_destroy (CPUState *cpu);int hvf_vcpu_exec (CPUState *cpu);hvf_slot *hvf_find_overlap_slot (uint64_t ,uint64_t ); +void hvf_kick_vcpu_thread (CPUState *cpu);#endif
target/arm/hvf/hvf.c new file +618 -0
618 lines not on this page · raw message
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 8/11 arm: Add Hypervisor.framework build target
In reply to Alexander GrafNow that we have all logic in place that we need to handle Hypervisor.framework on Apple Silicon systems, let's add CONFIG_HVF for aarch64 as well so that we can build it.
---
v1 -> v2:
- Fix build on 32bit arm
v3 -> v4:
- Remove i386-softmmu target
--- meson.build | 11 ++++++++++- target/arm/hvf/meson.build | 3 +++ target/arm/meson.build | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 target/arm/hvf/meson.build
meson.build +10 -1
@@ -74,16 +74,25 @@ else endif accelerator_targets = { 'CONFIG_KVM': kvm_targets } + +if cpu in ['x86', 'x86_64'] + hvf_targets = ['x86_64-softmmu'] +elif cpu in ['aarch64'] + hvf_targets = ['aarch64-softmmu'] +else + hvf_targets = [] +endif + if cpu in ['x86', 'x86_64', 'arm', 'aarch64'] # i368 emulator provides xenpv machine type for multiple architectures accelerator_targets += { 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'], + 'CONFIG_HVF': hvf_targets, } endif if cpu in ['x86', 'x86_64'] accelerator_targets += { 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'], - 'CONFIG_HVF': ['x86_64-softmmu'], 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'], } endif
target/arm/hvf/meson.build new file +3 -0
@@ -0,0 +1,3 @@ +arm_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( + 'hvf.c', +))
target/arm/meson.build +2 -0
@@ -56,5 +56,7 @@ arm_softmmu_ss.add(files( 'psci.c', )) +subdir('hvf') + target_arch += {'arm': arm_ss} target_softmmu_arch += {'arm': arm_softmmu_ss}
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 9/11 arm/hvf: Add a WFI handler
In reply to Alexander GrafFrom: Peter Collingbourne <[email protected]>
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.
--- accel/hvf/hvf-cpus.c | 5 ++-- include/sysemu/hvf_int.h | 1 + target/arm/hvf/hvf.c | 56 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-)
accel/hvf/hvf-cpus.c +2 -3
@@ -322,15 +322,14 @@ static int hvf_init_vcpu(CPUState *cpu) cpu->hvf =g_malloc0 (sizeof (*cpu->hvf));/* init cpu signals */ -sigset_t set;struct sigaction sigact;memset (&sigact,0 ,sizeof (sigact)); sigact.sa_handler = dummy_signal;sigaction (SIG_IPI , &sigact,NULL ); -pthread_sigmask (SIG_BLOCK ,NULL , &set); -sigdelset (&set,SIG_IPI ); +pthread_sigmask (SIG_BLOCK ,NULL , &cpu->hvf->unblock_ipi_mask); +sigdelset (&cpu->hvf->unblock_ipi_mask,SIG_IPI );#ifdef __aarch64__ r =hv_vcpu_create (&cpu->hvf->fd, (hv_vcpu_exit_t **)&cpu->hvf->exit,NULL );
include/sysemu/hvf_int.h +1 -0
@@ -51,6 +51,7 @@ extern HVFState *hvf_state;struct hvf_vcpu_state {uint64_t fd;void *exit; +sigset_t unblock_ipi_mask; };void assert_hvf_ok (hv_return_t ret);
target/arm/hvf/hvf.c +56 -0
86 lines not on this page · raw message
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 10/11 hvf: arm: Add support for GICv3
In reply to Alexander GrafWe 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 handling for all of the required system registers, so that we can run with more than 8 vCPUs.
--- target/arm/hvf/hvf.c | 141 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+)
target/arm/hvf/hvf.c +141 -0
@@ -22,6 +22,7 @@#include "exec/address-spaces.h" #include "hw/irq.h" +#include "hw/intc/gicv3_internal.h" #include "qemu/main-loop.h" #include "sysemu/accel.h" #include "sysemu/cpus.h"
@@ -46,6 +47,33 @@#define SYSREG_CNTPCT_EL0 SYSREG(3, 3, 1, 14, 0)#define SYSREG_PMCCNTR_EL0 SYSREG(3, 3, 0, 9, 13) +#define SYSREG_ICC_AP0R0_EL1 SYSREG(3, 0, 4, 12, 8) +#define SYSREG_ICC_AP0R1_EL1 SYSREG(3, 0, 5, 12, 8) +#define SYSREG_ICC_AP0R2_EL1 SYSREG(3, 0, 6, 12, 8) +#define SYSREG_ICC_AP0R3_EL1 SYSREG(3, 0, 7, 12, 8) +#define SYSREG_ICC_AP1R0_EL1 SYSREG(3, 0, 0, 12, 9) +#define SYSREG_ICC_AP1R1_EL1 SYSREG(3, 0, 1, 12, 9) +#define SYSREG_ICC_AP1R2_EL1 SYSREG(3, 0, 2, 12, 9) +#define SYSREG_ICC_AP1R3_EL1 SYSREG(3, 0, 3, 12, 9) +#define SYSREG_ICC_ASGI1R_EL1 SYSREG(3, 0, 6, 12, 11) +#define SYSREG_ICC_BPR0_EL1 SYSREG(3, 0, 3, 12, 8) +#define SYSREG_ICC_BPR1_EL1 SYSREG(3, 0, 3, 12, 12) +#define SYSREG_ICC_CTLR_EL1 SYSREG(3, 0, 4, 12, 12) +#define SYSREG_ICC_DIR_EL1 SYSREG(3, 0, 1, 12, 11) +#define SYSREG_ICC_EOIR0_EL1 SYSREG(3, 0, 1, 12, 8) +#define SYSREG_ICC_EOIR1_EL1 SYSREG(3, 0, 1, 12, 12) +#define SYSREG_ICC_HPPIR0_EL1 SYSREG(3, 0, 2, 12, 8) +#define SYSREG_ICC_HPPIR1_EL1 SYSREG(3, 0, 2, 12, 12) +#define SYSREG_ICC_IAR0_EL1 SYSREG(3, 0, 0, 12, 8) +#define SYSREG_ICC_IAR1_EL1 SYSREG(3, 0, 0, 12, 12) +#define SYSREG_ICC_IGRPEN0_EL1 SYSREG(3, 0, 6, 12, 12) +#define SYSREG_ICC_IGRPEN1_EL1 SYSREG(3, 0, 7, 12, 12) +#define SYSREG_ICC_PMR_EL1 SYSREG(3, 0, 0, 4, 6) +#define SYSREG_ICC_RPR_EL1 SYSREG(3, 0, 3, 12, 11) +#define SYSREG_ICC_SGI0R_EL1 SYSREG(3, 0, 7, 12, 11) +#define SYSREG_ICC_SGI1R_EL1 SYSREG(3, 0, 5, 12, 11) +#define SYSREG_ICC_SRE_EL1 SYSREG(3, 0, 5, 12, 12) +#define WFX_IS_WFE (1 << 0)struct hvf_reg_match {
@@ -418,6 +446,38 @@ void hvf_kick_vcpu_thread(CPUState *cpu)hv_vcpus_exit (&cpu->hvf->fd,1 ); } +static uint32_t hvf_reg2cp_reg (uint32_t reg) +{ +return ENCODE_AA64_CP_REG (CP_REG_ARM64_SYSREG_CP , + (reg >>10 ) &0xf , + (reg >>1 ) &0xf , + (reg >>20 ) &0x3 , + (reg >>14 ) &0x7 , + (reg >>17 ) &0x7 ); +} + +static uint64_t hvf_sysreg_read_cp (CPUState *cpu,uint32_t reg) +{ +ARMCPU *arm_cpu =ARM_CPU (cpu); +CPUARMState *env = &arm_cpu->env; +const ARMCPRegInfo *ri; +uint64_t val =0 ; + + ri =get_arm_cp_reginfo (arm_cpu->cp_regs,hvf_reg2cp_reg (reg)); +if (ri) { +if (ri->type &ARM_CP_CONST ) { + val = ri->resetvalue; + }else if (ri->readfn) { + val = ri->readfn (env, ri); + }else { + val =CPREG_FIELD64 (env, ri); + } +DPRINTF ("vgic read from %s [val=%016llx]" , ri->name, val); + } + +return val; +} +static uint64_t hvf_sysreg_read (CPUState *cpu,uint32_t reg) {ARMCPU *arm_cpu =ARM_CPU (cpu);
@@ -431,6 +491,39 @@ static uint64_t hvf_sysreg_read(CPUState *cpu, uint32_t reg)case SYSREG_PMCCNTR_EL0 : val =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL );break ; +case SYSREG_ICC_AP0R0_EL1 : +case SYSREG_ICC_AP0R1_EL1 : +case SYSREG_ICC_AP0R2_EL1 : +case SYSREG_ICC_AP0R3_EL1 : +case SYSREG_ICC_AP1R0_EL1 : +case SYSREG_ICC_AP1R1_EL1 : +case SYSREG_ICC_AP1R2_EL1 : +case SYSREG_ICC_AP1R3_EL1 : +case SYSREG_ICC_ASGI1R_EL1 : +case SYSREG_ICC_BPR0_EL1 : +case SYSREG_ICC_BPR1_EL1 : +case SYSREG_ICC_DIR_EL1 : +case SYSREG_ICC_EOIR0_EL1 : +case SYSREG_ICC_EOIR1_EL1 : +case SYSREG_ICC_HPPIR0_EL1 : +case SYSREG_ICC_HPPIR1_EL1 : +case SYSREG_ICC_IAR0_EL1 : +case SYSREG_ICC_IAR1_EL1 : +case SYSREG_ICC_IGRPEN0_EL1 : +case SYSREG_ICC_IGRPEN1_EL1 : +case SYSREG_ICC_PMR_EL1 : +case SYSREG_ICC_SGI0R_EL1 : +case SYSREG_ICC_SGI1R_EL1 : +case SYSREG_ICC_SRE_EL1 : + val =hvf_sysreg_read_cp (cpu, reg); +break ; +case SYSREG_ICC_CTLR_EL1 : + val =hvf_sysreg_read_cp (cpu, reg); + +/* AP0R registers above 0 don't trap, expose less PRIs to fit */ + val &= ~ICC_CTLR_EL1_PRIBITS_MASK ; + val |=4 <<ICC_CTLR_EL1_PRIBITS_SHIFT ; +break ;default : DPRINTF("unhandled sysreg read %08x (op0=%d op1=%d op2=%d " "crn=%d crm=%d)", reg, (reg >> 20) & 0x3,
@@ -442,6 +535,24 @@ static uint64_t hvf_sysreg_read(CPUState *cpu, uint32_t reg)return val; } +static void hvf_sysreg_write_cp (CPUState *cpu,uint32_t reg,uint64_t val) +{ +ARMCPU *arm_cpu =ARM_CPU (cpu); +CPUARMState *env = &arm_cpu->env; +const ARMCPRegInfo *ri; + + ri =get_arm_cp_reginfo (arm_cpu->cp_regs,hvf_reg2cp_reg (reg)); + +if (ri) { +if (ri->writefn) { + ri->writefn (env, ri, val); + }else { +CPREG_FIELD64 (env, ri) = val; + } +DPRINTF ("vgic write to %s [val=%016llx]" , ri->name, val); + } +} +static void hvf_sysreg_write (CPUState *cpu,uint32_t reg,uint64_t val) {ARMCPU *arm_cpu =ARM_CPU (cpu);
@@ -449,6 +560,36 @@ static void hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val)switch (reg) {case SYSREG_CNTPCT_EL0 :break ; +case SYSREG_ICC_AP0R0_EL1 : +case SYSREG_ICC_AP0R1_EL1 : +case SYSREG_ICC_AP0R2_EL1 : +case SYSREG_ICC_AP0R3_EL1 : +case SYSREG_ICC_AP1R0_EL1 : +case SYSREG_ICC_AP1R1_EL1 : +case SYSREG_ICC_AP1R2_EL1 : +case SYSREG_ICC_AP1R3_EL1 : +case SYSREG_ICC_ASGI1R_EL1 : +case SYSREG_ICC_BPR0_EL1 : +case SYSREG_ICC_BPR1_EL1 : +case SYSREG_ICC_CTLR_EL1 : +case SYSREG_ICC_DIR_EL1 : +case SYSREG_ICC_HPPIR0_EL1 : +case SYSREG_ICC_HPPIR1_EL1 : +case SYSREG_ICC_IAR0_EL1 : +case SYSREG_ICC_IAR1_EL1 : +case SYSREG_ICC_IGRPEN0_EL1 : +case SYSREG_ICC_IGRPEN1_EL1 : +case SYSREG_ICC_PMR_EL1 : +case SYSREG_ICC_SGI0R_EL1 : +case SYSREG_ICC_SGI1R_EL1 : +case SYSREG_ICC_SRE_EL1 : +hvf_sysreg_write_cp (cpu, reg, val); +break ; +case SYSREG_ICC_EOIR0_EL1 : +case SYSREG_ICC_EOIR1_EL1 : +hvf_sysreg_write_cp (cpu, reg, val); +qemu_set_irq (arm_cpu->gt_timer_outputs[GTIMER_VIRT ],0 ); +hv_vcpu_set_vtimer_mask (cpu->hvf->fd, false);default :DPRINTF ("unhandled sysreg write %08x" , reg);break ;
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH v5 11/11 hvf: arm: Implement -cpu host
In reply to Alexander GrafNow that we have working system register sync, we push more target CPU properties into the virtual machine. That might be useful in some situations, but is not the typical case that users want.
So let's add a -cpu host option that allows them to explicitly pass all CPU capabilities of their host CPU into the guest.
--- include/sysemu/hvf.h | 2 ++ target/arm/cpu.c | 9 ++++++--- target/arm/cpu.h | 2 ++ target/arm/hvf/hvf.c | 41 +++++++++++++++++++++++++++++++++++++++++ target/arm/kvm_arm.h | 2 -- 5 files changed, 51 insertions(+), 5 deletions(-)
include/sysemu/hvf.h +2 -0
@@ -19,6 +19,8 @@#ifdef CONFIG_HVF uint32_t hvf_get_supported_cpuid (uint32_t func,uint32_t idx,int reg); +struct ARMCPU ; +void hvf_arm_set_cpu_features_from_host (struct ARMCPU *cpu);extern bool hvf_allowed;#define hvf_enabled () (hvf_allowed)#else /* !CONFIG_HVF */
target/arm/cpu.c +6 -3
@@ -2276,12 +2276,16 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#endif } -#ifdef CONFIG_KVM +#if defined(CONFIG_KVM ) || defined(CONFIG_HVF )static void arm_host_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +#ifdef CONFIG_KVM kvm_arm_set_cpu_features_from_host (cpu); +#else +hvf_arm_set_cpu_features_from_host (cpu); +#endif if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); }
@@ -2293,7 +2297,6 @@ static const TypeInfo host_arm_cpu_type_info = { .parent = TYPE_AARCH64_CPU, .instance_init = arm_host_initfn, }; -#endif static void arm_cpu_instance_init (Object *obj)
@@ -2352,7 +2355,7 @@ static void arm_cpu_register_types(void)type_register_static (&arm_cpu_type_info); -#ifdef CONFIG_KVM +#if defined(CONFIG_KVM ) || defined(CONFIG_HVF )type_register_static (&host_arm_cpu_type_info);#endif
target/arm/cpu.h +2 -0
@@ -2855,6 +2855,8 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);#define ARM_CPU_TYPE_NAME (name) (name ARM_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_ARM_CPU +#define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU +#define cpu_signal_handler cpu_arm_signal_handler#define cpu_list arm_cpu_list
target/arm/hvf/hvf.c +41 -0
47 lines not on this page · raw message
target/arm/kvm_arm.h +0 -2
@@ -214,8 +214,6 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,*/ void kvm_arm_destroy_scratch_host_vcpu (int *fdarray); -#define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU -/** * ARMHostCPUFeatures: information about the host CPU (identified * by asking the host kernel)
Signature · 1 line
2.24.3 (Apple Git-128)
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH v5 00/11] hvf: Implement Apple Silicon Support
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected] - [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
56f4c6b hvf: arm: Implement -cpu host
b5c4db1 hvf: arm: Add support for GICv3
6c0280c arm/hvf: Add a WFI handler
26b170e arm: Add Hypervisor.framework build target a8820bd hvf: Add Apple Silicon support
d0b5c38 hvf: Simplify post reset/init/loadvm hooks d3c68ab arm: Set PSCI to 0.2 for HVF
360f48e hvf: Introduce hvf vcpu struct
87a09e8 hvf: Move common code out
ac925f0 hvf: x86: Remove unused definitions c77ce16 hvf: Add hypervisor entitlement to output binaries
=== OUTPUT BEGIN ===
1/11 Checking commit c77ce16832fb (hvf: Add hypervisor entitlement to output binaries)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #18:
new file mode 100644
total: 0 errors, 1 warnings, 62 lines checked
Patch 1/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/11 Checking commit ac925f0aaf18 (hvf: x86: Remove unused definitions) 3/11 Checking commit 87a09e81f925 (hvf: Move common code out)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #41:
new file mode 100644
total: 0 errors, 1 warnings, 1054 lines checked
Patch 3/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/11 Checking commit 360f48eb839f (hvf: Introduce hvf vcpu struct)
WARNING: line over 80 characters
#142: FILE: target/i386/hvf/hvf.c:213:
+ wvmcs(cpu->hvf->fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry,
ERROR: "(foo*)" should be "(foo *)"
#750: FILE: target/i386/hvf/x86hvf.c:85:
+ if (hv_vcpu_write_fpstate(cpu_state->hvf->fd, (void*)xsave, 4096)) {
ERROR: "(foo*)" should be "(foo *)"
#831: FILE: target/i386/hvf/x86hvf.c:167:
+ if (hv_vcpu_read_fpstate(cpu_state->hvf->fd, (void*)xsave, 4096)) {
total: 2 errors, 1 warnings, 996 lines checked
Patch 4/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/11 Checking commit d3c68ab7fa96 (arm: Set PSCI to 0.2 for HVF) 6/11 Checking commit d0b5c38651d5 (hvf: Simplify post reset/init/loadvm hooks) 7/11 Checking commit a8820bd60f6a (hvf: Add Apple Silicon support)
WARNING: architecture specific defines should be avoided
#48: FILE: accel/hvf/hvf-cpus.c:61:
+#ifdef __aarch64__
WARNING: architecture specific defines should be avoided #59: FILE: accel/hvf/hvf-cpus.c:335:
+#ifdef __aarch64__
WARNING: architecture specific defines should be avoided #91: FILE: include/sysemu/hvf_int.h:15:
+#ifdef __aarch64__
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #117:
new file mode 100644
WARNING: line over 80 characters
#579: FILE: target/arm/hvf/hvf.c:458:
+ hv_vcpu_set_pending_interrupt(cpu->hvf->fd, HV_INTERRUPT_TYPE_FIQ, true);
WARNING: line over 80 characters
#584: FILE: target/arm/hvf/hvf.c:463:
+ hv_vcpu_set_pending_interrupt(cpu->hvf->fd, HV_INTERRUPT_TYPE_IRQ, true);
total: 0 errors, 6 warnings, 691 lines checked
Patch 7/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
8/11 Checking commit 26b170ee618a (arm: Add Hypervisor.framework build target)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #49:
new file mode 100644
total: 0 errors, 1 warnings, 36 lines checked
Patch 8/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
9/11 Checking commit 6c0280c8b649 (arm/hvf: Add a WFI handler) 10/11 Checking commit b5c4db10905e (hvf: arm: Add support for GICv3) 11/11 Checking commit 56f4c6b7ff84 (hvf: arm: Implement -cpu host) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 8 lines · Alexander Graf
Now that Apple Silicon is widely available, people are obviously excited to try and run virtualized workloads on them, such as Linux and Windows.
This patch set implements a fully functional version to get the ball going on that. With this applied, I can successfully run both Linux and Windows as guests. I am not aware of any limitations specific to Hypervisor.framework apart from:
Quoted 5 lines
- Live migration / savevm
- gdbstub debugging (SP register)Enjoy!
I have been using a VM created using v4/v5 as my daily work machine since v4 came out so.
Quoted 109 lines
Alex
v1 -> v2:
- New patch: hvf: Actually set
SIG_IPImask
- New patch: hvf: Introduce hvf vcpu struct
- New patch: hvf: arm: Mark CPU as dirty on reset
- Removed patch: hw/arm/virt: Disable highmem when on hypervisor.framework
- Removed patch: arm: Synchronize CPU on PSCI on
- Fix build on 32bit arm
- Merge vcpu kick function patch into ARM enablement
- Implement WFI handling (allows vCPUs to sleep)
- Synchronize system registers (fixes OVMF crashes and reboot)
- Don't always callcpu_synchronize_state()
- Use more fine grained iothread locking
- Populate aa64mmfr0 from hardware
- Make safe to ctrl-C entitlement applicationv2 -> v3:
- Removed patch: hvf: Actually set
SIG_IPImask
- New patch: hvf: arm: Add support for GICv3
- New patch: hvf: arm: Implement -cpu host
- Advance PC on SMC
- Use cp list interface for sysreg syncs
- Do not setcurrent_cpu
- Fix sysreg isread mask
- Move sysreg handling to functions
- Remove WFI logic again
- Revert to global iothread lockingv3 -> v4:
- Removed patch: hvf: arm: Mark CPU as dirty on reset
- New patch: hvf: Simplify post reset/init/loadvm hooks
- Remove i386-softmmu target (meson.build for hvf target)
- Combine both if statements (PSCI)
- Usehv.hinstead ofHypervisor.hfor 10.15 compat
- Remove manual inclusion ofHypervisor.hin common .c files
- No longer includeHypervisor.hin arm hvf .c files
- Remove unusedexe_fullvariable
- Reuseexe_namevariablev4 -> v5:
- Use
g_free()on destroyAlexander Graf (10):
hvf: Add hypervisor entitlement to output binaries
hvf: x86: Remove unused definitions
hvf: Move common code out
hvf: Introduce hvf vcpu struct
arm: Set PSCI to 0.2 for HVF
hvf: Simplify post reset/init/loadvm hooks
hvf: Add Apple Silicon support
arm: Add Hypervisor.framework build target
hvf: arm: Add support for GICv3
hvf: arm: Implement -cpu hostPeter Collingbourne (1):
arm/hvf: Add a WFI handlerMAINTAINERS | 14 +- accel/hvf/entitlements.plist | 8 + accel/hvf/hvf-all.c | 54 +++ accel/hvf/hvf-cpus.c | 466 +++++++++++++++++++ accel/hvf/meson.build | 7 + accel/meson.build | 1 + include/hw/core/cpu.h | 3 +- include/sysemu/hvf.h | 2 + include/sysemu/hvf_int.h | 66 +++ meson.build | 40 +- scripts/entitlement.sh | 13 + target/arm/cpu.c | 13 +- target/arm/cpu.h | 2 + target/arm/hvf/hvf.c | 856 +++++++++++++++++++++++++++++++++++ target/arm/hvf/meson.build | 3 + target/arm/kvm_arm.h | 2 - target/arm/meson.build | 2 + target/i386/hvf/hvf-cpus.c | 131 ------ target/i386/hvf/hvf-cpus.h | 25 - target/i386/hvf/hvf-i386.h | 49 +- target/i386/hvf/hvf.c | 462 +++---------------- target/i386/hvf/meson.build | 1 - target/i386/hvf/vmx.h | 24 +- target/i386/hvf/x86.c | 28 +- target/i386/hvf/x86_descr.c | 26 +- target/i386/hvf/x86_emu.c | 62 +-- target/i386/hvf/x86_mmu.c | 4 +- target/i386/hvf/x86_task.c | 12 +- target/i386/hvf/x86hvf.c | 224 ++++----- target/i386/hvf/x86hvf.h | 2 - 30 files changed, 1786 insertions(+), 816 deletions(-) create mode 100644 accel/hvf/entitlements.plist create mode 100644 accel/hvf/hvf-all.c create mode 100644 accel/hvf/hvf-cpus.c create mode 100644 accel/hvf/meson.build create mode 100644 include/sysemu/hvf_int.h create mode 100755 scripts/entitlement.sh create mode 100644 target/arm/hvf/hvf.c create mode 100644 target/arm/hvf/meson.build delete mode 100644 target/i386/hvf/hvf-cpus.c delete mode 100644 target/i386/hvf/hvf-cpus.hSignature · 1 line
2.24.3 (Apple Git-128)
Quoted 8 lines · Alexander Graf
Now that Apple Silicon is widely available, people are obviously excited to try and run virtualized workloads on them, such as Linux and Windows.
This patch set implements a fully functional version to get the ball going on that. With this applied, I can successfully run both Linux and Windows as guests. I am not aware of any limitations specific to Hypervisor.framework apart from:
Quoted 6 lines
- Live migration / savevm
- gdbstub debugging (SP register)Enjoy!
Hi Alex,
For the ARM part:
Note, that it doesn't apply to current master. So I applied it over tagged v5.2.0.
Are there any outstanding issues that blocking merge apart from the rebase?
Thanks,
Roman
Quoted 107 lines
Alex
v1 -> v2:
- New patch: hvf: Actually set
SIG_IPImask
- New patch: hvf: Introduce hvf vcpu struct
- New patch: hvf: arm: Mark CPU as dirty on reset
- Removed patch: hw/arm/virt: Disable highmem when on hypervisor.framework
- Removed patch: arm: Synchronize CPU on PSCI on
- Fix build on 32bit arm
- Merge vcpu kick function patch into ARM enablement
- Implement WFI handling (allows vCPUs to sleep)
- Synchronize system registers (fixes OVMF crashes and reboot)
- Don't always callcpu_synchronize_state()
- Use more fine grained iothread locking
- Populate aa64mmfr0 from hardware
- Make safe to ctrl-C entitlement applicationv2 -> v3:
- Removed patch: hvf: Actually set
SIG_IPImask
- New patch: hvf: arm: Add support for GICv3
- New patch: hvf: arm: Implement -cpu host
- Advance PC on SMC
- Use cp list interface for sysreg syncs
- Do not setcurrent_cpu
- Fix sysreg isread mask
- Move sysreg handling to functions
- Remove WFI logic again
- Revert to global iothread lockingv3 -> v4:
- Removed patch: hvf: arm: Mark CPU as dirty on reset
- New patch: hvf: Simplify post reset/init/loadvm hooks
- Remove i386-softmmu target (meson.build for hvf target)
- Combine both if statements (PSCI)
- Usehv.hinstead ofHypervisor.hfor 10.15 compat
- Remove manual inclusion ofHypervisor.hin common .c files
- No longer includeHypervisor.hin arm hvf .c files
- Remove unusedexe_fullvariable
- Reuseexe_namevariablev4 -> v5:
- Use
g_free()on destroyAlexander Graf (10):
hvf: Add hypervisor entitlement to output binaries
hvf: x86: Remove unused definitions
hvf: Move common code out
hvf: Introduce hvf vcpu struct
arm: Set PSCI to 0.2 for HVF
hvf: Simplify post reset/init/loadvm hooks
hvf: Add Apple Silicon support
arm: Add Hypervisor.framework build target
hvf: arm: Add support for GICv3
hvf: arm: Implement -cpu hostPeter Collingbourne (1):
arm/hvf: Add a WFI handlerMAINTAINERS | 14 +- accel/hvf/entitlements.plist | 8 + accel/hvf/hvf-all.c | 54 +++ accel/hvf/hvf-cpus.c | 466 +++++++++++++++++++ accel/hvf/meson.build | 7 + accel/meson.build | 1 + include/hw/core/cpu.h | 3 +- include/sysemu/hvf.h | 2 + include/sysemu/hvf_int.h | 66 +++ meson.build | 40 +- scripts/entitlement.sh | 13 + target/arm/cpu.c | 13 +- target/arm/cpu.h | 2 + target/arm/hvf/hvf.c | 856 +++++++++++++++++++++++++++++++++++ target/arm/hvf/meson.build | 3 + target/arm/kvm_arm.h | 2 - target/arm/meson.build | 2 + target/i386/hvf/hvf-cpus.c | 131 ------ target/i386/hvf/hvf-cpus.h | 25 - target/i386/hvf/hvf-i386.h | 49 +- target/i386/hvf/hvf.c | 462 +++---------------- target/i386/hvf/meson.build | 1 - target/i386/hvf/vmx.h | 24 +- target/i386/hvf/x86.c | 28 +- target/i386/hvf/x86_descr.c | 26 +- target/i386/hvf/x86_emu.c | 62 +-- target/i386/hvf/x86_mmu.c | 4 +- target/i386/hvf/x86_task.c | 12 +- target/i386/hvf/x86hvf.c | 224 ++++----- target/i386/hvf/x86hvf.h | 2 - 30 files changed, 1786 insertions(+), 816 deletions(-) create mode 100644 accel/hvf/entitlements.plist create mode 100644 accel/hvf/hvf-all.c create mode 100644 accel/hvf/hvf-cpus.c create mode 100644 accel/hvf/meson.build create mode 100644 include/sysemu/hvf_int.h create mode 100755 scripts/entitlement.sh create mode 100644 target/arm/hvf/hvf.c create mode 100644 target/arm/hvf/meson.build delete mode 100644 target/i386/hvf/hvf-cpus.c delete mode 100644 target/i386/hvf/hvf-cpus.hSignature · 1 line
2.24.3 (Apple Git-128)