From patchwork Mon Apr 4 14:52:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65006 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1232563lbc; Mon, 4 Apr 2016 07:54:55 -0700 (PDT) X-Received: by 10.66.136.41 with SMTP id px9mr128381pab.80.1459781695145; Mon, 04 Apr 2016 07:54:55 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v13si888293pas.199.2016.04.04.07.54.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 07:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1an5t3-0005c1-TM; Mon, 04 Apr 2016 14:53:53 +0000 Received: from mail-lb0-x22c.google.com ([2a00:1450:4010:c04::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1an5sD-00056w-As for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2016 14:53:02 +0000 Received: by mail-lb0-x22c.google.com with SMTP id vo2so165459754lbb.1 for ; Mon, 04 Apr 2016 07:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B6vIHLB5L00QA4C0c+ATohabmAA+WTgGXoxeEsKnKPM=; b=O5pKKtME0EgQOp99nN8sp3J89PEa8RwIEpYcI8+zti18vDTB3nQXcg/lULWITk9qHx j5AsobZUcURh/bHgToxF4keSY3r9qK3mBgA7Lau5oSscjBuCq+I/p2VI/ZX+eDYVX77t bBogNvFb5h+yQL2pnlKO9JVB4kOOg0hQYEmlM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B6vIHLB5L00QA4C0c+ATohabmAA+WTgGXoxeEsKnKPM=; b=euZO78zkIx0R89i4sPkZRgh8o86Wj5d5FP1yw1ZM60rKojqhOjwit33xancfHOte6l atA/2a6bSmae2AFMRbk4l4CLvVkfNE/zIv91lWm79+tSHxMOdmJchr05G8PTn9WNY7PY oCx6MgDsaP4DqlONP9BMefl1zf9SgAPeNI+8QkMAgVI/hcZMjeGpwXI6/m/R7iVX+K3m f5u2XXuKnp+H4OjZLMjHaaWyeOaM7K6Fuz4yyDmm3v5r1DvJBP5Z9H6+toJIluP94Bxc rerf6EMGluPcDbHu5GVeLqcYK2Ni8Y1fy5OZZW48AhRRIeAWWlJ2fjcaC7QFUG9B4GQR oaTA== X-Gm-Message-State: AD7BkJLoEQo3GOtG4DqmYxVfrTMOekLpV0hiklGGqUiMJ7P5flUg6M7cFUK5vP5OULIrSMBv X-Received: by 10.28.145.196 with SMTP id t187mr12566852wmd.81.1459781559400; Mon, 04 Apr 2016 07:52:39 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id cf6sm7922528wjc.12.2016.04.04.07.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 07:52:38 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com Subject: [PATCH 5/8] arm64/kernel: refer to idmap_pg_dir and swapper_pg_dir directly Date: Mon, 4 Apr 2016 16:52:21 +0200 Message-Id: <1459781544-14310-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459781544-14310-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459781544-14310-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_075301_625943_A18CD3B1 X-CRM114-Status: GOOD ( 11.10 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c04:0:0:0:22c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Instead of keeping their addresses in globals in x25 and x26 in head.S, just refer to idmap_pg_dir or swapper_pg_dir directly using adrp instructions when needed. This reduces the number of callee saved register with file scope, which should increase maintainability. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 2a1b3ba1d81c..9201cddb53bc 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -215,7 +215,7 @@ ENTRY(stext) mov x23, xzr // KASLR offset, defaults to 0 adrp x24, __PHYS_OFFSET bl set_cpu_boot_mode_flag - bl __create_page_tables // x25=TTBR0, x26=TTBR1 + bl __create_page_tables /* * The following calls CPU setup code, see arch/arm64/mm/proc.S for * details. @@ -313,23 +313,21 @@ ENDPROC(preserve_boot_args) * been enabled */ __create_page_tables: - adrp x25, idmap_pg_dir - adrp x26, swapper_pg_dir mov x28, lr /* * Invalidate the idmap and swapper page tables to avoid potential * dirty cache lines being evicted. */ - mov x0, x25 - add x1, x26, #SWAPPER_DIR_SIZE + adrp x0, idmap_pg_dir + adrp x1, swapper_pg_dir + SWAPPER_DIR_SIZE bl __inval_cache_range /* * Clear the idmap and swapper page tables. */ - mov x0, x25 - add x6, x26, #SWAPPER_DIR_SIZE + adrp x0, idmap_pg_dir + adrp x6, swapper_pg_dir + SWAPPER_DIR_SIZE 1: stp xzr, xzr, [x0], #16 stp xzr, xzr, [x0], #16 stp xzr, xzr, [x0], #16 @@ -342,7 +340,7 @@ __create_page_tables: /* * Create the identity mapping. */ - mov x0, x25 // idmap_pg_dir + adrp x0, idmap_pg_dir adrp x3, __idmap_text_start // __pa(__idmap_text_start) #ifndef CONFIG_ARM64_VA_BITS_48 @@ -392,7 +390,7 @@ __create_page_tables: /* * Map the kernel image (starting with PHYS_OFFSET). */ - mov x0, x26 // swapper_pg_dir + adrp x0, swapper_pg_dir ldr x5, =KIMAGE_VADDR add x5, x5, x23 // add KASLR displacement create_pgd_entry x0, x5, x3, x6 @@ -406,8 +404,8 @@ __create_page_tables: * accesses (MMU disabled), invalidate the idmap and swapper page * tables again to remove any speculatively loaded cache lines. */ - mov x0, x25 - add x1, x26, #SWAPPER_DIR_SIZE + adrp x0, idmap_pg_dir + adrp x1, swapper_pg_dir + SWAPPER_DIR_SIZE dmb sy bl __inval_cache_range @@ -696,8 +694,6 @@ ENTRY(secondary_startup) /* * Common entry point for secondary CPUs. */ - adrp x25, idmap_pg_dir - adrp x26, swapper_pg_dir bl __cpu_setup // initialise processor ldr x27, .L__secondary_switched @@ -760,8 +756,10 @@ __enable_mmu: cmp x2, #ID_AA64MMFR0_TGRAN_SUPPORTED b.ne __no_granule_support update_early_cpu_boot_status 0, x1, x2 - msr ttbr0_el1, x25 // load TTBR0 - msr ttbr1_el1, x26 // load TTBR1 + adrp x4, idmap_pg_dir + adrp x5, swapper_pg_dir + msr ttbr0_el1, x4 // load TTBR0 + msr ttbr1_el1, x5 // load TTBR1 isb msr sctlr_el1, x0 isb