From patchwork Wed Mar 28 19:12:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Pilotti X-Patchwork-Id: 10313933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECD4B60212 for ; Wed, 28 Mar 2018 19:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE1D129566 for ; Wed, 28 Mar 2018 19:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2E202957D; Wed, 28 Mar 2018 19:13:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B2B729566 for ; Wed, 28 Mar 2018 19:13:51 +0000 (UTC) Received: from localhost ([::1]:40672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1GW6-00079s-CB for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Mar 2018 15:13:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1GVD-0006Eb-Na for qemu-devel@nongnu.org; Wed, 28 Mar 2018 15:12:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1GVC-0004WA-MC for qemu-devel@nongnu.org; Wed, 28 Mar 2018 15:12:55 -0400 Received: from smtp1.cloudbase.it ([46.107.15.2]:44659) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f1GVC-0004Vm-Do for qemu-devel@nongnu.org; Wed, 28 Mar 2018 15:12:54 -0400 Received: from localhost.localdomain (unknown [79.114.114.243]) by smtp1.cloudbase.it (Postfix) with ESMTPA id CF43050854; Wed, 28 Mar 2018 21:24:48 +0300 (EEST) From: Alessandro Pilotti To: qemu-devel@nongnu.org Date: Wed, 28 Mar 2018 22:12:21 +0300 Message-Id: <20180328191221.64777-2-apilotti@cloudbasesolutions.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20180328191221.64777-1-apilotti@cloudbasesolutions.com> References: <20180328191221.64777-1-apilotti@cloudbasesolutions.com> X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x [fuzzy] X-Received-From: 46.107.15.2 Subject: [Qemu-devel] [PATCH 1/1] WHPX Add signature CPUID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Alessandro Pilotti , juterry@microsoft.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include +#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,