Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp356505rdb; Thu, 22 Feb 2024 06:04:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUDZoODRrRR8G0wXmgRqAOEXftEMeMd697DB3xk/GDVySLHT8sgOLEmWssD5K9CyWqMrBu99LqUiX08aBBEemc9KFxl9skrYfYvwNBEOw== X-Google-Smtp-Source: AGHT+IEfzPrnAyE+rGKD1DmMH03Ecr97iazbrPNQrfkeLuMIdyoi7sUk7goSVy/WNtViKYNDXrEf X-Received: by 2002:a05:6122:4d17:b0:4c8:df97:139d with SMTP id fi23-20020a0561224d1700b004c8df97139dmr1839360vkb.2.1708610686146; Thu, 22 Feb 2024 06:04:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708610686; cv=pass; d=google.com; s=arc-20160816; b=PqQHsGVnuDM8T6XwEjmFvb/MZwEEd8HJjlzuWFBc81o63b182uW6ngB4T7a9VxU1g8 Spj2poHw6SQ3SUPpLU6Ga+TIrfpHAxgjHH9XX8i9QUTCZoYNs5iZ+vrQf8xDoqWjX/Qk nC/VOZXcoQt6QV7q9GZSzzQ3kQhmt7ZrX5WwA5Z9oWRxC4UkuIvx4JbjYFJCKXJ/RSGy Pdi8W/fThX9jefaP2waSYz7JYt/PpBMD38kE54PoWB/ldL08rRuhA5FK7VeZnabLEPaD bQgwn38HOhmODAfDyvcVbnl5WApo8GZ8s+TQuu3niayOzBuXiHqFusfYRQk2r9EqThst DKug== 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=r8Hpra8OPSwEXmY55gJjzDgWzVISb0YmMiM2wOV9yZg=; fh=b1CtWOVMAK8JQs6DB+SVg+AtEQpeOtyGwB1IJYlzURY=; b=rrpQkaO9JbtqqHTkHkNM3Odpz0jIMlqVzF/d1gEFQmaEK6l7gSm3NGfCaT48YUQFLF ynPYjjXh/NCt6RRDK9ngKjLxUjm5B2E5e2XM3iddM/X6sUi3+sI+u8WD5JXOOW0MDVTA maki83Rv2KaMj2hafwE5ZkLhptkkh6X8o+IXmZhp34/O/iXp9GXTqNaxunCPq5FALxpF cZLPMU0vWl6GUCXcW3tfyOTcdCl5EuBN+SxMUI61Nby3IMRvLvw3Ec9C/FHT7njG20aU 3s9cPKiw2h33l/U1CzgulDeIFquHFsrRptBjhZa0ZhT/amUUzqeaR+dm0mkoF2bE+Z4s Y+hA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UI2dxVYn; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76659-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o28-20020a056122179c00b004bff0cfa390si1118597vkf.139.2024.02.22.06.04.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 06:04:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UI2dxVYn; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76659-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 DA4281C2139C for ; Thu, 22 Feb 2024 14:04:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8123E139582; Thu, 22 Feb 2024 14:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UI2dxVYn" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 46D52134CFC for ; Thu, 22 Feb 2024 14:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708610678; cv=none; b=ACX7E5S769tXsCKKueHUyPv0A0GwkuX+WzUnx2N75SYkCfMhB1xaSGzu2LJJOR//2m+OU33yC+hjUdtTPv1pRsNS8y/bMex4WnVJi/zsZHDxHzNWvh3X8J9uEjPPu8VWL3gGybuF65UGQ20Dfaj/EiDYxUbydzvY+P42O8wO/lM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708610678; c=relaxed/simple; bh=E75gomph1S/AxYryUcEMcOovIP7yR0F0aFziV9Jmk+c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pCzN1L8blyzkY/2iy9YH+8Wk8G5soHdo2E9mHvPNgEEvRh6IaI8u38XUZVouBbBvOQNzZUyOSVs8UiBhEZuL9wvM3JB7LqOxtw6JL0Lf5jukIE72YwZTGGicm+mwRiA0Eu2aozAqLkJ8FFZMhAMppU06p65o8M2w1docvnyY+8I= 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=UI2dxVYn; arc=none smtp.client-ip=192.198.163.12 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=1708610677; x=1740146677; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=E75gomph1S/AxYryUcEMcOovIP7yR0F0aFziV9Jmk+c=; b=UI2dxVYnk4gaIKmiL5ioesUckdHm3EbegcuLjCOSJAOMCUB3Qo+L4Inc V/+CSWlWRaZC9RUEhc9revGXd9v7kWBRZaUEiMfTntsv9cXAzbQUTbqwA kDGYcYmkS+DPIeLc2d8KWaI7h3JDGm3B63PubYSYpMZtESwq3QjLvhaqd wUvb9zzRGJGvrP4ztWvlEc+DnRghw2/X0w+ffEY3rLWV8LSW6dCfJ7HAO qzVRRcMHRq/7PC54dE+fzJ4ix109o/gvzPIohWZNcvCQBGUrPPbWvZTZL HMc/IhF0DvPKfrmiI/8WAKDwY94vB6Vfy/NBlw4ETPCK54qZmkQqUifJu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="6613715" X-IronPort-AV: E=Sophos;i="6.06,177,1705392000"; d="scan'208";a="6613715" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 06:04:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="936853749" X-IronPort-AV: E=Sophos;i="6.06,177,1705392000"; d="scan'208";a="936853749" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 22 Feb 2024 06:04:18 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 353C1458; Thu, 22 Feb 2024 16:04:17 +0200 (EET) Date: Thu, 22 Feb 2024 16:04:17 +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 Thu, Feb 22, 2024 at 07:01:41PM +0800, Baoquan He wrote: > On 02/21/24 at 04:15pm, Kirill A. Shutemov wrote: > > 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. > > > * 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 (or NULL if > * the entry is none) and level of the entry. > > Hmm, I am confused. Why do we need to stress the level of the mapping > and level of the entry? Wondering what is the difference. I must miss > something. My bad. This is way I meant to write: * Lookup the page table entry for a virtual address in a specific pgd. * Return a pointer to the entry (or NULL if the entry does not exist) and * the level of the entry. -- Kiryl Shutsemau / Kirill A. Shutemov