All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessandro Pilotti <apilotti@cloudbasesolutions.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, juterry@microsoft.com,
	Alessandro Pilotti <apilotti@cloudbasesolutions.com>
Subject: [Qemu-devel] [PATCH 1/1] WHPX Add signature CPUID
Date: Wed, 28 Mar 2018 22:12:21 +0300	[thread overview]
Message-ID: <20180328191221.64777-2-apilotti@cloudbasesolutions.com> (raw)
In-Reply-To: <20180328191221.64777-1-apilotti@cloudbasesolutions.com>

Adds the CPUID trap for CPUID 0x40000000, sending the WHPX signature
to the guest upon request. This is consistent with other QEMU
accelerators (KVM).

Signed-off-by: Alessandro Pilotti <apilotti@cloudbasesolutions.com>
---
 target/i386/whpx-all.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
index efa1441479..4085002428 100644
--- a/target/i386/whpx-all.c
+++ b/target/i386/whpx-all.c
@@ -29,6 +29,8 @@
 #include <WinHvPlatform.h>
 #include <WinHvEmulation.h>
 
+#define WHPX_CPUID_SIGNATURE 0x40000000
+
 struct whpx_state {
     uint64_t mem_quota;
     WHV_PARTITION_HANDLE partition;
@@ -918,6 +920,7 @@ static int whpx_vcpu_run(CPUState *cpu)
             WHV_REGISTER_NAME reg_names[5];
             UINT32 reg_count = 5;
             UINT64 rip, rax, rcx, rdx, rbx;
+            UINT32 signature[3] = {0};
 
             rip = vcpu->exit_ctx.VpContext.Rip +
                   vcpu->exit_ctx.VpContext.InstructionLength;
@@ -932,6 +935,13 @@ static int whpx_vcpu_run(CPUState *cpu)
                     rdx = vcpu->exit_ctx.CpuidAccess.DefaultResultRdx;
                     rbx = vcpu->exit_ctx.CpuidAccess.DefaultResultRbx;
                     break;
+                case WHPX_CPUID_SIGNATURE:
+                    memcpy(signature, "WHPXWHPXWHPX", 12);
+                    rax = vcpu->exit_ctx.CpuidAccess.DefaultResultRax;
+                    rbx = signature[0];
+                    rcx = signature[1];
+                    rdx = signature[2];
+                    break;
                 default:
                     rax = vcpu->exit_ctx.CpuidAccess.DefaultResultRax;
                     rcx = vcpu->exit_ctx.CpuidAccess.DefaultResultRcx;
@@ -1338,7 +1348,7 @@ static int whpx_accel_init(MachineState *ms)
         goto error;
     }
 
-    UINT32 cpuidExitList[] = {1};
+    UINT32 cpuidExitList[] = {1, WHPX_CPUID_SIGNATURE};
     hr = WHvSetPartitionProperty(whpx->partition,
                                  WHvPartitionPropertyCodeCpuidExitList,
                                  cpuidExitList,
-- 
2.13.2

      reply	other threads:[~2018-03-28 19:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 19:12 [Qemu-devel] [PATCH 0/1] WHPX Add signature CPUID Alessandro Pilotti
2018-03-28 19:12 ` Alessandro Pilotti [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180328191221.64777-2-apilotti@cloudbasesolutions.com \
    --to=apilotti@cloudbasesolutions.com \
    --cc=juterry@microsoft.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.