From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D03ECA9EA0 for ; Tue, 22 Oct 2019 16:00:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3DE632086D for ; Tue, 22 Oct 2019 16:00:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388922AbfJVQAk (ORCPT ); Tue, 22 Oct 2019 12:00:40 -0400 Received: from [217.140.110.172] ([217.140.110.172]:56130 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S2387746AbfJVQAj (ORCPT ); Tue, 22 Oct 2019 12:00:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6C2C177F; Tue, 22 Oct 2019 09:00:14 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09A513F71A; Tue, 22 Oct 2019 09:00:12 -0700 (PDT) Date: Tue, 22 Oct 2019 17:00:10 +0100 From: Mark Rutland To: Nick Desaulniers Cc: Sami Tolvanen , Will Deacon , Catalin Marinas , Steven Rostedt , Ard Biesheuvel , Dave Martin , Kees Cook , Laura Abbott , clang-built-linux , Kernel Hardening , Linux ARM , LKML Subject: Re: [PATCH 12/18] arm64: reserve x18 only with Shadow Call Stack Message-ID: <20191022160010.GB699@lakrids.cambridge.arm.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20191018161033.261971-13-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 18, 2019 at 02:23:10PM -0700, Nick Desaulniers wrote: > On Fri, Oct 18, 2019 at 9:11 AM 'Sami Tolvanen' via Clang Built Linux > wrote: > > > > Only reserve x18 with CONFIG_SHADOW_CALL_STACK. Note that all external > > kernel modules must also have x18 reserved if the kernel uses SCS. > > Ah, ok. The tradeoff for maintainers to consider, either: > 1. one less GPR for ALL kernel code or > 2. remember not to use x18 in inline as lest you potentially break SCS This option only affects compiler-generated code, so I don't think that matters. I think it's fine to say that we should always avoid the use of x18 in hand-written assembly (with manual register allocation), while also allowing the compiler to use x18 if we're not using SCS. This can be folded into the earlier patch which always reserved x18. > This patch is 2 (the earlier patch was 1). Maybe we don't write > enough inline asm that this will be hard to remember, and we do have > CI in Android to watch for this (on mainline, not sure about -next). I think that we can trust the set of people who regularly review arm64 assembly to remember this. We could also document this somewhere -- we might need to document other constraints or conventions for assembly in preparation for livepatching and so on. If we wanted to, we could periodically grep for x18 to find any illicit usage. Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABB3CCA9EA0 for ; Tue, 22 Oct 2019 16:00:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 761DB214B2 for ; Tue, 22 Oct 2019 16:00:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="f54hGksi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 761DB214B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0vCdYxy4T33GJWrCsyotpj/c19KrB764Gk9H3PNGB+I=; b=f54hGksi+ZvidI SERrcL+u5erTrSos7SzUtt1f3Up8Lfv965GMBTtyPkKqlVQu+KjG1kLF9Jp87i4GdJEK5BJRiheWr y1VGOkueun+CYjEUXnRL3QEeASN2/Wjg8NWvLuEYwOqaWKjTX61lF0R70o1E68nZL9VeEtwOQacpJ tJPjBBPtGQ+1ggV1NB8xHJrhUgPr8Au0ONHxO4FfrA+A/DhZUiJVpuR105ArkpHJO1LcpO5FIguCb UUhu7jJY7LYi1jjiQUvp28Vnw1ISC+9U+nUp29fmJNpGL2f7CJU1gyK4Y4ym3T5QgmckNmfZiOq6m YuSYejk1mmfbuh00Jzyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMwaD-0002Hd-1c; Tue, 22 Oct 2019 16:00:29 +0000 Received: from [217.140.110.172] (helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMwa9-0001wU-RA for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2019 16:00:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6C2C177F; Tue, 22 Oct 2019 09:00:14 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09A513F71A; Tue, 22 Oct 2019 09:00:12 -0700 (PDT) Date: Tue, 22 Oct 2019 17:00:10 +0100 From: Mark Rutland To: Nick Desaulniers Subject: Re: [PATCH 12/18] arm64: reserve x18 only with Shadow Call Stack Message-ID: <20191022160010.GB699@lakrids.cambridge.arm.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20191018161033.261971-13-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191022_090025_939336_FF6A0A4A X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kees Cook , Ard Biesheuvel , Catalin Marinas , Kernel Hardening , LKML , Steven Rostedt , clang-built-linux , Sami Tolvanen , Laura Abbott , Will Deacon , Dave Martin , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 18, 2019 at 02:23:10PM -0700, Nick Desaulniers wrote: > On Fri, Oct 18, 2019 at 9:11 AM 'Sami Tolvanen' via Clang Built Linux > wrote: > > > > Only reserve x18 with CONFIG_SHADOW_CALL_STACK. Note that all external > > kernel modules must also have x18 reserved if the kernel uses SCS. > > Ah, ok. The tradeoff for maintainers to consider, either: > 1. one less GPR for ALL kernel code or > 2. remember not to use x18 in inline as lest you potentially break SCS This option only affects compiler-generated code, so I don't think that matters. I think it's fine to say that we should always avoid the use of x18 in hand-written assembly (with manual register allocation), while also allowing the compiler to use x18 if we're not using SCS. This can be folded into the earlier patch which always reserved x18. > This patch is 2 (the earlier patch was 1). Maybe we don't write > enough inline asm that this will be hard to remember, and we do have > CI in Android to watch for this (on mainline, not sure about -next). I think that we can trust the set of people who regularly review arm64 assembly to remember this. We could also document this somewhere -- we might need to document other constraints or conventions for assembly in preparation for livepatching and so on. If we wanted to, we could periodically grep for x18 to find any illicit usage. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel