From patchwork Mon Feb 26 12:12:47 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: 206601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2027960dyb; Mon, 26 Feb 2024 04:13:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW+e4ADvwk2tZRwOcH6TVqEMcwV355+RIajNNwj1JkfsoGkXk3rHGZGVCvBc7wUk2mCFeJLWgwRDmEEwkAIVOUBti6Gvg== X-Google-Smtp-Source: AGHT+IEyhjoYHCVyI7lhpBXPo0dRfQXQqvXXVPBqXnETqyMp/81lK/ASByaqc+F52RAYNyCYL0kp X-Received: by 2002:a05:620a:57c7:b0:787:9863:f4c0 with SMTP id wl7-20020a05620a57c700b007879863f4c0mr6995647qkn.51.1708949638230; Mon, 26 Feb 2024 04:13:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708949638; cv=pass; d=google.com; s=arc-20160816; b=iwf4TmROhWlluQPtHL/mmXE9CuWPJWVYI3zfQYlL7jgWsC/aU4Lwo25KmtsaiFqW+r mHwPPbUvD27JvhsSC8DUsiI4QMBcCQ/7uYtYyaSAtfiyVMmyTjRPAAb4i9atlC4Jx6fm 8vpaQlnPp+pM4wEUxoV745MCDJ17MQhiZ73nr+Xo+PQK3y4HZWnPQOUgV2LYE9y7f5S7 tt6JQhbCfGz/g2K6mg1oD7DgMNfEf5xogYueYhT6+qitzuJ6egLn3CNFdqurxPxZ1FAr 82TfcODGvfEtTQ+j7w3zeW3UJO93bE+pYYMk85BgYbbzrZJg5cFtU7nSQvQYGNzZjxq/ nGyg== 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=06BzHTpbA/22NpYtuS1jT3qMyjxhGzvHErj1VnfhLOc=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=Yfuv6QSLfYnkOdoEbs5L6SvqDlo7C7uehMh+dhAXVfTcYHBTS1bbPNYCKzWel3veJB IWk6ZzfxaWa9siGdDiQlsycBQIasw712kwAsbK4QhZEwLnFGjjZSBvW86y2QoaIRBgbk 2E1UqJNHzkgsmgKhORFR7Med1j9vi+ibJoC5aBz4UbmzdLmaK0U9gN8GiXjOM+HtNatP a8V0r5SaXMqJFouWA+cEIDG8NGtP72H4PRnpY29gRV/KCZrkjxUGxl5EFDmn4OqMefXC c1IM3kfrHw+YgPsi1hi1LyFMbhEQccIJSpuhTG1C2Oub86ZRCrKR8yWtddirR91x8qQE XdrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="j3W/T6T3"; 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-81344-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81344-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x1-20020a05620a098100b00787273438fcsi5017379qkx.352.2024.02.26.04.13.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 04:13:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81344-ouuuleilei=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=@linutronix.de header.s=2020 header.b="j3W/T6T3"; 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-81344-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81344-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0AFEA1C28380 for ; Mon, 26 Feb 2024 12:13:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EAF360BAA; Mon, 26 Feb 2024 12:12:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="j3W/T6T3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CPPddy4G" 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 2EFBA605A4; Mon, 26 Feb 2024 12:12:49 +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=1708949571; cv=none; b=ooR20DtiywrCDpcgPsVrBFm8XG9OdTbYa46+nOJNb3yz6T7VXx5VXsXvYP2j6xHrdastIK82//mEyoFSnjFOmMGhzlf5YTFajbIH1Leb3rWMsevkfZjCq+0uR288Fd+q7S7Q7XHMUdPDdT6Cq5G/htCJs3N+oAG2JgasPGVJn3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708949571; c=relaxed/simple; bh=M3zALqseM1xjDZx+ABhJazwOHjpUTiVSF2sLLX/zrZc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=MqFaEYkRf2gCQyulIx1N0eHlYR7IY4CIlCwr0YdgUNwCwcmpdjl1RPqQcGnv5pj1GqeZNIqN1D8i/exfgajPVSkEqHVfzX/PTriDcLvtH9pdWqqXlTmEd4VG46pAi1elhA24oxondOa+lNvLp6ysBO9Y2cBj+MYSPvBuOm5vTuQ= 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=j3W/T6T3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CPPddy4G; 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:47 -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=06BzHTpbA/22NpYtuS1jT3qMyjxhGzvHErj1VnfhLOc=; b=j3W/T6T3qmgcT6NuBU/TMyN/59caj/kDoI+vd2ItnyO9+sNnnYUuKo6xwktZfWx+NeraW4 DHpocK4tuZUJeWJ/hIBfVIfsrvCzy90jBGMCFacuO9Ixr3PblDGIcvxsh6QOiMaLpF9HE+ AM7Rr5pIjllijwTp6dqn1JAl/XgItvj/fa6anvSuzn3R90UaAzCVY2wqbKFRZyxKjbb2hZ bUyTnt00HLKvQKh07wR1WZZX3EdyuHkbKP6RDazav2ayurc+/A0gDw46Dst3k9dlOe+m36 oRoJ+u9Rej/djZwu8APS4qyuAaSIrjq1+Wx724NBkQoEzfCLCShuS2igF4sDnA== 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=06BzHTpbA/22NpYtuS1jT3qMyjxhGzvHErj1VnfhLOc=; b=CPPddy4GBvmkuchGpQ3XAcetsXnaeApV7DnX2yAZtvy3HKHmAHK7i1hAwCVZkfUMXmV59n Z+7ZasEvnS0OW5AQ== 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 assign 'phys_base' Cc: Ard Biesheuvel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221113506.2565718-20-ardb+git@google.com> References: <20240221113506.2565718-20-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: <170894956714.398.18401706511421124908.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: 1791963575959924857 X-GMAIL-MSGID: 1791963575959924857 The following commit has been merged into the x86/boot branch of tip: Commit-ID: d9ec1158056bedb6da8f4e02de30d300914b31f8 Gitweb: https://git.kernel.org/tip/d9ec1158056bedb6da8f4e02de30d300914b31f8 Author: Ard Biesheuvel AuthorDate: Wed, 21 Feb 2024 12:35:09 +01:00 Committer: Ingo Molnar CommitterDate: Mon, 26 Feb 2024 12:58:35 +01:00 x86/boot/64: Use RIP_REL_REF() to assign 'phys_base' 'phys_base' is assigned 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. While at it, move the assignment to before the addition of the SME mask so there is no need to subtract it again, and drop the unnecessary addition ('phys_base' is statically initialized to 0x0) Signed-off-by: Ard Biesheuvel Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20240221113506.2565718-20-ardb+git@google.com --- arch/x86/kernel/head64.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 1d6865e..f98f5b6 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -192,6 +192,7 @@ unsigned long __head __startup_64(unsigned long physaddr, * and the address I am actually running at. */ load_delta = physaddr - (unsigned long)(_text - __START_KERNEL_map); + RIP_REL_REF(phys_base) = load_delta; /* Is the address not 2M aligned? */ if (load_delta & ~PMD_MASK) @@ -301,12 +302,6 @@ unsigned long __head __startup_64(unsigned long physaddr, for (; i < PTRS_PER_PMD; i++) pmd[i] &= ~_PAGE_PRESENT; - /* - * Fixup phys_base - remove the memory encryption mask to obtain - * the true physical address. - */ - *fixup_long(&phys_base, physaddr) += load_delta - sme_get_me_mask(); - return sme_postprocess_startup(bp, pmd); }