From patchwork Sun Sep 3 12:07:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9936159 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 3EC8B6037D for ; Sun, 3 Sep 2017 12:12:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30D21286A9 for ; Sun, 3 Sep 2017 12:12:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25694286B3; Sun, 3 Sep 2017 12:12:29 +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 3CF73286A9 for ; Sun, 3 Sep 2017 12:12:28 +0000 (UTC) Received: (qmail 17896 invoked by uid 550); 3 Sep 2017 12:09:37 -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 17742 invoked from network); 3 Sep 2017 12:09:35 -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=FzGBKn0x+r7vD+P/c7CsKX8tzYpbL6vlD085qE2PMTk=; b=WnVXaskFt4QzdT4+GiTpmwIiGeRmT7QLUB2xjLhoVq5SHUEu1Dl09aP4J7snjHBTz5 Q73sAa+ZMOkBLt09Qd7mkJ7AyGml1uEJoG+ldxz6YhDHXC6DmK2F3KYbVp8qhg3zyi0q WBwTkChsKXD+uc73ZiH6Ky/lGVwgCv6DeGPEo= 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=FzGBKn0x+r7vD+P/c7CsKX8tzYpbL6vlD085qE2PMTk=; b=haZiZzgSjrY0OBdBLeYRTkNKahjLgC82JTGVj8qKn/jx3hM5ie58+iNoQO/KnDpfeX s48vszwOFibb6g4hQ44jcYJPj1sWiWppHyd4NXZruHyG1Rvu4NzxDzsT0guHjvHqoxN7 GxwlXyqOXquiu48KBJXbbM5P7ItkyHOLTQbSTvxWLTJ5FkNDsgElsEXp6KwdMUaHZIBe ux5Yurvmg73TYK7dI1PA/8iHW2eeS4DfBOYS9CxgDFbMtPR8YPYhQQmoo65/QeBYL2KE sdzpLy1Jkpxbz9UOPbl5nP/PLJZW/71ugRAGuZ0IzV2sa4yo5CeMi6lsLqfQDClN2NuO FU+A== X-Gm-Message-State: AHPjjUhNjLaFyZVhf6K714vR0Y4WV7y1CZ6HYA4GjpMsZ3PhCrx+OHnb cfShHLesaDizjROT X-Google-Smtp-Source: ADKCNb76egNUZ2CthsC9SlACrUSYEOtHY+UVooPO3br+DaKFPYuzBujGDgf0Bh6bjuL/MCm3q7i69Q== X-Received: by 10.223.166.78 with SMTP id k72mr789917wrc.245.1504440564065; Sun, 03 Sep 2017 05:09:24 -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:49 +0100 Message-Id: <20170903120757.14968-22-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 21/29] ARM: kernel: use PC relative symbol references in suspend/resume code X-Virus-Scanned: ClamAV using ClamSMTP Replace some unnecessary absolute references with relative ones. Also, to prepare for runtime relocation, which occurs with the caches on, defer taking the absolute address of cpu_resume_after_mmu() until after the MMU is enabled. Cc: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/sleep.S | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S index f4920b5d0fc4..5b02744f2f12 100644 --- a/arch/arm/kernel/sleep.S +++ b/arch/arm/kernel/sleep.S @@ -60,15 +60,14 @@ ENTRY(__cpu_suspend) stmfd sp!, {r4 - r11, lr} #ifdef MULTI_CPU - ldr r10, =processor - ldr r4, [r10, #CPU_SLEEP_SIZE] @ size of CPU sleep state + ldr_l r4, processor + CPU_SLEEP_SIZE @ size of CPU sleep state #else - ldr r4, =cpu_suspend_size + adr_l r4, cpu_suspend_size #endif mov r5, sp @ current virtual SP add r4, r4, #12 @ Space for pgd, virt sp, phys resume fn sub sp, sp, r4 @ allocate CPU state on stack - ldr r3, =sleep_save_sp + adr_l r3, sleep_save_sp stmfd sp!, {r0, r1} @ save suspend func arg and pointer ldr r3, [r3, #SLEEP_SAVE_SP_VIRT] ALT_SMP(W(nop)) @ don't use adr_l inside ALT_SMP() @@ -101,13 +100,13 @@ ENDPROC(cpu_suspend_abort) .align 5 .pushsection .idmap.text,"ax" ENTRY(cpu_resume_mmu) - ldr r3, =cpu_resume_after_mmu instr_sync mcr p15, 0, r0, c1, c0, 0 @ turn on MMU, I-cache, etc mrc p15, 0, r0, c0, c0, 0 @ read id reg instr_sync mov r0, r0 mov r0, r0 + ldr r3, =cpu_resume_after_mmu ret r3 @ jump to virtual address ENDPROC(cpu_resume_mmu) .popsection