From patchwork Wed Mar 14 14:52:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev\" via" X-Patchwork-Id: 10282363 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 DD6A060211 for ; Wed, 14 Mar 2018 14:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6E1C289B9 for ; Wed, 14 Mar 2018 14:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAF9C289BC; Wed, 14 Mar 2018 14:54:29 +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.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 30B84289BA for ; Wed, 14 Mar 2018 14:54:28 +0000 (UTC) Received: from localhost ([::1]:46652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ew7nP-00043l-EU for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Mar 2018 10:54:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ew7mI-0002fR-KO for qemu-devel@nongnu.org; Wed, 14 Mar 2018 10:53:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ew7mE-0001As-WA for qemu-devel@nongnu.org; Wed, 14 Mar 2018 10:53:18 -0400 Received: from mail-co1nam03on0105.outbound.protection.outlook.com ([104.47.40.105]:27552 helo=NAM03-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ew7mE-00018f-M5 for qemu-devel@nongnu.org; Wed, 14 Mar 2018 10:53:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=R4PltNolInWw1oOSqOJmn+T9zjLXkJIcnHzuhNpsjE8=; b=QyP3f1VYC/rWZQ+ViD013qI624xP6k1rVSbCNT4Y1zx6EA2hUKQyQkrE9NRsP4xRsSBSuT5ZTjKhtWTmYynq4N5XJkq9z2wuakuINzEqaP0oBxxp9wNlkMfzK8N3IErkEWixZzpX8mx5dCZDDUvU5wEkJSFlaIJ3Vij3u6VfZ0E= Received: from DESKTOP-CS4P60I.corp.microsoft.com (2001:4898:80e8:d::573) by DM5PR21MB0171.namprd21.prod.outlook.com (2603:10b6:3:a5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.2; Wed, 14 Mar 2018 14:53:11 +0000 To: qemu-devel@nongnu.org Date: Wed, 14 Mar 2018 07:52:43 -0700 Message-Id: <1521039163-138-4-git-send-email-juterry@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521039163-138-1-git-send-email-juterry@microsoft.com> References: <1521039163-138-1-git-send-email-juterry@microsoft.com> MIME-Version: 1.0 X-Originating-IP: [2001:4898:80e8:d::573] X-ClientProxiedBy: SN2PR01CA0002.prod.exchangelabs.com (2603:10b6:804:2::12) To DM5PR21MB0171.namprd21.prod.outlook.com (2603:10b6:3:a5::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 34a54c0d-f087-4b3d-8a5f-08d589bb4f18 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR21MB0171; X-Microsoft-Exchange-Diagnostics: 1; DM5PR21MB0171; 3:+iBC1ySCpgPpIShZEd1gkSVkgiqCY0dRoKGoD+2o028pEhrIddbF8ZBb/CoKVWZDdvhn+gKWOGFs10JZu9m6ixcPVQeby6+E7PN+LOPbJqvMeMdXUcLBKjWLZqn/g4x6uk44RNZ7nYbxrVoo2GAJq3ZhCEznZvWtLgWa1yPsKCMvPDnq5Ekpy+UcsmxP+rAMjxvrf2tJeJ3bzejxfItMk7FCls3BbmmKYY23gN5cF8FcCXmLR3ab4FD7UWzAGC3/; 25:LNrpm8ueoggHegr8Pw4j7lPgBe8SopyDcdEQlri4fn07j2lOZ/58wAyMAGvA3eLVELxOy+JGe516pkZcGvolSkKcuUsRJJfvgrfGcHpypZMRLoCcr0Zvea3kFGwB2+QBfy2maSgduxc1PiD5o0F72UyMa8XTNGYx/rKot/vjYb8Pb0YT9NZJ4vNtzzJq7wD6e8Lnso8gWm5E7fmQjm55KZVCc2kI7HsoFd/Bx5/1houIU6XcPG1DKny3ZlDpAC8lxM+hFCqhcHGpTdcVY7FI9n/KbKmpvcMYTeUR4K3BhBxgzZXmuCNCqo032ATjD9muNG6l6E2uQX6MWErd3wtnqQ==; 31:l7IaCvMC+PRo55HREztKHHJc4k03vjRD5SP67xD+8716G6Pqjz+gH4DJIbr4S0aST76r+0WXdZvmV66KYEZcUyZmwAY/pDs4tso+5dOvyYdHixYNHJMpHMbd2FFrhmLITu2kMlMnkRucAvBOefflKLiTHKf2LX3ct/SpT9gq/WaJplWUv5BHXhKvNk/TlYjyNKVmn35n2+a0aGLdWKt8Ugs1/6/VveWt7F1H/udYwbw= X-MS-TrafficTypeDiagnostic: DM5PR21MB0171: X-Microsoft-Exchange-Diagnostics: 1; DM5PR21MB0171; 20:KoUDaClJR+KZcqRys+Hsu0YMivPIieetL94EPVfXTWeS7A91p5savhcT51vm3o6DI3ZBVu6nsaqu8QH2nkkuv9NJ8Aeold/+X5n5sz/m21YIzQNg/tJqsZ6L5w/NvF6R+pVnNQlCHRJGc47yB2lJcXqCnvBgRQSHXFmU0KjSf5vAYPw6j5pEsEpULUhLyqolk8GQb3kkbXyyK7f6qOKHlB3TaZFYMMBVH1DRzXPrGthEcbjr02dVEPQ+XueiYuoYHZcIR9wNCwvWrgZOL2nub7BMi9l6NmMKJ0suoytxLEBlwaG5TLJGZ4jr6NpJdzWRzUAbJSiG1xmAbAGCZRaFnDK7+nyX2i1sh90SKAYRS+hDobj5usvremr83gaOJOvfhiVi2m9+PdTxKoVbUdzatw4IC+EMNPKxLrolCJM8typQCHCkOFYsnMHuVk5HJdsyuj1RD0DbSBjjEwg62UAxBHbtjQU3Go4T6plZcry+uBTUHR00Hj9s5zeA3VVGkbmn; 4:w1u9n9yIJyMw2HnasEHdLqXLuIJHKDK3bPuIYqGldM82npCidBBJa/ibJOHjtjvmqvXTNs9LbwAat5TfQdstq1q34z1a18UjSiQHuIIwikLXX7JZCMWnnWYn5KUAHWN92AM71FMa/dgi2zxnAGuYCqvWcpTiZyjCiv8RtSSm9UhEWTDpsJiKiprjAKZs4XucgEhAccuoo27JtqRPB8rlqCHsd01XoA6zpf8GDstLEpPU3nWExBBMQRJntbIAUdAZ5dB0MLdciHtO5BPnhesfNXF0StiYtqXSsWeRlqgXI8f6YtmoNUkDGEEdJ11NJ1tfTl7PM7EAKvJPCanajyRIeN3HKsr3rqz5Oj8KGBUQVuE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(28532068793085)(89211679590171); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231221)(944501260)(52105095)(6055026)(61426038)(61427038)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR21MB0171; BCL:0; PCL:0; RULEID:; SRVR:DM5PR21MB0171; X-Forefront-PRVS: 0611A21987 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39860400002)(346002)(366004)(376002)(39380400002)(396003)(189003)(199004)(36756003)(2906002)(22452003)(59450400001)(25786009)(16526019)(46003)(52396003)(16586007)(316002)(86362001)(51416003)(6346003)(8676002)(6486002)(186003)(7696005)(8936002)(52116002)(50226002)(5660300001)(10090500001)(305945005)(386003)(53936002)(105586002)(76176011)(81156014)(81166006)(10290500003)(6116002)(7736002)(68736007)(2351001)(106356001)(2361001)(107886003)(47776003)(4326008)(2950100002)(6666003)(6916009)(478600001)(48376002)(86612001)(97736004)(50466002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR21MB0171; H:DESKTOP-CS4P60I.corp.microsoft.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=juterry@microsoft.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR21MB0171; 23:3xZmA2ZycINy8359Y+DPFE4GQKzIYVexjWHmHoO3A?= =?us-ascii?Q?lfnO0o8mDJjtiT2bu3ziad6aeDbeGS2TkqNnhd8Jz1GoGTYeEveiPXscFVi5?= =?us-ascii?Q?gnXVFpS5z5nE1sOnTDO6qOAjPVPF12j0b1TXaHdtREX4eBKrrYX4YWpEJbC/?= =?us-ascii?Q?F3SxkBJirUwOt1sp5M4vUqqRKWvNvTb9RCbK1wLpbDx9zZAfaqYBF53y4uxP?= =?us-ascii?Q?UAqVKjLplrSlcSdenG4UEBzNoD/wJKHTuTtvbDF+/HBeXOILtmHY6qUG9s0q?= =?us-ascii?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gobHe9bTEzJxYpnIXgROnzlVhRta7BYuU0Jm5aSE3ZNO/QvgBKnD4BPjuB4ZB3uzucVOWOqC3gxZgNIz0m0Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR21MB0171; 7:R3W9cn0wK/UFECR1n/jMCBVOUOytpZpy8EzdoBh8xF1NlfA5Va00PseeLF7m4ESQS9gkYhWx3t3GW0VOXoXVWpk9tRphRir85dc/0MbM79vSdCteoPqljwCggg64wfOJsiVG4Kfy+5RdCmqIy/CVeo9h3TSc6v7ANWD+3cRIgXCQbiNqRx3ZJSsz/ZxEjgmfFq5zK84vh9nt7LiBU0MSbxjSUAZZTMNE7jTrj/6Uo5emWSWH5GxZBIQvrnwUUCpO; 20:fKOJlzmZmsSX/1nqJ7VIONgJFObAj5RG/b0DjsuIjlWIs6qJIMjQul3jwkW5I4pDl5BEXS3Zx0PA6ZzdNY/Y/6Vqe9Y16p5amAxDQmXhgIPwdeyf61lRowEjmGEosoJD4NjD60pAW59c7u+BbY2EHuTCKQto4yEtuntXu58d/TM= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2018 14:53:11.6456 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34a54c0d-f087-4b3d-8a5f-08d589bb4f18 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR21MB0171 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.40.105 Subject: [Qemu-devel] [PATCH 3/3] WHPX improve vcpu_post_run perf 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: , X-Patchwork-Original-From: "Justin Terry \(VM\) via Qemu-devel" From: "Denis V. Lunev\" via" Reply-To: "Justin Terry \(VM\)" Cc: pbonzini@redhat.com, "Justin Terry \(VM\)" , ehabkost@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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) --- 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; }