Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp232890lqp; Wed, 22 May 2024 02:58:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVChW0ixFSTucIw9B/rfxdG2HrH/elGEgfbISSRcJ/lBXzaA76+QC/w2Rhp5scKInbjkYKAexie+vPp0QFTlvKgTLl8fNLTRVWLJOdBfg== X-Google-Smtp-Source: AGHT+IHNjOodXeP0gvdtS/EoGx6x9zx8OyYcTwbhz7Sf4Gx3OxP3xBEtRFC8oja+yQ01P1YHvxLV X-Received: by 2002:ac2:4650:0:b0:51d:9ce:c282 with SMTP id 2adb3069b0e04-526c078364bmr892184e87.46.1716371891131; Wed, 22 May 2024 02:58:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716371891; cv=pass; d=google.com; s=arc-20160816; b=l6uFgKVVN4b1WhB+Wkj2jgUt+RmrVbqJS92aCSBmM/WH0I1eXjICoYSVPffQoILzSz lYISvf+6sviiX2RrVNs5mQXPzOQHthW/R1HctUWF8FV+RowGXTJ+B5qMnYdbgHrejugw 4rkAYg78m5yS2N/aVW/8FIAcRSxrj7GbjU4JV7Ck2u7bf/w+Mm3QV57m6V9G4K5zh7rg ecwd8oT2tJnDPt5LWepl8vLS4snaaC/3rc9GoPB07xStcGYFRJwyxskZ69eKvJJ2Xzvo j3iXxbRSi2qnHdH5So6pzxf8z4xNO+Ax6lYDAlU865jkxiOSsxSwgCiGPL7E+vpzFvK9 vzCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=YYcRdQHtgu6q/Fcsceek8ZJ4kHucWNk9eR+lcvD6/aQ=; fh=DaMZihOjR2eJ8mJRWt5S4Mcefgk5LGYLwQhUDuQs6vw=; b=z1eZNQIedchRf1Jo3b5Qqd7s8+NrGBkEpfmdOx0Xlw4ej6JvMHHAeA/ktM0WPX1UC+ JzjZAmRiCt+g0DapkklCFUdzgsHafBRMc8uPGSbpHCJ24+GvLZI+SoFsYD5w4SOb26uv corIMerllG8i8bokBISApf0JjB+mvVnzpB5UbASqZpOQyrfb0TVl0fwFH3i12HPfMpbR I6D2BYzjkQNO2MZZ1Dr3nVBdfen9fHmHKrKUttDrV5zNrFZeQnXwkFmmp55e5g/tOPKu v7ydYnYdrxe/zWVch6afxtbYoyywOcDq1S54EyE52FAmTbd0XyfFmnfMYVdX1BIjHJNh ISyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FZj2R2su; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-186016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c2bd6fsi1489836566b.914.2024.05.22.02.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 02:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FZj2R2su; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-186016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D57101F235C8 for ; Wed, 22 May 2024 09:58:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F17F481AA5; Wed, 22 May 2024 09:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FZj2R2su"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="z/6PVAQR" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C9F1E81723 for ; Wed, 22 May 2024 09:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371886; cv=none; b=Qm3eCNmRqnxW390WmV+6JXhDht74cR8To8X8iS3UD2cqtIXSXjJHN9iuVWhg93tMahx3eTe4GxJUf5CDPZJFad/WsingVTX8isBWi7Ji4O8JB2yCdKz2jCSlZe0czZzvkF6R6CunToI0gk4SYtmrk9ZVxRbNgppzhk5NhFq5rtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371886; c=relaxed/simple; bh=ai3Po91eHrHWSqQYU9MF/oxQql3OSFBpm9cVkudZZl8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Ir4bSoUmqrshBLRZBVeoQSeyzqQrbhPddAzkNpQC33unbHnNpinPP+A29QH5Rrn4bJSGz8yH3VA25ukBu2Lm7+vHwW3fZ8K51fA/4zgjCh/1INfvG3DG6gxdCkiFIqzbfXorsoV0QL4IucqW+bOdSS++OGNbV9kgOdt4tSYrnpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FZj2R2su; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=z/6PVAQR; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716371882; 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=YYcRdQHtgu6q/Fcsceek8ZJ4kHucWNk9eR+lcvD6/aQ=; b=FZj2R2suUUtPyM0B99TxvrVdlo7cQRAGGWO94+CRzGrLjE908T/MsEZW+TuqxWGYYDVH4h cmn026cytUjKHWh8KH0oK1a2TVbgqAIwgRUDaLmA9NHB36SI8fUuopBiqhB3bnn56WH+Xl kIyCDK0NI2hV+5lMx1Zd33v4WiRKi4+PCPUpwIulO+gMkrHUmfW050royKQ3IOZ0+hweLq c8ewMuHzj/GxQTDKnWlH5Mg6476l1Xa9S68KAgSiYCMSqz1XL2MmszDnughuQObNitYuXZ /Jm+2UdNcyqFbErmcB5FDdIT2YyIQccXGXNfXJsYbtWq119m0BadUA/hrGh2CQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716371882; 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=YYcRdQHtgu6q/Fcsceek8ZJ4kHucWNk9eR+lcvD6/aQ=; b=z/6PVAQRrIkLG++OVztMfV6dDelOY+v19rQl7GAOiupWX02TMje8txJyUrRPzOHXCWe1qr 9KnAsw4MrJpXNUBA== To: Wei Yang , mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Wei Yang , Vivek Goyal , "Kirill A . Shutemov" , Ingo Molnar , Steve Wahl , Borislav Petkov Subject: Re: [PATCH] x86/head/64: level2_kernel_pgt's kernel area is built with _PAGE_PRESENT set In-Reply-To: <20240323232621.10400-1-richard.weiyang@gmail.com> References: <20240323232621.10400-1-richard.weiyang@gmail.com> Date: Wed, 22 May 2024 11:58:01 +0200 Message-ID: <87jzjmgod2.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Sat, Mar 23 2024 at 23:26, Wei Yang wrote: > The code is first introduced in 'commit 1ab60e0f72f7 ("[PATCH] x86-64: > Relocatable Kernel Support")'. Then 'commit c88d71508e36b > ("x86/boot/64: Rewrite startup_64() in C")', convert it to c. And > 'commit 2aa85f246c181 ("x86/boot/64: Make level2_kernel_pgt pages > invalid outside kernel area")' limit the range from _text to _end. > > Originally, it does the check because the loop iterate the whole > level2_kernel_pgt, while currently it just fixup the kernel area. This > area is built with _PAGE_PRESENT set. What's the actual problem you are trying to solve? > /* fixup pages that are part of the kernel image */ > for (; i <= pmd_index((unsigned long)_end); i++) > - if (pmd[i] & _PAGE_PRESENT) > - pmd[i] += load_delta; > + pmd[i] += load_delta; Fixing up non-present PMDs is a pointless exercise. Thanks, tglx