Received: by 10.223.185.116 with SMTP id b49csp1136822wrg; Wed, 14 Feb 2018 12:11:20 -0800 (PST) X-Google-Smtp-Source: AH8x2252Jv4iIksE3eGAAb8pOeGrGpWk0HnR61ma7wK69Fsto1rvteRurL5PUPJr7U0Wm7bORv/w X-Received: by 10.101.81.68 with SMTP id g4mr170186pgq.276.1518639080121; Wed, 14 Feb 2018 12:11:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518639080; cv=none; d=google.com; s=arc-20160816; b=TS08h0qY8st/fPODtBTQd4PAjevWFAVGT61xEz5fD8sW5KhhHgQL890k45BUQFolEJ pMdTzTmTWtTlbgqz+PouMEPhTqkh4GzpOORb216AZeuGzQVbbvYtqeanXTN7gsy979t9 aAn4E+Atm/A6znKDUeB48CfYvHBnocR0iSy1W6u0ZrsTaJn1mpMG2Urh3B/9ed4+XtwU lEIlfAy/7fm4LgVpWmLcePciKuEqeRCgd9VUp4wRfB7DlHpF06I/WyyrGzC8Yuv4hcdX Yo73q8qm9OpdzVhAznb08P2rWH01CVNljgOk1eGzjNMOAlBtHK7pczsW+CtnRxEbeD/h dmQw== 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:dmarc-filter :arc-authentication-results; bh=eSSDsiBhIGZaYqeF9gPT0L4vCAUkuoRuwyIvbZn6sn8=; b=fx2dSlqf1I/Yxi6TWUqPgGUuEJL4kEiefG0Yoj9AgQmjjNBUlAGLSDVM12rCI1+A9p yO5gIhEjNarQmDiv3+QR4O6I37R0HHslIAnfij07RIzLrbFAob0ZXmPf6IUUNeZzLvdW SEIcdtMTmqLEk8FWc72N8PRDK3eno5sV0gJ+Ijkz5Hpvz8QS8Qs39watDbHHklcyVjoS wB6rNvBrc2vsv7d1E/rSJUIGaMUQPRt6us27xUTBeGkCI06KbEs5F0MvCHLXXBTHj6da hV6ysox0svMXvRiyvLcorJWCLfB8HEwpAqxMUqwgAe1k3asfJPZiOkpMdCghZhyd7acp scHA== ARC-Authentication-Results: i=1; mx.google.com; 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 z123si1701767pgb.280.2018.02.14.12.11.05; Wed, 14 Feb 2018 12:11:20 -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; 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 S1161658AbeBNSCj (ORCPT + 99 others); Wed, 14 Feb 2018 13:02:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:37492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161541AbeBNSCi (ORCPT ); Wed, 14 Feb 2018 13:02:38 -0500 Received: from mail-io0-f176.google.com (mail-io0-f176.google.com [209.85.223.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 193C4217C9 for ; Wed, 14 Feb 2018 18:02:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 193C4217C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org Received: by mail-io0-f176.google.com with SMTP id t126so2803993iof.4 for ; Wed, 14 Feb 2018 10:02:38 -0800 (PST) X-Gm-Message-State: APf1xPAqcyzuyYaQjRptZt33HCrwe/CLz2zW5RkFmIVetrkf9seS2Zd3 R/c+dQTjXVzitEi6EXpWIYpxBrn9y5sZKXeEELQqow== X-Received: by 10.107.7.153 with SMTP id g25mr19025ioi.271.1518631357385; Wed, 14 Feb 2018 10:02:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.137.84 with HTTP; Wed, 14 Feb 2018 10:02:16 -0800 (PST) In-Reply-To: <20180214175548.6uxpm3bspmgqi7hs@node.shutemov.name> References: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> <20180214111656.88514-9-kirill.shutemov@linux.intel.com> <20180214175548.6uxpm3bspmgqi7hs@node.shutemov.name> From: Andy Lutomirski Date: Wed, 14 Feb 2018 18:02:16 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , 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 5:55 PM, Kirill A. Shutemov wrote: > 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 > Nice!