From patchwork Mon Feb 26 12:12:46 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: 206600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2027878dyb; Mon, 26 Feb 2024 04:13:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXB9zf3ce/tf6YNvBtSI8foVelw3b7ScJTFF8jPvX75+EDsweoGg6gT9ZZ71HvHIU0cr+Y1WwFfD+xIZYugzNOLobNYqQ== X-Google-Smtp-Source: AGHT+IE5KYnlf72tEkvH34eJ0vVoZJY2Vp6kw01dj6C6J0ZoT/lnjkqnuAwYV/jRIdFm7sff2AA9 X-Received: by 2002:a17:90a:db84:b0:299:3780:e9c7 with SMTP id h4-20020a17090adb8400b002993780e9c7mr8160602pjv.2.1708949628185; Mon, 26 Feb 2024 04:13:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708949628; cv=pass; d=google.com; s=arc-20160816; b=0sPcYqb+RAxIANFhpw0kiU2svDnkx492iJmfRT6tcNQ4i0ht85XQbie8hPpk5BHrb/ HQ0IvtlbPh0755fDrL0wwC/K43djrEX6k/d1czB5IYElBsMEvYNE2CRqKmXM4vUdw1QB GsvlmFEXN0AAO0T23gyD43fZbO1UsMPELAuaZgwoa7PHY6AQFLZnp66UgYlaOe3666b6 jFV8UGE3AWzTjgB5Kj15ZUxBQljyCJ8oSIcP8syuVTys933IAenqQ3yu7APxG/dRhdP2 IL6sBJmLA4LGPo/zV0Y23g9a2WncCeRhv/l99sa+o6g7WPDyVF6wpfqihmFYfnJiEn/g YKfg== 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; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81343-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id nu8-20020a17090b1b0800b0029aa277aadcsi3380745pjb.115.2024.02.26.04.13.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 04:13:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81343-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81343-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 03D89289802 for ; Mon, 26 Feb 2024 12:13:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49C8B60907; Mon, 26 Feb 2024 12:12:53 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791963565371503507 X-GMAIL-MSGID: 1791963565371503507 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;