Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755281AbcLBTXd (ORCPT ); Fri, 2 Dec 2016 14:23:33 -0500 Received: from mail-ua0-f171.google.com ([209.85.217.171]:35008 "EHLO mail-ua0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753578AbcLBTXb (ORCPT ); Fri, 2 Dec 2016 14:23:31 -0500 MIME-Version: 1.0 In-Reply-To: References: <0a21157c2233ba7d0781bbf07866b3f2d7e7c25d.1480638597.git.luto@kernel.org> <20161202180343.gehqor7lgtmzwqq3@pd.tnic> <20161202185008.tdziqrzi4a3axord@pd.tnic> From: Andy Lutomirski Date: Fri, 2 Dec 2016 11:23:09 -0800 Message-ID: Subject: Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation To: Linus Torvalds Cc: Borislav Petkov , Andy Lutomirski , Peter Anvin , "the arch/x86 maintainers" , One Thousand Gnomes , Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Matthew Whitehead , Henrique de Moraes Holschuh , Peter Zijlstra , Andrew Cooper Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1652 Lines: 38 On Fri, Dec 2, 2016 at 11:03 AM, Linus Torvalds wrote: > On Fri, Dec 2, 2016 at 10:50 AM, Borislav Petkov wrote: >> >> Right, we can try to do something like invalidate_icache() or so in >> there with the JMP so that the BSP refetches modified code and see where >> it gets us. > > I'd really rather rjust mark it noinline with a comment. That way the > return from the function acts as the control flow change. > >> The good thing is, the early patching paths run before SMP is >> up but from looking at load_module(), for example, which does >> post_relocation()->module_finalize()->apply_alternatives(), this can >> happen late. >> >> Now there I'd like to avoid other cores walking into that address being >> patched. Or are we "safe" there in the sense that load_module() happens >> on one CPU only sequentially? (I haven't looked at that code to see >> what's going on there, actually). > > 'sync_core()' doesn't help for other CPU's anyway, you need to do the > cross-call IPI. So worrying about other CPU's is *not* a valid reason > to keep a "sync_core()" call. > > Seriously, the only reason I can see for "sync_core()" really is: > > - some deep non-serialized MSR access or similar (ie things like > firmware loading etc really might want it, and a mchine check might > want it) Not even firmware loading wants it. Firmware loading needs specifically cpuid(eax=1). It has nothing to do with serializing anything -- it's just a CPU bug that was turned into "architecture". I think it really is just cross-address or cross-core modification, and I'll add a comment to that effect. --Andy