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: 9936117 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 8AE146037D for ; Sun, 3 Sep 2017 12:09:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CC442866E for ; Sun, 3 Sep 2017 12:09:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70E63286B0; Sun, 3 Sep 2017 12:09:21 +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 AD4512866E for ; Sun, 3 Sep 2017 12:09:19 +0000 (UTC) Received: (qmail 9518 invoked by uid 550); 3 Sep 2017 12:08:45 -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 9409 invoked from network); 3 Sep 2017 12:08:43 -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=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=c4nBJZdwiENtfr8uzLrz217e4YJxMKGSN5LAM7lDEHKJCNmb2BrBRSraCGJrQPFG06 laJIMOGDflOn270K7/Ysh1SZ3R0LL6ao6aArI79QKecBxysEcEsaWJzdAwYiozTy/XvC qF+JkwZsohjCzH8RArKauLcnAyjwC4cohxeLvy+AIk8TTDmp0lrNznyzmg26e1grD501 5e1JNNId9hmsCgKscEZZFrwkw8hzaDqyHu+jgsBPhH+AlfKymea7kGKwKm1zlncvZHpM 9Rt3DPw0awUc0F6pJxTE5hFJ+1nhF5VCZwxZHiT4AXt15J5YWpEcRh1CsAiEY/DOpXd2 BAiQ== X-Gm-Message-State: AHPjjUhgPm6rJNCImsUG+x6QBCiPi0EXaoz3D6GS/TubUb6NhrXB8Oio qwAbRZ9WGaO1rnM8 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) 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: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> Subject: [kernel-hardening] [PATCH v2 05/29] ARM: head-common.S: use PC-relative insn sequence for idmap creation 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