From patchwork Tue Aug 15 12:50:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 110149 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5439593obb; Tue, 15 Aug 2017 05:53:06 -0700 (PDT) X-Received: by 10.84.132.13 with SMTP id 13mr31989306ple.42.1502801586645; Tue, 15 Aug 2017 05:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502801586; cv=none; d=google.com; s=arc-20160816; b=e8qR16juhRIQT8P5QhfsGzs7L3stKXx5LE44umVvNWPkWq1BRiriZSFXlY3/RW9PzO fVqGTm7hcNVbBIzeORb/GrjHE+CYJmrUrATZ8Djlra5Cp9rV5YbFUYwC1xC4cl/VsJAX ceHoUDaU9Fr6+gmlAaE81DT2FxI2/pPPvfUK6CQyx+tgFSppk8aP7cFu4VigSA2Nb5uX FPK0Hp8Qk0cun43kMDxwFf+jnlVd6gfUK4bnCZxzTKmOJLpp6UykBHuzOCl9tpvKA0SL zotOT/T5j53JILKPiLIW8QYFRlwYS+KthI/7vzW8UlXOYWWrJ+xfTcxcLpDWcGR4lEbS dIMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fpRpZkbtKY+BDSp7ztD9RhxkFVKMiZh6KAbEjsiKDWU=; b=vT/nKIPaRQte0YXDB9W0bgUvIuY4oQCKJ9qJ0sq/z7DMGESbQmdPajPSuUJeBVzDCZ cMrE4rmgtHijSGkznoQ2RfoK0s/cqicX/QH+zZ7KDdmOo9zUYq/NHXoRgkrPbKFetIQT hrc6Dz8xhbvNT1H1TXF1+4du6wr3Rhf79dA1sEr+g8kJMi9hRxhudzsaGXHUYa1nbPV9 QGDdcI7zV/qWqfB6xDC5sEi7fKdUpQzQdCpkDFiHXfDcGZB3yE3u4TZcGHbz2JEQ5yN8 8YOLR67u+s5j42RobuMiMnmVmJn8UDJsRKCRgPBkeyy3XLRJZPb/YYy7GYs/LgSfH+jn mnYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b68si5504932pfc.322.2017.08.15.05.53.06; Tue, 15 Aug 2017 05:53:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752833AbdHOMxB (ORCPT + 25 others); Tue, 15 Aug 2017 08:53:01 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51580 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752756AbdHOMxA (ORCPT ); Tue, 15 Aug 2017 08:53:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D0EC3169F; Tue, 15 Aug 2017 05:52:59 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BDD0A3F540; Tue, 15 Aug 2017 05:52:57 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ard.biesheuvel@linaro.org, catalin.marinas@arm.com, james.morse@arm.com, labbott@redhat.com, linux-kernel@vger.kernel.org, luto@amacapital.net, mark.rutland@arm.com, matt@codeblueprint.co.uk, will.deacon@arm.com, kernel-hardening@lists.openwall.com, keescook@chromium.org Subject: [PATCHv2 10/14] arm64: assembler: allow adr_this_cpu to use the stack pointer Date: Tue, 15 Aug 2017 13:50:45 +0100 Message-Id: <1502801449-29246-11-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502801449-29246-1-git-send-email-mark.rutland@arm.com> References: <1502801449-29246-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel Given that adr_this_cpu already requires a temp register in addition to the destination register, tweak the instruction sequence so that sp may be used as well. This will simplify switching to per-cpu stacks in subsequent patches. While this limits the range of adr_this_cpu, to +/-4GiB, we don't currently use adr_this_cpu in modules, and this is not problematic for the main kernel image. Signed-off-by: Ard Biesheuvel [Mark: add more commit text] Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: James Morse Cc: Laura Abbott Cc: Will Deacon --- arch/arm64/include/asm/assembler.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 610a420..2f2bd51 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -230,12 +230,18 @@ .endm /* - * @dst: Result of per_cpu(sym, smp_processor_id()) + * @dst: Result of per_cpu(sym, smp_processor_id()), can be SP for + * non-module code * @sym: The name of the per-cpu variable * @tmp: scratch register */ .macro adr_this_cpu, dst, sym, tmp +#ifndef MODULE + adrp \tmp, \sym + add \dst, \tmp, #:lo12:\sym +#else adr_l \dst, \sym +#endif mrs \tmp, tpidr_el1 add \dst, \dst, \tmp .endm