From patchwork Mon Feb 26 12:12:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 206598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2027648dyb; Mon, 26 Feb 2024 04:13:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXnsXYWWyqXte+dVq5VWndQkS6rAqW/sbAU8NpnxhBl0YrdnVYDJugrbnmy0soXauF3ME8fQzWwIJStDgTVJjPAlvbFmg== X-Google-Smtp-Source: AGHT+IESqc96XOqJ8Pbw6dPL4xiOrtRpPWe3zMdwIVnHyGbYourHYRyCB9tDtNTZCU/wa8IUGWCD X-Received: by 2002:a17:906:e0c8:b0:a43:5d8:95c8 with SMTP id gl8-20020a170906e0c800b00a4305d895c8mr4208250ejb.7.1708949601408; Mon, 26 Feb 2024 04:13:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708949601; cv=pass; d=google.com; s=arc-20160816; b=M2WMKANhDM/yxVJvxEqu+WebktKyQocPVVvSY3GfbxTzxF8n7PDvXiOGVfNFqa2PR8 0dcaHbgDcb/skeGwFAIUAX3KufHoSXvrHo9+ADhPGkMABhLJUFzfjilbiQSFerymTEfb RXM34+ReZvayAtDLJ3hUyGr869QtEqaAEHWZO18tRSfIWBONF50Npv468Af+c0QS4vhb ECfy3y4VwlPhhTBRVqiweMdA6h8AtUXLPU4mcY/UzVGfoiXeiNQFDcUOkmJU8HXx8OX6 ENfCi96kx33GRd17+abqbAWptV+rHV8DuxPy3WxFbq+g/UO1So5tx5fJonH5j28yRVaf lDCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=JdFo9kC6jinpYH6jRd2rYz38dFc64c3+PKmAeRxOHio=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=hcXFpIbb3VidC9w/cK6Mxp7vcx7H4NZVGL8rs8kPllHZkm1j6eNptberi2HyvicCXE D+qOoCvpBwpN1X3e7Pwzt9zJs44DgHTL8W5NXhlbtNbuRgzlZtPeL0nugX8RgAGNKyiz t0y681fl3k7zdMy3xg9pLg8IKKd+vfM8dXw/XmXY5rPyFrGbYq2bFJVKHgNazSdV+phX 7VNNd32Bwfj5hXCYyMP8wtzo2+0gHy5q5lqLadCqMYIe/u1eaz6nx/fgqKSbhF1XuYVS B9gWcLJmmGRdjpLV2BM+bZ5sY7c5bqvKzOqakNwKuob0KV0YqL0CLvLVCG/Rr0eQnuUo f1zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Px3a+r85; 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-81341-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81341-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h16-20020a1709060f5000b00a435afc169asi683767ejj.996.2024.02.26.04.13.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 04:13:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81341-ouuuleilei=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=Px3a+r85; 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-81341-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81341-ouuuleilei=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 0A3501F25C84 for ; Mon, 26 Feb 2024 12:13:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10F17605C6; Mon, 26 Feb 2024 12:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Px3a+r85"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DM7HSrcU" 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 DD35D6027E; Mon, 26 Feb 2024 12:12:46 +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=1708949568; cv=none; b=ccQTjE3wmVyV/qAM9WidYAJDVpfpes1W31YGOUxnqtp/HYcGe7xl4pKgU4ziQTb8hLjZ0d0a1rMLjmXvx36IlcNecFlhUAQUEME9Tn+ya8uKOlBhhwfWOudV9PLYb0x6K2m/JczY+HlOyFBFY7kgTszh5W6HQhORo86YbFIZ8Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708949568; c=relaxed/simple; bh=mWDVcYPf4K4buLKqQJVFqO0wcp+5c2TANsnglXeQUC8=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=QgonNLpWX9XB8SxRA7A/PbedFOE6dtI5u+tEZhWaE+y97XCqaeAZiEoC8r303Lsqst3DQw23qwRnFzH6O+EBx0BXoqIEBIDXjTFUCFlOpDURz4CEZunmAhDiTyBz9tk28kc00TpYz7Nz8h901BaFa6CAmhsex+ueEjUshCagRv8= 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=Px3a+r85; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=DM7HSrcU; 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 Date: Mon, 26 Feb 2024 12:12:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708949565; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JdFo9kC6jinpYH6jRd2rYz38dFc64c3+PKmAeRxOHio=; b=Px3a+r85l109dlvt0xH30pgaHRJC7AG15Qy7AwkSmYC6xob2vQsKeiDdvbch9IxMieOuXj NM2/y8RRpqC1duaC5ZksWktdj9CQrCOAW9/cW8MlxjBhrLhw2SeX6PcPHG3/yXCcWIBEB4 7l7ntywJHZYl6cMNX5roMVLu3utbK5lcAiTCw2eqc5VX9RBli+zS7i1tVRE6/Pl5bNNCkk RzF32EYK3XY7rZ5VYHPEjKvh/3ozv2qkmY+KNg+ckpKkvTjgp8mQzIwHdE8lNgcjtTV7fx dfAFhdSFFeQ+qUrOjBvbqghCf3a9CacM2p+jbbetERLqDcrWvvBsC78RF6cbeQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708949565; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JdFo9kC6jinpYH6jRd2rYz38dFc64c3+PKmAeRxOHio=; b=DM7HSrcUQA2ia4rDdvcTwIjaDnnMg9vbahBTrdOYchOIZHKqCKCzk0GVe+BStICW+irsAw sP0adkPlV18hRHCA== From: "tip-bot2 for Ard Biesheuvel" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/boot/64: Use RIP_REL_REF() to access early page tables Cc: Ard Biesheuvel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221113506.2565718-23-ardb+git@google.com> References: <20240221113506.2565718-23-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170894956442.398.17374990463017406130.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791963537161997483 X-GMAIL-MSGID: 1791963537161997483 The following commit has been merged into the x86/boot branch of tip: Commit-ID: eb54c2ae4a4825c42a6a2b4022926bda7448f735 Gitweb: https://git.kernel.org/tip/eb54c2ae4a4825c42a6a2b4022926bda7448f735 Author: Ard Biesheuvel AuthorDate: Wed, 21 Feb 2024 12:35:12 +01:00 Committer: Ingo Molnar CommitterDate: Mon, 26 Feb 2024 12:58:35 +01:00 x86/boot/64: Use RIP_REL_REF() to access early page tables The early statically allocated page tables are populated from code that executes from a 1:1 mapping so it cannot use plain accesses from C. Replace the use of fixup_pointer() with RIP_REL_REF(), which is better and simpler. Signed-off-by: Ard Biesheuvel Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20240221113506.2565718-23-ardb+git@google.com --- arch/x86/kernel/head64.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index e2573dd..7e2c9b5 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -215,13 +215,11 @@ unsigned long __head __startup_64(unsigned long physaddr, p4d[511] += load_delta; } - pud = fixup_pointer(level3_kernel_pgt, physaddr); - pud[510] += load_delta; - pud[511] += load_delta; + RIP_REL_REF(level3_kernel_pgt)[PTRS_PER_PUD - 2].pud += load_delta; + RIP_REL_REF(level3_kernel_pgt)[PTRS_PER_PUD - 1].pud += load_delta; - pmd = fixup_pointer(level2_fixmap_pgt, physaddr); for (i = FIXMAP_PMD_TOP; i > FIXMAP_PMD_TOP - FIXMAP_PMD_NUM; i--) - pmd[i] += load_delta; + RIP_REL_REF(level2_fixmap_pgt)[i].pmd += load_delta; /* * Set up the identity mapping for the switchover. These @@ -284,7 +282,7 @@ unsigned long __head __startup_64(unsigned long physaddr, * error, causing the BIOS to halt the system. */ - pmd = fixup_pointer(level2_kernel_pgt, physaddr); + pmd = &RIP_REL_REF(level2_kernel_pgt)->pmd; /* invalidate pages before the kernel image */ for (i = 0; i < pmd_index((unsigned long)_text); i++)