From patchwork Thu Nov 23 16:40:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10073085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65CBC60375 for ; Thu, 23 Nov 2017 16:41:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 564142A026 for ; Thu, 23 Nov 2017 16:41:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B4F62A02B; Thu, 23 Nov 2017 16:41:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF67E2A026 for ; Thu, 23 Nov 2017 16:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=OofeW0JuF+tGBVyyij6FjOBaCpwuCeZ09CfFw2g0jy4=; b=RMZaVXa2uWu7vktqjDnVDcV+K9 5frcPeqhmvRci9cIvB4K5IGJcsDbZ7Q+MKvwOnSex4Kl9u+CgMlN5I/B9dwdtYRqo4YD5nXOlqXxo hBiW8zY5rEEeSyuj/RucLN3CIV7c6mjNPmzl3duVJNmfJkEz61oB9w75f5GpOk0nyuRqYNivM6Ebk VoDHcV6UIUHbeF5ANfh2UGRpk846PjxB+xQWW2FqtfWXvdiWWb1WxNAX2dRpB/iF6HT6ukCQiJFX9 S9RSkNQWqWFcoWQxHhYhnzvFdUc/ldEM9w2qe/HdvZUdCVdlcWXP+tdduhFgpAQezJBxS7oExRf8n bAGZzKZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eHuZC-0004V1-6Q; Thu, 23 Nov 2017 16:41:34 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eHuYu-0004D9-0L for linux-arm-kernel@lists.infradead.org; Thu, 23 Nov 2017 16:41:17 +0000 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 A840915A2; Thu, 23 Nov 2017 08:40:55 -0800 (PST) Received: from capper-debian.emea.arm.com (unknown [10.37.7.143]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8FCB13F236; Thu, 23 Nov 2017 08:40:54 -0800 (PST) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 1/2] arm64: Re-order reserved_ttbr0 in linker script Date: Thu, 23 Nov 2017 16:40:39 +0000 Message-Id: <20171123164040.31551-2-steve.capper@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123164040.31551-1-steve.capper@arm.com> References: <20171123164040.31551-1-steve.capper@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171123_084116_101108_BF77A090 X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, kristina.martsenko@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently one resolves the location of the reserved_ttbr0 for PAN by taking a positive offset from swapper_pg_dir. In a future patch we wish to extend the swapper s.t. its size is determined at link time rather than compile time, rendering SWAPPER_DIR_SIZE unsuitable for such a low level calculation. In this patch we re-arrange the order of the linker script s.t. instead one computes reserved_ttbr0 by subtracting RESERVED_TTBR0_SIZE from swapper_pg_dir. Signed-off-by: Steve Capper Acked-by: Mark Rutland Reviewed-by: Ard Biesheuvel --- arch/arm64/include/asm/asm-uaccess.h | 6 +++--- arch/arm64/include/asm/uaccess.h | 2 +- arch/arm64/kernel/vmlinux.lds.S | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h index b3da6c886835..e09f02cd3e7a 100644 --- a/arch/arm64/include/asm/asm-uaccess.h +++ b/arch/arm64/include/asm/asm-uaccess.h @@ -12,9 +12,9 @@ */ #ifdef CONFIG_ARM64_SW_TTBR0_PAN .macro __uaccess_ttbr0_disable, tmp1 - mrs \tmp1, ttbr1_el1 // swapper_pg_dir - add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir - msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1 + mrs \tmp1, ttbr1_el1 // swapper_pg_dir + sub \tmp1, \tmp1, #RESERVED_TTBR0_SIZE // reserved_ttbr0 just before swapper_pg_dir + msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1 isb .endm diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index fc0f9eb66039..66170fd4b58f 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -108,7 +108,7 @@ static inline void __uaccess_ttbr0_disable(void) unsigned long ttbr; /* reserved_ttbr0 placed at the end of swapper_pg_dir */ - ttbr = read_sysreg(ttbr1_el1) + SWAPPER_DIR_SIZE; + ttbr = read_sysreg(ttbr1_el1) - RESERVED_TTBR0_SIZE; write_sysreg(ttbr, ttbr0_el1); isb(); } diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 7da3e5c366a0..2a9475733e84 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -206,13 +206,12 @@ SECTIONS . = ALIGN(PAGE_SIZE); idmap_pg_dir = .; . += IDMAP_DIR_SIZE; - swapper_pg_dir = .; - . += SWAPPER_DIR_SIZE; - #ifdef CONFIG_ARM64_SW_TTBR0_PAN reserved_ttbr0 = .; . += RESERVED_TTBR0_SIZE; #endif + swapper_pg_dir = .; + . += SWAPPER_DIR_SIZE; __pecoff_data_size = ABSOLUTE(. - __initdata_begin); _end = .;