Received: by 10.223.185.116 with SMTP id b49csp992691wrg; Wed, 14 Feb 2018 09:56:50 -0800 (PST) X-Google-Smtp-Source: AH8x2279T4s1FLCKpVxwuieEJaNBDfcKxmNQvEmX6RPkdaNShKs7SewgP+pS1lea1gFVfv5Bfzkw X-Received: by 10.99.145.199 with SMTP id l190mr4386685pge.397.1518631010482; Wed, 14 Feb 2018 09:56:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518631010; cv=none; d=google.com; s=arc-20160816; b=LBIVGKFIOIBtbwsxzR+ECENyofPmcVmIt78gAgt9b5MBcfQm+oUZ57bWdEZVNpQgoa SUeZSP6moDw6FiEcVEOJesyEituBS+parfjoqqAOHz2Czeto8FGHAC0lTbCmHHb6LyYS XKDFVQBTHY/tGBirH1TRDZDloe6ff4dd04aNnMgqY3xQ6FjkwE5UXQBNiDUSwt5TgtBk fj0D6qP/qDVpJu2fPc75GR02XKPzKzJtLjUbIbJ9u0CtgKbhOsgrXnHKqvQPjoslkxQM 6ri9M5c0NzdwEa2gh1RwlV76RG9hMohj7pBzePxyhfMQJ2kBF8Q4MkyMHZjV6NRkStAY KK2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=C9f4igiyWW/tqWvZmf8XL480dvhMruZmW56TX8+tS5E=; b=T+5ewligB9jv3CdaBp09TZmwZL+si6nAHasCXipGMFsu9XCqyk3pyrkpALsb0kbiGU NLsAjAcYq/JW/mWlHV6MPjZRqyoqqGnTMIU4nccufLi1hQhlWKnlg75h5NhJZsObnXoY yshz22D3RCHtKEFoXE3oo6kJkv5TRw0bM/AhQQcWHrDZ5dKC3txKTCvZ62/PGhg8LCxk rx8u9yQXDruevX9UeBqHxhB0kiW7Q82NP7mWGLn+yjfaajXYY8QTnN0C328Cz2pY4YnD 7+8JHegO2wj++WCD2gye4F6iI7uNwkkE0b3fUQ6HzWdAACdqFgdLeW3HMj68iL+YS0kf rgpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=uLdw3uzX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si18938plj.651.2018.02.14.09.56.34; Wed, 14 Feb 2018 09:56:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=uLdw3uzX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161544AbeBNRzx (ORCPT + 99 others); Wed, 14 Feb 2018 12:55:53 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33553 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161300AbeBNRzw (ORCPT ); Wed, 14 Feb 2018 12:55:52 -0500 Received: by mail-wm0-f67.google.com with SMTP id x4so18806655wmc.0 for ; Wed, 14 Feb 2018 09:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=C9f4igiyWW/tqWvZmf8XL480dvhMruZmW56TX8+tS5E=; b=uLdw3uzXwlL6LB5vjRVz55RnefJhIAQBHu9LFmkZgUR8j3nQN/eg/2xiSbfNaeYdBp 5P03zsNmAXPicLH7irzy8YIuCpUIy2dWcAMose+VOV/wGu9/G2hyh8SxxxbSte79K9/r NKImUOQ4IaDXrMRc0Wh7S5Xr1jxEdpXo+yb5z34R1RB6vrsu84QE1gQ5K0chnbEGw4P2 sWJE9pryLk6DSn+kn4eHK0b21DV/cBo1DTIGaJALB/70IF5jYGeOTjT1DS+Xwk0WBdQ2 outeUpBCD8aHVFRDspgHXp/RWs46i7NPZes76TEQVuMYkX7hWZPUhcnhFDOACM+OPKej wGzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=C9f4igiyWW/tqWvZmf8XL480dvhMruZmW56TX8+tS5E=; b=RKejrKi5AlrEEZaR5fyIAvwpunERoyUdeVExdzl0sOWOxCEeltP3GRfmuPQrA3Q5yF pXwNYesESstPl1Zp+XndVK9IUDrYR9f6mFRwdn0PGVyWfBULBlrD6xbmH99+ndqYJcnZ blItQovjwFJ7NOdp9wNmZCYXNv0cg2TitkWSyCbDDZaHb79HZk96ObgKc1SMVs0r3upR j+v+An6NpZBleSBikodpuq87BJzHcrSU6sgCwzyuP/9MTxwPHLQ6auwoXEqwQtZQcam/ lRkPRTbl4h6hvnnf4lthttqVCnJHBZPPrFNdKHZrM+h2OTJSxGAuGdTNC+g2uuqNh6EL O0+A== X-Gm-Message-State: APf1xPDBmWH07OyIpCod1QW+f+vb1gi/UMrnoMXvBowHmCHKxDqNqnBw txHJUeTn/3XVYwgNJZShTvRxgw== X-Received: by 10.80.192.138 with SMTP id k10mr3393674edf.237.1518630950847; Wed, 14 Feb 2018 09:55:50 -0800 (PST) Received: from node.shutemov.name ([178.121.192.223]) by smtp.gmail.com with ESMTPSA id a14sm4315153edn.93.2018.02.14.09.55.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 09:55:49 -0800 (PST) Received: by node.shutemov.name (Postfix, from userid 1000) id 254F8648D520; Wed, 14 Feb 2018 20:55:48 +0300 (+03) Date: Wed, 14 Feb 2018 20:55:48 +0300 From: "Kirill A. Shutemov" To: Andy Lutomirski Cc: "Kirill A. Shutemov" , Ingo Molnar , X86 ML , Thomas Gleixner , "H. Peter Anvin" , Linus Torvalds , Borislav Petkov , Andi Kleen , Linux-MM , LKML Subject: Re: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic Message-ID: <20180214175548.6uxpm3bspmgqi7hs@node.shutemov.name> References: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> <20180214111656.88514-9-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 14, 2018 at 05:22:58PM +0000, Andy Lutomirski wrote: > On Wed, Feb 14, 2018 at 11:16 AM, Kirill A. Shutemov > wrote: > > For boot-time switching between paging modes, we need to be able to > > adjust virtual mask shifts. > > > > The change doesn't affect the kernel image size much: > > > > text data bss dec hex filename > > 8628892 4734340 1368064 14731296 e0c820 vmlinux.before > > 8628966 4734340 1368064 14731370 e0c86a vmlinux.after > > > > Signed-off-by: Kirill A. Shutemov > > --- > > arch/x86/entry/entry_64.S | 12 ++++++++++++ > > arch/x86/include/asm/page_64_types.h | 2 +- > > arch/x86/mm/dump_pagetables.c | 12 ++++++++++-- > > arch/x86/mm/kaslr.c | 4 +++- > > 4 files changed, 26 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > > index cd216c9431e1..1608b13a0b36 100644 > > --- a/arch/x86/entry/entry_64.S > > +++ b/arch/x86/entry/entry_64.S > > @@ -260,8 +260,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) > > * Change top bits to match most significant bit (47th or 56th bit > > * depending on paging mode) in the address. > > */ > > +#ifdef CONFIG_X86_5LEVEL > > + testl $1, pgtable_l5_enabled(%rip) > > + jz 1f > > + shl $(64 - 57), %rcx > > + sar $(64 - 57), %rcx > > + jmp 2f > > +1: > > + shl $(64 - 48), %rcx > > + sar $(64 - 48), %rcx > > +2: > > +#else > > shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx > > sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx > > +#endif > > Eww. > > Can't this be ALTERNATIVE "shl ... sar ...", "shl ... sar ...", > X86_FEATURE_5LEVEL or similar? Optimization comes in a separate patch: https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git/commit/?h=la57/boot-switching/wip&id=015fa3576a7f2b8bd271096bb3a12b06cdc845af -- Kirill A. Shutemov