Received: by 10.223.176.5 with SMTP id f5csp2865199wra; Mon, 29 Jan 2018 05:21:49 -0800 (PST) X-Google-Smtp-Source: AH8x226KTnCxJ1yfTo9BHNZcdQQuauD1NibGfvmPIv1p52GAP9ggOqb06enRGMc6daZVtb8j83KU X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr19271799plg.107.1517232109447; Mon, 29 Jan 2018 05:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517232109; cv=none; d=google.com; s=arc-20160816; b=wPHfP1uNK59kjrmbVTXSTakjpabfQuv0xrOeUE8Fq/EMsqSoG9VZHrrdhSvpaWFCZk 9z77T+whnphvaMTyl/+m4WcIGdIzMu1aD4eZRY/uE1RLD9LaQeld4eCBKBQMHjbubLRL uGtV11S+Jc4HG1IaMZJjBoPis+H2HlS2JXTyw3zqw7uQWtQrfP8MoxGp6FspHodbtlmu HEVeLrKm3NhrBeMWHI2ACJmDO4uOOFSeFG1DWKRN/3sTTOXutf6+PcVnOc7qsrg4Mktx PcifyqXzy2phMmh2wfkqMtLpz00mcxmgRAPpN+A7vr8DyfLfUnB0n4uDdzxxAtRcCA2l FpTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ZXea6+J7ItYKB83dP7bKOGylm34PksCC395745ErZ7s=; b=Y3ujBzBAc0kd6EdO1/Vu61r+xwe06cMLzrDSM5qP1ypnriGRnWzAc0NqXGZaALKywZ +ljg2/0PctHiiyLJytXe/bDrHBSNu8J9tb3u4WaBXAAZGXvAKsidbtG8hhB/Tc8InTBo teVarpU2Na7IwWa3gzebLlGiaJEjQVvclHIaVvJqhJVFhv7gjF/JJJ4sgC7e5Innb0Zg e7IAIaQaqoxk0s5yl1a8zMUyp2ZO5LybJHQTsJN/9TtroUTOMbhwXOWZ+3/k4Bsk8mnF Vafeb0dByG/mfP11qKvrrfc6XPfSJcmCjKx259BmrfAdf+qEzfd4RHpYvyIW2aEbS7li xOGQ== 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 j189si4379936pgc.789.2018.01.29.05.21.34; Mon, 29 Jan 2018 05:21:49 -0800 (PST) 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 S1751898AbeA2NTo (ORCPT + 99 others); Mon, 29 Jan 2018 08:19:44 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:40154 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbeA2NTm (ORCPT ); Mon, 29 Jan 2018 08:19:42 -0500 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 3CFE21596; Mon, 29 Jan 2018 05:19:42 -0800 (PST) Received: from edgewater-inn.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 0D91C3F24D; Mon, 29 Jan 2018 05:19:42 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id E10161AE3127; Mon, 29 Jan 2018 13:19:42 +0000 (GMT) Date: Mon, 29 Jan 2018 13:19:42 +0000 From: Will Deacon To: Andy Lutomirski Cc: Linus Torvalds , Al Viro , Alan Cox , David Laight , the arch/x86 maintainers , LKML , Greg Kroah-Hartman , Jann Horn , Samuel Neves , Dan Williams , Kernel Hardening , Borislav Petkov Subject: Re: [PATCH] x86/retpoline/entry: Disable the entire SYSCALL64 fast path with retpolines on Message-ID: <20180129131942.GC25549@arm.com> References: <1516976647.5438.6.camel@linux.intel.com> <20180126180722.GA13338@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On Fri, Jan 26, 2018 at 10:23:23AM -0800, Andy Lutomirski wrote: > On Fri, Jan 26, 2018 at 10:13 AM, Linus Torvalds > wrote: > > On Fri, Jan 26, 2018 at 10:07 AM, Al Viro wrote: > >> > >> Umm... What about other architectures? Or do you want SYSCALL_DEFINE... > >> to be per-arch? I wonder how much would that "go through pt_regs" hurt > >> on something like sparc... > > > > No, but I just talked to Will Deacon about register clearing on entry, > > and so I suspect that arm64 might want something similar too. > > > > So I think some opt-in for letting architectures add their own > > function would be good. Because it wouldn't be all architectures, but > > it probably _would_ be more than just x86. > > > > You need to add architecture-specific "load argX from ptregs" macros anyway. > > I mocked that up, and it's straightforward. I ended up with something like: > > #define __ARCH_SYSCALL_ARGS(n, ...) (regs->di, ...) > > (obviously modified so it actually compiles.) > > The issue is that doing it this way gives us, effectively: > > long sys_foo(int a, int b) > { > body here; > } > > long SyS_foo(const struct pt_regs *regs) > { > return sys_foo(regs->di, regs->si); > } > > whereas what we want is *static* long sys_foo(...). So I could split > the macros into: > > DEFINE_SYSCALL2(foo, ....) > > and > > DEFINE_EXTERN_SYSCALL2(foo, ...) > > or I could just fix up all the code that expects calling sys_foo() > across files to work. Another issue with this style of macro definition exists on architectures where the calling convention needs you to carry state around depending on how you packed the previous parameters. For example, on 32-bit ARM, 64-bit values are passed in adjacent pairs of registers but the low numbered register needs to be even. This is what stopped me from trying to use existing helpers such as syscall_get_arguments to unpack the pt_regs and it generally means that anything that says "get me argument n" is going to require constructing arguments 0..n-1 first. To do this properly I think we'll either need to pass back the size and current register offset to the arch code, or just allow the thing to be overridden per syscall (the case above isn't especially frequent). Will