Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752325AbeAJHPQ (ORCPT + 1 other); Wed, 10 Jan 2018 02:15:16 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33176 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751388AbeAJHPO (ORCPT ); Wed, 10 Jan 2018 02:15:14 -0500 X-Google-Smtp-Source: ACJfBov2xOmemmZRz5EtOVXv+X2KpkLFAx0IJCC48OWgj7hRP9w+ccgx8/ZD0TUE/TXIbdo9FVT8Cw== Date: Wed, 10 Jan 2018 08:15:10 +0100 From: Ingo Molnar To: Willy Tarreau Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Borislav Petkov , Brian Gerst , Dave Hansen , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , "H. Peter Anvin" , Greg Kroah-Hartman , Kees Cook Subject: Re: [RFC PATCH v2 6/6] x86/entry/pti: don't switch PGD on when pti_disable is set Message-ID: <20180110071510.nfice2pjtuylqirc@gmail.com> References: <1515502580-12261-1-git-send-email-w@1wt.eu> <1515502580-12261-7-git-send-email-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1515502580-12261-7-git-send-email-w@1wt.eu> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: * Willy Tarreau wrote: > When a syscall returns to userspace with pti_disable set, it means the > current mm is configured to disable page table isolation (PTI). In this > case, returns from kernel to user will not switch the CR3, leaving it > to the kernel one which already maps both user and kernel pages. This > avoids a TLB flush, and saves another one on next entry. > > Thanks to these changes, haproxy running under KVM went back from > 12700 conn/s (without PCID) or 19700 (with PCID) to 23100 once loaded > after calling prctl(), indicating that PTI has no measurable impact on > this workload. > > Signed-off-by: Willy Tarreau > Cc: Andy Lutomirski > Cc: Borislav Petkov > Cc: Brian Gerst > Cc: Dave Hansen > Cc: Ingo Molnar > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: Josh Poimboeuf > Cc: "H. Peter Anvin" > Cc: Greg Kroah-Hartman > Cc: Kees Cook > > v2: > - use pti_disable instead of task flag > --- > arch/x86/entry/calling.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h > index 2c0d3b5..5361a10 100644 > --- a/arch/x86/entry/calling.h > +++ b/arch/x86/entry/calling.h > @@ -229,6 +229,11 @@ > > .macro SWITCH_TO_USER_CR3_NOSTACK scratch_reg:req scratch_reg2:req > ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI > + > + /* The "pti_disable" mm attribute is mirrored into this per-cpu var */ > + cmpb $0, PER_CPU_VAR(pti_disable) > + jne .Lend_\@ Could you please do this small change for future iterations: s/per-cpu /per-CPU ... to make the spelling more consistent with the rest of the code base? Thanks, Ingo