Received: by 10.223.164.202 with SMTP id h10csp5732184wrb; Tue, 21 Nov 2017 14:47:00 -0800 (PST) X-Google-Smtp-Source: AGs4zMarzXkPsUgGjSusYciZGbBOgMUwEegyYlmPwFLK/tFZsJ6iiTKMR1Ks5XsqqLWM0DukZ4CS X-Received: by 10.101.65.74 with SMTP id x10mr7247995pgp.388.1511304420071; Tue, 21 Nov 2017 14:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511304420; cv=none; d=google.com; s=arc-20160816; b=sCuOBmUrN7nvz/RcwKzvd2OgVLn0A0tZog9ZF6HkUQT5KxGhPxCs1ascJWF+pBI51I A36hjX3eGi/Xs+DXdDhSUnLqOmjYznhhWGAnI8kADd7StbK0TE6Sxd2T+Un88/o1hWwz 2RGQHDNXbhg+tixTQyH5cU8Cy4NySEgB7JY3B0lLgfpTMbdfSe+9P1Ca/kXOVzPTjXCa 89DUb4xZKvJtailuWR//pFFfzczAUP2+jStWnFgOmHIBHe6Q1100jntCQzMyVN8K+QQd 548nbRJSGLo08MhiHaG+rk+mph9v8RLYvfjPi7lE+CvhQ+CsB3mn+D5JQUOH8fRGGupJ hQpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=4ZuKluLPd6H1tdIKvBaMMlFurKIL28cZz+WjAoBSKDs=; b=cxeDlSuQ5MiVRqHL04WGAjr8FM4UW4ea9Ijz+Mql7FinqEYQmOkrcE9FW1NvZRqI8y s1nDSLtfmRDXoTdOvrDETsbceFB7AK5XM+xrKbEt7l3bxHUpi+Hc0uxiawl2E5MDPDDi 9pspwdL/2GNGW4UnHDWnVXfWd5S70axV2VHOP/3l+hbgcgMR0F6jG9ex4tOyxe3J5sDS Opuj19k6biMHWEeC0bF2F2LpD5a4W8TDndsh9YNPW8d+8FbqckrI/DqXUDb3av7s915z y01w+IR9q4SL8tv9uHUW2V4KcbSf3Uf6zcNUM4iVMbyPd26La5a2zWCcnEuL3goSdX7I 8WAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=1O78IlSe; 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 i8si12945286pfk.151.2017.11.21.14.46.48; Tue, 21 Nov 2017 14:47:00 -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=1O78IlSe; 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 S1751458AbdKUWqJ (ORCPT + 76 others); Tue, 21 Nov 2017 17:46:09 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:33223 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbdKUWqI (ORCPT ); Tue, 21 Nov 2017 17:46:08 -0500 Received: by mail-ot0-f193.google.com with SMTP id s12so11984577otc.0 for ; Tue, 21 Nov 2017 14:46:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4ZuKluLPd6H1tdIKvBaMMlFurKIL28cZz+WjAoBSKDs=; b=1O78IlSegfkLBhYqOc4Vhg0mCkwXndwpAAA6ufSGpY4WRM8qWoPd2DB0ADRpTjL2Mz Dn4oqT9exTzjiZ2gsc/BaIIU7lFPlKma2PrmCAk3N4bvb2Y+PD4CTo96/tHhvEzo72WG hA1v6vsA966sYU98fF+NRdfs6M/wCCSRYDwU8cyQvM53MiZyRL7V2MyVNDDryd1uxEaB pxaojr/tnarGsgg5RRJBgfHYNb0bJoG8NTJHOyniON858cobDkOYxOQW3CwuhjlV6PVS dYbhcaM1v0GimpursMjiK2MfuurnIZZjLn5ljy2l8XPcom4/gZH8iktfnauhnfRot8Re 4P0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4ZuKluLPd6H1tdIKvBaMMlFurKIL28cZz+WjAoBSKDs=; b=Q27gh/Zfz73WVZaE8lp7RIdBkN6Ec4kboHEPatTCaLO1IQNx768FutrTqKfFuaAy+n M2AagglEhjv+Dg6885QKhzgNWxLJWtKDceJ8qib41rxSx07jg6a1LSvgQ2LVIGIh/Tvo +ZR2VHHvMJKZ5AfDyMRasqW3Gjkmr5oGWThz5CZMQ88XksTipSO0pT5UHzWO9U2ypL3B iGrFmceRMmhktx1AFlRhLQ7y9hzNUMrGopNBnuGd4vAXu1exJB6bBTIwkJZwWihNW9ar zfx24MAEJV3dBhsMEdmjRds12OTcwjzqzgek5GP2YmWw3r/O4fBQrb3BPrr6QsPTXfvL FH4w== X-Gm-Message-State: AJaThX7ubnAr8JP4OJxrSnuJpzX+n3HTPlfjf73eUDPHB3j37/5vM/qi jfFe7+Fz3QZw0pgxWhSkOxFLQg== X-Received: by 10.157.12.4 with SMTP id 4mr12598721otr.302.1511304367406; Tue, 21 Nov 2017 14:46:07 -0800 (PST) Received: from ?IPv6:2600:100e:b002:b840:6dd9:a92b:ad81:8138? ([2600:100e:b002:b840:6dd9:a92b:ad81:8138]) by smtp.gmail.com with ESMTPSA id v21sm6246072ote.74.2017.11.21.14.46.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 14:46:06 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables From: Andy Lutomirski X-Mailer: iPhone Mail (15B150) In-Reply-To: Date: Tue, 21 Nov 2017 15:46:05 -0700 Cc: Andy Lutomirski , Thomas Gleixner , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , moritz.lipp@iaik.tugraz.at, Daniel Gruss , michael.schwarz@iaik.tugraz.at, richard.fellner@student.tugraz.at, Linus Torvalds , Kees Cook , Hugh Dickins , X86 ML Content-Transfer-Encoding: quoted-printable Message-Id: References: <20171110193058.BECA7D88@viggo.jf.intel.com> <20171110193125.EBF58596@viggo.jf.intel.com> To: Dave Hansen Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 21, 2017, at 2:19 PM, Dave Hansen wro= te: >=20 > On 11/20/2017 12:46 PM, Andy Lutomirski wrote: >>>> + /* >>>> + * We could theoretically do this in setup_fixmap_gdt(). >>>> + * But, we would need to rewrite the above page table >>>> + * allocation code to use the bootmem allocator. The >>>> + * buddy allocator is not available at the time that we >>>> + * call setup_fixmap_gdt() for CPU 0. >>>> + */ >>>> + kaiser_add_user_map_early(get_cpu_gdt_ro(0), PAGE_SIZE, >>>> + __PAGE_KERNEL_RO | _PAGE_GLOBAL); >>> This one is needs to stay. >> When you rebase on to my latest version, this should change to mapping >> the entire cpu_entry_area. >=20 > I did this, but unfortunately it ends up having to individually map all > four pieces of cpu_entry_area. They all need different permissions and > while theoretically we could do TSS+exception-stacks in the same call, > they're not next to each other: >=20 > GDT: R/O > TSS: R/W at least because of trampoline stack > entry code: EXEC+R/O > exception stacks: R/W Can you avoid code duplication by adding some logic right after the kernel c= pu_entry_area is set up to iterate page by page over the PTEs in the cpu_ent= ry_area for that CPU and just install exactly the same PTEs into the kaiser t= able? E.g. just call kaiser_add_mapping once per page but with the paramete= rs read out from the fixmap PTEs instead of hard coded? As a fancier but maybe better option, we could fiddle with the fixmap indice= s so that the whole cpu_entry_area range is aligned to a PMD boundary or hig= her. We'd preallocate all the page tables for this range before booting any= APs. Then the kaiser tables could just reference the same page tables, and= we don't need any AP kaiser setup at all. This should be a wee bit faster, too, since we reduce the number of cache li= nes needed to refill the TLB when needed. I'm really hoping we can get rid of kaiser_add_mapping entirely.= From 1584715511245350932@xxx Tue Nov 21 22:14:41 +0000 2017 X-GM-THRID: 1583709058753301727 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread