* [kvm-unit-tests PATCH 0/2] Add support of hvf accel
@ 2020-03-20 14:55 Roman Bolshakov
2020-03-20 14:55 ` [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing " Roman Bolshakov
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Roman Bolshakov @ 2020-03-20 14:55 UTC (permalink / raw)
To: kvm; +Cc: Cameron Esfahani, Roman Bolshakov
HVF is a para-virtualized QEMU accelerator for macOS based on Hypervisor.framework (HVF). Hypervisor.framework is a thin user-space wrapper around Intel VT/VMX that enables to run VMMs such as QEMU in non-privileged mode. The unit tests can be run on macOS to verify completeness of the HVF accel implementation.
Roman Bolshakov (2):
scripts/arch-run: Support testing of hvf accel
README: Document steps to run the tests on macOS
README.macOS.md | 47 +++++++++++++++++++++++++++++++++++++++++++
README.md | 6 ++++--
scripts/arch-run.bash | 13 ++++++++++++
3 files changed, 64 insertions(+), 2 deletions(-)
create mode 100644 README.macOS.md
--
2.24.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing of hvf accel
2020-03-20 14:55 [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
@ 2020-03-20 14:55 ` Roman Bolshakov
2020-03-23 22:16 ` Cameron Esfahani
2020-03-20 14:55 ` [kvm-unit-tests PATCH 2/2] README: Document steps to run the tests on macOS Roman Bolshakov
2020-03-20 15:37 ` [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
2 siblings, 1 reply; 7+ messages in thread
From: Roman Bolshakov @ 2020-03-20 14:55 UTC (permalink / raw)
To: kvm; +Cc: Cameron Esfahani, Roman Bolshakov
The tests can be run if Hypervisor.framework API is available:
https://developer.apple.com/documentation/hypervisor?language=objc#1676667
Cc: Cameron Esfahani <dirty@apple.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
scripts/arch-run.bash | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index d3ca19d..197ae6c 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -315,17 +315,30 @@ kvm_available ()
( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
}
+hvf_available ()
+{
+ [ "$(sysctl -n kern.hv_support 2>/dev/null)" = "1" ] || return 1
+ [ "$HOST" = "$ARCH_NAME" ] ||
+ ( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
+}
+
get_qemu_accelerator ()
{
if [ "$ACCEL" = "kvm" ] && ! kvm_available; then
echo "KVM is needed, but not available on this host" >&2
return 2
fi
+ if [ "$ACCEL" = "hvf" ] && ! hvf_available; then
+ echo "HVF is needed, but not available on this host" >&2
+ return 2
+ fi
if [ "$ACCEL" ]; then
echo $ACCEL
elif kvm_available; then
echo kvm
+ elif hvf_available; then
+ echo hvf
else
echo tcg
fi
--
2.24.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [kvm-unit-tests PATCH 2/2] README: Document steps to run the tests on macOS
2020-03-20 14:55 [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
2020-03-20 14:55 ` [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing " Roman Bolshakov
@ 2020-03-20 14:55 ` Roman Bolshakov
2020-03-23 22:17 ` Cameron Esfahani
2020-03-20 15:37 ` [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
2 siblings, 1 reply; 7+ messages in thread
From: Roman Bolshakov @ 2020-03-20 14:55 UTC (permalink / raw)
To: kvm; +Cc: Cameron Esfahani, Roman Bolshakov
While at it, mention that hvf is a valid accel parameter.
Cc: Cameron Esfahani <dirty@apple.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
README.macOS.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++
README.md | 6 ++++--
2 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 README.macOS.md
diff --git a/README.macOS.md b/README.macOS.md
new file mode 100644
index 0000000..de46d5f
--- /dev/null
+++ b/README.macOS.md
@@ -0,0 +1,47 @@
+# kvm-unit-tests on macOS
+
+Cross-compiler with ELF support is required for build of kvm-unit-tests on
+macOS.
+
+## Building cross-compiler from source
+
+A cross-compiler toolchain can be built from source using crosstool-ng. The
+latest released version of
+[crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) can be installed
+using [homebrew](https://brew.sh)
+```
+$ brew install crosstool-ng
+```
+
+A case-sensitive APFS/HFS+ volume has to be created using Disk Utility as a
+build and installation directory for the cross-compiler. Please [see Apple
+documentation](https://support.apple.com/guide/disk-utility/dsku19ed921c/mac)
+for details.
+
+Assuming the case-sensitive volume is named /Volumes/BuildTools, the
+cross-compiler can be built and installed there:
+```
+$ X_BUILD_DIR=/Volumes/BuildTools/ct-ng-build
+$ X_INSTALL_DIR=/Volumes/BuildTools/x-tools
+$ mkdir $X_BUILD_DIR
+$ ct-ng -C $X_BUILD_DIR x86_64-unknown-linux-gnu
+$ ct-ng -C $X_BUILD_DIR build CT_PREFIX=$X_INSTALL_DIR
+```
+
+Once compiled, the cross-compiler can be used to build the tests:
+```
+$ ./configure --cross-prefix=$X_INSTALL_DIR/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-
+$ make
+```
+
+## Pre-built cross-compiler
+
+x86_64-elf-gcc package in Homebrew provides pre-built cross-compiler but it
+fails to compile kvm-unit-tests.
+
+## Running the tests
+
+GNU coreutils should be installed prior to running the tests:
+```
+$ brew install coreutils
+```
diff --git a/README.md b/README.md
index 396fbf8..48be206 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,8 @@ To create the test images do:
in this directory. Test images are created in ./ARCH/\*.flat
+NOTE: GCC cross-compiler is required for [build on macOS](README.macOS.md).
+
## Standalone tests
The tests can be built as standalone. To create and use standalone tests do:
@@ -47,7 +49,7 @@ environment variable:
QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
-To select an accelerator, for example "kvm" or "tcg", specify the
+To select an accelerator, for example "kvm", "hvf" or "tcg", specify the
ACCEL=name environment variable:
ACCEL=kvm ./x86-run ./x86/msr.flat
@@ -78,7 +80,7 @@ which can then be accessed in the usual ways, e.g. VAL = getenv("KEY").
Any key=val strings can be passed, but some have reserved meanings in
the framework. The list of reserved environment variables is below
- QEMU_ACCEL either kvm or tcg
+ QEMU_ACCEL either kvm, hvf or tcg
QEMU_VERSION_STRING string of the form `qemu -h | head -1`
KERNEL_VERSION_STRING string of the form `uname -r`
--
2.24.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [kvm-unit-tests PATCH 0/2] Add support of hvf accel
2020-03-20 14:55 [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
2020-03-20 14:55 ` [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing " Roman Bolshakov
2020-03-20 14:55 ` [kvm-unit-tests PATCH 2/2] README: Document steps to run the tests on macOS Roman Bolshakov
@ 2020-03-20 15:37 ` Roman Bolshakov
2020-03-23 22:18 ` Cameron Esfahani
2 siblings, 1 reply; 7+ messages in thread
From: Roman Bolshakov @ 2020-03-20 15:37 UTC (permalink / raw)
To: kvm; +Cc: Cameron Esfahani
I'm sorry for broken formating in the cover letter. Here's a reformat at
your convenience.
HVF is a para-virtualized QEMU accelerator for macOS based on
Hypervisor.framework (HVF). Hypervisor.framework is a thin user-space
wrapper around Intel VT/VMX that enables to run VMMs such as QEMU in
non-privileged mode.
The unit tests can be run on macOS to verify completeness of the HVF
accel implementation.
Regards,
Roman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing of hvf accel
2020-03-20 14:55 ` [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing " Roman Bolshakov
@ 2020-03-23 22:16 ` Cameron Esfahani
0 siblings, 0 replies; 7+ messages in thread
From: Cameron Esfahani @ 2020-03-23 22:16 UTC (permalink / raw)
To: Roman Bolshakov; +Cc: kvm
Reviewed-by: Cameron Esfahani <dirty@apple.com>
Cameron Esfahani
dirty@apple.com
"The cake is a lie."
Common wisdom
> On Mar 20, 2020, at 7:55 AM, Roman Bolshakov <r.bolshakov@yadro.com> wrote:
>
> The tests can be run if Hypervisor.framework API is available:
>
> https://developer.apple.com/documentation/hypervisor?language=objc#1676667
>
> Cc: Cameron Esfahani <dirty@apple.com>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
> scripts/arch-run.bash | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index d3ca19d..197ae6c 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -315,17 +315,30 @@ kvm_available ()
> ( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
> }
>
> +hvf_available ()
> +{
> + [ "$(sysctl -n kern.hv_support 2>/dev/null)" = "1" ] || return 1
> + [ "$HOST" = "$ARCH_NAME" ] ||
> + ( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
> +}
> +
> get_qemu_accelerator ()
> {
> if [ "$ACCEL" = "kvm" ] && ! kvm_available; then
> echo "KVM is needed, but not available on this host" >&2
> return 2
> fi
> + if [ "$ACCEL" = "hvf" ] && ! hvf_available; then
> + echo "HVF is needed, but not available on this host" >&2
> + return 2
> + fi
>
> if [ "$ACCEL" ]; then
> echo $ACCEL
> elif kvm_available; then
> echo kvm
> + elif hvf_available; then
> + echo hvf
> else
> echo tcg
> fi
> --
> 2.24.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [kvm-unit-tests PATCH 2/2] README: Document steps to run the tests on macOS
2020-03-20 14:55 ` [kvm-unit-tests PATCH 2/2] README: Document steps to run the tests on macOS Roman Bolshakov
@ 2020-03-23 22:17 ` Cameron Esfahani
0 siblings, 0 replies; 7+ messages in thread
From: Cameron Esfahani @ 2020-03-23 22:17 UTC (permalink / raw)
To: Roman Bolshakov; +Cc: kvm
Reviewed-by: Cameron Esfahani <dirty@apple.com>
Cameron Esfahani
dirty@apple.com
"We do what we must because we can."
Aperture Science
> On Mar 20, 2020, at 7:55 AM, Roman Bolshakov <r.bolshakov@yadro.com> wrote:
>
> While at it, mention that hvf is a valid accel parameter.
>
> Cc: Cameron Esfahani <dirty@apple.com>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
> README.macOS.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> README.md | 6 ++++--
> 2 files changed, 51 insertions(+), 2 deletions(-)
> create mode 100644 README.macOS.md
>
> diff --git a/README.macOS.md b/README.macOS.md
> new file mode 100644
> index 0000000..de46d5f
> --- /dev/null
> +++ b/README.macOS.md
> @@ -0,0 +1,47 @@
> +# kvm-unit-tests on macOS
> +
> +Cross-compiler with ELF support is required for build of kvm-unit-tests on
> +macOS.
> +
> +## Building cross-compiler from source
> +
> +A cross-compiler toolchain can be built from source using crosstool-ng. The
> +latest released version of
> +[crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) can be installed
> +using [homebrew](https://brew.sh)
> +```
> +$ brew install crosstool-ng
> +```
> +
> +A case-sensitive APFS/HFS+ volume has to be created using Disk Utility as a
> +build and installation directory for the cross-compiler. Please [see Apple
> +documentation](https://support.apple.com/guide/disk-utility/dsku19ed921c/mac)
> +for details.
> +
> +Assuming the case-sensitive volume is named /Volumes/BuildTools, the
> +cross-compiler can be built and installed there:
> +```
> +$ X_BUILD_DIR=/Volumes/BuildTools/ct-ng-build
> +$ X_INSTALL_DIR=/Volumes/BuildTools/x-tools
> +$ mkdir $X_BUILD_DIR
> +$ ct-ng -C $X_BUILD_DIR x86_64-unknown-linux-gnu
> +$ ct-ng -C $X_BUILD_DIR build CT_PREFIX=$X_INSTALL_DIR
> +```
> +
> +Once compiled, the cross-compiler can be used to build the tests:
> +```
> +$ ./configure --cross-prefix=$X_INSTALL_DIR/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-
> +$ make
> +```
> +
> +## Pre-built cross-compiler
> +
> +x86_64-elf-gcc package in Homebrew provides pre-built cross-compiler but it
> +fails to compile kvm-unit-tests.
> +
> +## Running the tests
> +
> +GNU coreutils should be installed prior to running the tests:
> +```
> +$ brew install coreutils
> +```
> diff --git a/README.md b/README.md
> index 396fbf8..48be206 100644
> --- a/README.md
> +++ b/README.md
> @@ -15,6 +15,8 @@ To create the test images do:
>
> in this directory. Test images are created in ./ARCH/\*.flat
>
> +NOTE: GCC cross-compiler is required for [build on macOS](README.macOS.md).
> +
> ## Standalone tests
>
> The tests can be built as standalone. To create and use standalone tests do:
> @@ -47,7 +49,7 @@ environment variable:
>
> QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
>
> -To select an accelerator, for example "kvm" or "tcg", specify the
> +To select an accelerator, for example "kvm", "hvf" or "tcg", specify the
> ACCEL=name environment variable:
>
> ACCEL=kvm ./x86-run ./x86/msr.flat
> @@ -78,7 +80,7 @@ which can then be accessed in the usual ways, e.g. VAL = getenv("KEY").
> Any key=val strings can be passed, but some have reserved meanings in
> the framework. The list of reserved environment variables is below
>
> - QEMU_ACCEL either kvm or tcg
> + QEMU_ACCEL either kvm, hvf or tcg
> QEMU_VERSION_STRING string of the form `qemu -h | head -1`
> KERNEL_VERSION_STRING string of the form `uname -r`
>
> --
> 2.24.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [kvm-unit-tests PATCH 0/2] Add support of hvf accel
2020-03-20 15:37 ` [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
@ 2020-03-23 22:18 ` Cameron Esfahani
0 siblings, 0 replies; 7+ messages in thread
From: Cameron Esfahani @ 2020-03-23 22:18 UTC (permalink / raw)
To: Roman Bolshakov; +Cc: kvm
The first sentence doesn't make much sense. HVF is not QEMU specific. Other VMMs use it.
Cameron Esfahani
dirty@apple.com
"The cake is a lie."
Common wisdom
> On Mar 20, 2020, at 8:37 AM, Roman Bolshakov <r.bolshakov@yadro.com> wrote:
>
> I'm sorry for broken formating in the cover letter. Here's a reformat at
> your convenience.
>
> HVF is a para-virtualized QEMU accelerator for macOS based on
> Hypervisor.framework (HVF). Hypervisor.framework is a thin user-space
> wrapper around Intel VT/VMX that enables to run VMMs such as QEMU in
> non-privileged mode.
>
> The unit tests can be run on macOS to verify completeness of the HVF
> accel implementation.
>
> Regards,
> Roman
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-03-24 20:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 14:55 [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
2020-03-20 14:55 ` [kvm-unit-tests PATCH 1/2] scripts/arch-run: Support testing " Roman Bolshakov
2020-03-23 22:16 ` Cameron Esfahani
2020-03-20 14:55 ` [kvm-unit-tests PATCH 2/2] README: Document steps to run the tests on macOS Roman Bolshakov
2020-03-23 22:17 ` Cameron Esfahani
2020-03-20 15:37 ` [kvm-unit-tests PATCH 0/2] Add support of hvf accel Roman Bolshakov
2020-03-23 22:18 ` Cameron Esfahani
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.