Received: by 10.223.185.116 with SMTP id b49csp1136845wrg; Wed, 14 Feb 2018 12:11:22 -0800 (PST) X-Google-Smtp-Source: AH8x224eQ+Vzcvul+o+EZfAjfOPois861oeWFOMfC4BpEWNJgFRCuEE/M988LdaYd004idJDy+ew X-Received: by 2002:a17:902:34a:: with SMTP id 68-v6mr198075pld.276.1518639081987; Wed, 14 Feb 2018 12:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518639081; cv=none; d=google.com; s=arc-20160816; b=ZvOicphNLOKuuPPE8/Aeygbpd7lzmUInlRe8rP6ElP4IaiORJ+lUBCQFB+fbU8mXSn p/lcYtfGNiwCR2hpRxqi2+YZ7+dTRR1yK1Cl7ynrfJwPhictVQW4KAr+YgEFAhdy024S 8rJzNCkzRLJ+QssHnKXsdFVETnsIZL/AresgFJU35E6TfvFm0uo+m9UZ6igHrhwAcb49 +VzAiK9ZQ1p1dY6+ZkSfdj3pddkfGvgSa2ZI3rpIpJbTvqF9HuPV1r0g/jfZI1BK2qe+ mTZRWDKdZZTg5kb5pSv2NY1p9Vrp+/y/DX5/z+M3xMopj1NKTcgqSgCZ/dTuzjAOr0Eo EYEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=HcdCymb53Z7nuU20/CNnFhn7wv/gIvtclYxtMW7W4Ro=; b=A2sqoDbIRnRS/I8UMWYZlfewZ9894/uOR3YqqhYHaqCnSLmRwu0MQoSZSv//XF4OEG /MV9NKUUjMzSaf/OL/uEu6HXAojEgY8CAP8WI5SNNwtE71jYCt5DWwKMx9YWJooK5Ps7 DGtjI9sksvgx2//HQ8kN1okqxqLaYeaj4bI1ycuaDZVBgBc9/sKlRnB24NoP5CikWkZO XiK31eUsXfCoDRurUi9o3PrHKM6P7eWkCXKlMchBLRddi1e0YAsV+4MImlCG3nFG86pU 90VJwwNbCsqctzqsx0yQdOmVEAF19kR/59ABPX4r2FponYwR/LpcBg5nR2jfoelOESS/ xi5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=ABEAZjPZ; 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 r1si1734704pgf.327.2018.02.14.12.11.07; Wed, 14 Feb 2018 12:11:21 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=ABEAZjPZ; 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 S1161174AbeBNRX1 (ORCPT + 99 others); Wed, 14 Feb 2018 12:23:27 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:39584 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161065AbeBNRXZ (ORCPT ); Wed, 14 Feb 2018 12:23:25 -0500 Received: by mail-it0-f66.google.com with SMTP id l187so6180724ith.4 for ; Wed, 14 Feb 2018 09:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=HcdCymb53Z7nuU20/CNnFhn7wv/gIvtclYxtMW7W4Ro=; b=ABEAZjPZXRm4b19+U6RqgFnHM/k7kV/G02Ok4fVLp2Apk3QKTKhvGqPDnNvPfqAhK8 iB5T3diCi0XFV0YrWf3hZn6y+jJsJWqn9Lsu80AMRsh4i4wrVbh/UXY6LR9ILENLCitC OhoC7yNhkBZoZIuuSbx8UeAN5Q7QSjVOsIJJ16j9rUZ7OyJhJpTi3025XudDlAmJ5vhM CsEgVwwoRvyuslK1G537Jf15wVG4KbBLnTqgDt/Jbw+hT4EfQ3/7RKx4qvyk89cITJvl OJDG3ywnXd4bLHnL10vnJid+XqASFnq01EmbFfrOvO8tH3ECnJrL4u7Ea8Kg7oUibZe9 T/pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=HcdCymb53Z7nuU20/CNnFhn7wv/gIvtclYxtMW7W4Ro=; b=GUdcrShA2ZTSD8zaF9jGXcBu6t3g6MNRjzpmV5jpXY05CD/X9U5go1c0UPUMT1kex7 6RxsoUjBvNCTkTLSGSMdXrdqyjHHUrLqNzNP7bq1tA9DHyhL5ZR5OWmvXi2bxmgHKWNB 2zwD9/EGuBezLqO0+41yt1vsJvAOX3Q6HjVeGe5yRYjNW+r/5oKUG5/aOjeFqdF1OEVV QRZ7VBWyEIsj8i+NoIgBEB5811lwbVwplTY4+LUaNSxJZAXY0YjFimyzh+aoemZ80kYl 31Pg/zGhVl/JyGunT4mVykYwZHeiYoeXqLcl2oxkEaM9FGbWrFXrLgB0IJjxM/GRYZF6 tShw== X-Gm-Message-State: APf1xPCSDW4mnp3cNqSLl5kI6xLAmEopy3//p+Ha4lXcoWYV+JOrgBFx 4TT6CF3GXQzlxX1A2+8FOkTSB/gwLAGU1b7beTkirA== X-Received: by 10.36.73.133 with SMTP id e5mr6701439itd.109.1518628998645; Wed, 14 Feb 2018 09:23:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.137.84 with HTTP; Wed, 14 Feb 2018 09:22:58 -0800 (PST) In-Reply-To: <20180214111656.88514-9-kirill.shutemov@linux.intel.com> References: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> <20180214111656.88514-9-kirill.shutemov@linux.intel.com> From: Andy Lutomirski Date: Wed, 14 Feb 2018 17:22:58 +0000 Message-ID: Subject: Re: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic To: "Kirill A. Shutemov" Cc: Ingo Molnar , X86 ML , Thomas Gleixner , "H. Peter Anvin" , Linus Torvalds , Borislav Petkov , Andi Kleen , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" 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 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? --Andy