From patchwork Mon Sep 4 08:14:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 9936811 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 5D60B601EB for ; Mon, 4 Sep 2017 08:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EF2728770 for ; Mon, 4 Sep 2017 08:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4361A2877E; Mon, 4 Sep 2017 08:17:53 +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 BE50028770 for ; Mon, 4 Sep 2017 08:17:52 +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 1domXL-0006mF-3P; Mon, 04 Sep 2017 08:15:15 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1domXJ-0006ka-9N for xen-devel@lists.xen.org; Mon, 04 Sep 2017 08:15:13 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 48/A8-03454-09B0DA95; Mon, 04 Sep 2017 08:15:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplkeJIrShJLcpLzFFi42JxWrrBXncC99p Ig0nt7BZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bzC9uYCz6IVjzv38PawPhSsIuRk0NCwF9i 3ptWFhCbTUBPYuPsV0wgtoiArMTqrjnsIDazwCcmiYZjjiC2sIC5RM+ZY8wgNouAisSJnTfB6 nkFbCXOtK1khJgpL7Gr7SIriM0pYCdxdvUbsLgQUE3P4sPMELaqxOsXu1ggegUlTs58wgKxS0 Li4IsXzBMYeWchSc1CklrAyLSKUaM4tagstUjX2FgvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NSc xqVgvOT93EyMweBiAYAfjzvWBhxglOZiURHnvP14TKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC 9zjn2kghwaLU9NSKtMwcYBjDpCU4eJREeLVB0rzFBYm5xZnpEKlTjIpS4rxHQRICIImM0jy4N ljsXGKUlRLmZQQ6RIinILUoN7MEVf4VozgHo5IwLxMX0BSezLwSuOmvgBYzAS2uerkGZHFJIk JKqoGxuchZ9bjW6seMFnpN6ooMLBV6CzM2b7jONd1kRrLFgTDjv+WvN1ts4+R/lppRyH33TEw Ow7p7Bw4HvuHT8WKZc3RK1Or3bSw+F684BDq97NVYxnKw83eWnLYHYx5X57F9E7les51oCGq9 F+Zz/HrSNNM9hel7N76Kcvbctm7pBAPpO75z/ayUWIozEg21mIuKEwEmX2s6mAIAAA== X-Env-Sender: prvs=413848043=sergey.dyasli@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1504512908!77498317!4 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 41832 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-3.tower-21.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="446424745" From: Sergey Dyasli To: Date: Mon, 4 Sep 2017 09:14:43 +0100 Message-ID: <20170904081452.12960-6-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 05/14] x86/np2m: add np2m_generation 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 Add np2m_generation element to both p2m_domain and nestedvcpu. np2m's generation will be incremented each time the np2m is flushed. This will allow to detect if a nested vcpu has the stale np2m. Signed-off-by: Sergey Dyasli --- xen/arch/x86/hvm/nestedhvm.c | 1 + xen/arch/x86/mm/p2m.c | 3 +++ xen/include/asm-x86/hvm/vcpu.h | 1 + xen/include/asm-x86/p2m.h | 1 + 4 files changed, 6 insertions(+) diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c index f2f7469d86..32b8acca6a 100644 --- a/xen/arch/x86/hvm/nestedhvm.c +++ b/xen/arch/x86/hvm/nestedhvm.c @@ -56,6 +56,7 @@ nestedhvm_vcpu_reset(struct vcpu *v) nv->nv_vvmcxaddr = INVALID_PADDR; nv->nv_flushp2m = 0; nv->nv_p2m = NULL; + nv->np2m_generation = 0; hvm_asid_flush_vcpu_asid(&nv->nv_n2asid); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b735950349..2999b858e4 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -73,6 +73,7 @@ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) p2m->p2m_class = p2m_host; p2m->np2m_base = P2M_BASE_EADDR; + p2m->np2m_generation = 0; for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i ) p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN); @@ -1732,6 +1733,7 @@ p2m_flush_table_locked(struct p2m_domain *p2m) /* This is no longer a valid nested p2m for any address space */ p2m->np2m_base = P2M_BASE_EADDR; + p2m->np2m_generation++; /* Make sure nobody else is using this p2m table */ nestedhvm_vmcx_flushtlb(p2m); @@ -1806,6 +1808,7 @@ static void assign_np2m(struct vcpu *v, struct p2m_domain *p2m) nv->nv_flushp2m = 0; nv->nv_p2m = p2m; + nv->np2m_generation = p2m->np2m_generation; cpumask_set_cpu(v->processor, p2m->dirty_cpumask); } diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index 6c54773f1c..91651581db 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -115,6 +115,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; struct hvm_vcpu_asid nv_n2asid; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 1d17fd5f97..1a7002cbcd 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -209,6 +209,7 @@ struct p2m_domain { * to set it to any other value. */ #define P2M_BASE_EADDR (~0ULL) uint64_t np2m_base; + uint64_t np2m_generation; /* Nested p2ms: linked list of n2pms allocated to this domain. * The host p2m hasolds the head of the list and the np2ms are