From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753944AbdKAAWA (ORCPT ); Tue, 31 Oct 2017 20:22:00 -0400 Received: from mga03.intel.com ([134.134.136.65]:47830 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbdKAAV6 (ORCPT ); Tue, 31 Oct 2017 20:21:58 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,326,1505804400"; d="scan'208";a="169704902" Subject: Re: [PATCH 00/23] KAISER: unmap most of the kernel from userspace page tables To: Dave Hansen , Linus Torvalds , Andy Lutomirski References: <20171031223146.6B47C861@viggo.jf.intel.com> <9e45a167-3528-8f93-80bf-c333ae6acb71@linux.intel.com> Cc: Linux Kernel Mailing List , linux-mm , Kees Cook , Hugh Dickins From: Dave Hansen Message-ID: Date: Tue, 31 Oct 2017 17:21:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <9e45a167-3528-8f93-80bf-c333ae6acb71@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/31/2017 04:44 PM, Dave Hansen wrote: >> That seems insane. Why isn't only tyhe top level shadowed, and >> then lower levels are shared between the shadowed and the "kernel" >> page tables? > There are obviously two PGDs. The userspace half of the PGD is an exact > copy so all the lower levels are shared. You can see this bit in the > memcpy that we do in clone_pgd_range(). This is wrong. The userspace copying is done via the code we add to native_set_pgd(). Whenever we set the kernel PGD, we also make sure to make a corresponding entry in the user/shadow PGD. The memcpy() that I was talking about does the kernel portion of the PGD.