From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbdKVWp7 (ORCPT ); Wed, 22 Nov 2017 17:45:59 -0500 Received: from mga06.intel.com ([134.134.136.31]:48841 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752016AbdKVWp5 (ORCPT ); Wed, 22 Nov 2017 17:45:57 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,438,1505804400"; d="scan'208";a="152260703" Subject: Re: [PATCH 08/30] x86, kaiser: unmap kernel from userspace page tables (core patch) To: Thomas Gleixner References: <20171110193058.BECA7D88@viggo.jf.intel.com> <20171110193112.6A962D6A@viggo.jf.intel.com> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, richard.fellner@student.tugraz.at, moritz.lipp@iaik.tugraz.at, daniel.gruss@iaik.tugraz.at, michael.schwarz@iaik.tugraz.at, luto@kernel.org, torvalds@linux-foundation.org, keescook@google.com, hughd@google.com, x86@kernel.org From: Dave Hansen Message-ID: <82d2d82f-32a0-64e6-03b2-3ca0a9f97de6@linux.intel.com> Date: Wed, 22 Nov 2017 14:45:54 -0800 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: 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 11/20/2017 09:21 AM, Thomas Gleixner wrote: >> + pgd = native_get_shadow_pgd(pgd_offset_k(0UL)); >> + for (i = PTRS_PER_PGD / 2; i < PTRS_PER_PGD; i++) { >> + unsigned long addr = PAGE_OFFSET + i * PGDIR_SIZE; > This looks wrong. The kernel address space gets incremented by PGDIR_SIZE > and does not make a jump from PAGE_OFFSET to PAGE_OFFSET + 256 * PGDIR_SIZE > > int i, j; > > for (i = PTRS_PER_PGD / 2, j = 0; i < PTRS_PER_PGD; i++, j++) { > unsigned long addr = PAGE_OFFSET + j * PGDIR_SIZE; > > Not that is has any effect right now. Neither p4d_alloc_one() nor > pud_alloc_one() are using the 'addr' argument. Ahh, you're saying that 'i' is effectively starting *at* PAGE_OFFSET since it's halfway up the address space already doing PTRS_PER_PGD/2. Adding PAGE_OFFSET to PAGE_OFFSET is nonsense. Would it just be simpler to do: > for (i = PTRS_PER_PGD / 2; i < PTRS_PER_PGD; i++) { > unsigned long addr = i * PGDIR_SIZE; ?