mbox series

[v8,00/19] hvf: Implement Apple Silicon Support

Message ID 20210519202253.76782-1-agraf@csgraf.de (mailing list archive)
Headers show
Series hvf: Implement Apple Silicon Support | expand

Message

Alexander Graf May 19, 2021, 8:22 p.m. UTC
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)
  - missing GICv3 support


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

v7 -> v8:

  - checkpatch fixes
  - Do not advance for HVC, PC is already updated by hvf
    (fixes Linux boot)

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            | 962 ++++++++++++++++++++++++++++++++
 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, 1887 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

Comments

no-reply@patchew.org May 19, 2021, 8:45 p.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/20210519202253.76782-1-agraf@csgraf.de/



Hi,

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

Type: series
Message-id: 20210519202253.76782-1-agraf@csgraf.de
Subject: [PATCH v8 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
 - [tag update]      patchew/20210519165002.1195745-1-titusr@google.com -> patchew/20210519165002.1195745-1-titusr@google.com
 * [new tag]         patchew/20210519202253.76782-1-agraf@csgraf.de -> patchew/20210519202253.76782-1-agraf@csgraf.de
Switched to a new branch 'test'
a91491a hvf: arm: Handle Windows 10 SMC call
3dc7553 arm: Enable Windows 10 trusted SMCCC boot call
65e8115 arm: Add Hypervisor.framework build target
1cfa1d0 hvf: arm: Implement PSCI handling
63e0f6f hvf: arm: Implement -cpu host
3cf833e arm/hvf: Add a WFI handler
ca30893 hvf: Add Apple Silicon support
8a591bd hvf: Simplify post reset/init/loadvm hooks
0cd15e4 hvf: Introduce hvf vcpu struct
086f42d hvf: Remove hvf-accel-ops.h
63ca75b hvf: Make synchronize functions static
6a10390 hvf: Use cpu_synchronize_state()
b06558a hvf: Split out common code on vcpu init and destroy
de8ace6 hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t
f4b7940 hvf: Make hvf_set_phys_mem() static
83983fc hvf: Move hvf internal definitions into common header
e011dbb hvf: Move cpu functions into common directory
ac7d522 hvf: Move vcpu thread functions into common directory
72aa7ae hvf: Move assert_hvf_ok() into common directory

=== OUTPUT BEGIN ===
1/19 Checking commit 72aa7aeb05e7 (hvf: Move assert_hvf_ok() into common directory)
2/19 Checking commit ac7d522e0cae (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 e011dbb4cc58 (hvf: Move cpu functions into common directory)
4/19 Checking commit 83983fc96e4f (hvf: Move hvf internal definitions into common header)
5/19 Checking commit f4b79405bcc5 (hvf: Make hvf_set_phys_mem() static)
6/19 Checking commit de8ace6033f1 (hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t)
7/19 Checking commit b06558a826a4 (hvf: Split out common code on vcpu init and destroy)
8/19 Checking commit 6a103903f401 (hvf: Use cpu_synchronize_state())
9/19 Checking commit 63ca75b7c904 (hvf: Make synchronize functions static)
10/19 Checking commit 086f42de24b5 (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 0cd15e48075a (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 8a591bd4b86b (hvf: Simplify post reset/init/loadvm hooks)
13/19 Checking commit ca3089321cb9 (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__

total: 0 errors, 3 warnings, 796 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 3cf833ede182 (arm/hvf: Add a WFI handler)
15/19 Checking commit 63e0f6fb8c65 (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 1cfa1d082968 (hvf: arm: Implement PSCI handling)
WARNING: Block comments use a leading /* on a separate line
#124: FILE: target/arm/hvf/hvf.c:618:
+        /* QEMU reset and shutdown are async requests, but PSCI

total: 0 errors, 1 warnings, 170 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 65e81151cc57 (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 3dc7553180fb (arm: Enable Windows 10 trusted SMCCC boot call)
19/19 Checking commit a91491a61ffc (hvf: arm: Handle Windows 10 SMC call)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210519202253.76782-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
Peter Maydell June 3, 2021, 1:43 p.m. UTC | #2
On Wed, 19 May 2021 at 21:22, Alexander Graf <agraf@csgraf.de> wrote:
>
> 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)
>   - missing GICv3 support

> 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

I haven't had time to review the tail-end of this series yet,
I'm afraid, but these first 12 patches are clearly all OK, so
I'm going to put them into target-arm.next so that at least
that refactoring part is in master and won't go stale.

The last 7 patches are still on my todo list to review.

thanks
-- PMM
Alexander Graf June 3, 2021, 1:53 p.m. UTC | #3
> Am 03.06.2021 um 15:44 schrieb Peter Maydell <peter.maydell@linaro.org>:
> 
> On Wed, 19 May 2021 at 21:22, Alexander Graf <agraf@csgraf.de> wrote:
>> 
>> 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)
>>  - missing GICv3 support
> 
>> 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
> 
> I haven't had time to review the tail-end of this series yet,
> I'm afraid, but these first 12 patches are clearly all OK, so
> I'm going to put them into target-arm.next so that at least
> that refactoring part is in master and won't go stale.
> 
> The last 7 patches are still on my todo list to review.

Thank you ;)

Alex

> 
> thanks
> -- PMM
Peter Maydell June 15, 2021, 12:54 p.m. UTC | #4
On Thu, 3 Jun 2021 at 14:43, Peter Maydell <peter.maydell@linaro.org> wrote:
> I haven't had time to review the tail-end of this series yet,
> I'm afraid, but these first 12 patches are clearly all OK, so
> I'm going to put them into target-arm.next so that at least
> that refactoring part is in master and won't go stale.
>
> The last 7 patches are still on my todo list to review.

...and now I've gone through those last 7. Sorry for the delay.

-- PMM