From patchwork Mon Aug 14 12:53:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9898813 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 670AC603FB for ; Mon, 14 Aug 2017 12:57:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C368285FD for ; Mon, 14 Aug 2017 12:57:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50E2A28628; Mon, 14 Aug 2017 12:57:19 +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 3F6E5285E3 for ; Mon, 14 Aug 2017 12:57:17 +0000 (UTC) Received: (qmail 22397 invoked by uid 550); 14 Aug 2017 12:55:16 -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 22179 invoked from network); 14 Aug 2017 12:55:10 -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=khCcAZQyJDuVBs0KsUOlv2VjFEnf9n5+cTvAFfBqvKfVoBGIfX74DEks2WlHYpaTSn OPCpcZW4SF4j4YgUu75BpSOkiB3JZuSRtkVLm5gqOK6WpXA3JPoaLSPbkn0ZXPnKySff tMZAgHWDwOe0ogYzhizkLhwim45b/ce5+xSNg= 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=ezmkAwL5qp8KY/XVkA4ayRsggByQe7BN4eoyjpjUPddAfPfnRKMGbtB3+E4ssyOxhr jSrkxcY/qbvHZGyql/StWrER9klQh2GVhqOUbMQVgdSwNem32n2ZIxsFZkf8phn4pfYg EpR7ZoMoxDgsbDKoSnMFwX8f+d5GEzQLdr4R4kyhQV0gzzL7mVvsaIdVpKJFB9OhlzPf a2Trdyx7K3Rx79779ndt7CGlHuqAHLPuMm5VqxGhgRGH+T81N9iSqxEKNsQtgCINKteB xB3QarkE3lK3/aDUgGtpxVvUT4g4sldK3v792RyHDOpGOA2mHyp/LWRAQAMBZ/UiHqqm SmoQ== X-Gm-Message-State: AHYfb5hfiquStERBxAN6zjePckCHcmzXL0OA1tCkogcvZQS2h0dzckyu Z4pN5+FaZcbfWlKop8ZUew== X-Received: by 10.28.225.139 with SMTP id y133mr3741206wmg.41.1502715299211; Mon, 14 Aug 2017 05:54:59 -0700 (PDT) From: Ard Biesheuvel To: kernel-hardening@lists.openwall.com Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Arnd Bergmann , Nicolas Pitre , Russell King , Kees Cook , Thomas Garnier , Marc Zyngier , Mark Rutland , Tony Lindgren , Matt Fleming , Dave Martin Date: Mon, 14 Aug 2017 13:53:51 +0100 Message-Id: <20170814125411.22604-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170814125411.22604-1-ard.biesheuvel@linaro.org> References: <20170814125411.22604-1-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH 10/30] 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 --- 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