Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758751AbeAIAsP (ORCPT + 1 other); Mon, 8 Jan 2018 19:48:15 -0500 Received: from mail-it0-f43.google.com ([209.85.214.43]:33590 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754683AbeAIAsK (ORCPT ); Mon, 8 Jan 2018 19:48:10 -0500 X-Google-Smtp-Source: ACJfBos3dBjR3IRqhQT6r70Xl9O+bD7ZqKxFyGV7ByK8C4pvCLJG8PDsyq611kvQOID4929iAySVSU1t0w2UZjeTE8g= MIME-Version: 1.0 In-Reply-To: <1515458545.4423.76.camel@infradead.org> References: <1515363085-4219-1-git-send-email-dwmw@amazon.co.uk> <1515455051.15588.7.camel@infradead.org> <1515455902.4423.59.camel@amazon.co.uk> <1515458545.4423.76.camel@infradead.org> From: Linus Torvalds Date: Mon, 8 Jan 2018 16:48:09 -0800 X-Google-Sender-Auth: fvWjwa4BLAv8BDxKEdUnfJXD_5Q Message-ID: Subject: Re: [PATCH v6 11/10] x86/retpoline: Avoid return buffer underflows on context switch To: David Woodhouse Cc: "linux-kernel@vger.kernel.org" , "tim.c.chen@linux.intel.com" , "peterz@infradead.org" , "tglx@linutronix.de" , "ak@linux.intel.com" , "riel@redhat.com" , "keescook@google.com" , "gnomes@lxorguk.ukuu.org.uk" , "pjt@google.com" , "dave.hansen@intel.com" , "luto@amacapital.net" , "jikos@kernel.org" , "gregkh@linux-foundation.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 8, 2018 at 4:42 PM, David Woodhouse wrote: > > Hm... on a context switch you're reloading the registers that were in > the other saved context. Actually, iirc we used to very actively try to minimize that by having the inline asm mark a lot of registers as clobbered. We moved away from that and now have that "switch_to_asm()" call instead, but that was for unrelated reasons. If I remember our old inline asm, we actually had *very* little real data that was actually live on context switch, particularly that last "branch to new EIP" point. Partly because we had different targets, one of which was that "return from fork" case. But maybe I mis-remember. Wouldn't be the first time. This is code I used to know well, but that was many many moons ago, now there are other suckers^W maintainers who actually work with it. Linus