Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp263281rdb; Thu, 22 Feb 2024 03:02:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0AeQSs1t2qDT55Z6PWpJXgDGc0aG8IjKPZQ/wCjRhWcXh4jRbKXx1Md6M64Ut1aDnWCzDevUTbE2uyXVG5aWthe9HyLObcVhjXidzmQ== X-Google-Smtp-Source: AGHT+IGeJzRgM0MffJd2H7ROD1LByxc4eEB8QUSKtuRwKHoq3oM85AjhyKz8pGD8TCYUlv3qOHM8 X-Received: by 2002:a05:622a:1196:b0:42e:1f86:3910 with SMTP id m22-20020a05622a119600b0042e1f863910mr11504241qtk.62.1708599739036; Thu, 22 Feb 2024 03:02:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708599739; cv=pass; d=google.com; s=arc-20160816; b=BwOrUYnJPPQ0EK2R5RUSAu7YLqaCin6YMns17ovNDsrJv5GfSobd8bUPjlkQzVFuIU K5EhQ+u5l59GJDbz5Rk0+wlClVOdD/wc+/z//UoqiJ1AChQz+QgAhUiAr6e93b992Aij WKTrfIEz8K48NiH40Tbai3fiXMl1mEw51FR5ZJHWh541Oilru/0+PjP3c8hftMHyJMO9 fygwsx7mYwW/5fT2qSshyKy17sFh77E5ZHjUZXZbZVWYm9bTLnB1f3n8EJGxSzvpcql4 UxsW643Zb1PUZAVRlMCyQigrH8QasO1WyFrk2bR0w7DRGPBr48QCXw8XYF1qSou5iiG8 EcSA== 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=VFwcHVEtiDhTvRigoTq212XHeG8ky/6AjwT+KI1KNaQ=; fh=n4OnCdto9ks8g3/ozZ8KTfkEmd/DPhDnPmomDuJFCko=; b=xsAA8t6136u6Q0GLoG4IKwfqRGVWCA6D6Duu7GJsZB1HH106ecvigaE9hAlFmvr8Uq iTy8Z/N7J0wRagJYEyg5djY8S5nRq7qQMKTx0smCzkcc6RkdSLMcpbsfJJRflowjP3Xg +/5dBJWdRqcPNMInWS0T6E6+RnPrBF5WtakdHtV3nvHw2cGxuQ7aTv6MPSztREy1FTkp TwdO/3mIWg/P31bj+Cx3574pNLAq2sEcx34AcHMfW9hTvQ+QVqVSdsTrBmL3wGFPlDsn U3RsWiPpzuxOe4lsx4ESXNtws7YNXCo6xyHU9EBi1oozOjQL7HLO+WvpjcNKX7TdA83+ 8juA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BHmfZ+5k; 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-76376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76376-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. [147.75.199.223]) by mx.google.com with ESMTPS id f4-20020ac84984000000b0042d345271d8si11814714qtq.11.2024.02.22.03.02.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:02:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76376-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=@redhat.com header.s=mimecast20190719 header.b=BHmfZ+5k; 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-76376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76376-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 BEB2E1C21B35 for ; Thu, 22 Feb 2024 11:02:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9793B40BED; Thu, 22 Feb 2024 11:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BHmfZ+5k" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 50615219E8 for ; Thu, 22 Feb 2024 11:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708599711; cv=none; b=gZkAHChOKZ1gjIPk2ElOzrEN3eFBJ6qdU1yMH+42IR3uoOS6cY5jN/+KXe/WbrqxoeFPmjE7lM23lQ5l1fINAynCk0j1lJkqt7fbk2XiTxLeDqM9ZD313js8GMXxzGmQq0Wu5mcisXCJDxvK64G0vmFv/FJ7/8hqu0BlFyW6y+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708599711; c=relaxed/simple; bh=WI+8ToSVJ6JGQhk6slvgL1Ffo12svsX2MFuD22j76uY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TSYf08yzUJrAKZ6m+cbeOX0Q0i41pQoN22noKEKmTdq60epXhOvdWOq+Q/sorrlCbc9E6v6kQMBOTzXTp/NXjVbQW92T36vrX68AxRekciEd7fOesaiTzoN5bvadTmu3746owIDaxCPyxT1lJUMjzX8d+xGqeXEhU3r+F7sZTZw= 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=BHmfZ+5k; arc=none smtp.client-ip=170.10.129.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=1708599709; 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=VFwcHVEtiDhTvRigoTq212XHeG8ky/6AjwT+KI1KNaQ=; b=BHmfZ+5kLckbl5zoDQxiMDySoLkFU2sNQvELgzltft8HofS6ou+7fvAIynPZcS0oAHCnJC A3z4h7cbYVEp+cSUXAG35DgayOjMQlire/KR36jCyIRSXxXxRJojAZ1jCp9SORN8QGdPSd L7mfzuJK0lLmFO1VviZVRLeMgYuY1E0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-375-OcOjjzq9PGa9bb85kAn-jA-1; Thu, 22 Feb 2024 06:01:46 -0500 X-MC-Unique: OcOjjzq9PGa9bb85kAn-jA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 26A20386A0A0; Thu, 22 Feb 2024 11:01:45 +0000 (UTC) Received: from localhost (unknown [10.72.116.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73904492BD7; Thu, 22 Feb 2024 11:01:44 +0000 (UTC) Date: Thu, 22 Feb 2024 19:01:41 +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.10 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.