From patchwork Fri Aug 18 14:23:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Deegan X-Patchwork-Id: 9909241 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 7480A602C8 for ; Fri, 18 Aug 2017 14:26:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60F8928CDF for ; Fri, 18 Aug 2017 14:26:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55BA928CE1; Fri, 18 Aug 2017 14:26:13 +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 B4DDD28CDF for ; Fri, 18 Aug 2017 14:26:12 +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 1diiBh-0001UP-Ui; Fri, 18 Aug 2017 14:23:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diiBg-0001UG-LJ for xen-devel@lists.xen.org; Fri, 18 Aug 2017 14:23:48 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 6F/39-03406-378F6995; Fri, 18 Aug 2017 14:23:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDIsWRWlGSWpSXmKPExsXCqh5zXbf4x7R Ig713hS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oymJ/9ZCu7wVGza28PawLiOq4uRi0NIYCGj ROvzzyxdjJwcLAKqEr8eXGIFsdkE5CTWbbzBBmKLCOhKPFvwDMjm4GAW8JC4sTwfJCws4CvR2 LkMrJxXwFKi8d1fJhBbSGA7o8SxMxYQcUGJkzOfgI1nFtCR2Ln1DtQYaYnl/zhAwpwCVhJfly 8EaxUVUJG4MuEtO4gtISAi8evOJ2YIW1Pi4KVNLBC2gsT9z9fYIOxAiWmN25knMArOQrJtFpJ tsxC2LWBkXsWoUZxaVJZapGtooJdUlJmeUZKbmJkD5Jnp5aYWFyemp+YkJhXrJefnbmIEBiwD EOxgPP4+7hCjJAeTkijv71lTIoX4kvJTKjMSizPii0pzUosPMapzcAhc3fY3XIolLz8vVUmCt +T7tEghwaLU9NSKtMwcYETBVEpw8CiJ8L4BSfMWFyTmFmemQ6ROMRpzrFiw9QsTR9/E7V+YhM AmSYnzJoOUCoCUZpTmwQ2CRfolRlkpYV5GoCuFeApSi3IzS1DlXzGKczAqCfN2gkzhycwrgdv 3CugUJqBTDFvBTilJREhJNTDGpHFmtWxM32Jl4cn/jLez4/JTHs3t6+QSyh+s6sg5/9579uSz JzyMWN1fCU21PGs28a1dzP1rPqE5TBvfPD8rHiEu3pvrUeD7lJU7OWNB7Y3uJZ9ltqS6vfMO3 6Dx4cD2rrXPzkitFiqUmnPyNfv1L35POlzFL7zRuFcUsvD6iYePmlef3rtAiaU4I9FQi7moOB EAAadKLO8CAAA= X-Env-Sender: tim@xen.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1503066227!71894693!1 X-Originating-IP: [5.39.92.215] X-SpamReason: No, hits=0.2 required=7.0 tests=RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13966 invoked from network); 18 Aug 2017 14:23:47 -0000 Received: from deinos.phlegethon.org (HELO deinos.phlegethon.org) (5.39.92.215) by server-10.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Aug 2017 14:23:47 -0000 Received: from tjd by deinos.phlegethon.org with local (Exim 4.89 (FreeBSD)) (envelope-from ) id 1diiBc-0006dg-L7; Fri, 18 Aug 2017 14:23:44 +0000 Date: Fri, 18 Aug 2017 15:23:44 +0100 From: Tim Deegan To: Andrew Cooper Message-ID: <20170818142344.GD7137@deinos.phlegethon.org> References: <1502882530-31700-1-git-send-email-andrew.cooper3@citrix.com> <1502882530-31700-3-git-send-email-andrew.cooper3@citrix.com> <20170818135528.GB7137@deinos.phlegethon.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170818135528.GB7137@deinos.phlegethon.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Known-Good: Yes X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tim@xen.org X-SA-Exim-Scanned: No (on deinos.phlegethon.org); SAEximRunCond expanded to false Cc: Jan Beulich , Xen-devel Subject: [Xen-devel] [PATCH] xen/x86/shadow: adjust barriers around gtable_dirty_version. 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 Use the smp_ variants, as we're only synchronizing against other CPUs. Add a write barrier before incrementing the version. x86's memory ordering rules and the presence of various out-of-unit function calls mean that this code worked OK before, and the barriers are mostly decorative. Signed-off-by: Tim Deegan Reviewed-by: Andrew Cooper --- xen/arch/x86/mm/shadow/multi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index c9c2252..f8a8928 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -206,6 +206,7 @@ shadow_check_gwalk(struct vcpu *v, unsigned long va, walk_t *gw, int version) ASSERT(paging_locked_by_me(d)); + /* No need for smp_rmb() here; taking the paging lock was enough. */ if ( version == atomic_read(&d->arch.paging.shadow.gtable_dirty_version) ) return 1; @@ -3112,7 +3113,7 @@ static int sh_page_fault(struct vcpu *v, * will make sure no inconsistent mapping being translated into * shadow page table. */ version = atomic_read(&d->arch.paging.shadow.gtable_dirty_version); - rmb(); + smp_rmb(); walk_ok = sh_walk_guest_tables(v, va, &gw, error_code); #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) @@ -3188,6 +3189,7 @@ static int sh_page_fault(struct vcpu *v, * overlapping with this one may be inconsistent */ perfc_incr(shadow_rm_write_flush_tlb); + smp_wmb(); atomic_inc(&d->arch.paging.shadow.gtable_dirty_version); flush_tlb_mask(d->domain_dirty_cpumask); }