Received: by 10.223.185.116 with SMTP id b49csp1475010wrg; Fri, 23 Feb 2018 20:21:26 -0800 (PST) X-Google-Smtp-Source: AH8x224C/iOr9ECh/FNuN6qmeOJgLuXcVYDtq8UGrPe7lXJFICpBUFda8XGU1qKsBlhBPfOoA2sW X-Received: by 10.101.68.141 with SMTP id l13mr3079576pgq.65.1519446085997; Fri, 23 Feb 2018 20:21:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519446085; cv=none; d=google.com; s=arc-20160816; b=nL1RBWEePQDM5YLff+v3pW92bpftP9iJtkAUrTEtmQxUu1ZeODGhd6l+fRlSGw7qS/ T45hbkocWcaaOJlsx0mfSMwGbBGWKLy1Fxev5f1uhQSo1gahAfBv13M+FOxWD9EThE27 BtMCK7Fq/q9YPis4GlveVemvGvbC+3P4OabSLCun7cCAVP/vz1KWXus30uMfH7KyTF1I oqstqOx6v4BtZZS27nKdUT9DSfIttSm1RWAVcU/Q1FkqowvHCjw75eqpmhAmNzNj5h0g 0urg68JeFKxGnQnfNuw46RYOTk08tMWutQl+Ih2D2Om+0EvizltW3NhBQdqmnokS6g7O /+fg== 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:dkim-signature :arc-authentication-results; bh=hzBbZpRFwl71ezm0QUF0tXf19Axv45Z1THJhp5LukFc=; b=j+QzV4wUbRLR+lvSafB1XpLGrDeYPbpMrqxTY4C/4PeRFd+x1/aXU8YPd0vgPFWZJp rb85b80xpiZlGvc8RrcCq/ZM1TlTLPXvuEfd5pu9QYe9E8pT/fLZy1IlbT7xl6xSuljs ISDOWvWpAm/6ia6/aYmrhANbE2wxApiZUxoR5as9uIPgEU2B3Vnm95CpFr523PdR4zvC QOdlYx/Ir8AV0XLSUb0P/Bc42GffXclBmA2v28ZZ3xS2hhI7wr+pMdE+eeqr5XPNFjOW DCF7s94/os/gOnWqGfXn+kxI7xKX8DH5sMrXNyuqdCuCXi2xieKox83ylc7JcUjhneO6 j3qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dxBVK2gG; dkim=fail header.i=@linux-foundation.org header.s=google header.b=bIF0mATd; 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 1-v6si2882947plz.756.2018.02.23.20.21.00; Fri, 23 Feb 2018 20:21:25 -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=fail header.i=@gmail.com header.s=20161025 header.b=dxBVK2gG; dkim=fail header.i=@linux-foundation.org header.s=google header.b=bIF0mATd; 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 S1752512AbeBXEUD (ORCPT + 99 others); Fri, 23 Feb 2018 23:20:03 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:50599 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751917AbeBXEUC (ORCPT ); Fri, 23 Feb 2018 23:20:02 -0500 Received: by mail-it0-f68.google.com with SMTP id a75so5255029itd.0 for ; Fri, 23 Feb 2018 20:20:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=hzBbZpRFwl71ezm0QUF0tXf19Axv45Z1THJhp5LukFc=; b=dxBVK2gG+f53aYrcjJ7it0W33jnM+E3rqQzqPwR0flR5JbYSG5dhod7iznX64UUfBM Bv4xUWmjDkerZpS+zFkfA2njFhcbjftIiC3HKtE0sIGDdEtpJ4zyE2ElUEguGeLjr+OA IHxS5bi03tb5pweYSpBBjm+/9Qr1TBzS4AP88GOsPErAqdPT+PljFFxFcI0mjfPwUu0p MJ9t23hYziEp5QMygrizYIpmny+TDZEwpv1YhE/lAagXGFz+iDKul69s8RWzuPwrzO1H 05Bt7NuA6g24Bf91uskflVwQwchmqKIqun+/4gtbhbXDgF0bUXHHMHj3mApj6TNpXGIS JTfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=hzBbZpRFwl71ezm0QUF0tXf19Axv45Z1THJhp5LukFc=; b=bIF0mATdhtFc5DtiQxtTTaRoPFxziRELhT6B+WnlgBH+D9BychXgD8We2cwFuLNLRq IrhASVtdQV4ICKiv102SNg+FiIcMbwi5lC6Cgg9MoFh9t+mpy15xLrNhrmiPzrwSaReQ 8XxuHgVuXuMrvgva0DZODiM9vHLKSXef6dHcg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=hzBbZpRFwl71ezm0QUF0tXf19Axv45Z1THJhp5LukFc=; b=sO/OWudPRlrzV5mx8MGQtXFsy73yB2pWvueEjJjR1AZOJ87ROwalskva765WWk5l2N v/ViNrCDQf7S/fJ5OESBw1TGnw8wSEtSsBops3+Zk1CDch3dLmiitAF2dXdDNcbbcRq5 C4LXbXW4qux2yXGiHcLNBIdVHqjViE0HnUji65PGuRI9hRnYngkc6YZpxPEQOa0UYEVa eHFh5aAd0xVvH7grW8UFi/DYfnvw0ZbdrJEELZgyxcu9vnDlALQG/vPWXtpBqCIZuXWy v2FsKo1+RSNeZRyazMayjoOrdkOTXc6v0HpqI1usN0QMXKE09Y9qyt4xaYaK5r7SBHME G2mw== X-Gm-Message-State: APf1xPCoN5gJoT6EeVac/K0zui2vLf+Iyu2bc4ItpvZHA2RZ39HdLmOu q/FySclEoziNn+pG+3GIDyXTOWEsGPArQ05cvGg= X-Received: by 10.36.254.199 with SMTP id w190mr3678204ith.108.1519446001219; Fri, 23 Feb 2018 20:20:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.135.221 with HTTP; Fri, 23 Feb 2018 20:20:00 -0800 (PST) In-Reply-To: <7e81fb89-5908-7d31-9225-defc48dbfa41@linux.intel.com> References: <20180222203651.B776810C@viggo.jf.intel.com> <7e81fb89-5908-7d31-9225-defc48dbfa41@linux.intel.com> From: Linus Torvalds Date: Fri, 23 Feb 2018 20:20:00 -0800 X-Google-Sender-Auth: qbIwT6-dvCB0FRFNq19QaWPF6fM Message-ID: Subject: Re: [RFC][PATCH 00/10] Use global pages with PTI To: Dave Hansen Cc: Linux Kernel Mailing List , Andrea Arcangeli , Andrew Lutomirski , Kees Cook , Hugh Dickins , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , "the arch/x86 maintainers" , namit@vmware.com 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 Fri, Feb 23, 2018 at 5:49 PM, Dave Hansen wrote: > On 02/22/2018 01:52 PM, Linus Torvalds wrote: >> Side note - and this may be crazy talk - I wonder if it might make >> sense to have a mode where we allow executable read-only kernel pages >> to be marked global too (but only in the kernel mapping). > > We did that accidentally, somewhere. It causes machine checks on K8's > iirc, which is fun (52994c256df fixed it). So, we'd need to make sure > we avoid it there, or just make it global in the user mapping too. They'd be missing _entirely_ in the user maps, which should be fine. The problem that commit 52994c256df3 fixed was that they actually existed in the user maps, just with different data, and then you can have a ITLB and a DTLB entry for the same address that don't match (because one has been loaded from the kernel mapping and the other from the user one). But when the address isn't mapped at all in the user map, that should be fine - because there's no associated TLB entry to get mixed up about. It's no different from clearing a page from the page table before then flushing the TLB entry later - which is the normal (and required) behavior for unmapping a page. For a while it exists in the TLB without existing in the page tables. > Just for fun, I tried a 4-core Skylake system with KPTI and nopcid and > compiled a random kernel 10 times. I did three configs: no global, all > kernel text global + cpu_entry_area, and only cpu_entry_area + entry > text. The delta percentages are from the Baseline. The deltas are > measurable, but the largest bang for our buck is obviously the entry text. > > User Time Kernel Time Clock Elapsed > Baseline (33 GLB PTEs) 907.6 81.6 264.7 > Entry (28 GLB PTEs) 910.9 (+0.4%) 84.0 (+2.9%) 265.2 (+0.2%) > No global( 0 GLB PTEs) 914.2 (+0.7%) 89.2 (+9.3%) 267.8 (+1.2%) That's actually noticeable. Maybe not so much in the final elapsed time itself, but almost 3% for just the kernel side sounds meaningful. Of course, that's with nopcid, so it's a fairly small special case, but still. > It's a single line of code to go from the "33" to "28" configuration, so > it's totally doable. But, it means having and parsing another boot > option that confuses people and then I have to go write actual > documentation, which I detest. :) Heh. Ok, maybe the complexity isn't in the code, but in the concept. Linus