Received: by 10.223.176.46 with SMTP id f43csp2689200wra; Thu, 25 Jan 2018 13:39:56 -0800 (PST) X-Google-Smtp-Source: AH8x2259PfHjXB2yetEAFsRH7dMKfRcyCdNxZx+XeUMzSQu9/Yd55aYJslZndDQIWO/Uc3tWp072 X-Received: by 2002:a17:902:6ec5:: with SMTP id l5-v6mr12730617pln.443.1516916396607; Thu, 25 Jan 2018 13:39:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516916396; cv=none; d=google.com; s=arc-20160816; b=x0Kg8HcAWnIUg+bSCHFgV4Qr/bMrzKRYYHnPfWNSjRtQsX+RoqT7fFKUK/9djTh0Wr 6b3hpmmlzTEmy2oWt9fmsQFWmU9k3iYZUHA4UHX8SjyhX2IRi761zgxTq/KpA8gCpQ+2 dGgMoZ5bkz/tYAfH92uhdiUAxmNJ+YhmvUj3Zi4UYc7c4Bf4e/vNY2IS6e43yIu+vwdB icLZ8Dliscezn7xE0HHgyyyhNX95OR9n1Mf4/vmPyRhZh1xKngMjo+EOi2JojkQ3haCA cZDzb6d0CdZFFmjsFtXKQHhuXqV0eUjzXAFGr74ext0dqE723TFf3toYapKPqigAf1G9 TwcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=0JoMYTshsCAkFkwq4YqVzWHqGUlUsGRGlpJuoz49eq4=; b=wjAh3o+cf2utOP+101FVo7spMZWkcSjmEiykoWFnpNiCUovlKbCXYisJTF0oeiW5RI 7pC3ifyKOPpjMYQfTP6s//ZpcfxSEpKm6JNi1k0OqE6WYPIfGVl4lU6zyQ9xFIQ8ZQwP lpJS2pmLXh95337ARJR0R5Y9f/tS/uKlTg+rYP/LchqNkNzwduA10dxObKV3tI6tQwin HY1Rx+Aoo+7SUCHRKgXMjNn+lp38h0FWgjFkJsuoSma6bgCC7wfverAFeCXZH55n0R+b /LprlcihOAxg6PsPQVjjwjKVuZfoOixPv+L5Hi4KWZnaWQYmrxogdCZ3tzjYM9PJh8M2 US5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=DH26NHP+; 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 m26si2048032pgc.375.2018.01.25.13.39.41; Thu, 25 Jan 2018 13:39:56 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=DH26NHP+; 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 S1751406AbeAYVjH (ORCPT + 99 others); Thu, 25 Jan 2018 16:39:07 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:40665 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751181AbeAYVjG (ORCPT ); Thu, 25 Jan 2018 16:39:06 -0500 Received: by mail-oi0-f66.google.com with SMTP id a184so6426126oif.7 for ; Thu, 25 Jan 2018 13:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0JoMYTshsCAkFkwq4YqVzWHqGUlUsGRGlpJuoz49eq4=; b=DH26NHP+hhd96OAHgmdyMNLhSquVOQyqs1ub/6jvxZptoU2lsmBm1dzz5zMkCAFGyA uO9hkfdwdo+kqjyaKAsmmz04pxcshbap906ApM8H7UpoJeb9z4FkU7NEd60PMsjcc/rG WCFLHPHT+F2fRNpIwoTSyRyyMBbJHHHrgVUQXYmk3IT+pCKgHzIzNIYcUxWP3Ro+luyu Tw3tx0GX+mFv+3WFmr1Bjv2MvuZ5/7eyv9Av3bO2VpTjKbKN638htvmoTgq7n23+2r9g l2Sq2iCgX7mhbexhp5GLM2/+35Pnmd05D7wpvguKjgbpNiyEjD5NCOf6LUd/uxaf2AcC uQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0JoMYTshsCAkFkwq4YqVzWHqGUlUsGRGlpJuoz49eq4=; b=loCUXaw9v/Isak76CmOtSC8QrNMwrmxthppp+vTvN/nro3qG6ZDfdi7Yg+ZgTU9YBL iyX08R153+8XegZNU+beQQoz8UZ51NztIWpAWjVhzn3KC0ogu73KcX0Oy2V31/2Arh1G xBE2QpZDuIk7Rz05lA+0LneuuHLp/f2gXoWyLkdGjKWD2PNxgjkd8010sWfpGnrxdNGG ccX5S29PW2hpWe5422Ha189LdKffaAmH8K4X7vKSqS4TBYRpCS0tU6b0GGJmo7hRU1g9 soRJjqhbyYtHOn5KeOC0KbDKBQcJs2zU3Muj067x1abkQ0If1yIGUIFvOkLifkLNqj2x mOQg== X-Gm-Message-State: AKwxytcfyJxsxxzpXlwnM+MvZTWSNaSznh+QtSwLP2iuC1McU2+jJALt xYiuZGXPdx3KZ0jsai5krUHbINFXSQgYlh52PGQt3nXA X-Received: by 10.202.171.14 with SMTP id u14mr11116929oie.187.1516916345765; Thu, 25 Jan 2018 13:39:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.62.72 with HTTP; Thu, 25 Jan 2018 13:39:05 -0800 (PST) In-Reply-To: References: <503224b776b9513885453756e44bab235221124e.1516644136.git.luto@kernel.org> From: Dan Williams Date: Thu, 25 Jan 2018 13:39:05 -0800 Message-ID: Subject: Re: [PATCH] x86/retpoline/entry: Disable the entire SYSCALL64 fast path with retpolines on To: Andy Lutomirski Cc: Linus Torvalds , "the arch/x86 maintainers" , LKML , Greg Kroah-Hartman , Alan Cox , Jann Horn , Samuel Neves , Kernel Hardening , Borislav Petkov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 25, 2018 at 1:31 PM, Andy Lutomirski wrote: > On Thu, Jan 25, 2018 at 1:20 PM, Linus Torvalds > wrote: >> On Thu, Jan 25, 2018 at 1:08 PM, Andy Lutomirski wrote: >>> >>> With retpoline, the retpoline in the trampoline sucks. I don't need >>> perf for that -- I've benchmarked it both ways. It sucks. I'll fix >>> it, but it'll be kind of complicated. >> >> Ahh, I'd forgotten about that (and obviously didn't see it in the profiles). >> >> But yeah, that is fixable even if it does require a page per CPU. Or >> did you have some clever scheme in mind? > > Nothing clever. I was going to see if I could get actual > binutils-generated relocations to work in the trampoline. We already > have code to parse ELF relocations and turn them into a simple table, > and it shouldn't be *that* hard to run a separate pass on the entry > trampoline. > > Another potentially useful if rather minor optimization would be to > rejigger the SYSCALL_DEFINE macros a bit. Currently we treat all > syscalls like this: > > long func(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5); > > I wonder if we'd be better off doing: > > long func(const struct pt_regs *regs); > > and autogenerating: > > static long SyS_read(const struct pt_regs *regs) > { > return sys_reg(regs->di, ...); > } If you're rejiggering, can we also put in a mechanism for detecting which registers to clear so that userspace can't inject useful values into speculation paths? https://patchwork.kernel.org/patch/10153753/