From patchwork Tue May 15 11:37:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucian Petrut X-Patchwork-Id: 913579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="njqoePdp"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40lbFh3ZRbz9s1B for ; Tue, 15 May 2018 21:39:36 +1000 (AEST) Received: from localhost ([::1]:32788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIYIo-00043q-3m for incoming@patchwork.ozlabs.org; Tue, 15 May 2018 07:39:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIYHg-0003p2-Mp for qemu-devel@nongnu.org; Tue, 15 May 2018 07:38:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIYH3-0007Y0-4m for qemu-devel@nongnu.org; Tue, 15 May 2018 07:38:24 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:41579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIYH2-0007Wm-FG for qemu-devel@nongnu.org; Tue, 15 May 2018 07:37:44 -0400 Received: by mail-wr0-x243.google.com with SMTP id g21-v6so15627879wrb.8 for ; Tue, 15 May 2018 04:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Gb7jjr1SlFTy8lMYwkNMyUJ7ByKDsYdM9YOVBTXmzbk=; b=njqoePdpuUToH+6mbGoL3OcyouXnksM09Rum41WD6hebgVSA9YEekdM3C90dxrRwts CEBVdEa/BqapilseFYjSbyPYexn/o1q26W0RmHP6ANXESERmJ2yDRkiRyWDny4PO6HGy ljgHPNqipdD5Kf2jZOqlLo6CeMo5FzCp21359++QhcSuIGvjffvVJNLvRmBhbebPQ7fS yNczDDkV6FKiqec1e69GSJ5FwangT6aWUpgH0B0hfYDQkcfqFcbYlmFoVr1Tn4PKO7lC o2VgCErJolVNzm3EKJi7OQtta1fdssF49/o6OJ6ePg+jNUqLFHO723UfkkWr3td044xu 4FTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Gb7jjr1SlFTy8lMYwkNMyUJ7ByKDsYdM9YOVBTXmzbk=; b=AwsM5Vx42eRjPU2O73qfQfrvHaFkvwAxlxh+7TjDfxc3+/ls32ZjFF/vdItMmVOO7l TybHxRJ78QbV8ay2ee1YIr2KNXdB80oJUEZx+/Ls/vww7zPRsgKhPrMoMZHqrb3mNfrm qVswPv+JMsNBI6h9EojuV2eEm9VdZhYcO2Zdol32tGSuTd57qOtYy876lCrtHZZpsey3 kSuARiS/ToVz2foZf79/YoFw2VihSphCoWmfRkLsUnWBxFam8ugO5dvYfTS/Dkac5cZS N8Kvt1uhgW00Il0sBCXAZhTcKgc6JToNP6sOYhMbBb8X8q2WkrWMrs/MIICt967c+rAf kg7w== X-Gm-Message-State: ALKqPwe1bC1FqrmoIShbSeJ4EWF1CuTi7r8ILoOrm43vSeo9tW9G/K9m vIPLniYuRmVr0y4Ue/tcCtQ= X-Google-Smtp-Source: AB8JxZp6YyO3F64JOZqbii4tmqC5N2JFce121He2iZuaH+vNSrusAaROQNKK+Kjvoh28rOMLAaircw== X-Received: by 2002:adf:80cd:: with SMTP id 71-v6mr10131360wrl.238.1526384263063; Tue, 15 May 2018 04:37:43 -0700 (PDT) Received: from DESKTOP-OQ1TBVC.localdomain ([89.46.161.178]) by smtp.gmail.com with ESMTPSA id q7-v6sm14937464wrf.49.2018.05.15.04.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 May 2018 04:37:42 -0700 (PDT) From: petrutlucian94@gmail.com X-Google-Original-From: lpetrut@cloudbasesolutions.com To: Date: Tue, 15 May 2018 14:37:38 +0300 Message-Id: <1526384258-3581-1-git-send-email-lpetrut@cloudbasesolutions.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH] 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: Lucian Petrut , Eduardo Habkost , "open list:All patches CC here" , Alessandro Pilotti , Justin Terry , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Lucian Petrut 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 Signed-off-by: Justin Terry (VM) Signed-off-by: Lucian Petrut --- As opposed to the previous patch, this one will set the result of this specific CPUID leaf when initializing the accelerator so that we avoid a vcpu exit. target/i386/whpx-all.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c index 5843517..c8310de 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; @@ -1342,6 +1344,27 @@ static int whpx_accel_init(MachineState *ms) cpuidExitList, RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); + UINT32 signature[3] = {0}; + memcpy(signature, "WHPXWHPXWHPX", 12); + + WHV_X64_CPUID_RESULT cpuidResultList[1] = {0}; + cpuidResultList[0].Function = WHPX_CPUID_SIGNATURE; + cpuidResultList[0].Eax = 0; + cpuidResultList[0].Ebx = signature[0]; + cpuidResultList[0].Ecx = signature[1]; + cpuidResultList[0].Edx = signature[2]; + hr = WHvSetPartitionProperty(whpx->partition, + WHvPartitionPropertyCodeCpuidResultList, + cpuidResultList, + RTL_NUMBER_OF(cpuidResultList) * + sizeof(WHV_X64_CPUID_RESULT)); + if (FAILED(hr)) { + error_report("WHPX: Failed to set partition CpuidResultList hr=%08lx", + hr); + ret = -EINVAL; + goto error; + } + if (FAILED(hr)) { error_report("WHPX: Failed to set partition CpuidExitList hr=%08lx", hr);