From patchwork Mon Aug 14 17:42:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 9899855 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 7D0FD60230 for ; Mon, 14 Aug 2017 17:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 688A62237D for ; Mon, 14 Aug 2017 17:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BBAA223A1; Mon, 14 Aug 2017 17:44:31 +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, RCVD_IN_DNSWL_MED 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 D94AA26419 for ; Mon, 14 Aug 2017 17:44:29 +0000 (UTC) Received: (qmail 5651 invoked by uid 550); 14 Aug 2017 17:44:25 -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 5629 invoked from network); 14 Aug 2017 17:44:24 -0000 Date: Mon, 14 Aug 2017 18:42:59 +0100 From: Mark Rutland To: Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, keescook@chromium.org, ard.biesheuvel@linaro.org, matt@codeblueprint.co.uk, kernel-hardening@lists.openwall.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, luto@amacapital.net, james.morse@arm.com, labbott@redhat.com Message-ID: <20170814174259.GA25890@leverpostej> References: <1502130965-18710-1-git-send-email-mark.rutland@arm.com> <1502130965-18710-11-git-send-email-mark.rutland@arm.com> <20170814171338.gvtn76awussgxctn@armageddon.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170814171338.gvtn76awussgxctn@armageddon.cambridge.arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [kernel-hardening] Re: [PATCH 10/14] arm64: assembler: allow adr_this_cpu to use the stack pointer X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Aug 14, 2017 at 06:13:39PM +0100, Catalin Marinas wrote: > On Mon, Aug 07, 2017 at 07:36:01PM +0100, Mark Rutland wrote: > > .macro adr_this_cpu, dst, sym, tmp > > - adr_l \dst, \sym > > + adrp \tmp, \sym > > + add \dst, \tmp, #:lo12:\sym > > mrs \tmp, tpidr_el1 > > add \dst, \dst, \tmp > > .endm > > Nitpick: it may be worth adding an #ifndef MODULE around these macros, > together with a comment, just in case. There are other macros in this > file like adr_l which are used in modules (crypto). I've folded in the below, in keeping with the other MODULE fallbacks. Thanks, Mark. ---->8---- diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 4775af5..50c5592 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -230,13 +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 \tmp, \sym +#endif mrs \tmp, tpidr_el1 add \dst, \dst, \tmp .endm