From patchwork Sun Sep 3 12:07:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9936173 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 05E1E603D7 for ; Sun, 3 Sep 2017 12:13:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB73E286B0 for ; Sun, 3 Sep 2017 12:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFD73286B3; Sun, 3 Sep 2017 12:13:41 +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 3D9B5286B5 for ; Sun, 3 Sep 2017 12:13:39 +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=HTUVTTccI9GbQhjBgD+E8giRvsIc85ZCNAbKbvF5W3A=; b=SPDmqRGKfuz/jwrGijf8Lwc4hg FadiyvTd1KQae/WYR5qk1VTrgb41kl3O8TeBaoFdkHb/x8huTS7sg7nQe3w9inCzZuOfZdSGqDBzj YRHykH6gdQO7w4abXLz3iaTvC/BTvPfjtcL72uqjPFjCpOf+PGCeXvclBFLYsyhqF5wOubnYgh4dY Sd/qZTg/qSV7Q9EtVG8MDorGOU0ed2TLJXujpsJvuGoviYtBJW6Y++Z9nGLU8jRA9/vLzn21fraFD 5Y4kfbetE6wFAyC70vRRLfsZNH0pZHsNmKuvQBFt/ad2HoVf4NaDCf0Dj7OCMSAou95KfyYGMe7+y a+NE5SDg==; 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 1doTlb-0006Dd-Ue; Sun, 03 Sep 2017 12:12:43 +0000 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1doTi1-0001TF-1s for linux-arm-kernel@lists.infradead.org; Sun, 03 Sep 2017 12:09:03 +0000 Received: by mail-wr0-x230.google.com with SMTP id 40so8878475wrv.5 for ; Sun, 03 Sep 2017 05:08:40 -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=fouFkB02QaVsylENwgwALsIOy3KflFNC0G0jEBYzWk4=; b=IzC/GhzrpOtcOT4muXGs3sAvliQoW6NoeDM5bY8spYrzv84/aNy7YcMg25JWrUWDsR 3VHBNSJbXRtOgLc9dSWRzhfIElS811p4Bv653mvLDG0PeJvlEQs77XEr6zsD3t//AzDK kRgPpzqfSwemrObGHg1owIKwGyFJiNtESaGwM= 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=fouFkB02QaVsylENwgwALsIOy3KflFNC0G0jEBYzWk4=; b=pACaO9MBu8ZiY+L9LAVy1u7i7gT6tacb9ffRe8nTE7oDF/5tY866iDi6ukR6MtoQ/a AQCXfZFNxxAYVKj+y9F4o2pTnXE18s3L4IE6nvgo0t+iuFN65cUCE6gOrkPR+rLqDEz1 MiwdCTibsxSJB4930KdgV/3ydBWAHrb4Clt0UZ6qYLgwGNXLIUZR5wuO2X9azJjwYOQI NJ640NBiuRFcj0owqEKtcrFVfqAkXBac/gALDvLlylmTT2CXCCJGcuT53Jw/HxkWhaF1 g1KGL/riOC6wh3N7vjUT8gdzs8FY784wnkEhaqnzw0ayUAzx48w2SInI2YoLQgUvvM0W dgBw== X-Gm-Message-State: AHPjjUjOBjPdbzfW5+6E5A2XIkxCHxqLwnyaVK4VvM/oRpcL3XCGItFL WHO+UkLSxJs96iD5CrUlXw== X-Google-Smtp-Source: ADKCNb6sm9rtpi9iPUYWwCVA5uABtEoBVYd7k8EH1b2c5CQcBeu+qKupFHIrGNoJ+BI/ZFXYOQqKeA== X-Received: by 10.223.195.140 with SMTP id p12mr4623226wrf.299.1504440519029; Sun, 03 Sep 2017 05:08:39 -0700 (PDT) Received: from localhost.localdomain ([154.151.223.220]) by smtp.gmail.com with ESMTPSA id b196sm4392664wmd.29.2017.09.03.05.08.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Sep 2017 05:08:38 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 07/29] ARM: kernel: use relative references for UP/SMP alternatives Date: Sun, 3 Sep 2017 13:07:35 +0100 Message-Id: <20170903120757.14968-8-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_050901_321340_761B6146 X-CRM114-Status: GOOD ( 10.87 ) 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 To avoid absolute references that are subject to runtime relocation when running a kernel built with CONFIG_RELOCATABLE=y, use relative references in the smp.alt entries. Cc: Russell King Signed-off-by: Ard Biesheuvel Acked-by: Nicolas Pitre --- arch/arm/include/asm/assembler.h | 4 ++-- arch/arm/include/asm/processor.h | 2 +- arch/arm/kernel/head.S | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 341e4ed1ef84..a0906c1fc65d 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -260,7 +260,7 @@ */ #define ALT_UP(instr...) \ .pushsection ".alt.smp.init", "a" ;\ - .long 9998b ;\ + .long 9998b - . ;\ 9997: instr ;\ .if . - 9997b == 2 ;\ nop ;\ @@ -272,7 +272,7 @@ #define ALT_UP_B(label) \ .equ up_b_offset, label - 9998b ;\ .pushsection ".alt.smp.init", "a" ;\ - .long 9998b ;\ + .long 9998b - . ;\ W(b) . + up_b_offset ;\ .popsection #else diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h index c3d5fc124a05..3667b395bb17 100644 --- a/arch/arm/include/asm/processor.h +++ b/arch/arm/include/asm/processor.h @@ -92,7 +92,7 @@ unsigned long get_wchan(struct task_struct *p); #define __ALT_SMP_ASM(smp, up) \ "9998: " smp "\n" \ " .pushsection \".alt.smp.init\", \"a\"\n" \ - " .long 9998b\n" \ + " .long 9998b - .\n" \ " " up "\n" \ " .popsection\n" #else diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 6e9df3663a57..ec22f42fd8bb 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -548,14 +548,15 @@ smp_on_up: __do_fixup_smp_on_up: cmp r4, r5 reths lr - ldmia r4!, {r0, r6} - ARM( str r6, [r0, r3] ) - THUMB( add r0, r0, r3 ) + ldmia r4, {r0, r6} + ARM( str r6, [r0, r4] ) + THUMB( add r0, r0, r4 ) + add r4, r4, #8 #ifdef __ARMEB__ THUMB( mov r6, r6, ror #16 ) @ Convert word order for big-endian. #endif THUMB( strh r6, [r0], #2 ) @ For Thumb-2, store as two halfwords - THUMB( mov r6, r6, lsr #16 ) @ to be robust against misaligned r3. + THUMB( mov r6, r6, lsr #16 ) @ to be robust against misaligned r0. THUMB( strh r6, [r0] ) b __do_fixup_smp_on_up ENDPROC(__do_fixup_smp_on_up) @@ -564,7 +565,6 @@ ENTRY(fixup_smp) stmfd sp!, {r4 - r6, lr} mov r4, r0 add r5, r0, r1 - mov r3, #0 bl __do_fixup_smp_on_up ldmfd sp!, {r4 - r6, pc} ENDPROC(fixup_smp)