[PATCH 0/8] hvf: Implement Apple Silicon Support

Alexander Graf posted 8 patches 3 years, 4 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201126215017.41156-1-agraf@csgraf.de
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Cameron Esfahani <dirty@apple.com>, Eduardo Habkost <ehabkost@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Alexander Graf <agraf@csgraf.de>, Roman Bolshakov <r.bolshakov@yadro.com>
There is a newer version of this series
MAINTAINERS                  |  14 +-
accel/hvf/entitlements.plist |   8 +
accel/hvf/hvf-all.c          |  56 ++++
accel/hvf/hvf-cpus.c         | 484 +++++++++++++++++++++++++++++++++++
accel/hvf/meson.build        |   7 +
accel/meson.build            |   1 +
hw/arm/virt.c                |   9 +
include/hw/core/cpu.h        |   3 +-
include/sysemu/hvf_int.h     |  69 +++++
meson.build                  |  39 ++-
scripts/entitlement.sh       |  11 +
target/arm/arm-powerctl.c    |   3 +
target/arm/cpu.c             |   4 +
target/arm/hvf/hvf.c         | 345 +++++++++++++++++++++++++
target/arm/hvf/meson.build   |   3 +
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   |  48 +---
target/i386/hvf/hvf.c        | 360 +-------------------------
target/i386/hvf/meson.build  |   1 -
target/i386/hvf/x86hvf.c     |  11 +-
target/i386/hvf/x86hvf.h     |   2 -
23 files changed, 1061 insertions(+), 575 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
[PATCH 0/8] hvf: Implement Apple Silicon Support
Posted by Alexander Graf 3 years, 4 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 rudimentary, first version to get the ball
going on that. With this applied, I can successfully run both Linux and
Windows as guests, albeit with a few caveats:

  * no WFI emulation, a vCPU always uses 100%
  * vtimer handling is a bit hacky
  * we handle most sysregs flying blindly, just returning 0
  * XHCI breaks in OVMF, works in Linux+Windows

Despite those drawbacks, it's still an exciting place to start playing
with the power of Apple Silicon.

Enjoy!

Alex

Alexander Graf (8):
  hvf: Add hypervisor entitlement to output binaries
  hvf: Move common code out
  arm: Set PSCI to 0.2 for HVF
  arm: Synchronize CPU on PSCI on
  hvf: Add Apple Silicon support
  hvf: Use OS provided vcpu kick function
  arm: Add Hypervisor.framework build target
  hw/arm/virt: Disable highmem when on hypervisor.framework

 MAINTAINERS                  |  14 +-
 accel/hvf/entitlements.plist |   8 +
 accel/hvf/hvf-all.c          |  56 ++++
 accel/hvf/hvf-cpus.c         | 484 +++++++++++++++++++++++++++++++++++
 accel/hvf/meson.build        |   7 +
 accel/meson.build            |   1 +
 hw/arm/virt.c                |   9 +
 include/hw/core/cpu.h        |   3 +-
 include/sysemu/hvf_int.h     |  69 +++++
 meson.build                  |  39 ++-
 scripts/entitlement.sh       |  11 +
 target/arm/arm-powerctl.c    |   3 +
 target/arm/cpu.c             |   4 +
 target/arm/hvf/hvf.c         | 345 +++++++++++++++++++++++++
 target/arm/hvf/meson.build   |   3 +
 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   |  48 +---
 target/i386/hvf/hvf.c        | 360 +-------------------------
 target/i386/hvf/meson.build  |   1 -
 target/i386/hvf/x86hvf.c     |  11 +-
 target/i386/hvf/x86hvf.h     |   2 -
 23 files changed, 1061 insertions(+), 575 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

-- 
2.24.3 (Apple Git-128)


Re: [PATCH 0/8] hvf: Implement Apple Silicon Support
Posted by Eduardo Habkost 3 years, 4 months ago
On Thu, Nov 26, 2020 at 10:50:09PM +0100, Alexander Graf 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 rudimentary, first version to get the ball
> going on that. With this applied, I can successfully run both Linux and
> Windows as guests, albeit with a few caveats:
> 
>   * no WFI emulation, a vCPU always uses 100%
>   * vtimer handling is a bit hacky
>   * we handle most sysregs flying blindly, just returning 0
>   * XHCI breaks in OVMF, works in Linux+Windows
> 
> Despite those drawbacks, it's still an exciting place to start playing
> with the power of Apple Silicon.
> 
> Enjoy!
> 
> Alex
> 
> Alexander Graf (8):
>   hvf: Add hypervisor entitlement to output binaries
>   hvf: Move common code out
>   arm: Set PSCI to 0.2 for HVF
>   arm: Synchronize CPU on PSCI on
>   hvf: Add Apple Silicon support
>   hvf: Use OS provided vcpu kick function
>   arm: Add Hypervisor.framework build target
>   hw/arm/virt: Disable highmem when on hypervisor.framework
> 
>  MAINTAINERS                  |  14 +-
>  accel/hvf/entitlements.plist |   8 +
>  accel/hvf/hvf-all.c          |  56 ++++
>  accel/hvf/hvf-cpus.c         | 484 +++++++++++++++++++++++++++++++++++
>  accel/hvf/meson.build        |   7 +
>  accel/meson.build            |   1 +

This seems to conflict with the accel cleanup work being done by
Claudio[1].  Maybe Claudio could cherry-pick some of the code
movement patches from this series, or this series could be
rebased on top of his.

[1] https://lore.kernel.org/qemu-devel/20201124162210.8796-1-cfontana@suse.de

>  hw/arm/virt.c                |   9 +
>  include/hw/core/cpu.h        |   3 +-
>  include/sysemu/hvf_int.h     |  69 +++++
>  meson.build                  |  39 ++-
>  scripts/entitlement.sh       |  11 +
>  target/arm/arm-powerctl.c    |   3 +
>  target/arm/cpu.c             |   4 +
>  target/arm/hvf/hvf.c         | 345 +++++++++++++++++++++++++
>  target/arm/hvf/meson.build   |   3 +
>  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   |  48 +---
>  target/i386/hvf/hvf.c        | 360 +-------------------------
>  target/i386/hvf/meson.build  |   1 -
>  target/i386/hvf/x86hvf.c     |  11 +-
>  target/i386/hvf/x86hvf.h     |   2 -
>  23 files changed, 1061 insertions(+), 575 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
> 
> -- 
> 2.24.3 (Apple Git-128)
> 

-- 
Eduardo


Re: [PATCH 0/8] hvf: Implement Apple Silicon Support
Posted by Philippe Mathieu-Daudé 3 years, 4 months ago
On 11/26/20 11:10 PM, Eduardo Habkost wrote:
> On Thu, Nov 26, 2020 at 10:50:09PM +0100, Alexander Graf 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 rudimentary, first version to get the ball
>> going on that. With this applied, I can successfully run both Linux and
>> Windows as guests, albeit with a few caveats:
>>
>>   * no WFI emulation, a vCPU always uses 100%
>>   * vtimer handling is a bit hacky
>>   * we handle most sysregs flying blindly, just returning 0
>>   * XHCI breaks in OVMF, works in Linux+Windows
>>
>> Despite those drawbacks, it's still an exciting place to start playing
>> with the power of Apple Silicon.
>>
>> Enjoy!
>>
>> Alex
>>
>> Alexander Graf (8):
>>   hvf: Add hypervisor entitlement to output binaries
>>   hvf: Move common code out
>>   arm: Set PSCI to 0.2 for HVF
>>   arm: Synchronize CPU on PSCI on
>>   hvf: Add Apple Silicon support
>>   hvf: Use OS provided vcpu kick function
>>   arm: Add Hypervisor.framework build target
>>   hw/arm/virt: Disable highmem when on hypervisor.framework
>>
>>  MAINTAINERS                  |  14 +-
>>  accel/hvf/entitlements.plist |   8 +
>>  accel/hvf/hvf-all.c          |  56 ++++
>>  accel/hvf/hvf-cpus.c         | 484 +++++++++++++++++++++++++++++++++++
>>  accel/hvf/meson.build        |   7 +
>>  accel/meson.build            |   1 +
> 
> This seems to conflict with the accel cleanup work being done by
> Claudio[1].  Maybe Claudio could cherry-pick some of the code
> movement patches from this series, or this series could be
> rebased on top of his.

It seems easier for Claudio to cherry-pick patch 2/8
of this series ("hvf: Move common code out") and rebase
on top.

Claudio's series is still tagged RFC, but if you were
planing to queue it, you could take patch 2/8 out of
this series, as it is generic, and let the HVF/AA64
specific bits still being discussed.

> 
> [1] https://lore.kernel.org/qemu-devel/20201124162210.8796-1-cfontana@suse.de