Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp415085rdb; Thu, 22 Feb 2024 07:38:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVv9Gkf5x/gA+1k13vtof7EXR1VVfvlq+1ScFFYwNM2qGia4+pdnCBG680QtMH5sjxPIy69FJ71PcHcSUcL+2cdASYPi7t44u3kwvqmxA== X-Google-Smtp-Source: AGHT+IHxes17PIURPo2u1CDyzvpvxb0YhWGXzAsK1r/IeNDQV1bFGF3r2lA3JOKGLW41D9eoU5S3 X-Received: by 2002:a05:620a:8316:b0:787:8b2f:19c5 with SMTP id pa22-20020a05620a831600b007878b2f19c5mr4781926qkn.15.1708616315750; Thu, 22 Feb 2024 07:38:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708616315; cv=pass; d=google.com; s=arc-20160816; b=PMTFIfyYF7QIjr+4CB2UpQ/WkyWrAyYJid/k3TWZuLJI0zLrT2HGkf09iI/IbKjgEp 7yzHCKUtx8L4Qtc82Zm8OrCXD7nS4jkok0mnJVUnmexNE2inmx+HyfJN9yoiVlJvOVr0 PvFiKAZB1pDMkvi+qoScIlOmFAKP9KYM3J5UdgPtaJRtRpgMRmw4gJY+jKN+5UklA6dS 3T23IHiL5DOSfy0UGceMdJxsbZO/9G+OGfqUfWeIP3c/Er731qGoTilTMyKrzkzCexUD zoBMjWyY0SrCt+8QNh52iMvHa99rmkF3gnY4CdYan/157NPmpRyqbWO77I97nSZasl7d AH4g== 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=Z2zLTzF/EaarbV0Ayz1K5vhiNlvZJ6XriwzG+FJ76a8=; fh=n4OnCdto9ks8g3/ozZ8KTfkEmd/DPhDnPmomDuJFCko=; b=l7Mqxw8OFa+A823dk0l6Js4jWAC53B9zyny7u6BXE2jTwZaltGypifuNmcMOUAUhrz xIc/J7d8iZtPbybEx50/QrSGcaJrJ03ReM+m7wnV1EoelVdLgjtwDKLSVQfi2CqBM2Z/ 1kA//08hHmK86NfEICvll2H/oEDzRsyV+5U/enkr27cqcNpjMsyEwHbdIqXyFwJGSa3S 4aqTRy7+G34gBAqBnS7a6OFYUcZqdPqHN8jpmIdUtsE6Q+lUQgjXRmxZSSn8Zeg86/mU /GY+WAZZnAvOHj9mpn3a7mWmCR+odOTrogFmPuPb46qusxnmcaW00G+eraWk2p27xVhQ Ox2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jWE1EkAr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-76787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 j15-20020a05620a146f00b007858a85f87asi13274162qkl.569.2024.02.22.07.38.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:38:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76787-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=@redhat.com header.s=mimecast20190719 header.b=jWE1EkAr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-76787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 81CBF1C24158 for ; Thu, 22 Feb 2024 15:38:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09C6514F9D0; Thu, 22 Feb 2024 15:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jWE1EkAr" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 AFED314A093 for ; Thu, 22 Feb 2024 15:38:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708616292; cv=none; b=avYnVkkKzXVbXghvSY4n9xUNTdoSVLWxzanc+J660cUw0Uaqs/wx8ou75wkwqiKC7DIvGMD77Ky4X28/Wde0RzrcCCdSGvvJQj4rP6yOc4n+pHkIeOxwm7vh9wRhm6exEuh66bBiOOFU/lASIxgiFC1NA5fZXML4FUVfGNxEK+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708616292; c=relaxed/simple; bh=SjlZWaZo4IOCJl163JtnSm92bFyN5RFQkXSgAX+7pwE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kmtz0l7Z1pGvCTGGpQ/i9/Z2ebwdL4rZJE/C5s4NXqaxKy3rFNuFsuSFbgLjyrpqH90AebvKEfGsIb/YFjnVZQjIy2XoE1UBwYKweP37SPSmhAJ8pKDXJFzX1inWbDDWDykBGY2EFs6t3OnphmabKd+fnyi7rg33GznsjQDgx48= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jWE1EkAr; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708616289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Z2zLTzF/EaarbV0Ayz1K5vhiNlvZJ6XriwzG+FJ76a8=; b=jWE1EkArz38yYcyDG0IRa27xxwOBHIi2Iq7lfZMxKInlIUURZc+/NlTSAwoBc3f5fq8+kr dVzVrEKMfZfNUEcEpLEzTa1S7wB6EtN2kA5DYnZg1IDyeHU67HiZabTknfTS0m3p4+zaZL sPK7Wa/LC0ckNqpsHkTPeL1iudCw8c4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-SDpRsDIIPQCfsD-HL-3ZTA-1; Thu, 22 Feb 2024 10:38:07 -0500 X-MC-Unique: SDpRsDIIPQCfsD-HL-3ZTA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85A6B830DCC; Thu, 22 Feb 2024 15:38:03 +0000 (UTC) Received: from localhost (unknown [10.72.116.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5F8F40C94A7; Thu, 22 Feb 2024 15:38:02 +0000 (UTC) Date: Thu, 22 Feb 2024 23:37:59 +0800 From: Baoquan He To: "Kirill A. Shutemov" 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: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 On 02/22/24 at 04:04pm, Kirill A. Shutemov wrote: > 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. ACK. Thanks.