All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110
@ 2018-03-14 14:52 Justin Terry (VM)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 1/3] WHPX fix WHvGetCapability out WrittenSizeInBytes Justin Terry (VM)
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Justin Terry (VM) @ 2018-03-14 14:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, rth, ehabkost, Justin Terry (VM)

This change set fixes two breaking changes that were introduced in the
Windows Insider SDK 17110. First, a change to the WHvGetCapability function
decl to include the 'out' WrittenSizeInBytes. Second, changes to the
WHvSetPartitionProperty function decl and WHV_PARTITION_PROPERTY structure
to directly pass the PropertyCode at invocation.

Lastly, it introduces a major performance improvement in whpx_vcpu_post_run
using the VpContext exit structure rather than another round trip call to
WHvGetVirtualProcessorRegisters to synchronize vp state.

QEMU compiled against this SDK (17110+) is expected to work on all Windows
Insider Builds (17115+).

Thanks,
Justin Terry

Justin Terry (VM) (3):
  WHPX fix WHvGetCapability out WrittenSizeInBytes
  WHPX fix WHvSetPartitionProperty in PropertyCode
  WHPX improve vcpu_post_run perf

 configure              |  4 +++-
 target/i386/whpx-all.c | 46 ++++++++++++++--------------------------------
 2 files changed, 17 insertions(+), 33 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/3] WHPX fix WHvGetCapability out WrittenSizeInBytes
  2018-03-14 14:52 [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Justin Terry (VM)
@ 2018-03-14 14:52 ` Justin Terry (VM)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 2/3] WHPX fix WHvSetPartitionProperty in PropertyCode Justin Terry (VM)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Justin Terry (VM) @ 2018-03-14 14:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, rth, ehabkost, Justin Terry (VM)

This fixes a breaking change to WHvGetCapability to include the 'out'
WrittenSizeInBytes introduced in Windows Insider SDK 17110.

This specifies on return the safe length to read into the WHV_CAPABILITY
structure passed to the call.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
---
 configure              | 4 +++-
 target/i386/whpx-all.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index af72fc852e..1ad153cdfb 100755
--- a/configure
+++ b/configure
@@ -2491,7 +2491,9 @@ if test "$whpx" != "no" ; then
 #include <WinHvEmulation.h>
 int main(void) {
     WHV_CAPABILITY whpx_cap;
-    WHvGetCapability(WHvCapabilityCodeFeatures, &whpx_cap, sizeof(whpx_cap));
+    UINT32 writtenSize;
+    WHvGetCapability(WHvCapabilityCodeFeatures, &whpx_cap, sizeof(whpx_cap),
+                     &writtenSize);
     return 0;
 }
 EOF
diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
index 940bbe590d..2080d58c4c 100644
--- a/target/i386/whpx-all.c
+++ b/target/i386/whpx-all.c
@@ -1254,6 +1254,7 @@ static int whpx_accel_init(MachineState *ms)
     int ret;
     HRESULT hr;
     WHV_CAPABILITY whpx_cap;
+    UINT32 whpx_cap_size;
     WHV_PARTITION_PROPERTY prop;
 
     whpx = &whpx_global;
@@ -1262,7 +1263,7 @@ static int whpx_accel_init(MachineState *ms)
     whpx->mem_quota = ms->ram_size;
 
     hr = WHvGetCapability(WHvCapabilityCodeHypervisorPresent, &whpx_cap,
-                          sizeof(whpx_cap));
+                          sizeof(whpx_cap), &whpx_cap_size);
     if (FAILED(hr) || !whpx_cap.HypervisorPresent) {
         error_report("WHPX: No accelerator found, hr=%08lx", hr);
         ret = -ENOSPC;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/3] WHPX fix WHvSetPartitionProperty in PropertyCode
  2018-03-14 14:52 [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Justin Terry (VM)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 1/3] WHPX fix WHvGetCapability out WrittenSizeInBytes Justin Terry (VM)
@ 2018-03-14 14:52 ` Justin Terry (VM)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 3/3] WHPX improve vcpu_post_run perf Justin Terry (VM)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Justin Terry (VM) @ 2018-03-14 14:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, rth, ehabkost, Justin Terry (VM)

This fixes a breaking change to WHvSetPartitionProperty to pass the 'in'
PropertyCode on function invocation introduced in Windows Insider SDK 17110.
Usage of this indicates the PropertyCode of the opaque PropertyBuffer passed in
on function invocation.

Also fixes the removal of the PropertyCode parameter from the
WHV_PARTITION_PROPERTY struct as it is now passed to the function directly.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
---
 target/i386/whpx-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
index 2080d58c4c..63e6e1b6f2 100644
--- a/target/i386/whpx-all.c
+++ b/target/i386/whpx-all.c
@@ -1278,9 +1278,9 @@ static int whpx_accel_init(MachineState *ms)
     }
 
     memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
-    prop.PropertyCode = WHvPartitionPropertyCodeProcessorCount;
     prop.ProcessorCount = smp_cpus;
     hr = WHvSetPartitionProperty(whpx->partition,
+                                 WHvPartitionPropertyCodeProcessorCount,
                                  &prop,
                                  sizeof(WHV_PARTITION_PROPERTY));
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/3] WHPX improve vcpu_post_run perf
  2018-03-14 14:52 [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Justin Terry (VM)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 1/3] WHPX fix WHvGetCapability out WrittenSizeInBytes Justin Terry (VM)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 2/3] WHPX fix WHvSetPartitionProperty in PropertyCode Justin Terry (VM)
@ 2018-03-14 14:52 ` Justin Terry (VM)
  2018-03-14 16:13 ` [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Paolo Bonzini
  2019-01-17 20:37 ` Stefan Weil
  4 siblings, 0 replies; 8+ messages in thread
From: Justin Terry (VM) @ 2018-03-14 14:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, rth, ehabkost, Justin Terry (VM)

This removes the additional call to WHvGetVirtualProcessorRegisters in
whpx_vcpu_post_run now that the WHV_VP_EXIT_CONTEXT is returned in all
WHV_RUN_VP_EXIT_CONTEXT structures.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
---
 target/i386/whpx-all.c | 41 +++++++++++------------------------------
 1 file changed, 11 insertions(+), 30 deletions(-)

diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
index 63e6e1b6f2..63f2b68910 100644
--- a/target/i386/whpx-all.c
+++ b/target/i386/whpx-all.c
@@ -153,7 +153,7 @@ struct whpx_vcpu {
     bool interruptable;
     uint64_t tpr;
     uint64_t apic_base;
-    WHV_X64_PENDING_INTERRUPTION_REGISTER interrupt_in_flight;
+    bool interruption_pending;
 
     /* Must be the last field as it may have a tail */
     WHV_RUN_VP_EXIT_CONTEXT exit_ctx;
@@ -695,7 +695,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu)
     qemu_mutex_lock_iothread();
 
     /* Inject NMI */
-    if (!vcpu->interrupt_in_flight.InterruptionPending &&
+    if (!vcpu->interruption_pending &&
         cpu->interrupt_request & (CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) {
         if (cpu->interrupt_request & CPU_INTERRUPT_NMI) {
             cpu->interrupt_request &= ~CPU_INTERRUPT_NMI;
@@ -724,7 +724,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu)
     }
 
     /* Get pending hard interruption or replay one that was overwritten */
-    if (!vcpu->interrupt_in_flight.InterruptionPending &&
+    if (!vcpu->interruption_pending &&
         vcpu->interruptable && (env->eflags & IF_MASK)) {
         assert(!new_int.InterruptionPending);
         if (cpu->interrupt_request & CPU_INTERRUPT_HARD) {
@@ -781,44 +781,25 @@ static void whpx_vcpu_pre_run(CPUState *cpu)
 
 static void whpx_vcpu_post_run(CPUState *cpu)
 {
-    HRESULT hr;
-    struct whpx_state *whpx = &whpx_global;
     struct whpx_vcpu *vcpu = get_whpx_vcpu(cpu);
     struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr);
     X86CPU *x86_cpu = X86_CPU(cpu);
-    WHV_REGISTER_VALUE reg_values[4];
-    const WHV_REGISTER_NAME reg_names[4] = {
-        WHvX64RegisterRflags,
-        WHvX64RegisterCr8,
-        WHvRegisterPendingInterruption,
-        WHvRegisterInterruptState,
-    };
 
-    hr = WHvGetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index,
-                                         reg_names, 4, reg_values);
-    if (FAILED(hr)) {
-        error_report("WHPX: Failed to get interrupt state regusters,"
-                     " hr=%08lx", hr);
-        vcpu->interruptable = false;
-        return;
-    }
+    env->eflags = vcpu->exit_ctx.VpContext.Rflags;
 
-    assert(reg_names[0] == WHvX64RegisterRflags);
-    env->eflags = reg_values[0].Reg64;
-
-    assert(reg_names[1] == WHvX64RegisterCr8);
-    if (vcpu->tpr != reg_values[1].Reg64) {
-        vcpu->tpr = reg_values[1].Reg64;
+    uint64_t tpr = vcpu->exit_ctx.VpContext.Cr8;
+    if (vcpu->tpr != tpr) {
+        vcpu->tpr = tpr;
         qemu_mutex_lock_iothread();
         cpu_set_apic_tpr(x86_cpu->apic_state, vcpu->tpr);
         qemu_mutex_unlock_iothread();
     }
 
-    assert(reg_names[2] == WHvRegisterPendingInterruption);
-    vcpu->interrupt_in_flight = reg_values[2].PendingInterruption;
+    vcpu->interruption_pending =
+        vcpu->exit_ctx.VpContext.ExecutionState.InterruptionPending;
 
-    assert(reg_names[3] == WHvRegisterInterruptState);
-    vcpu->interruptable = !reg_values[3].InterruptState.InterruptShadow;
+    vcpu->interruptable =
+        !vcpu->exit_ctx.VpContext.ExecutionState.InterruptShadow;
 
     return;
 }
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110
  2018-03-14 14:52 [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Justin Terry (VM)
                   ` (2 preceding siblings ...)
  2018-03-14 14:52 ` [Qemu-devel] [PATCH 3/3] WHPX improve vcpu_post_run perf Justin Terry (VM)
@ 2018-03-14 16:13 ` Paolo Bonzini
  2019-01-17 20:37 ` Stefan Weil
  4 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2018-03-14 16:13 UTC (permalink / raw)
  To: Justin Terry (VM), qemu-devel; +Cc: rth, ehabkost

On 14/03/2018 15:52, Justin Terry (VM) wrote:
> This change set fixes two breaking changes that were introduced in the
> Windows Insider SDK 17110. First, a change to the WHvGetCapability function
> decl to include the 'out' WrittenSizeInBytes. Second, changes to the
> WHvSetPartitionProperty function decl and WHV_PARTITION_PROPERTY structure
> to directly pass the PropertyCode at invocation.
> 
> Lastly, it introduces a major performance improvement in whpx_vcpu_post_run
> using the VpContext exit structure rather than another round trip call to
> WHvGetVirtualProcessorRegisters to synchronize vp state.
> 
> QEMU compiled against this SDK (17110+) is expected to work on all Windows
> Insider Builds (17115+).
> 
> Thanks,
> Justin Terry
> 
> Justin Terry (VM) (3):
>   WHPX fix WHvGetCapability out WrittenSizeInBytes
>   WHPX fix WHvSetPartitionProperty in PropertyCode
>   WHPX improve vcpu_post_run perf
> 
>  configure              |  4 +++-
>  target/i386/whpx-all.c | 46 ++++++++++++++--------------------------------
>  2 files changed, 17 insertions(+), 33 deletions(-)
> 

Queued, thanks.

Paolo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110
  2018-03-14 14:52 [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Justin Terry (VM)
                   ` (3 preceding siblings ...)
  2018-03-14 16:13 ` [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Paolo Bonzini
@ 2019-01-17 20:37 ` Stefan Weil
  2019-01-23 20:18   ` Justin Terry (VM)
  2019-01-24 16:56   ` Frank Yang
  4 siblings, 2 replies; 8+ messages in thread
From: Stefan Weil @ 2019-01-17 20:37 UTC (permalink / raw)
  To: Justin Terry (VM), qemu-devel; +Cc: pbonzini, ehabkost, rth

Am 14.03.2018 um 15:52 schrieb Justin Terry (VM) via Qemu-devel:
> This change set fixes two breaking changes that were introduced in the
> Windows Insider SDK 17110. First, a change to the WHvGetCapability function
> decl to include the 'out' WrittenSizeInBytes. Second, changes to the
> WHvSetPartitionProperty function decl and WHV_PARTITION_PROPERTY structure
> to directly pass the PropertyCode at invocation.
> 
> Lastly, it introduces a major performance improvement in whpx_vcpu_post_run
> using the VpContext exit structure rather than another round trip call to
> WHvGetVirtualProcessorRegisters to synchronize vp state.
> 
> QEMU compiled against this SDK (17110+) is expected to work on all Windows
> Insider Builds (17115+).
> 
> Thanks,
> Justin Terry


Hi Justin,

as far as I know it still not possible to cross build a legal QEMU for
Windows on a Linux machine due to the license limitations of the SDK
which is needed. The header files needed for the QEMU build are "All
rights reserved".

People often ask me to add WHPX support to the QEMU installer for
Windows, but I have to tell them that I cannot do that currently.

This problem could be solved if the necessary header files were added to
QEMU with a permissive license by someone who has the rights to do so.

Could you add WinHvEmulation.h and WinHvPlatform.h or am I allowed to
make such files from the documentation at https://docs.microsoft.com/?

Thanks,
Stefan Weil

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110
  2019-01-17 20:37 ` Stefan Weil
@ 2019-01-23 20:18   ` Justin Terry (VM)
  2019-01-24 16:56   ` Frank Yang
  1 sibling, 0 replies; 8+ messages in thread
From: Justin Terry (VM) @ 2019-01-23 20:18 UTC (permalink / raw)
  To: Stefan Weil, qemu-devel; +Cc: pbonzini, ehabkost, rth

Hey Stefan,

Not trying to ignore you here. I have reached out to members of management on our side I just don’t have any responses yet on what we can do here. Will update as I learn more.

Thanks,
Justin Terry

> -----Original Message-----
> From: Stefan Weil <sw@weilnetz.de>
> Sent: Thursday, January 17, 2019 12:38 PM
> To: Justin Terry (VM) <juterry@microsoft.com>; qemu-devel@nongnu.org
> Cc: pbonzini@redhat.com; ehabkost@redhat.com; rth@twiddle.net
> Subject: Re: [Qemu-devel] [PATCH 0/3] WHPX introduce changes for
> Windows Insider SDK 17110
> 
> Am 14.03.2018 um 15:52 schrieb Justin Terry (VM) via Qemu-devel:
> > This change set fixes two breaking changes that were introduced in the
> > Windows Insider SDK 17110. First, a change to the WHvGetCapability
> > function decl to include the 'out' WrittenSizeInBytes. Second, changes
> > to the WHvSetPartitionProperty function decl and
> > WHV_PARTITION_PROPERTY structure to directly pass the PropertyCode at
> invocation.
> >
> > Lastly, it introduces a major performance improvement in
> > whpx_vcpu_post_run using the VpContext exit structure rather than
> > another round trip call to WHvGetVirtualProcessorRegisters to synchronize
> vp state.
> >
> > QEMU compiled against this SDK (17110+) is expected to work on all
> > Windows Insider Builds (17115+).
> >
> > Thanks,
> > Justin Terry
> 
> 
> Hi Justin,
> 
> as far as I know it still not possible to cross build a legal QEMU for Windows
> on a Linux machine due to the license limitations of the SDK which is needed.
> The header files needed for the QEMU build are "All rights reserved".
> 
> People often ask me to add WHPX support to the QEMU installer for
> Windows, but I have to tell them that I cannot do that currently.
> 
> This problem could be solved if the necessary header files were added to
> QEMU with a permissive license by someone who has the rights to do so.
> 
> Could you add WinHvEmulation.h and WinHvPlatform.h or am I allowed to
> make such files from the documentation at
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs
> .microsoft.com%2F&amp;data=02%7C01%7Cjuterry%40microsoft.com%7Cae
> d2532cd05b4f2a5a0208d67cbba58f%7C72f988bf86f141af91ab2d7cd011db47%
> 7C1%7C0%7C636833542719466921&amp;sdata=%2FA7Kjkx5fnjMVnqezdmqi
> wgCZAFwoaNe2oCA%2BSdPbuo%3D&amp;reserved=0?
> 
> Thanks,
> Stefan Weil

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110
  2019-01-17 20:37 ` Stefan Weil
  2019-01-23 20:18   ` Justin Terry (VM)
@ 2019-01-24 16:56   ` Frank Yang
  1 sibling, 0 replies; 8+ messages in thread
From: Frank Yang @ 2019-01-24 16:56 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Justin Terry (VM), qemu-devel, Paolo Bonzini, ehabkost, rth

Is this useful at all for the Android Emulator? Does it break backward
compatibility for older Windows versions?

On Thu, Jan 17, 2019 at 12:39 PM Stefan Weil <sw@weilnetz.de> wrote:

> Am 14.03.2018 um 15:52 schrieb Justin Terry (VM) via Qemu-devel:
> > This change set fixes two breaking changes that were introduced in the
> > Windows Insider SDK 17110. First, a change to the WHvGetCapability
> function
> > decl to include the 'out' WrittenSizeInBytes. Second, changes to the
> > WHvSetPartitionProperty function decl and WHV_PARTITION_PROPERTY
> structure
> > to directly pass the PropertyCode at invocation.
> >
> > Lastly, it introduces a major performance improvement in
> whpx_vcpu_post_run
> > using the VpContext exit structure rather than another round trip call to
> > WHvGetVirtualProcessorRegisters to synchronize vp state.
> >
> > QEMU compiled against this SDK (17110+) is expected to work on all
> Windows
> > Insider Builds (17115+).
> >
> > Thanks,
> > Justin Terry
>
>
> Hi Justin,
>
> as far as I know it still not possible to cross build a legal QEMU for
> Windows on a Linux machine due to the license limitations of the SDK
> which is needed. The header files needed for the QEMU build are "All
> rights reserved".
>
> People often ask me to add WHPX support to the QEMU installer for
> Windows, but I have to tell them that I cannot do that currently.
>
> This problem could be solved if the necessary header files were added to
> QEMU with a permissive license by someone who has the rights to do so.
>
> Could you add WinHvEmulation.h and WinHvPlatform.h or am I allowed to
> make such files from the documentation at https://docs.microsoft.com/?
>
> Thanks,
> Stefan Weil
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-24 16:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 14:52 [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Justin Terry (VM)
2018-03-14 14:52 ` [Qemu-devel] [PATCH 1/3] WHPX fix WHvGetCapability out WrittenSizeInBytes Justin Terry (VM)
2018-03-14 14:52 ` [Qemu-devel] [PATCH 2/3] WHPX fix WHvSetPartitionProperty in PropertyCode Justin Terry (VM)
2018-03-14 14:52 ` [Qemu-devel] [PATCH 3/3] WHPX improve vcpu_post_run perf Justin Terry (VM)
2018-03-14 16:13 ` [Qemu-devel] [PATCH 0/3] WHPX introduce changes for Windows Insider SDK 17110 Paolo Bonzini
2019-01-17 20:37 ` Stefan Weil
2019-01-23 20:18   ` Justin Terry (VM)
2019-01-24 16:56   ` Frank Yang

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.