Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1262246rbb; Mon, 26 Feb 2024 04:13:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUhhG0tfKLlUtk6XxFxLlThxTZUOlp2g0osh3+oouR1tzLmqvEzk+QAXPceapCVa+zde47gcs3nWwPxsgwer7GFCYs1eZj2W0Utb899Bg== X-Google-Smtp-Source: AGHT+IETkDMrV4eiCOt3S5nVFWklA2QWEQMinWWqrMQSxDQoWgM6HS3XuHhq79kRnEh/SXckeOrG X-Received: by 2002:a05:6214:2b83:b0:68f:de5f:44b4 with SMTP id kr3-20020a0562142b8300b0068fde5f44b4mr13296274qvb.10.1708949605347; Mon, 26 Feb 2024 04:13:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708949605; cv=pass; d=google.com; s=arc-20160816; b=dk892JaWimSpUnnwesRSftZAsi+OJEop05bLO0monxUdBbhwha3smpEMnzA5XDg1/6 f/GolCZEzzedgcVeKMWj4dcy+CbKwYkleMjNdkrEwVRXTu1xXqdr7MFy8cr3k8w/3dr1 rZwtKWlnvPqjXs8hxiIHanSPtCiUtYL99v+whM7lFCLBuZfDfBQTNJIIsfryRfRbi/yp 2LR1PZeY2LSkq+y3GRX2LKnxDE3o7XWrpDk739ob/BucKjejrnyxofDHj1iFORA72+Vh jhplmeb6FHk8JZL1zTt6Z7ZEeHLOJr+lVhYYYL/GjcYwT7p5OoiB6tyX+DSKOetPaw6B 8a7Q== 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=+OBg9ZV/wuOo69DqfiRmpGlAZHe81AT1vWBq75vGgNc=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=xR4FtlEVWP8SXi1zeMRclDDixUIg9GT+bqtcWrfEX2QNlVeQ5xK/Yb4nHH8UTeG+Jo /RKmqZ2iuzDtyqgUiOu01bYG2y51ruzNM6XHfX/7rUbPQGEBgRlPAxYRIUEkCe+liEIX /Tf1uCMkbpxB0iTruBs353CJb/QcF/DNZ+Z8EZ9D/HlSbYdzn7x/w9kdfRgr5Pv8tC09 hHyYa3AODJdG3nx7+p8F3PZlfgYwTdFeHb2n8FRKHF/qbdEuzmsR1g5/HpJuh4OrVS8I AkKZna8bDn6sfMjoqyy3CFJrObOQt09G2atDeN53U18R33Q8reE10yoiRGsvFXMk3UBx HVtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=g4zDpWCB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=HRYiRWH0; 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-81343-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 4-20020ad45b84000000b0068cd964819asi4944970qvp.392.2024.02.26.04.13.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 04:13:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81343-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=@linutronix.de header.s=2020 header.b=g4zDpWCB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=HRYiRWH0; 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-81343-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81343-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id ED3E51C28429 for ; Mon, 26 Feb 2024 12:13:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53F56605D2; 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="g4zDpWCB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HRYiRWH0" 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 DE565604BB; Mon, 26 Feb 2024 12:12:48 +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=1708949570; cv=none; b=UqstpXDSJdad9oz3yi2RCuvTR4Ud/KrvNkvpi7MIga9y3JdsDa5DYLgKhq3BxG97ORnAlA+mpmk3Ek7oPQZ+4Xh/NBThYQK0+YulDr+/sI/uKJg6UvqWPbvJikjSLfc6XkBpgaHfCXwRwOK1dpufhyWSa9pf/XzCGJSbR6hhivo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708949570; c=relaxed/simple; bh=fPKA2huygjKpPaXhIEytXpwpJrP0HZn0qRmhERmXfuw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=U8vKbJh5CpGtE3uAjzCkFoddBgQVcFAcEE2mLwBmFdW7/A5Lbt9abVv8h2Y9IfZMn4pDl0H66THlYMQwzGQHwYcucLayuNHj5IG5AyJeBHG5iXF7cFyQYiLcW01WKdHHkJi+dyA0huv2lIbm/hMu+TXZP5t07NwHZMO++ZRzMNo= 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=g4zDpWCB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HRYiRWH0; 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:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708949567; 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=+OBg9ZV/wuOo69DqfiRmpGlAZHe81AT1vWBq75vGgNc=; b=g4zDpWCBoymyvLxaofeI7ZNT2fpja/ZdJaYACD3LEi1yYIDewga9gGk4Rtj2zPOhmZrmyS SMI8htmchPpY1C0nNuE/0UxOZx4PhcdrsUITkVJ52l8q05gGadt7aZ7abx1a1oXCO7IX7u cSkw0vZ4kZlok8UwGj0+AsHtrOj8EmFcglvQ/GukguKgwbX13FaoYmZtdTAVHt6BiJvKDo usTrTW8R/PKgrCT1OdGoA5u6b47JP0En4BsK9prL5jt2xM3Lguac/JTayd5QB7MGQvOyVv kBaez9vQ2nFw4pK06YgDhLttBpcJvs4IhOAZ73gxDLK4RzF58kmyjAEkZA5sZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708949567; 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=+OBg9ZV/wuOo69DqfiRmpGlAZHe81AT1vWBq75vGgNc=; b=HRYiRWH0cY506RmvDyTSzGJ6hMp9NMv4NNj+PwU547vuOASwTOaXwHF61Vod7QKVXVxXDK iC/4bTqRNhXzT/AQ== 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_dynamic_pgts[] Cc: Ard Biesheuvel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221113506.2565718-21-ardb+git@google.com> References: <20240221113506.2565718-21-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: <170894956625.398.12847281794218073539.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/boot branch of tip: Commit-ID: b0fe5fb6095be0f68b570c4cf4cd86b7e70c2e38 Gitweb: https://git.kernel.org/tip/b0fe5fb6095be0f68b570c4cf4cd86b7e70c2e38 Author: Ard Biesheuvel AuthorDate: Wed, 21 Feb 2024 12:35:10 +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_dynamic_pgts[] early_dynamic_pgts[] and next_early_pgt are accessed from code that executes from a 1:1 mapping so it cannot use a plain access 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-21-ardb+git@google.com --- arch/x86/kernel/head64.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index f98f5b6..2ac9041 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -170,6 +170,7 @@ static unsigned long __head sme_postprocess_startup(struct boot_params *bp, pmdv unsigned long __head __startup_64(unsigned long physaddr, struct boot_params *bp) { + pmd_t (*early_pgts)[PTRS_PER_PMD] = RIP_REL_REF(early_dynamic_pgts); unsigned long load_delta, *p; unsigned long pgtable_flags; pgdval_t *pgd; @@ -179,7 +180,6 @@ unsigned long __head __startup_64(unsigned long physaddr, pteval_t *mask_ptr; bool la57; int i; - unsigned int *next_pgt_ptr; la57 = check_la57_support(physaddr); @@ -231,15 +231,14 @@ unsigned long __head __startup_64(unsigned long physaddr, * it avoids problems around wraparound. */ - next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr); - pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); - pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); + pud = &early_pgts[0]->pmd; + pmd = &early_pgts[1]->pmd; + RIP_REL_REF(next_early_pgt) = 2; pgtable_flags = _KERNPG_TABLE_NOENC + sme_get_me_mask(); if (la57) { - p4d = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], - physaddr); + p4d = &early_pgts[RIP_REL_REF(next_early_pgt)++]->pmd; i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD; pgd[i + 0] = (pgdval_t)p4d + pgtable_flags;