Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758548AbcLARqM (ORCPT ); Thu, 1 Dec 2016 12:46:12 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:26111 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756134AbcLARqL (ORCPT ); Thu, 1 Dec 2016 12:46:11 -0500 X-IronPort-AV: E=Sophos;i="5.33,282,1477958400"; d="scan'208";a="36008013" Subject: Re: [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to serialize To: Andy Lutomirski , Borislav Petkov , Jan Beulich References: <46816abe4f68ac3eb9b80231bf64ba8edcebc2f7.1480536936.git.luto@kernel.org> <20161201092228.calajwwv4k4k4l6f@pd.tnic> CC: Andy Lutomirski , X86 ML , One Thousand Gnomes , "linux-kernel@vger.kernel.org" , Brian Gerst , Matthew Whitehead , Henrique de Moraes Holschuh From: Andrew Cooper Message-ID: <76d0ec7c-5482-0782-af35-6871c8c88016@citrix.com> Date: Thu, 1 Dec 2016 17:46:08 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1316 Lines: 32 On 01/12/16 17:08, Andy Lutomirski wrote: > On Thu, Dec 1, 2016 at 1:22 AM, Borislav Petkov wrote: >> On Wed, Nov 30, 2016 at 12:34:55PM -0800, Andy Lutomirski wrote: >>> Aside from being excessively slow, CPUID is problematic: Linux runs >>> on a handful of CPUs that don't have CPUID. MOV to CR2 is always >>> available, so use it instead. >>> >>> Signed-off-by: Andy Lutomirski >>> --- >>> arch/x86/include/asm/processor.h | 31 ++++++++----------------------- >>> 1 file changed, 8 insertions(+), 23 deletions(-) >> Looks nice. >> >> I'm wondering if we should leave this one in tip for an additional cycle >> to have it tested on more hw. I know, it is architectural and so on but >> who knows what every implementation actually does... > I want the Xen opinion as well. > > Xen folks, can Linux use write_cr2 to serialize the CPU core on Xen PV > or do we need something a bit heavier weight like native_write_cr2? To sum up our conversation on IRC. xen_write_cr2() is not serialising; it is just a write into a shared page. native_write_cr2() would trap and be emulated. This will incur #GP[0] due to cpl, although not necessarily an iret on the way back out of Xen. Something like an iret-to-self would be far quicker, and avoid trapping into the hypervisor. ~Andrew