From patchwork Sun Sep 3 12:07:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9936155 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 73E196037D for ; Sun, 3 Sep 2017 12:12:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65690286A9 for ; Sun, 3 Sep 2017 12:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A4CD286B3; Sun, 3 Sep 2017 12:12:08 +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 CFA9C286A9 for ; Sun, 3 Sep 2017 12:12:07 +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=VIZuNUc4f0x0gD16aeg8RkgOZukNG5/FIAbJeSM2oTM=; b=sBxu14VGSN/XsbmY96kHYlxVbX ixLdmPZSrayu+wqXmmgY5sF+MmcWt/+FueTUtY8LvY6WVqR7nqYqjBrouUJn6gS38K7+XwN/cDXl8 KI5XqqjSYwdFDfp1h2F3s0SFBlvzMil9sk46LicdLVogHQnEUk2aMSxzO9FkL8B3eFRxSU2+/BGj7 Vb/rcppldFr+4MmAAbpH2NCyjKb+1rbf/7a08Zh1SxZqWXoQzeM7nuwG0Xk+EsyVM214mMiY/l7m/ aikvWqY3U8pLbxr/icTaXIGFqH1Lfb3vpl/K2WHEw7JKfTZz4YR+AJauRANWMNVq+BacBmFlggHa4 cxF1yZ+w==; 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 1doTkz-0005Ji-6m; Sun, 03 Sep 2017 12:12:05 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1doThu-0001SI-KO for linux-arm-kernel@lists.infradead.org; Sun, 03 Sep 2017 12:08:56 +0000 Received: by mail-wm0-x231.google.com with SMTP id v2so21058571wmf.0 for ; Sun, 03 Sep 2017 05:08:33 -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=H0cG3/ha0K93rVBrXvlrPqfdbkpdwBqPpuoPWQfWjqU=; b=TayRKApm7pe0jtmnJtyp2KY29uPrL8S9pWY6M8JtptMREMa4OoKomwR2GTxAd/Vn0c RH5/0R8CwwEWWSsIcTZw0TQwNIPpg6ZhUX/6CrJZkp0M7OBtRPNB0bHBmvKIqkMKoOdt h+Oo79PjeP2Sw09feuxXDXreUJsLo0RxzFhYg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H0cG3/ha0K93rVBrXvlrPqfdbkpdwBqPpuoPWQfWjqU=; b=l/aCNodL6zNAMrZA+LfwwUj/qCashh8mwEpYpNem6s1JuJ6DVJlvEN0b90C9aBGD+1 sWQJ+VgVT/U7Livklou/rnW7UpL4D/hGpuuqvht68farbIs1P3/ZJ5OggDfXTEg/PBdh yvr8U+lPBT/8Ubb1jTKSI9uKhaKfzM79hxJGLwz4NpKYtbzQ2ZYGzLLtb/Iy0Ls98zEG ct8XJDaFM+9flwqOM6lrhdvG7i8a7YaXW4aLIGyegZsU8i/2bcdTOhaPFy5Buyej9dcQ l/D2VsYXt86TFDbmgd3ZVcwJA8GjL1Z0neEPgTjCSNG1CdRpe6sTXulgW7OokltfnLbJ ziJQ== X-Gm-Message-State: AHPjjUgRklB5R6F4Cyrc+LWX7O6inIBhifF59n2wi4PZJrSJjDxhysaJ D3RWang0sbJCfpxmOE+vKw== X-Google-Smtp-Source: ADKCNb6+/+xs12eQamtWZz9vCYU++TeETY8swzBaHmHzHHeMNokaGL8TIVFy090HJ97MsB0eFbsWqg== X-Received: by 10.28.229.206 with SMTP id c197mr1968766wmh.193.1504440512219; Sun, 03 Sep 2017 05:08:32 -0700 (PDT) Received: from localhost.localdomain ([154.151.223.220]) by smtp.gmail.com with ESMTPSA id b196sm4392664wmd.29.2017.09.03.05.08.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Sep 2017 05:08:31 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 05/29] ARM: head-common.S: use PC-relative insn sequence for idmap creation Date: Sun, 3 Sep 2017 13:07:33 +0100 Message-Id: <20170903120757.14968-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170903120757.14968-1-ard.biesheuvel@linaro.org> References: <20170903120757.14968-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170903_050854_879538_A9AAA0A1 X-CRM114-Status: GOOD ( 10.62 ) 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 , Kees Cook , Arnd Bergmann , Nicolas Pitre , Marc Zyngier , Ard Biesheuvel , Russell King , Dave Martin , Tony Lindgren , Thomas Garnier , Matt Fleming 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 Replace the open coded PC relative offset calculations involving __turn_mmu_on and __turn_mmu_on_end with a pair of adr_l invocations. This ensures these quantities are invariant under runtime relocation. Cc: Russell King Signed-off-by: Ard Biesheuvel Acked-by: Nicolas Pitre --- arch/arm/kernel/head.S | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 04286fd9e09c..0a98aec0e39d 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -227,11 +227,8 @@ __create_page_tables: * Create identity mapping to cater for __enable_mmu. * This identity mapping will be removed by paging_init(). */ - adr r0, __turn_mmu_on_loc - ldmia r0, {r3, r5, r6} - sub r0, r0, r3 @ virt->phys offset - add r5, r5, r0 @ phys __turn_mmu_on - add r6, r6, r0 @ phys __turn_mmu_on_end + adr_l r5, __turn_mmu_on @ _pa(__turn_mmu_on) + adr_l r6, __turn_mmu_on_end @ _pa(__turn_mmu_on_end) mov r5, r5, lsr #SECTION_SHIFT mov r6, r6, lsr #SECTION_SHIFT @@ -354,11 +351,6 @@ __create_page_tables: ret lr ENDPROC(__create_page_tables) .ltorg - .align -__turn_mmu_on_loc: - .long . - .long __turn_mmu_on - .long __turn_mmu_on_end #if defined(CONFIG_SMP) .text