From patchwork Tue Jul 18 10:34:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 9847681 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 8ACBD602C8 for ; Tue, 18 Jul 2017 10:36:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86A302853A for ; Tue, 18 Jul 2017 10:36:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B8C92854A; Tue, 18 Jul 2017 10:36:42 +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 25C142853A for ; Tue, 18 Jul 2017 10:36:42 +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 1dXPpw-00067r-EO; Tue, 18 Jul 2017 10:34:40 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXPpv-000640-AC for xen-devel@lists.xen.org; Tue, 18 Jul 2017 10:34:39 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id F8/77-02177-E34ED695; Tue, 18 Jul 2017 10:34:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrohUtfuSW6 kwZS5nBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aPaTsYCz6KVpxru8LewPhKsIuRk0NCwF/i ya4prCA2m4CexMbZr5hAbBEBWYnVXXPYQWxmgU9MEg3HHLsYOTiEBSwkjn+1BAmzCKhKTH51A aycV8BW4mfbVnaIkfISu9ougo3kFLCTmPe8kwXEFgKqWX1hFyuErSrx+sUuFoheQYmTM5+wQK ySkDj44gXzBEbeWUhSs5CkFjAyrWJUL04tKkst0rXQSyrKTM8oyU3MzNE1NDDVy00tLk5MT81 JTCrWS87P3cQIDBwGINjBeLDZ+RCjJAeTkijv6gO5kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQk eOUfA+UEi1LTUyvSMnOAIQyTluDgURLhDQJJ8xYXJOYWZ6ZDpE4x6nK8mvD/G5MQS15+XqqUO G8wSJEASFFGaR7cCFg8XWKUlRLmZQQ6SoinILUoN7MEVf4VozgHo5Iw75ZHQFN4MvNK4Da9Aj qCCegIYd8ckCNKEhFSUg2M5tt/3stev4g1eMbz5R4RteIdrbvK25qrfpr173jP7OlgaagUJbr vrXfhh2alTZI2phwNBsnO3M8PHNLve858Y3aXs9d3xZjSvh/7l518E99//2WD962WuH0xK/hm GXcJvoyNbfSK4j7k/uf6D92Nik4uzrkzP2s8eh7qMNswqs1V8l6EUKYSS3FGoqEWc1FxIgD+w LeJogIAAA== X-Env-Sender: prvs=365bef495=sergey.dyasli@citrix.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1500374076!83584988!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57757 invoked from network); 18 Jul 2017 10:34:37 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 18 Jul 2017 10:34:37 -0000 X-IronPort-AV: E=Sophos;i="5.40,377,1496102400"; d="scan'208";a="431880764" From: Sergey Dyasli To: Date: Tue, 18 Jul 2017 11:34:22 +0100 Message-ID: <20170718103429.25020-6-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170718103429.25020-1-sergey.dyasli@citrix.com> References: <20170718103429.25020-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 RFC 05/12] 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 variable 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 e7bd0dbac8..4fc2d94b46 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); @@ -1735,6 +1736,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); @@ -1811,6 +1813,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 cc1bab9eb7..eedc7fd412 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