Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2386942rdb; Wed, 21 Feb 2024 06:16:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUahcgibM194DNRIg+yemJwu+mZIhxMsukZcmUpdThDjr1yOSW0o1iS5OTRfmfRBTz2uJbP5L4iwgzc5JcpxoZwVvZ8X+rBlqz1fM2FAw== X-Google-Smtp-Source: AGHT+IHruH2R4ZdeqWVl43wa9ox/ZeW639hTVlkRat+dncnCCmMtHfy0W07gkX6GNoPzKa5hFqlM X-Received: by 2002:a05:620a:1a0a:b0:787:2a72:c2ec with SMTP id bk10-20020a05620a1a0a00b007872a72c2ecmr23240083qkb.56.1708525015057; Wed, 21 Feb 2024 06:16:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708525015; cv=pass; d=google.com; s=arc-20160816; b=rAM72vgzusv0GhYppQrivT/1QzZfEnfYEq7ZQsuoQs70v087iQLcR6bw9NH1MuUm9e J03L8MthG/Yf8eWKAiM7OylMqJsN2YqhR2DmbplJqkanGKK9fKzTBSFn8I2CXmNBypXx 16tabpZ499E8nqMmgC35mDZTBDTAHQ6Ph8asKyxjhwh3hlWnlmVB/nEEaKn9abXjMsu7 0QpkFL2ukrDj68OQNgl7jHaiVlh69lYxb1oA+QzXLILrTf1GiLdDbaP2TbtSg35QLUBL eQjSRlbnGQHsfI7YCCl9B8DIidOn4ONvKXoSFX+KOhiy/6dGOEQpn1+7fkCsg698qFfq R32A== 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=TrHnPNYJ50zFz4WuMS56gUmiNvg64dXQbJid59etxY4=; fh=b1CtWOVMAK8JQs6DB+SVg+AtEQpeOtyGwB1IJYlzURY=; b=0eghODDftNKVeHL+95EKa+YbQ/7xAWlDzRoO0I6/QkI1Gj5/glmcQmguh0X3m6Ehb8 zX2g9cskn/bi3/HZGGyTpENWI8Bi9gYiu94QCEQ6e3CRdLHpyA2i4YUt4YP3Vb9l3PVG gEg3du4fO9753CjERR3h7HT3vPotxt6O/C8G2ekmNu0D7UJmMxc3gyOwboYHva4S6J0K u1kk4lLX8LpAXk5Ud008kwFzZ/OrITUjRrIMdIeT3mauImxeN8g0cJu2VgBTWLx9zFEL 48xzUglm8+6taRqZ3nM/fMUv0Q5n7X3pbZzbN4iPzIaDPefgADtanurYQP7iCZyH3tl6 EVrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lpjYdbGP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-74874-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74874-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 a22-20020a05620a16d600b007877ae48be4si3231821qkn.563.2024.02.21.06.16.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 06:16:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74874-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=lpjYdbGP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-74874-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74874-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 C4FF61C238FE for ; Wed, 21 Feb 2024 14:16:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A9267D3E3; Wed, 21 Feb 2024 14:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lpjYdbGP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 6F8927C09A for ; Wed, 21 Feb 2024 14:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708524936; cv=none; b=PBTvki+17Nq6H5vEvQjMWQV+HkNwpPCo9yqtBACI3vM/NbdUpfU8dx3JRcdwaQjUPjcnhhr4NSQ078CBAVnOSVOxknV6pSvPwEKBCLnwX1bTw3Z3I3cXswRY/4iJVTALIqaGSiUxqtqpSQm0IMuPSZlrDoE66pLEsKMe9AOQsl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708524936; c=relaxed/simple; bh=/vYbdGx/biRaDTrw8g8KGes/oIyLAhiiHJyRW4pxB+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ta3DZk4ov3Sq5kOIkMZ9Ju8MDY/rGY48uXnVysa0JxyKb3iGEDLrkmEJYXy745295tGd04SpYJKhs8ezVIrwzOix19U9WbjySwcyDkdfPU1d5SxyAh70ibuKnbzdCaU6U9xMIkRosr6ueeqPFISPHC8lJ+LrfZRK32TEcv/bMNQ= 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=lpjYdbGP; arc=none smtp.client-ip=198.175.65.14 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=1708524934; x=1740060934; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/vYbdGx/biRaDTrw8g8KGes/oIyLAhiiHJyRW4pxB+Y=; b=lpjYdbGPaZPL7tjqptdduzJ2ckcHht0Yrn5LbBpdqyLNTjazF5RUJWzh LeT7osONuHngXyP35I9g/q19Q7H0KnolkNI43DpSznjxzX0zp0HO4n50h h4Z+6Plv8yVECdjxs7J7PICs+urOLpz/F9Y+oiQu3Bt8OCNuiZa5fAtTm 11udXFtdD5qiukSJfavgWdBZ2TbByuK+kaQoJ751qCGnm0mkW32/M/JoC fH5iAaFQsyafOPtiRo48nAN0AoEmlK3UMasDe66tkHuxsci0o/yD5Wxn9 t3I/QoJlGIUpIPpBfiqKgUw1SzA2mknV/OlHSAsApKWTWnEKA80ANZuUU w==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="6500408" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="6500408" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 06:15:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="936650868" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="936650868" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 21 Feb 2024 06:15:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id CEA572AB; Wed, 21 Feb 2024 16:15:27 +0200 (EET) Date: Wed, 21 Feb 2024 16:15:27 +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 Wed, Feb 21, 2024 at 10:37:29AM +0800, Baoquan He wrote: > > diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c > > index 3612e3167147..425ff6e192e6 100644 > > --- a/arch/x86/mm/pat/set_memory.c > > +++ b/arch/x86/mm/pat/set_memory.c > > @@ -657,7 +657,8 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star > > > > /* > > * Lookup the page table entry for a virtual address in a specific pgd. > > - * Return a pointer to the entry and the level of the mapping. > > + * Return a pointer to the entry and the level of the mapping (or NULL if > > + * the entry is none) and level of the entry. > ^ this right parenthesis may need be moved to the end. > > > ======= > * Return a pointer to the entry and the level of the mapping (or NULL if > * the entry is none and level of the entry). > ======= Emm.. I like my variant more. We return level regardless if the entry none or not. I don't see a reason to repeat it twice. > > */ > > pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address, > > unsigned int *level) > > @@ -704,9 +705,8 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address, > > * Lookup the page table entry for a virtual address. Return a pointer > > * to the entry and the level of the mapping. > > * > > - * Note: We return pud and pmd either when the entry is marked large > > - * or when the present bit is not set. Otherwise we would return a > > - * pointer to a nonexisting mapping. > > + * Note: the function returns p4d, pud and pmd either when the entry is marked > ~~~ > ^ s/and/or/ Fair enough. -- Kiryl Shutsemau / Kirill A. Shutemov