From patchwork Wed Jan 31 18:14:48 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: 194895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp2072336dyb; Wed, 31 Jan 2024 10:15:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaZ1aYKXkai8hy+YHTKoQ8k+ynB7AtQ/blczaNTd+u9vEWe+LAyDUrtyrmtdLrQErdof08 X-Received: by 2002:a17:907:a4c1:b0:a35:bd6a:60bf with SMTP id vq1-20020a170907a4c100b00a35bd6a60bfmr5979226ejc.17.1706724907721; Wed, 31 Jan 2024 10:15:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706724907; cv=pass; d=google.com; s=arc-20160816; b=vnS2fOnJBWt16DuX0nh7Ei4JcM9bho1oat/G289/cUycj1KtvohdlmNhy19ncKH/Mi 646/ueDoHXFXrZ1gj/rCTNBpZyA9r3Bau3GUrj6ZEMBhtLBGfnNpgBzpqOcdLdG/itEc NWAkOljt6bFUtU9Xd4FsScVxCVO9YOqTZfWwZNBSe1yQ0wBmzDNnmZzrq9/HwMgGC/Rz AjHZu6vksWozlcwDX5OdI59WVBuAZuzNhF/pCdIKCtET3s///pSutC8DNvZTsOT7NNfZ rd8A4bqOki5ljT+BFMy9D8VdTOOCbp84EbM3BukCgovJFmpYPE06/yx97PSkfp2kXqnp Kz0g== 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=MypSRSwvNNFQNgU+xvq2l6bkUXCa3/+75PcoXD4s/ug=; fh=J/RXiwY8bghhs9w0852099+06D/v050KsYIhOaWZf14=; b=HiBlxakEBM5JbfjUgICn4IeYFUtE62pNGtPy5asf4Zd9J65q7Oy1zT1yCf1D+LgptX v6q4PcN/CTOtgWFCzhnA4H8TAKA1wmeXedCPT9KSt20YjI3CoCcAG1sYUC7jehFpIpBR oxGqLwE4wkMY9VTa57DZdP+WsW2m7yiNbqgH16NWDEPfcI11Krf8fbQLWfpdqZUXoMs0 Mi5JUyg/trykp8wQ7XBwP1qFr4/Sftji7x9PuPhfeVBy+IDEkF8T3Okt/wIV9QBDYCUV Hu4RsNXEyP6V9h6XciXBnrv8cJ5/iGyKKqMn1NeseZJVRACQi/eIgxw96+KQpy7LuMwr ucGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=azAuT+Vs; 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-46959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46959-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCXZxVMrV0LHTBZg+YSnda1JwhTW3fYSjUqepIQZM/eABAvajY5mrfb/WhMXsP/vYx6MrytyWfcbuNBPR0+wotmnKXCalA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kb26-20020a1709070f9a00b00a26e29352b9si5664644ejc.301.2024.01.31.10.15.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 10:15:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=azAuT+Vs; 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-46959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46959-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 39BB11F2297F for ; Wed, 31 Jan 2024 18:15:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A442C131750; Wed, 31 Jan 2024 18:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="azAuT+Vs"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JUa4BKfQ" 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 4CD1C12FF6F; Wed, 31 Jan 2024 18:14:50 +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=1706724892; cv=none; b=SFDZ1Z7+Fpn09w7jm5u7pmy7OqcIs86qGLSydGoPMYtqO3nC/PKZlN4T0KKyA/m5Xo/EIuqwed/kwnJ+qv+dgZPC93YGzvbe/CdCvpLmCbbyxl2sbbFtSHHDEDRpXf9fFufJjJQElkDmnYzD+eQqAobUK7rS7t0EO06BWALv1sM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706724892; c=relaxed/simple; bh=Kxm3b0Tq6I4GCPKFx8UHEBf5T8K/P8TVsl4iccrNuAI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=XJKhv9H4niBrW6Ui0ZZ3LDY3pp7q1Lh/kEO5ZIwgnPp6Y7XcvLNAwJm4ypBwIR2hAdp+MEQ2RGresz7CcCwC/OtTFYn2zGRfe9TWC1VQOY0jQOOHwVyrmZb7PE7hG7yirJna21YIPohwK1mgkQQPtkDBwlWEpDgCuQiFZJ/vLV8= 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=azAuT+Vs; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JUa4BKfQ; 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: Wed, 31 Jan 2024 18:14:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706724889; 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=MypSRSwvNNFQNgU+xvq2l6bkUXCa3/+75PcoXD4s/ug=; b=azAuT+VsJtnhRefVqZ08Jc1iaWy6xNLpzIu5H1FAjBFuj9FaUx1OhwS34gx6ro1JKb94No xyYOGuCTjgEhaTGO+DMYkTi8CBiVc4n1sOFQTV8zTiDTgMEl41RHOVfzDuROkP9+csSHjL DIMF8elBPC7cSe3EYiHQqulR/8jGlxOj7cpGoTNQ3ACgYaSieZhifmOd57RBnL4wNh2QjU m5QZKqZqTPUlW1KrsiFGO0xbnuf8sf41faIDI18jN5UC+Ktw+Tn/PD3tu+kpdC2cvAsbtB a2va+iKf35IH+hoLzBf0FGptLQuI/H8My1bYirdOlas+qM2UWx3Zh4GFXdMRnw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706724889; 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=MypSRSwvNNFQNgU+xvq2l6bkUXCa3/+75PcoXD4s/ug=; b=JUa4BKfQZ8SVSp6FSPZl0PnOvFM7oTimTjw9GZ0oWzBD8ADPI1HSeVgdRYF5fnxhv/qagv vgDPlN6P/aSwCPBg== 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/startup_64: Drop long return to initial_code pointer Cc: Ard Biesheuvel , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240129180502.4069817-24-ardb+git@google.com> References: <20240129180502.4069817-24-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: <170672488825.398.2902692058954576766.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: 1789449069477359112 X-GMAIL-MSGID: 1789630776870476353 The following commit has been merged into the x86/boot branch of tip: Commit-ID: 15675706241887ed7fdad9e91f4bf977b9896d0f Gitweb: https://git.kernel.org/tip/15675706241887ed7fdad9e91f4bf977b9896d0f Author: Ard Biesheuvel AuthorDate: Mon, 29 Jan 2024 19:05:06 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 31 Jan 2024 18:31:21 +01:00 x86/startup_64: Drop long return to initial_code pointer Since 866b556efa12 ("x86/head/64: Install startup GDT") the primary startup sequence sets the code segment register (CS) to __KERNEL_CS before calling into the startup code shared between primary and secondary boot. This means a simple indirect call is sufficient here. Signed-off-by: Ard Biesheuvel Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20240129180502.4069817-24-ardb+git@google.com --- arch/x86/kernel/head_64.S | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index d4918d0..bfbac50 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -428,39 +428,10 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL) movq %r15, %rdi .Ljump_to_C_code: - /* - * Jump to run C code and to be on a real kernel address. - * Since we are running on identity-mapped space we have to jump - * to the full 64bit address, this is only possible as indirect - * jump. In addition we need to ensure %cs is set so we make this - * a far return. - * - * Note: do not change to far jump indirect with 64bit offset. - * - * AMD does not support far jump indirect with 64bit offset. - * AMD64 Architecture Programmer's Manual, Volume 3: states only - * JMP FAR mem16:16 FF /5 Far jump indirect, - * with the target specified by a far pointer in memory. - * JMP FAR mem16:32 FF /5 Far jump indirect, - * with the target specified by a far pointer in memory. - * - * Intel64 does support 64bit offset. - * Software Developer Manual Vol 2: states: - * FF /5 JMP m16:16 Jump far, absolute indirect, - * address given in m16:16 - * FF /5 JMP m16:32 Jump far, absolute indirect, - * address given in m16:32. - * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect, - * address given in m16:64. - */ - pushq $.Lafter_lret # put return address on stack for unwinder xorl %ebp, %ebp # clear frame pointer - movq initial_code(%rip), %rax - pushq $__KERNEL_CS # set correct cs - pushq %rax # target address in negative space - lretq -.Lafter_lret: - ANNOTATE_NOENDBR + ANNOTATE_RETPOLINE_SAFE + callq *initial_code(%rip) + ud2 SYM_CODE_END(secondary_startup_64) #include "verify_cpu.S"