From patchwork Tue May 14 12:31:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 164202 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2561891ili; Tue, 14 May 2019 05:32:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDr+bWGUGM4QBC2qjXZ2BlHLnL9ZOB9F9vkFeu4ofw1l7jZKOmaGIEd3+Ryl56B8ur/GGO X-Received: by 2002:a24:354c:: with SMTP id k73mr3472068ita.175.1557837161529; Tue, 14 May 2019 05:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557837161; cv=none; d=google.com; s=arc-20160816; b=bRjhY/E7IMndtQBF1hdAUTX1iecKiB2GA4n4Vu7IWJ3v6u/RR4h8JL0PvPffTjFcC9 ky68PvvNffhW4cseCD1hAZ7pNFfjvtE/QzZrGAvZeQ8y/EyV9bb08d512SXoudGnz9lJ O0MwuDHqugwInXkY7oGU76JsZjGxy+UwaKzh1B97qiW4pJiXpTrwLjg6+tDlj4JNRn4N UrtKkFXK029Rm7O3JoyEttx5DzGwgEgEoqX2zHVhfWg6geFM4FtMp6ybT7G3BCzRBxJB 9eXGFIp8LK7MT8wLdmun8EqLC+wBWCXFer4Eg5+jporjWufL2cOOtKCuBkcuIaTRN7Nw I9iw== 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=q/5fO5w8i5zfDMpa1uLC2hOGVREryTjNX266uOdlSzI=; b=DTF8tkL4dHd0zg34PGjUDADEZCwcuqPBs764axqE6ytkHb/ZEfNV2mr62K+QGd8+U0 o1ofdLlAV2RjK+v8nC1ZeNgWCom2//J8/Yz1SnGnpCCDnfjsw/wQuJH6Si6suGztUgM2 Yqu5UoQj0AEMx5vtB0ioOgJwU6Q6lnyg4prDqDZPZFXW0KzW7AgeW7nBGC0VDyKxy2my 5cVtVMVwkoIWxl4+ZDNIoz+ccdRAMDX8IGtKUQ5XaSRKSFXkspN5cYMCh8MnIz8JEIfb vLZ44ZExdHvHjH/FbEqEwUCnkJozwqm2vG7pNGHTSfG5z0YnYY5D9q9mragx+fFGAFrq 1A7A== 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 n70si10693213iod.141.2019.05.14.05.32.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 05:32:41 -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 1hQWb0-0005Vt-3w; Tue, 14 May 2019 12:31:50 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWay-0005U8-LN for xen-devel@lists.xenproject.org; Tue, 14 May 2019 12:31:48 +0000 X-Inumbo-ID: 3dba290c-7644-11e9-8b9c-93296919fc85 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 3dba290c-7644-11e9-8b9c-93296919fc85; Tue, 14 May 2019 12:31:47 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5E11C341; Tue, 14 May 2019 05:31:47 -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 2ACDC3F71E; Tue, 14 May 2019 05:31:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 14 May 2019 13:31:24 +0100 Message-Id: <20190514123125.29086-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190514123125.29086-1-julien.grall@arm.com> References: <20190514123125.29086-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART3 v2 11/12] 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 --- 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 9a40754f44..23ca61e8f0 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.