From patchwork Wed Apr 24 16:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 162787 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp895659jan; Wed, 24 Apr 2019 10:01:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiUzrwVKF7VnNGsLco8E5/XTdQUBMHMESZJ64b55JhZ0ISIuPqmXTX7el6eOayHrUVEf6g X-Received: by 2002:a0d:e10c:: with SMTP id k12mr28107412ywe.353.1556125312697; Wed, 24 Apr 2019 10:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556125312; cv=none; d=google.com; s=arc-20160816; b=HtIb9MshckJlHb3wqgbgh6xRzoF8xt28mCFW3sI/64KXg0/06zA40wxdFD/prDjiYo bDCW8LARAk1Yp91QzkGdmPkLf5TzHX/Z56KH/ncahohadSrYlGcY2tIc5/qNnzhisbFb gKV2BhayP2ZN8CKhM0TPGRxXDmybFJzcV8veGJy4C7U/vb8D8gjbBLa1iYa0vTxvzLD3 WoGDtFLf1sWSW/A/dk//HzKmpVK0jj/4DGsMbn67lFmkQ5xuWpko6BrBnJ7jXwWqXAsy BnqaRkpTcbDbKX0hhU2lzVpX0tvSr2de9wPS1BtyOpa4HL/XAPyzBu9jIv0R+AY+tA4S +Atg== 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=kGVrH3Kn+5uS2Ad5pkgcMxLuMSOBZq7zhjVLK9j1V3c=; b=EzCowqer5+DcKZBXlD9Dum6lL0vM/MgNwl1DaWaRA2wBm3QUdBOKRaJdjRy5F/cDAI 9MwgkuS1W/bYF5DqB5GVhDBjkS1tY1gHcEgW5e74i1Wsae5lCq0AgM7+sMeT4QMF+bIB Mx53CGeeZUoPbbl/PDOxJM8K1e5vqY5osgYygTVQ7mWMbOD2Hre+vgHDN45CVzVjbP3I 3YzGf4irbuFKRTwF0OA6ALbHXts2k9eS/L+GTRAAnaSgaXH3YeXs7FfPrlxttHAwAqIS dJFF0X1nvhC0jZkJeT8E/YDIT/eSD/MYY6bF+WWZe8Ta+iQmw9V2HqwQd39EkzKjz7vq abrQ== 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 u188si13144927ywb.220.2019.04.24.10.01.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 10:01:52 -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 1hJLFu-0007qj-Bt; Wed, 24 Apr 2019 17:00:22 +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 1hJLFs-0007pn-QE for xen-devel@lists.xenproject.org; Wed, 24 Apr 2019 17:00:20 +0000 X-Inumbo-ID: 70fe5c76-66b2-11e9-a695-fff1a3e162a4 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 70fe5c76-66b2-11e9-a695-fff1a3e162a4; Wed, 24 Apr 2019 17:00:19 +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 9609115BE; Wed, 24 Apr 2019 10:00:19 -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 7B9DD3F557; Wed, 24 Apr 2019 10:00:18 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 24 Apr 2019 17:59:54 +0100 Message-Id: <20190424165955.23718-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190424165955.23718-1-julien.grall@arm.com> References: <20190424165955.23718-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 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 , sstabellini@kernel.org, Andrii_Anisov@epam.com 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 --- 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 022967ff9f..7e6df9f877 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -343,19 +343,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.