Received: by 10.223.176.46 with SMTP id f43csp2301612wra; Thu, 25 Jan 2018 07:53:39 -0800 (PST) X-Google-Smtp-Source: AH8x226H851rFzz5lZr048DuEffYs01kScUVP46HbGDqmpt4cFk0xmQR/Vm3Qbeiz2dDtbD+9IH3 X-Received: by 10.99.177.4 with SMTP id r4mr13423903pgf.245.1516895619111; Thu, 25 Jan 2018 07:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516895619; cv=none; d=google.com; s=arc-20160816; b=yDNHlhEMq0r0owULwEec/wg0lZ9KCLUCkNUEbOOc+h+SETYQ+A++ynPCOJIQbYZnt0 ERPL0dgUbdsO2wVvHm1u+LTpCAn9VncfzZZFI+QpqbKQcWCtehWBB/K9jZmey2IMx/rH pGe8xLMfI6jLsvWZRckCXs38FVVqo8vkBizuSEVieVQqLIKKAFXu87fdIILsIAL/b8x4 J3La4WZtwTiJaJ3MZIOjqCxPHA1PMm1XcMX/IEOw7NVlcAN/jDmJePtgvY79+PLxHgQz Mrsg5Yr4vO7AYM6R8k0nM0W7HUbmRc28XypswiJL7OgsM+4OkgDq0+lIpZcHf5f3hAKR /9jw== 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=t8w2OKwDWR4UAVDv7Wz3YJfVpYtZZhL3BtZbUlE2Ukw=; b=HmNKwcu2IUDDnATXnj94zYf3pRrBRW3C17tWX/IEjzP6modMLQuAmGOtDtskQC8Iu5 sMzTEHY40A3yYQb0HEg/viLewDbIYOvkrhuSr2r5/4WQaLWEswpFMdy5jaEmowEON4tR a4boK8940iUEP9uzMAr8kxiHUkik7wVgoszAKCST3Ca5oD0FQ+PgJb4PGdBcCzl/WA3w 675eJHKQONwNgk9hZDTWbzdDHNAcUux2DuhOI9UxRfI/YQi8oJqqp6NniHafX6llESnd jybaYctGhnDezcSD1Vg8jR+9DmK+zwzIOkBq+Y3YFX6peeyPD/gatn9YJX8+kPdWzNYT bXUQ== 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 a138si4777617pfd.161.2018.01.25.07.53.24; Thu, 25 Jan 2018 07:53:39 -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 S1751367AbeAYPvW (ORCPT + 99 others); Thu, 25 Jan 2018 10:51:22 -0500 Received: from mail.skyhub.de ([5.9.137.197]:46528 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751114AbeAYPvV (ORCPT ); Thu, 25 Jan 2018 10:51:21 -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 p2qmGZywkoUT; Thu, 25 Jan 2018 16:51:19 +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 B33FE1EC030F; Thu, 25 Jan 2018 16:51:19 +0100 (CET) Date: Thu, 25 Jan 2018 16:51:10 +0100 From: Borislav Petkov To: Josh Poimboeuf Cc: David Woodhouse , 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, 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: <20180125155110.mw655b7fwgm7qqc7@pd.tnic> References: <1515755487-8524-1-git-send-email-dwmw@amazon.co.uk> <20180125120743.ey32gvl5mjam4r2s@pd.tnic> <1516882849.30244.94.camel@infradead.org> <20180125124554.vdx7rrnfrxrzl2ng@pd.tnic> <20180125151024.bidjr26r667vs7h5@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180125151024.bidjr26r667vs7h5@treble> 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 09:10:24AM -0600, Josh Poimboeuf wrote: > Huh? GCC doesn't even look inside the inline asm. That's why we had to > implement ASM_CALL_CONSTRAINT. That wasn't very correct. What I meant was: *we* need to tell gcc that the inline asm *might* clobber registers and which those might be. What David suggested with ASM_NO_INPUT_CLOBBER is the proper thing to do. > And the seg fault is objtool's way of telling you you need a > ANNOTATE_NOSPEC_ALTERNATIVE above the alternative ;-) Except that it blew up when I did this which doesn't have ALTERNATIVE (it's the diff I saved :-)) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 390b3dc3d438..16cc2e73d17d 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -281,3 +281,19 @@ ssize_t cpu_show_spectre_v2(struct device *dev, return sprintf(buf, "%s\n", spectre_v2_strings[spectre_v2_enabled]); } #endif + +#ifdef CONFIG_RETPOLINE +void __fill_rsb_nop(void) +{ + cpu_relax(); +} + +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 -- > (I know that's not the best answer, will fix it soon.) Thx. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.