From patchwork Tue May 14 12:31:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 164203 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2561947ili; Tue, 14 May 2019 05:32:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+KVOT+MCwnnxrty+I+WpADKUMa5AJIRpb+ycwZ8MCILdsjmQuLOJ3sv0xH/qohBY0R2Ab X-Received: by 2002:a05:6602:11a:: with SMTP id s26mr1179398iot.201.1557837163611; Tue, 14 May 2019 05:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557837163; cv=none; d=google.com; s=arc-20160816; b=ea2j9RFT/+nShyTPxiaOFSPq31LcLEZpO0xVcI3e1qG2j7rfisiO+KDBUduhYat2Of FPyrzi7sF56lvzEKZ7cKJ/J5d27t2hxvwR6EtzAPEGhLcKnSqyA8BRo6JnX0dd4HYKtL 13OWD3fP3LZHOZ6GRbGa2ambDpGAd44F8fOfJ8FdUCpoAcMtHn9K8B6HsrUXLrxPn75p Jhyytv5SOtQl3YqZN2TYw+IlztzLqdxnEWSkG0FdAWhfZL7JpNQfLP/gCHpR5ZdrRpgC IXwB2tRkDbRxrk/GEropEbJpJZHznXLYr6xkwd7j8JPxLl02/vso4mXSrc1tDV9rQxkl lJTw== 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=KZfDxa9HDPTMdTvVn3yYmFaSRApeZAiwsNjCCCAspik=; b=HViEzBUZMIwtR8kSO5QiCJN74v1gbgguGuSSSlgM3gQBNSGr9mhDC66sNSpwt5JzEk IQf1NAvIp/ERkuANCRqIBdzmulbBp1PDXg5AetwSUv99bPz059LMT3U5iPH0ekRIN1BZ SPTn95Et2NRqVnhvvu9gOkGLKslWB3Qt+j1hW+ggh5ilr6CBKMmIRYF7rgXGqKGWjekV JI4LXuu+e4VcbL8+TLZi+5i4zE4QLjKwUUiCOlraQab/2Bb9sO+b01VN1pJxlwwfSWFC L3ZBYv9usAyqzbb0Y6oonyWE9BSTqnrkH7HayFdioKmTsvQPxKA8kW4R3FUsPKycKaEe WLkg== 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 m4si8286450ioq.50.2019.05.14.05.32.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 05:32:43 -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 1hQWal-0005L3-6n; Tue, 14 May 2019 12:31:35 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWaj-0005Kr-Vd for xen-devel@lists.xenproject.org; Tue, 14 May 2019 12:31:34 +0000 X-Inumbo-ID: 34e55125-7644-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 34e55125-7644-11e9-8980-bc764e045a96; Tue, 14 May 2019 12:31:32 +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 B456815AB; Tue, 14 May 2019 05:31:32 -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 80F4A3F71E; Tue, 14 May 2019 05:31:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 14 May 2019 13:31:14 +0100 Message-Id: <20190514123125.29086-2-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 01/12] xen/arm: lpae: Add a macro to generate offsets from an address 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" There are few places requiring to generate offsets from an address. Rather than open-coding everywhere, we can introduce a macro to do the job for us. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Acked-by: Stefano Stabellini --- Changes in v2: - Add Andrii's reviewed-by --- xen/arch/arm/p2m.c | 23 +++-------------------- xen/include/asm-arm/lpae.h | 9 +++++++++ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 92c2413f20..06fa342a8f 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -368,12 +368,7 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn, p2m_type_t _t; /* Convenience aliases */ - const unsigned int offsets[4] = { - zeroeth_table_offset(addr), - first_table_offset(addr), - second_table_offset(addr), - third_table_offset(addr) - }; + DECLARE_OFFSETS(offsets, addr); ASSERT(p2m_is_locked(p2m)); BUILD_BUG_ON(THIRD_MASK != PAGE_MASK); @@ -888,7 +883,6 @@ static int __p2m_set_entry(struct p2m_domain *p2m, p2m_type_t t, p2m_access_t a) { - paddr_t addr = gfn_to_gaddr(sgfn); unsigned int level = 0; unsigned int target = 3 - (page_order / LPAE_SHIFT); lpae_t *entry, *table, orig_pte; @@ -897,12 +891,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, bool removing_mapping = mfn_eq(smfn, INVALID_MFN); /* Convenience aliases */ - const unsigned int offsets[4] = { - zeroeth_table_offset(addr), - first_table_offset(addr), - second_table_offset(addr), - third_table_offset(addr) - }; + DECLARE_OFFSETS(offsets, gfn_to_gaddr(sgfn)); ASSERT(p2m_is_write_locked(p2m)); @@ -1199,15 +1188,9 @@ bool p2m_resolve_translation_fault(struct domain *d, gfn_t gfn) unsigned int level = 0; bool resolved = false; lpae_t entry, *table; - paddr_t addr = gfn_to_gaddr(gfn); /* Convenience aliases */ - const unsigned int offsets[4] = { - zeroeth_table_offset(addr), - first_table_offset(addr), - second_table_offset(addr), - third_table_offset(addr) - }; + DECLARE_OFFSETS(offsets, gfn_to_gaddr(gfn)); p2m_write_lock(p2m); diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index 545b0c8f24..c22780f8f3 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -218,6 +218,15 @@ TABLE_OFFSET_HELPERS(64); #undef TABLE_OFFSET #undef TABLE_OFFSET_HELPERS +/* Generate an array @var containing the offset for each level from @addr */ +#define DECLARE_OFFSETS(var, addr) \ + const unsigned int var[4] = { \ + zeroeth_table_offset(addr), \ + first_table_offset(addr), \ + second_table_offset(addr), \ + third_table_offset(addr) \ + } + #endif /* __ASSEMBLY__ */ /*