From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x2257FnNK7sjyRQWLexEzSt/DQw8IrabUq+RqjassXQVv1+TZTTYYfFQp1xe80vxJOXYSgbfb ARC-Seal: i=1; a=rsa-sha256; t=1516895480; cv=none; d=google.com; s=arc-20160816; b=EOu9bnjqpE6JmmyIcCXd750XBvjtVYnLyI1SCRpEaCjtf2jrrDXwS4ZDatqwHbDZeb ya8V80kpuOGklpkSxDODkuNsImxBRRTYwCuZv9Aoi/ODJoG++I8Z7vyuKZYUiwj+85B6 VBCMG5cefSV/alnybmriz8lvh/ZI74PxBGu8GAkfulH1h/QGaEW8/7C5SjjssSmgcDGO pl8AZXgds4b6/utZ87SNulCIQbsslyoeihGBl3DJen8VbKxeF7JCdLrqjQ5qOWmk04tC /dlkhSK5i0lxHKXiYm+plRWSOb25YnUBd3ZBU2z3TNjpxXV55fVAYYkcJQ+LndXUfwL8 gDzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=t8w2OKwDWR4UAVDv7Wz3YJfVpYtZZhL3BtZbUlE2Ukw=; b=Dkby8oVrxsUmUR+WljVuWt6WicS4Djb5rB3NVsKYYETu4tLMwdMLmQ7n7vR+di+yPn 7MQO6e8cRxSCOJ3ZORzQgv1bsduc79wSIfFvOsUHKujARneQ+IcDigJlwaaz5CVMTnf/ vuyyXz8h76ANhEYNQWprADVynU8pl7emc49F8/vzrcxbCYmOkYKBQ6tANgGEYvMn6E5e JKzaOTCoIUtqJnfQObNlmis/R5HkV+rPIrdJ40klLbYSEz0D6HUm73NuRrrhbDeEDccC 8n/tVphaubQRGxUYn2nAha1lHoYsOLf6NYg9ZgXeRma8NYJilCasSis4LQChSsGE1QH8 1Q6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bp@alien8.de designates 2a01:4f8:190:11c2::b:1457 as permitted sender) smtp.mailfrom=bp@alien8.de Authentication-Results: mx.google.com; spf=pass (google.com: domain of bp@alien8.de designates 2a01:4f8:190:11c2::b:1457 as permitted sender) smtp.mailfrom=bp@alien8.de 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) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1589334225298273984?= X-GMAIL-MSGID: =?utf-8?q?1590580195497366766?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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.