aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-05-07 06:14:15 -0500
committerRichard Henderson <richard.henderson@linaro.org>2022-05-07 06:14:16 -0500
commitf1336649156cf57f5d874a98e619fb362e3fcb59 (patch)
treeddbb191913b6fe8e867f1045285a7624d9591cbb /target
parent11314643c35401b18c5374f4ec82ee7d3d5d2692 (diff)
parent6033b9ecd4f6a26b78f44a94813e1e464f5b0549 (diff)
downloadqemu-f1336649156cf57f5d874a98e619fb362e3fcb59.zip
qemu-f1336649156cf57f5d874a98e619fb362e3fcb59.tar.gz
qemu-f1336649156cf57f5d874a98e619fb362e3fcb59.tar.bz2
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* WHPX support for xcr0 * qga-wss fixes * Meson conversions * Removed -soundhw pcspk # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmJ2CEcUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroMHUAgAq6BXpuqyAMMnrylvt77qwGG37keV # lxw8aGciztUJIZFi1dAxIuw2ohsFGdfxKKt1sEIUu33OSBeb1I786f2xuLF7t7Am # An0Jd5I/V/9ClRrz2ITiLOCBzPTU3faY8h382OdnMJCkAFjjF5PIoECZWRBtjPVq # B4jDKuredgCt4EGDViQr0R5om+bBdHQmHcPHTNIv3UsRu2RhzIieBy4qLBUADIMU # wJeW0jIdtfE9gwfdjtdom1tDxxKNtYttyIAQY8SpSEGLHzpqfNW0Z3UFGcswIk8g # QCJpsddJzKivvS3a8pm/3tKkSWmqcgGNH2b3CFEZ26MkkLZIOYiVmPGNqQ== # =7/z9 # -----END PGP SIGNATURE----- # gpg: Signature made Sat 07 May 2022 12:48:55 AM CDT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [undefined] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (25 commits) pc: remove -soundhw pcspk configure, meson: move vhost options to Meson meson: use have_vhost_* variables to pick sources meson: create have_vhost_* variables build: move vhost-user-fs configuration to Kconfig build: move vhost-scsi configuration to Kconfig build: move vhost-vsock configuration to Kconfig configure: simplify vhost-net-{user, vdpa} configuration meson, virtio: place all virtio-pci devices under virtio_pci_ss configure: omit options with default values from meson command line meson: pass more options directly as -D configure: switch directory options to automatic parsing meson: always combine directories with prefix meson, configure: move --interp-prefix to meson meson, configure: move --with-pkgversion, CONFIG_STAMP to meson meson, configure: move bdrv whitelists to meson meson, configure: move --tls-priority to meson configure: switch string options to automatic parsing configure: move Windows flags detection to meson configure, meson: move iasl detection to meson ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'target')
-rw-r--r--target/i386/whpx/whpx-all.c87
-rw-r--r--target/i386/whpx/whpx-internal.h3
2 files changed, 90 insertions, 0 deletions
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b625ad5..23ae639 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -246,9 +246,15 @@ static bool whpx_allowed;
static bool whp_dispatch_initialized;
static HMODULE hWinHvPlatform, hWinHvEmulation;
static uint32_t max_vcpu_index;
+static WHV_PROCESSOR_XSAVE_FEATURES whpx_xsave_cap;
+
struct whpx_state whpx_global;
struct WHPDispatch whp_dispatch;
+static bool whpx_has_xsave(void)
+{
+ return whpx_xsave_cap.XsaveSupport;
+}
/*
* VP support
@@ -300,6 +306,28 @@ static SegmentCache whpx_seg_h2q(const WHV_X64_SEGMENT_REGISTER *hs)
return qs;
}
+/* X64 Extended Control Registers */
+static void whpx_set_xcrs(CPUState *cpu)
+{
+ CPUX86State *env = cpu->env_ptr;
+ HRESULT hr;
+ struct whpx_state *whpx = &whpx_global;
+ WHV_REGISTER_VALUE xcr0;
+ WHV_REGISTER_NAME xcr0_name = WHvX64RegisterXCr0;
+
+ if (!whpx_has_xsave()) {
+ return;
+ }
+
+ /* Only xcr0 is supported by the hypervisor currently */
+ xcr0.Reg64 = env->xcr0;
+ hr = whp_dispatch.WHvSetVirtualProcessorRegisters(
+ whpx->partition, cpu->cpu_index, &xcr0_name, 1, &xcr0);
+ if (FAILED(hr)) {
+ error_report("WHPX: Failed to set register xcr0, hr=%08lx", hr);
+ }
+}
+
static int whpx_set_tsc(CPUState *cpu)
{
CPUX86State *env = cpu->env_ptr;
@@ -435,6 +463,12 @@ static void whpx_set_registers(CPUState *cpu, int level)
/* 8 Debug Registers - Skipped */
+ /*
+ * Extended control registers needs to be handled separately depending
+ * on whether xsave is supported/enabled or not.
+ */
+ whpx_set_xcrs(cpu);
+
/* 16 XMM registers */
assert(whpx_register_names[idx] == WHvX64RegisterXmm0);
idx_next = idx + 16;
@@ -541,6 +575,30 @@ static int whpx_get_tsc(CPUState *cpu)
return 0;
}
+/* X64 Extended Control Registers */
+static void whpx_get_xcrs(CPUState *cpu)
+{
+ CPUX86State *env = cpu->env_ptr;
+ HRESULT hr;
+ struct whpx_state *whpx = &whpx_global;
+ WHV_REGISTER_VALUE xcr0;
+ WHV_REGISTER_NAME xcr0_name = WHvX64RegisterXCr0;
+
+ if (!whpx_has_xsave()) {
+ return;
+ }
+
+ /* Only xcr0 is supported by the hypervisor currently */
+ hr = whp_dispatch.WHvGetVirtualProcessorRegisters(
+ whpx->partition, cpu->cpu_index, &xcr0_name, 1, &xcr0);
+ if (FAILED(hr)) {
+ error_report("WHPX: Failed to get register xcr0, hr=%08lx", hr);
+ return;
+ }
+
+ env->xcr0 = xcr0.Reg64;
+}
+
static void whpx_get_registers(CPUState *cpu)
{
struct whpx_state *whpx = &whpx_global;
@@ -634,6 +692,12 @@ static void whpx_get_registers(CPUState *cpu)
/* 8 Debug Registers - Skipped */
+ /*
+ * Extended control registers needs to be handled separately depending
+ * on whether xsave is supported/enabled or not.
+ */
+ whpx_get_xcrs(cpu);
+
/* 16 XMM registers */
assert(whpx_register_names[idx] == WHvX64RegisterXmm0);
idx_next = idx + 16;
@@ -2513,6 +2577,29 @@ static int whpx_accel_init(MachineState *ms)
goto error;
}
+ /*
+ * Query the XSAVE capability of the partition. Any error here is not
+ * considered fatal.
+ */
+ hr = whp_dispatch.WHvGetPartitionProperty(
+ whpx->partition,
+ WHvPartitionPropertyCodeProcessorXsaveFeatures,
+ &whpx_xsave_cap,
+ sizeof(whpx_xsave_cap),
+ &whpx_cap_size);
+
+ /*
+ * Windows version which don't support this property will return with the
+ * specific error code.
+ */
+ if (FAILED(hr) && hr != WHV_E_UNKNOWN_PROPERTY) {
+ error_report("WHPX: Failed to query XSAVE capability, hr=%08lx", hr);
+ }
+
+ if (!whpx_has_xsave()) {
+ printf("WHPX: Partition is not XSAVE capable\n");
+ }
+
memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
prop.ProcessorCount = ms->smp.cpus;
hr = whp_dispatch.WHvSetPartitionProperty(
diff --git a/target/i386/whpx/whpx-internal.h b/target/i386/whpx/whpx-internal.h
index 2416ec7..dbb7e7b 100644
--- a/target/i386/whpx/whpx-internal.h
+++ b/target/i386/whpx/whpx-internal.h
@@ -48,6 +48,9 @@ void whpx_apic_get(DeviceState *s);
#define WHV_E_UNKNOWN_CAPABILITY 0x80370300L
+/* This should eventually come from the Windows SDK */
+#define WHV_E_UNKNOWN_PROPERTY 0x80370302
+
#define LIST_WINHVPLATFORM_FUNCTIONS(X) \
X(HRESULT, WHvGetCapability, (WHV_CAPABILITY_CODE CapabilityCode, VOID* CapabilityBuffer, UINT32 CapabilityBufferSizeInBytes, UINT32* WrittenSizeInBytes)) \
X(HRESULT, WHvCreatePartition, (WHV_PARTITION_HANDLE* Partition)) \