From patchwork Fri Jul 18 13:33:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 33851 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8AB8D20CA0 for ; Fri, 18 Jul 2014 13:42:58 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id w10sf18073733pde.3 for ; Fri, 18 Jul 2014 06:42:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=evjr9XiIzvV4ZqY9nckQevnEePj2LQI+n9gaIccjPdY=; b=XBUFH0y48Al7c+1+dirXxAYg2Nwk1oJllG/2An4K9OOPkyUaG+QDnf1IjOlHBuXdpI 2SqNXI4tAYudeaaE+n43SqIn9y3vf7g1X2KIUQ2lFEuZDmnPxsSx4fsm/MbmQH4R6vN5 8QPW3xGNUgRwb9u9ZR/FeF64lIh4099paCWpawfpMZFMzcU4YR+B6bke45A3p15QviTn KiYUH0iBscFfuSFR9tbPE131aMhhlw29eq/yjjhMkcONKsQbtb1F1awvJhEkYJhVcrMb 1pKNAd1OjQThYN3SVBxRXYd2ag8S5kcI1HKsByreWermJRJMb3AqxZ4K/7ySdutNGeuG lmrQ== X-Gm-Message-State: ALoCoQkD4LtN6SlwMGQL+M0hX8kyGA4n8nGm0AxfoEgVqF14Da9c0GJsClKKFb9cTYA18kY2d1NP X-Received: by 10.66.252.166 with SMTP id zt6mr2321597pac.1.1405690977728; Fri, 18 Jul 2014 06:42:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.100.214 with SMTP id s80ls985683qge.99.gmail; Fri, 18 Jul 2014 06:42:57 -0700 (PDT) X-Received: by 10.220.5.138 with SMTP id 10mr3850697vcv.67.1405690977613; Fri, 18 Jul 2014 06:42:57 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ol3si5717337vcb.30.2014.07.18.06.42.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jul 2014 06:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so7312014vcb.23 for ; Fri, 18 Jul 2014 06:42:55 -0700 (PDT) X-Received: by 10.52.37.81 with SMTP id w17mr3207615vdj.95.1405690975010; Fri, 18 Jul 2014 06:42:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp12322vcb; Fri, 18 Jul 2014 06:42:34 -0700 (PDT) X-Received: by 10.42.37.13 with SMTP id w13mr7525664icd.13.1405690944698; Fri, 18 Jul 2014 06:42:24 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id x10si5085986igg.53.2014.07.18.06.42.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 18 Jul 2014 06:42:24 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X88Oe-0000Me-He; Fri, 18 Jul 2014 13:40:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X88Od-0000MM-Bh for xen-devel@lists.xen.org; Fri, 18 Jul 2014 13:40:23 +0000 Received: from [85.158.137.68:44640] by server-17.bemta-3.messagelabs.com id 72/78-27015-6C329C35; Fri, 18 Jul 2014 13:40:22 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1405690820!16603873!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3628 invoked from network); 18 Jul 2014 13:40:21 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 18 Jul 2014 13:40:21 -0000 X-IronPort-AV: E=Sophos;i="5.01,685,1400025600"; d="scan'208";a="153677943" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 18 Jul 2014 13:40:20 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Fri, 18 Jul 2014 09:40:19 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1X88IS-0001sL-4F; Fri, 18 Jul 2014 14:34:01 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Fri, 18 Jul 2014 14:34:00 +0100 From: Ian Campbell To: Date: Fri, 18 Jul 2014 14:33:59 +0100 Message-ID: <1405690440-32211-1-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH v2] xen: arm: avoid reusing incorrect mappings when walking the p2m. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: When we change which PT page we are mapping at a given level then we need to invalidate any cached mappings further down the tree, otherwise we risk using them because their offset might match but be based on a different offset further up the table. e.g. when remapping first then cur_first_offset and cur_second_offset (which indicate the currently mapped second and third tables respectively) both become invalid Signed-off-by: Ian Campbell Acked-by: Julien Grall --- v2: Also invalidate cur_first_offset when changing cur_first_page. Corrected/clarified commit message, this issue isn't really specific to superpages, they just happen to expose it. --- xen/arch/arm/p2m.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 2f855b5..8ffddac 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -743,6 +743,8 @@ static int apply_p2m_changes(struct domain *d, goto out; } cur_first_page = p2m_first_level_index(addr); + /* Any mapping further down is now invalid */ + cur_first_offset = cur_second_offset = ~0; } /* We only use a 3 level p2m at the moment, so no level 0, @@ -765,6 +767,8 @@ static int apply_p2m_changes(struct domain *d, if (second) unmap_domain_page(second); second = map_domain_page(first[first_table_offset(addr)].p2m.base); cur_first_offset = first_table_offset(addr); + /* Any mapping further down is now invalid */ + cur_second_offset = ~0; } /* else: second already valid */