From patchwork Sun Sep 3 12:07:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9936131 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 5F2196037D for ; Sun, 3 Sep 2017 12:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50CCC286A9 for ; Sun, 3 Sep 2017 12:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 458AF286B3; Sun, 3 Sep 2017 12:10:28 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 409C8286A9 for ; Sun, 3 Sep 2017 12:10:27 +0000 (UTC) Received: (qmail 13384 invoked by uid 550); 3 Sep 2017 12:09:05 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 12183 invoked from network); 3 Sep 2017 12:09:03 -0000 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=JolYpLxgIOrNzQqtLaecim2sNtjnvkIVwdafnMx1nhc=; b=UCeP3CpkWuO2ZP4cGDSwLyD8eNSsplfFJtr4LrXmJSU4HJBfNEo627vTQ6oe0idWBl pVtpE4ysAQT6qwKjxJ6EzmApS5P0qfMMC8xIIlvPE1HqiEE41MStqHiu5rVlWm/S67UW Wmyq4DQT6nvJV4dFf3vgIPwINmbUwUISiizJo= 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=JolYpLxgIOrNzQqtLaecim2sNtjnvkIVwdafnMx1nhc=; b=YZP9fX25LqKU7HNHPs8hzQlgvSw8no5HcKwaBp1JMn4ihHGU2yI3y6teMatH00xKfM +YYve51aOIt5kFJvnJ56Ad2qYjYPiPFoxvUTHYGYr5Xz/2AJCu4vV4ANwgWE5ABDLiQg anhyHYKiXXumlpBUx61KlD4pDPr3snOmwNtgzxpFfBteJn/6qgflLWRUhH/rVneGKgFk vgDo/60wCmOUEYCGzQ3t+a4dHgiBxK57YGOPILXyjHouFxRbloFOB9/55JlRPP32K9cR +LBZ2OEUTdMyq1YxavN0HsohYRueXnC6Y5ZTVl3VMLFoqfFGnLcBko8eY9K/kslPLtJG DQPA== X-Gm-Message-State: AHPjjUiGHAKfEjFUdqmCZvIfY/RRhMiYVFXTNh4Xn/YKViQuNvHN33hE aiZQSL4DrMCU7o3f X-Google-Smtp-Source: ADKCNb6cK9LqgjBFi7g0iP94CWIY9xv3rZVRb3QRAX3DFX+Wk7Og4QYtsmK85NaIE1HPEcuLsNDv8g== X-Received: by 10.28.223.4 with SMTP id w4mr2525955wmg.33.1504440531881; Sun, 03 Sep 2017 05:08:51 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Cc: Ard Biesheuvel , Arnd Bergmann , Nicolas Pitre , Russell King , Kees Cook , Thomas Garnier , Marc Zyngier , Mark Rutland , Tony Lindgren , Matt Fleming , Dave Martin Date: Sun, 3 Sep 2017 13:07:39 +0100 Message-Id: <20170903120757.14968-12-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> Subject: [kernel-hardening] [PATCH v2 11/29] ARM: head.S: use PC relative insn sequence to calculate PHYS_OFFSET X-Virus-Scanned: ClamAV using ClamSMTP Replace the open coded arithmetic with a simple adr_l/sub pair. 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 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index f607e290ef4b..62c961849035 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -106,10 +106,8 @@ ENTRY(stext) #endif #ifndef CONFIG_XIP_KERNEL - adr r3, 2f - ldmia r3, {r4, r8} - sub r4, r3, r4 @ (PHYS_OFFSET - PAGE_OFFSET) - add r8, r8, r4 @ PHYS_OFFSET + adr_l r8, _text @ __pa(_text) + sub r8, r8, #TEXT_OFFSET @ PHYS_OFFSET #else ldr r8, =PLAT_PHYS_OFFSET @ always constant in this case #endif @@ -161,10 +159,6 @@ ENTRY(stext) 1: b __enable_mmu ENDPROC(stext) .ltorg -#ifndef CONFIG_XIP_KERNEL -2: .long . - .long PAGE_OFFSET -#endif /* * Setup the initial page tables. We only setup the barest