From patchwork Fri Jun 14 17:51:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 166868 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2351236ilk; Fri, 14 Jun 2019 10:53:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzD1S1a1+OI8erOLzMpA2mxhq/JLxbV25zaqwCVFRYb2SNOi2KJToCMRBhK2Ke52CsZsfv5 X-Received: by 2002:a02:3308:: with SMTP id c8mr775jae.103.1560534811348; Fri, 14 Jun 2019 10:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534811; cv=none; d=google.com; s=arc-20160816; b=pxSKMT092FEtiBtsYrKDGAY9gTon17uDaP67VjCD4SOTyE5/9NA8ufF8nk3V2/hOAf asYjpj3S+j+oo5Q1Ee0ryKEIiIGJA2l6flrIY3KU1zB1V+1gw40lVGlQHgFx8fipcFY5 6nAkp26VXirDjLyd42yDMk4OYiSd3Jyfi+32ikPpZiueWOUnta7ReQ5RKK09xuIsRpbK PyaDgSICyTgGPSy9nTdx62hb803Kxejo21wtxdqYaapKMr6yEyFPBAgcMk/1LlmPY323 T8L4fAtEE6m6s0dr/3aI5KY3MEpLLVmF9vXpai6ZQ9tSxA457gyb0kYfvxAeMVvK1lzf eNtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=H2E8C87rypFj2pp+Mxu+vqaZWf/38uSzUl4kiCl0O18=; b=RgiiMMSZvaXPPPULGOlIc4r4s0Z1Xi/Ge8hSNcxkjXDbYnsShwkwGaUBw+QW+/h+pb rTWrztR5zRLSxBtcKSHOV2rmrKaUXrfZB+IpiScqdorZ/4pjEQYEzFBfrAijbHfHPaoZ 2Ws9ZBe8k3aycCPFOPwzXdN4pSdIJzt89Agyx345Qmup15kr8faL4VJq0Chky0FyiZrc m5g1qjm0OI3q9lZoyVU19USVl9BCryfNyQ+PTVuhOxFvtYfsRpUXoLoTYOiBXfRgQ4hm Jwr6ZCyWeBhgtmC+LWBuNaJhpEy2BM+A3cpNzirP5jGaHB1xnAo1h0GCdGT0KApne2LT zfNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l7si3815669iof.39.2019.06.14.10.53.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:53:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbqMu-0001t2-Fs; Fri, 14 Jun 2019 17:52:04 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbqMs-0001rD-J4 for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 17:52:02 +0000 X-Inumbo-ID: 1ca75bb1-8ecd-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 1ca75bb1-8ecd-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 17:52:01 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 112D7344; Fri, 14 Jun 2019 10:52:01 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 295123F718; Fri, 14 Jun 2019 10:52:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 14 Jun 2019 18:51:43 +0100 Message-Id: <20190614175144.20046-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190614175144.20046-1-julien.grall@arm.com> References: <20190614175144.20046-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART3 v3 8/9] xen/arm: mm: Don't open-code Xen PT update in {set, clear}_fixmap() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr_Tyshchenko@epam.com, Julien Grall , Stefano Stabellini , Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" {set, clear}_fixmap() are currently open-coding update to the Xen page-tables. This can be avoided by using the generic helpers map_pages_to_xen() and destroy_xen_mappings(). Both function are not meant to fail for fixmap, hence the BUG_ON() checking the return. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Acked-by: Stefano Stabellini --- Changes in v3: - Add Stefano's acked-by Changes in v2: - Add Andrii's reviewed-by --- xen/arch/arm/mm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 028fbd38ad..46bc3d8075 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -348,19 +348,19 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) /* Map a 4k page in a fixmap entry */ void set_fixmap(unsigned map, mfn_t mfn, unsigned int flags) { - lpae_t pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags)); - pte.pt.table = 1; /* 4k mappings always have this bit set */ - pte.pt.xn = 1; - write_pte(xen_fixmap + third_table_offset(FIXMAP_ADDR(map)), pte); - flush_xen_tlb_range_va(FIXMAP_ADDR(map), PAGE_SIZE); + int res; + + res = map_pages_to_xen(FIXMAP_ADDR(map), mfn, 1, flags); + BUG_ON(res != 0); } /* Remove a mapping from a fixmap entry */ void clear_fixmap(unsigned map) { - lpae_t pte = {0}; - write_pte(xen_fixmap + third_table_offset(FIXMAP_ADDR(map)), pte); - flush_xen_tlb_range_va(FIXMAP_ADDR(map), PAGE_SIZE); + int res; + + res = destroy_xen_mappings(FIXMAP_ADDR(map), FIXMAP_ADDR(map) + PAGE_SIZE); + BUG_ON(res != 0); } /* Create Xen's mappings of memory.