From patchwork Mon Aug 12 17:29:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 171150 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp509381ily; Mon, 12 Aug 2019 23:51:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcsArc4LRZgHGV56jbJe2TAJ2afje1bBQBlzZRvZu3OWAuwla2UrX0mnhvGUMg4eyi8J4s X-Received: by 2002:a02:b715:: with SMTP id g21mr10556339jam.137.1565679106128; Mon, 12 Aug 2019 23:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565679106; cv=none; d=google.com; s=arc-20160816; b=TBH+Ss9LXma6hgCR3v23NX2MmoFFgTJWUrueeP71BTzR2v+eENtABSGLS4xUGwBviQ opG/2g85oAQCBmgnYjTiYEQJv8/YJ/N7CACMQHKaAXLCUttPmFbuPnihBe7tYHKfzkjw ZLGe/pGKQxb5H8cC2T//T/ovuGsEvaYdYXwChoy6203yxRcFga6P0iNOmYO4hmByDpKP fK1mqh7FPUDX1hzbMavkKIws4dXk4qWa1z7EhqlUyQaKOU+pom3XjO38c7rImxJ3KWq3 9K9wanTIyaV4DR7lcRapOAxQyKxFYO1isa6/9w9WJfhpKdBSOGJ+YflSDBww/tMhhB3A kyyQ== 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=NJzD68mVF0YOtqarzMpQ++9R36OqyRysmbIg9IsulfI=; b=ZEGZhFRKPg+iHrTAx1JGBV55QOVzl7uZjDOoDpFSzgT4ttNeHIGo0MLtovX/2ArI6w tabco85uGu8evQo+6azXuV820h95joh+6JL1ouZzT706KvIMryfzk49bM8/OHjvPJDCh vpJR8LW85HLPMW+rH6ckHZ59Bf0fE/mRs70fk+rd6bkg3KRjU7r72borYC3Xn9SMUiqT Y6naNwSZPOHMsUyJEw8/XAw9BUy9xufIGVvFqX9Cg9U4rRpOGvT0FY3GXI2hJ7jemMu4 7Fiebp1NoeT4t1nw9ON3I2YSq6hIUn07XqQVhlm/GaUEB4NPNwLtzqm0jr7vMpC3QFU0 hCQg== 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 s140si14498086ios.146.2019.08.12.23.51.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Aug 2019 23:51:46 -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 1hxQdv-0001PO-Io; Tue, 13 Aug 2019 06:50:51 +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 1hxQdt-0001P2-HG for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 06:50:49 +0000 X-Inumbo-ID: e335e1d6-bd26-11e9-80d0-7b22129d03e0 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id e335e1d6-bd26-11e9-80d0-7b22129d03e0; Mon, 12 Aug 2019 17:30:33 +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 A305A1715; Mon, 12 Aug 2019 10:30: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 F146E3F706; Mon, 12 Aug 2019 10:30:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 18:29:57 +0100 Message-Id: <20190812173019.11956-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812173019.11956-1-julien.grall@arm.com> References: <20190812173019.11956-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v3 06/28] xen/arm64: head: Introduce a macro to get a PC-relative address of a symbol 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Arm64 provides instructions to load a PC-relative address, but with some limitations: - adr is enable to cope with +/-1MB - adrp is enale to cope with +/-4GB but relative to a 4KB page address Because of that, the code requires to use 2 instructions to load any Xen symbol. To make the code more obvious, introducing a new macro adr_l is introduced. The new macro is used to replace a couple of open-coded use in efi_xen_start. The macro is copied from Linux 5.2-rc4. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v3: - Fix typo in my e-mail address - Add Stefano's acked-by Changes in v2: - Patch added --- xen/arch/arm/arm64/head.S | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 9b703e79ce..cd03101196 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -117,6 +117,18 @@ #endif /* !CONFIG_EARLY_PRINTK */ +/* + * Pseudo-op for PC relative adr , where is + * within the range +/- 4GB of the PC. + * + * @dst: destination register (64 bit wide) + * @sym: name of the symbol + */ +.macro adr_l, dst, sym + adrp \dst, \sym + add \dst, \dst, :lo12:\sym +.endm + /* Load the physical address of a symbol into xb */ .macro load_paddr xb, sym ldr \xb, =\sym @@ -895,11 +907,9 @@ ENTRY(efi_xen_start) * Flush dcache covering current runtime addresses * of xen text/data. Then flush all of icache. */ - adrp x1, _start - add x1, x1, #:lo12:_start + adr_l x1, _start mov x0, x1 - adrp x2, _end - add x2, x2, #:lo12:_end + adr_l x2, _end sub x1, x2, x1 bl __flush_dcache_area