Skip to content

Commit d57bc3c

Browse files
agrafpm215
authored andcommitted
hvf: Move assert_hvf_ok() into common directory
Until 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 start moving common code out into its own accel directory. This patch moves assert_hvf_ok() and introduces generic build infrastructure. Signed-off-by: Alexander Graf <[email protected]> Reviewed-by: Sergio Lopez <[email protected]> Message-id: [email protected] Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
1 parent 3c93dfa commit d57bc3c

File tree

6 files changed

+81
-32
lines changed

6 files changed

+81
-32
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,15 @@ M: Roman Bolshakov <[email protected]>
436436
W: https://wiki.qemu.org/Features/HVF
437437
S: Maintained
438438
F: target/i386/hvf/
439+
440+
HVF
441+
M: Cameron Esfahani <[email protected]>
442+
M: Roman Bolshakov <[email protected]>
443+
W: https://wiki.qemu.org/Features/HVF
444+
S: Maintained
445+
F: accel/hvf/
439446
F: include/sysemu/hvf.h
447+
F: include/sysemu/hvf_int.h
440448

441449
WHPX CPUs
442450
M: Sunil Muthuswamy <[email protected]>

accel/hvf/hvf-all.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* QEMU Hypervisor.framework support
3+
*
4+
* This work is licensed under the terms of the GNU GPL, version 2. See
5+
* the COPYING file in the top-level directory.
6+
*
7+
* Contributions after 2012-01-13 are licensed under the terms of the
8+
* GNU GPL, version 2 or (at your option) any later version.
9+
*/
10+
11+
#include "qemu/osdep.h"
12+
#include "qemu-common.h"
13+
#include "qemu/error-report.h"
14+
#include "sysemu/hvf.h"
15+
#include "sysemu/hvf_int.h"
16+
17+
void assert_hvf_ok(hv_return_t ret)
18+
{
19+
if (ret == HV_SUCCESS) {
20+
return;
21+
}
22+
23+
switch (ret) {
24+
case HV_ERROR:
25+
error_report("Error: HV_ERROR");
26+
break;
27+
case HV_BUSY:
28+
error_report("Error: HV_BUSY");
29+
break;
30+
case HV_BAD_ARGUMENT:
31+
error_report("Error: HV_BAD_ARGUMENT");
32+
break;
33+
case HV_NO_RESOURCES:
34+
error_report("Error: HV_NO_RESOURCES");
35+
break;
36+
case HV_NO_DEVICE:
37+
error_report("Error: HV_NO_DEVICE");
38+
break;
39+
case HV_UNSUPPORTED:
40+
error_report("Error: HV_UNSUPPORTED");
41+
break;
42+
default:
43+
error_report("Unknown Error");
44+
}
45+
46+
abort();
47+
}

accel/hvf/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hvf_ss = ss.source_set()
2+
hvf_ss.add(files(
3+
'hvf-all.c',
4+
))
5+
6+
specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss)

accel/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ specific_ss.add(files('accel-common.c'))
22
softmmu_ss.add(files('accel-softmmu.c'))
33
user_ss.add(files('accel-user.c'))
44

5+
subdir('hvf')
56
subdir('qtest')
67
subdir('kvm')
78
subdir('tcg')

include/sysemu/hvf_int.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* QEMU Hypervisor.framework (HVF) support
3+
*
4+
* This work is licensed under the terms of the GNU GPL, version 2 or later.
5+
* See the COPYING file in the top-level directory.
6+
*
7+
*/
8+
9+
/* header to be included in HVF-specific code */
10+
11+
#ifndef HVF_INT_H
12+
#define HVF_INT_H
13+
14+
#include <Hypervisor/hv.h>
15+
16+
void assert_hvf_ok(hv_return_t ret);
17+
18+
#endif

target/i386/hvf/hvf.c

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "qemu/error-report.h"
5252

5353
#include "sysemu/hvf.h"
54+
#include "sysemu/hvf_int.h"
5455
#include "sysemu/runstate.h"
5556
#include "hvf-i386.h"
5657
#include "vmcs.h"
@@ -76,38 +77,6 @@
7677

7778
HVFState *hvf_state;
7879

79-
static void assert_hvf_ok(hv_return_t ret)
80-
{
81-
if (ret == HV_SUCCESS) {
82-
return;
83-
}
84-
85-
switch (ret) {
86-
case HV_ERROR:
87-
error_report("Error: HV_ERROR");
88-
break;
89-
case HV_BUSY:
90-
error_report("Error: HV_BUSY");
91-
break;
92-
case HV_BAD_ARGUMENT:
93-
error_report("Error: HV_BAD_ARGUMENT");
94-
break;
95-
case HV_NO_RESOURCES:
96-
error_report("Error: HV_NO_RESOURCES");
97-
break;
98-
case HV_NO_DEVICE:
99-
error_report("Error: HV_NO_DEVICE");
100-
break;
101-
case HV_UNSUPPORTED:
102-
error_report("Error: HV_UNSUPPORTED");
103-
break;
104-
default:
105-
error_report("Unknown Error");
106-
}
107-
108-
abort();
109-
}
110-
11180
/* Memory slots */
11281
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
11382
{

0 commit comments

Comments
 (0)