From nobody Wed May 1 20:03:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522264459010766.7760335332988; Wed, 28 Mar 2018 12:14:19 -0700 (PDT) Received: from localhost ([::1]:40672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1GWR-00079s-Bv for importer@patchew.org; Wed, 28 Mar 2018 15:14:11 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =20 +#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 =3D 5; UINT64 rip, rax, rcx, rdx, rbx; + UINT32 signature[3] =3D {0}; =20 rip =3D vcpu->exit_ctx.VpContext.Rip + vcpu->exit_ctx.VpContext.InstructionLength; @@ -932,6 +935,13 @@ static int whpx_vcpu_run(CPUState *cpu) rdx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRdx; rbx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRbx; break; + case WHPX_CPUID_SIGNATURE: + memcpy(signature, "WHPXWHPXWHPX", 12); + rax =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRax; + rbx =3D signature[0]; + rcx =3D signature[1]; + rdx =3D signature[2]; + break; default: rax =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRax; rcx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRcx; @@ -1338,7 +1348,7 @@ static int whpx_accel_init(MachineState *ms) goto error; } =20 - UINT32 cpuidExitList[] =3D {1}; + UINT32 cpuidExitList[] =3D {1, WHPX_CPUID_SIGNATURE}; hr =3D WHvSetPartitionProperty(whpx->partition, WHvPartitionPropertyCodeCpuidExitList, cpuidExitList, --=20 2.13.2