Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1144115rdb; Mon, 19 Feb 2024 05:52:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWZhUEt7FxOv2qwAZzyjlorAjFfShbvK4GKaqMfvNBiBK66ehF0F73C0W9qGtb4IsokTe4/4Pdh8qLDtaheYUXdnXWnmj6/qtaOvLOxhg== X-Google-Smtp-Source: AGHT+IEwto+Ov2qnySEaM0gdfQH+qF49CdmihCUjvXNEytdaDUFDA+M4mG6bdDXVnof3UyZbJzb4 X-Received: by 2002:a1f:e207:0:b0:4cb:fc25:7caa with SMTP id z7-20020a1fe207000000b004cbfc257caamr1701879vkg.14.1708350777791; Mon, 19 Feb 2024 05:52:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708350777; cv=pass; d=google.com; s=arc-20160816; b=BGtRGUfIKyECzWE5QIRKJ85lVM5famlTRl7B/S7xHRDx9yJV0CjmkOxj1rOPag3HcI EfWXRZ/Od0SgiDhZBgaWbximSvrLMlnGGfEAslZ3H2UBtHQ8TNuXHSv2KpgXhM/0vFyn v3oTWsmzpoFlR4nwrAH1QRhJs+5j2fbVr7vioprFrSFJ79I40h+dGmBW21LzJOMcPs4b G281MoQhv//lT5a8X2zWCM7Ecs2kmMO1jWWfpHKSQPsXaBMo6LlslQAI54SpmRwiNhdC Xa/GMk/5WC1KN+1IDYUSsehn2IUWBbzsxSz2s3C/+6pgKaVzxbQ7iQoLN67uPR62KnX4 SHzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=L7TGI7HJrhAkrTLoAbin6qj9V6C8R507WbD0hRLSdQE=; fh=b1CtWOVMAK8JQs6DB+SVg+AtEQpeOtyGwB1IJYlzURY=; b=N7afaCekt5LQtj+jhRfTzwFi34yN9d4Xr12Ax7plecgmN53j01vO6yy+VI69SQ4ifV vs4FYxZjqTphyE+WMj2uXQq/y/plMvKQzSvoZPD9xuahk0Fmk1Qc4cwp7sbWsBW7WkNE +QTXcvE0BPFgPg26fr84WeODkBqMf4yOXnQW086DPDCqUuSzPmsnk675AZEd6F7hDnJ5 P44WkTppWEh1Ce27lEJOeOOpGptG9xPbwFp4FRUJxSZ1Gk/7zk2KHR3aGGhV0Cvimixn lvIjN8J7U+x1cnLaYACuwGY+fD8X0j7Qam3IfrZKaBEaERgDXRGqivFMd3fE8IM9t+Dl iX4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lcte9Ltr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-71430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id kd24-20020a056214401800b0068f6035f58dsi3131558qvb.168.2024.02.19.05.52.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:52:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lcte9Ltr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-71430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8B8551C21477 for ; Mon, 19 Feb 2024 13:52:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB31236AEE; Mon, 19 Feb 2024 13:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lcte9Ltr" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D74A36134 for ; Mon, 19 Feb 2024 13:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708350770; cv=none; b=EImvzW6yTRTeTF3ld//G8sTVeTXoZbL+PsRNMW+QBVD28T6QtoRsR7fnkbEYhqjJn1dR0BAfijxTVwxBQTXOYzvy+Uf5KG5pdXMXuVkkUhy1CSfjPJzTx9OydZPe7ymp2NLxpnSvosgCDEVTZFiJLPoh762eWxAmlLadn6o5oQY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708350770; c=relaxed/simple; bh=yPMBSovixa7VCIL6tvi34aVw1yfzyVwmD5bVU4sWDNs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fZ7RmbM4mm2U/Qg4pr3kWcTivM/H8mtICiK1diRhU6bRY5PCrqd4hcDArGP+leK6JXuEE4ND2LU1iyMWZEm7Y0+xZ1frb0AS5C7s/ojRDky2f99I6zsQfNkj5VTgNmjsu/GMkyYiABhJDStx0hrU0WxK7vglea7IsFvFvenlOuc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lcte9Ltr; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708350768; x=1739886768; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=yPMBSovixa7VCIL6tvi34aVw1yfzyVwmD5bVU4sWDNs=; b=lcte9LtrzVR/a2XNInONQlzTJbiRZHhyNQjXnzYk8x3Z7AEtxjRigOF7 lMIUiuiMu/AogGAd6rrhk+mmeX8AYyDtMkhL/2finxOINhSYvN+EeZ5qp 7P/+HJVnu9yfPRz1n0yM/iVXotWM/4ScWMIocQBCkD48gcBI8tnGUi9ey XTn7KXKXO3dccMNuozpE7yb/3pz9tX/OClo3b4im86OosLUIF1/Omb8kP WCI1hyHF7SeRv2qxjrtYDxRSt70Ef4Y8/GSdPuMOM1CbxfrkUBm52MxVh nH9wTnVi7n0ImTkDHTs321WLnSqMe1b4m8Su8349QFxi4Uappooxlnmcz A==; X-IronPort-AV: E=McAfee;i="6600,9927,10988"; a="2333811" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="2333811" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2024 05:52:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10988"; a="936293708" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="936293708" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 19 Feb 2024 05:52:42 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 9DC35350; Mon, 19 Feb 2024 15:52:41 +0200 (EET) Date: Mon, 19 Feb 2024 15:52:41 +0200 From: "Kirill A. Shutemov" To: Baoquan He Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCHv7 07/16] x86/mm: Return correct level from lookup_address() if pte is none Message-ID: References: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> <20240212104448.2589568-8-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Feb 19, 2024 at 01:12:32PM +0800, Baoquan He wrote: > On 02/12/24 at 12:44pm, Kirill A. Shutemov wrote: > > lookup_address() only returns correct page table level for the entry if > > the entry is not none. > > > > Make the helper to always return correct 'level'. It allows to implement > > iterator over kernel page tables using lookup_address(). > > > > Add one more entry into enum pg_level to indicate size of VA covered by > > one PGD entry in 5-level paging mode. > > > > Signed-off-by: Kirill A. Shutemov > > Reviewed-by: Rick Edgecombe > > --- > > arch/x86/include/asm/pgtable_types.h | 1 + > > arch/x86/mm/pat/set_memory.c | 8 ++++---- > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h > > index 0b748ee16b3d..3f648ffdfbe5 100644 > > --- a/arch/x86/include/asm/pgtable_types.h > > +++ b/arch/x86/include/asm/pgtable_types.h > > @@ -548,6 +548,7 @@ enum pg_level { > > PG_LEVEL_2M, > > PG_LEVEL_1G, > > PG_LEVEL_512G, > > + PG_LEVEL_256T, > > PG_LEVEL_NUM > > }; > > > > diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c > > index f92da8c9a86d..3612e3167147 100644 > > --- a/arch/x86/mm/pat/set_memory.c > > +++ b/arch/x86/mm/pat/set_memory.c > > @@ -666,32 +666,32 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address, > > LGTM, > > Reviewed-by: Baoquan He > > By the way, we may need update the code comment above function > lookup_address_in_pgd() and function lookup_address() since they don't > reflect the latest behaviour of them. I am not sure what part of the comment you see doesn't reflect the behaviour. From my PoV, changed code matches the comment closer that original. Hm? -- Kiryl Shutsemau / Kirill A. Shutemov