[PATCH v7 00/19] hvf: Implement Apple Silicon Support

Alexander Graf posted 19 patches 2 years, 11 months ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210516195855.28869-1-agraf@csgraf.de
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Alexander Graf <agraf@csgraf.de>, Roman Bolshakov <r.bolshakov@yadro.com>, Paolo Bonzini <pbonzini@redhat.com>, Cameron Esfahani <dirty@apple.com>
There is a newer version of this series
MAINTAINERS                     |  13 +
accel/hvf/hvf-accel-ops.c       | 484 ++++++++++++++++
accel/hvf/hvf-all.c             |  47 ++
accel/hvf/meson.build           |   7 +
accel/meson.build               |   1 +
include/hw/core/cpu.h           |   3 +-
include/sysemu/hvf_int.h        |  66 +++
meson.build                     |   8 +
target/arm/cpu.c                |  13 +-
target/arm/cpu.h                |   2 +
target/arm/hvf/hvf.c            | 959 ++++++++++++++++++++++++++++++++
target/arm/hvf/meson.build      |   3 +
target/arm/hvf/trace-events     |  11 +
target/arm/hvf_arm.h            |  19 +
target/arm/kvm-consts.h         |   2 +
target/arm/kvm_arm.h            |   2 -
target/arm/meson.build          |   2 +
target/arm/psci.c               |   2 +
target/i386/hvf/hvf-accel-ops.c | 146 -----
target/i386/hvf/hvf-accel-ops.h |  23 -
target/i386/hvf/hvf-i386.h      |  33 +-
target/i386/hvf/hvf.c           | 464 ++-------------
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        | 222 ++++----
target/i386/hvf/x86hvf.h        |   2 -
31 files changed, 1884 insertions(+), 807 deletions(-)
create mode 100644 accel/hvf/hvf-accel-ops.c
create mode 100644 accel/hvf/hvf-all.c
create mode 100644 accel/hvf/meson.build
create mode 100644 include/sysemu/hvf_int.h
create mode 100644 target/arm/hvf/hvf.c
create mode 100644 target/arm/hvf/meson.build
create mode 100644 target/arm/hvf/trace-events
create mode 100644 target/arm/hvf_arm.h
delete mode 100644 target/i386/hvf/hvf-accel-ops.c
delete mode 100644 target/i386/hvf/hvf-accel-ops.h
[PATCH v7 00/19] hvf: Implement Apple Silicon Support
Posted by Alexander Graf 2 years, 11 months ago
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

v5 -> v6:

  - Switch SYSREG() macro order to the same as asm intrinsics

v6 -> v7:

  - Already merged: hvf: Add hypervisor entitlement to output binaries
  - Already merged: hvf: x86: Remove unused definitions
  - Patch split: hvf: Move common code out
    -> hvf: Move assert_hvf_ok() into common directory
    -> hvf: Move vcpu thread functions into common directory
    -> hvf: Move cpu functions into common directory
    -> hvf: Move hvf internal definitions into common header
    -> hvf: Make hvf_set_phys_mem() static
    -> hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t
    -> hvf: Split out common code on vcpu init and destroy
    -> hvf: Use cpu_synchronize_state()
    -> hvf: Make synchronize functions static
    -> hvf: Remove hvf-accel-ops.h
  - New patch: hvf: arm: Implement PSCI handling
  - New patch: arm: Enable Windows 10 trusted SMCCC boot call
  - New patch: hvf: arm: Handle Windows 10 SMC call
  - Removed patch: "arm: Set PSCI to 0.2 for HVF" (included above)
  - Removed patch: "hvf: arm: Add support for GICv3" (deferred to later)
  - Remove osdep.h include from hvf_int.h
  - Synchronize SIMD registers as well
  - Prepend 0x for hex values
  - Convert DPRINTF to trace points
  - Use main event loop (fixes gdbstub issues)
  - Remove PSCI support, inject UDEF on HVC/SMC
  - Change vtimer logic to look at ctl.istatus for vtimer mask sync
  - Add kick callback again (fixes remote CPU notification)
  - Move function define to own header
  - Do not propagate SVE features for HVF
  - Remove stray whitespace change
  - Verify that EL0 and EL1 do not allow AArch32 mode
  - Only probe host CPU features once
  - Move WFI into function
  - Improve comment wording
  - Simplify HVF matching logic in meson build file

Alexander Graf (18):
  hvf: Move assert_hvf_ok() into common directory
  hvf: Move vcpu thread functions into common directory
  hvf: Move cpu functions into common directory
  hvf: Move hvf internal definitions into common header
  hvf: Make hvf_set_phys_mem() static
  hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t
  hvf: Split out common code on vcpu init and destroy
  hvf: Use cpu_synchronize_state()
  hvf: Make synchronize functions static
  hvf: Remove hvf-accel-ops.h
  hvf: Introduce hvf vcpu struct
  hvf: Simplify post reset/init/loadvm hooks
  hvf: Add Apple Silicon support
  hvf: arm: Implement -cpu host
  hvf: arm: Implement PSCI handling
  arm: Add Hypervisor.framework build target
  arm: Enable Windows 10 trusted SMCCC boot call
  hvf: arm: Handle Windows 10 SMC call

Peter Collingbourne (1):
  arm/hvf: Add a WFI handler

 MAINTAINERS                     |  13 +
 accel/hvf/hvf-accel-ops.c       | 484 ++++++++++++++++
 accel/hvf/hvf-all.c             |  47 ++
 accel/hvf/meson.build           |   7 +
 accel/meson.build               |   1 +
 include/hw/core/cpu.h           |   3 +-
 include/sysemu/hvf_int.h        |  66 +++
 meson.build                     |   8 +
 target/arm/cpu.c                |  13 +-
 target/arm/cpu.h                |   2 +
 target/arm/hvf/hvf.c            | 959 ++++++++++++++++++++++++++++++++
 target/arm/hvf/meson.build      |   3 +
 target/arm/hvf/trace-events     |  11 +
 target/arm/hvf_arm.h            |  19 +
 target/arm/kvm-consts.h         |   2 +
 target/arm/kvm_arm.h            |   2 -
 target/arm/meson.build          |   2 +
 target/arm/psci.c               |   2 +
 target/i386/hvf/hvf-accel-ops.c | 146 -----
 target/i386/hvf/hvf-accel-ops.h |  23 -
 target/i386/hvf/hvf-i386.h      |  33 +-
 target/i386/hvf/hvf.c           | 464 ++-------------
 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        | 222 ++++----
 target/i386/hvf/x86hvf.h        |   2 -
 31 files changed, 1884 insertions(+), 807 deletions(-)
 create mode 100644 accel/hvf/hvf-accel-ops.c
 create mode 100644 accel/hvf/hvf-all.c
 create mode 100644 accel/hvf/meson.build
 create mode 100644 include/sysemu/hvf_int.h
 create mode 100644 target/arm/hvf/hvf.c
 create mode 100644 target/arm/hvf/meson.build
 create mode 100644 target/arm/hvf/trace-events
 create mode 100644 target/arm/hvf_arm.h
 delete mode 100644 target/i386/hvf/hvf-accel-ops.c
 delete mode 100644 target/i386/hvf/hvf-accel-ops.h

-- 
2.30.1 (Apple Git-130)


Re: [PATCH v7 00/19] hvf: Implement Apple Silicon Support
Posted by no-reply@patchew.org 2 years, 11 months ago
Patchew URL: https://patchew.org/QEMU/20210516195855.28869-1-agraf@csgraf.de/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210516195855.28869-1-agraf@csgraf.de
Subject: [PATCH v7 00/19] 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
   9b1e81d..6005ee0  master     -> master
 * [new tag]         patchew/20210516195855.28869-1-agraf@csgraf.de -> patchew/20210516195855.28869-1-agraf@csgraf.de
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Switched to a new branch 'test'
51b6048 hvf: arm: Handle Windows 10 SMC call
f23720b arm: Enable Windows 10 trusted SMCCC boot call
06e2184 arm: Add Hypervisor.framework build target
e5c9561 hvf: arm: Implement PSCI handling
d61ad07 hvf: arm: Implement -cpu host
22268ee arm/hvf: Add a WFI handler
d4bfd38 hvf: Add Apple Silicon support
2a57549 hvf: Simplify post reset/init/loadvm hooks
2169cd5 hvf: Introduce hvf vcpu struct
fb67de4 hvf: Remove hvf-accel-ops.h
a6dc95d hvf: Make synchronize functions static
26045be hvf: Use cpu_synchronize_state()
d888737 hvf: Split out common code on vcpu init and destroy
6742b0a hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t
bad87f2 hvf: Make hvf_set_phys_mem() static
37ba42a hvf: Move hvf internal definitions into common header
db1c2eb hvf: Move cpu functions into common directory
5e5ba4e hvf: Move vcpu thread functions into common directory
1501777 hvf: Move assert_hvf_ok() into common directory

=== OUTPUT BEGIN ===
1/19 Checking commit 1501777fce49 (hvf: Move assert_hvf_ok() into common directory)
2/19 Checking commit 5e5ba4e4171b (hvf: Move vcpu thread functions into common directory)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#17: 
 {target/i386 => accel}/hvf/hvf-accel-ops.c | 0

total: 0 errors, 1 warnings, 21 lines checked

Patch 2/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/19 Checking commit db1c2ebca7b9 (hvf: Move cpu functions into common directory)
4/19 Checking commit 37ba42a9217d (hvf: Move hvf internal definitions into common header)
5/19 Checking commit bad87f2351a2 (hvf: Make hvf_set_phys_mem() static)
6/19 Checking commit 6742b0a0e9a0 (hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t)
7/19 Checking commit d8887370f041 (hvf: Split out common code on vcpu init and destroy)
8/19 Checking commit 26045bee3b8a (hvf: Use cpu_synchronize_state())
9/19 Checking commit a6dc95d38d0b (hvf: Make synchronize functions static)
10/19 Checking commit fb67de47006a (hvf: Remove hvf-accel-ops.h)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#33: 
deleted file mode 100644

total: 0 errors, 1 warnings, 23 lines checked

Patch 10/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/19 Checking commit 2169cd5bfabb (hvf: Introduce hvf vcpu struct)
WARNING: line over 80 characters
#154: FILE: target/i386/hvf/hvf.c:263:
+    wvmcs(cpu->hvf->fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry,

ERROR: "(foo*)" should be "(foo *)"
#767: FILE: target/i386/hvf/x86hvf.c:83:
+    if (hv_vcpu_write_fpstate(cpu_state->hvf->fd, (void*)xsave, 4096)) {

ERROR: "(foo*)" should be "(foo *)"
#848: FILE: target/i386/hvf/x86hvf.c:165:
+    if (hv_vcpu_read_fpstate(cpu_state->hvf->fd, (void*)xsave, 4096)) {

total: 2 errors, 1 warnings, 1001 lines checked

Patch 11/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

12/19 Checking commit 2a575495eee5 (hvf: Simplify post reset/init/loadvm hooks)
13/19 Checking commit d4bfd3851069 (hvf: Add Apple Silicon support)
WARNING: architecture specific defines should be avoided
#56: FILE: accel/hvf/hvf-accel-ops.c:63:
+#ifdef __aarch64__

WARNING: architecture specific defines should be avoided
#67: FILE: accel/hvf/hvf-accel-ops.c:382:
+#ifdef __aarch64__

WARNING: architecture specific defines should be avoided
#101: FILE: include/sysemu/hvf_int.h:14:
+#ifdef __aarch64__

WARNING: line over 80 characters
#475: FILE: target/arm/hvf/hvf.c:331:
+        ret = hv_vcpu_set_simd_fp_reg(cpu->hvf->fd, hvf_fpreg_match[i].reg, fpval);

WARNING: line over 80 characters
#606: FILE: target/arm/hvf/hvf.c:462:
+static void hvf_raise_exception(CPUARMState *env, uint32_t excp, uint32_t syndrome)

ERROR: superfluous trailing semicolon
#609: FILE: target/arm/hvf/hvf.c:465:
+    unsigned int old_mode = pstate_read(env);;

WARNING: line over 80 characters
#668: FILE: target/arm/hvf/hvf.c:524:
+        hv_vcpu_set_pending_interrupt(cpu->hvf->fd, HV_INTERRUPT_TYPE_FIQ, true);

WARNING: line over 80 characters
#673: FILE: target/arm/hvf/hvf.c:529:
+        hv_vcpu_set_pending_interrupt(cpu->hvf->fd, HV_INTERRUPT_TYPE_IRQ, true);

ERROR: Hex numbers must be prefixed with '0x'
#855: FILE: target/arm/hvf/trace-events:6:
+hvf_sysreg_read(uint32_t reg, uint32_t op0, uint32_t op1, uint32_t crn, uint32_t crm, uint32_t op2, uint64_t val) "sysreg read 0x%08x (op0=%d op1=%d crn=%d crm=%d op2=%d) = %016"PRIx64

ERROR: Hex numbers must be prefixed with '0x'
#856: FILE: target/arm/hvf/trace-events:7:
+hvf_sysreg_write(uint32_t reg, uint32_t op0, uint32_t op1, uint32_t crn, uint32_t crm, uint32_t op2, uint64_t val) "sysreg write 0x%08x (op0=%d op1=%d crn=%d crm=%d op2=%d, val=%016"PRIx64")"

ERROR: Hex numbers must be prefixed with '0x'
#857: FILE: target/arm/hvf/trace-events:8:
+hvf_unknown_hvf(uint64_t x0) "unknown HVC! %016"PRIx64

ERROR: Hex numbers must be prefixed with '0x'
#858: FILE: target/arm/hvf/trace-events:9:
+hvf_unknown_smc(uint64_t x0) "unknown SMC! %016"PRIx64

total: 5 errors, 7 warnings, 792 lines checked

Patch 13/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

14/19 Checking commit 22268eef970e (arm/hvf: Add a WFI handler)
15/19 Checking commit d61ad072f45b (hvf: arm: Implement -cpu host)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#179: 
new file mode 100644

total: 0 errors, 1 warnings, 160 lines checked

Patch 15/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
16/19 Checking commit e5c95615d9ef (hvf: arm: Implement PSCI handling)
WARNING: line over 80 characters
#92: FILE: target/arm/hvf/hvf.c:584:
+    trace_hvf_psci_call(param[0], param[1], param[2], param[3], arm_cpu->mp_affinity);

WARNING: Block comments use a leading /* on a separate line
#123: FILE: target/arm/hvf/hvf.c:615:
+        /* QEMU reset and shutdown are async requests, but PSCI

ERROR: Hex numbers must be prefixed with '0x'
#214: FILE: target/arm/hvf/trace-events:11:
+hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=%016"PRIx64" x1=%016"PRIx64" x2=%016"PRIx64" x3=%016"PRIx64" cpu=%x"

total: 1 errors, 2 warnings, 171 lines checked

Patch 16/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

17/19 Checking commit 06e21844ac34 (arm: Add Hypervisor.framework build target)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#41: 
new file mode 100644

total: 0 errors, 1 warnings, 23 lines checked

Patch 17/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
18/19 Checking commit f23720b08e1c (arm: Enable Windows 10 trusted SMCCC boot call)
19/19 Checking commit 51b6048f8a96 (hvf: arm: Handle Windows 10 SMC call)
WARNING: line over 80 characters
#32: FILE: target/arm/hvf/hvf.c:932:
+            /* This special SMC is called by Windows 10 on boot. Return error. */

total: 0 errors, 1 warnings, 10 lines checked

Patch 19/19 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210516195855.28869-1-agraf@csgraf.de/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com