From patchwork Mon Sep 4 08:14:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 9936803 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 B37D9601EB for ; Mon, 4 Sep 2017 08:17:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F53D28781 for ; Mon, 4 Sep 2017 08:17:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9257A2877D; Mon, 4 Sep 2017 08:17:50 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5FC0428781 for ; Mon, 4 Sep 2017 08:17:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1domXK-0006lt-Lt; Mon, 04 Sep 2017 08:15:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1domXI-0006k6-Un for xen-devel@lists.xen.org; Mon, 04 Sep 2017 08:15:13 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 3F/23-01916-F8B0DA95; Mon, 04 Sep 2017 08:15:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42JxWrrBXrefe22 kwYkH0hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aK9yfZCt6LVGzdfYutgfGBQBcjB4eEgL/E ohviXYycHGwCehIbZ79iArFFBGQlVnfNYQexmQU+MUk0HHMEKRcWMJc4M8cVxGQRUJH43qkPU sErYCux7916RhBbQkBeYlfbRVYQm1PATuLs6jdgcSGgmp7Fh5khbFWJ1y92sUD0CkqcnPmEBW KThMTBFy+YJzDyzkKSmoUktYCRaRWjenFqUVlqka6hXlJRZnpGSW5iZo6uoYGxXm5qcXFiemp OYlKxXnJ+7iZGYNAwAMEOxuUfnQ4xSnIwKYny3n+8JlKILyk/pTIjsTgjvqg0J7X4EKMMB4eS BO9BrrWRQoJFqempFWmZOcDwhUlLcPAoifDKgaR5iwsSc4sz0yFSpxgVpcR53UASAiCJjNI8u DZYzFxilJUS5mUEOkSIpyC1KDezBFX+FaM4B6OSMK8dyBSezLwSuOmvgBYzAS2uerkGZHFJIk JKqoHxkoO1uP7LwjfSbVq2cybt9Z4QNr3rcq/Xj2z7yB0Pvf8eXXc+dqPeiea0iW45cp2pvwL UEiV9vmq1TE1JuHT9+LauKUJLVq+6NUtBZp/jw+My3eHXLvNP2VooaJT/6elcm+/pD68+129d tnpy3pQnB9/6F9vbn7d3u71Bf//Nyk8nF02aKHWuRImlOCPRUIu5qDgRAEAIOpWUAgAA X-Env-Sender: prvs=413848043=sergey.dyasli@citrix.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1504512909!57475412!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7603 invoked from network); 4 Sep 2017 08:15:11 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 4 Sep 2017 08:15:11 -0000 X-IronPort-AV: E=Sophos;i="5.41,473,1498521600"; d="scan'208";a="446424744" From: Sergey Dyasli To: Date: Mon, 4 Sep 2017 09:14:44 +0100 Message-ID: <20170904081452.12960-7-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170904081452.12960-1-sergey.dyasli@citrix.com> References: <20170904081452.12960-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Cc: Sergey Dyasli , Kevin Tian , Jun Nakajima , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Boris Ostrovsky , Suravee Suthikulpanit Subject: [Xen-devel] [PATCH v1 06/14] x86/np2m: add stale_np2m flag X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The new element will indicate if update of a shadow p2m_base is needed prior to vmentry. Update is required if a nested vcpu gets a new np2m or if its np2m was flushed by an IPI. Add nvcpu_flush() helper function. Signed-off-by: Sergey Dyasli --- xen/arch/x86/hvm/nestedhvm.c | 2 ++ xen/arch/x86/mm/p2m.c | 10 ++++++++-- xen/include/asm-x86/hvm/vcpu.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c index 32b8acca6a..5b012568c4 100644 --- a/xen/arch/x86/hvm/nestedhvm.c +++ b/xen/arch/x86/hvm/nestedhvm.c @@ -57,6 +57,7 @@ nestedhvm_vcpu_reset(struct vcpu *v) nv->nv_flushp2m = 0; nv->nv_p2m = NULL; nv->np2m_generation = 0; + nv->stale_np2m = false; hvm_asid_flush_vcpu_asid(&nv->nv_n2asid); @@ -108,6 +109,7 @@ nestedhvm_flushtlb_ipi(void *info) */ hvm_asid_flush_core(); vcpu_nestedhvm(v).nv_p2m = NULL; + vcpu_nestedhvm(v).stale_np2m = true; } void diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 2999b858e4..053df0c9aa 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1812,6 +1812,12 @@ static void assign_np2m(struct vcpu *v, struct p2m_domain *p2m) cpumask_set_cpu(v->processor, p2m->dirty_cpumask); } +static void nvcpu_flush(struct vcpu *v) +{ + hvm_asid_flush_vcpu(v); + vcpu_nestedhvm(v).stale_np2m = true; +} + struct p2m_domain * p2m_get_nestedp2m(struct vcpu *v) { @@ -1835,7 +1841,7 @@ p2m_get_nestedp2m(struct vcpu *v) if ( p2m->np2m_base == np2m_base || p2m->np2m_base == P2M_BASE_EADDR ) { if ( p2m->np2m_base == P2M_BASE_EADDR ) - hvm_asid_flush_vcpu(v); + nvcpu_flush(v); p2m->np2m_base = np2m_base; assign_np2m(v, p2m); p2m_unlock(p2m); @@ -1852,7 +1858,7 @@ p2m_get_nestedp2m(struct vcpu *v) p2m_flush_table(p2m); p2m_lock(p2m); p2m->np2m_base = np2m_base; - hvm_asid_flush_vcpu(v); + nvcpu_flush(v); assign_np2m(v, p2m); p2m_unlock(p2m); nestedp2m_unlock(d); diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index 91651581db..16af97942f 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -116,6 +116,7 @@ struct nestedvcpu { bool_t nv_flushp2m; /* True, when p2m table must be flushed */ struct p2m_domain *nv_p2m; /* used p2m table for this vcpu */ uint64_t np2m_generation; + bool stale_np2m; /* True when p2m_base in VMCX02 is no longer valid */ struct hvm_vcpu_asid nv_n2asid;