Received: by 10.223.176.46 with SMTP id f43csp2096280wra; Thu, 25 Jan 2018 04:59:01 -0800 (PST) X-Google-Smtp-Source: AH8x2258tThMhTr8yeMdHD32vwULhKis2uHDz46pRK9g8oW/sDBRGwpaDcgqzgWN32ma3hg9HANv X-Received: by 2002:a17:902:6c0e:: with SMTP id q14-v6mr11448115plk.445.1516885141510; Thu, 25 Jan 2018 04:59:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516885141; cv=none; d=google.com; s=arc-20160816; b=L+qGDV4BxW2QAbCYcntf25HeccqEInwzIGD8b2l5RTRZ1bMroNqS0bUJAoMDrW0yFL 5OhYPe7oR/5ti0Ae2pjGMwYkoZXF1u8uBE6gzIbohh3Onn2Xi1CWxwc3i4JI+0C2yNQ9 BQLePKHRFikJsWRfNZOcHvUc3hfHwBaKbghz3RKBRb+214qZZWgTc6mj/BTUMbFD2OIu ydADkAl8UNG9TOkUhk2pcvJx36MdTuDVKDbOh1qqBT1QtZ6B55hinsebZ4vUTyZOKY7u mVMonZNjNzAkNxUroH6viJ47IpFGpXoU9gDMdOllpgsAY9PdjVTzsyNelr7cFry3QR6C VG2Q== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=rdP00KTXmxsdr7LvNoUIYElMvJDCNO+ZkCud7nCpal4=; b=E2Vy89tQ0rOO8WQM3k+tXcU+I93GgTQc/KgfdEE0D1fTlc65kCbd7qW0JTxFsLX4tZ gIYAlZb7dTN4s1lOBPEn0xDACJ0ggsXTwZhKNfNMfqQHZ55fqenG3fT/Hj60fg0K8nsH CmsH3dNd0+twHMWz7Jvr6wn937rf+mpXJx38CHhzEHUv1/wk4QrZW+1qtpAw8G6R/3Bc iXuZcSYZvtlEyEOzO3L0kwKhJT7Rtyh65i9f2803LwAqm5P+mMIxH1M9eZ/EVPxfbtHU rR70BF48oQUMtB97THsgrGfP1bB86vUEZofbRT+mS29Yu9aYl/oW4BbT/VAJ2RvDopDy fU7g== 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 o65si4595716pfg.18.2018.01.25.04.58.47; Thu, 25 Jan 2018 04:59:01 -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 S1751803AbeAYMqG (ORCPT + 99 others); Thu, 25 Jan 2018 07:46:06 -0500 Received: from mail.skyhub.de ([5.9.137.197]:39768 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbeAYMqF (ORCPT ); Thu, 25 Jan 2018 07:46:05 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id WmeMSkO1A0vb; Thu, 25 Jan 2018 13:46:03 +0100 (CET) Received: from pd.tnic (p200300EC2BD0EE0024194793E6CFFC7A.dip0.t-ipconnect.de [IPv6:2003:ec:2bd0:ee00:2419:4793:e6cf:fc7a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6D3BC1EC02BE; Thu, 25 Jan 2018 13:46:03 +0100 (CET) Date: Thu, 25 Jan 2018 13:45:54 +0100 From: Borislav Petkov To: David Woodhouse Cc: tim.c.chen@linux.intel.com, pjt@google.com, jikos@kernel.org, gregkh@linux-foundation.org, dave.hansen@intel.com, mingo@kernel.org, riel@redhat.com, luto@amacapital.net, torvalds@linux-foundation.org, ak@linux.intel.com, keescook@google.com, jpoimboe@redhat.com, peterz@infradead.org, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org Subject: Re: [tip:x86/pti] x86/retpoline: Fill return stack buffer on vmexit Message-ID: <20180125124554.vdx7rrnfrxrzl2ng@pd.tnic> References: <1515755487-8524-1-git-send-email-dwmw@amazon.co.uk> <20180125120743.ey32gvl5mjam4r2s@pd.tnic> <1516882849.30244.94.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516882849.30244.94.camel@infradead.org> User-Agent: NeoMutt/20170609 (1.8.3) 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 12:20:49PM +0000, David Woodhouse wrote: > I haven't had lunch yet, so I don't feel queasy Oh, I caught you on time then :-) > and I'm vaguely interested... *why* does it break kABI? Kernels < 4.1 don't have the insn padding I did back then so when one tries to backport this, struct alt_instr size changes. Fun. > > +/* Like alternative_io, but for replacing a direct call with another one. */ > > +#define alternative_void_call(oldfunc, newfunc, feature, input...) \ > > + asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \ > > + : : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) > > But you aren't doing the call at all in the other case, and > alternatives *always* handled the case where the first 'alternative' > instruction was a branch, didn't it? > > So couldn't it just be alternative(nop, call __fill_rsb_func)? > > But I still don't understand why it matters. You need for both to be CALL instructions there so that gcc can manage the callee clobbers properly - i.e., recognize that there's a function call there. Otherwise you need to do uglies like the hunk in arch/x86/Kconfig in d61931d89be5 ("x86: Add optimized popcnt variants") which I killed later after all as it broke profiling and other tools. And besides, calling a NOPpy function on CONFIG_RETPOLINE=n is the least of our troubles. Also, the installations running CONFIG_RETPOLINE=n are going to be a very very very small number. > > +void __fill_rsb(void) > > +{ > > + unsigned long loops; > > + > > + asm volatile (__stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)) > > +       : "=r" (loops), ASM_CALL_CONSTRAINT > > +       : : "memory" ); > > +} > > +#endif > > The out-of-line function should be __clear_rsb() if it's using > RSB_CLEAR_LOOPS, and __fill_rsb() if it's using RSB_FILL_LOOPS. I think > we're only using one right now but Andi at least is posting patches > which use the other, as part of the Skylake clusterfuck. Ok. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.