Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1834875rdb; Wed, 31 Jan 2024 10:24:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA+eLFjgoeo6fb+ucjsT39tAaFYTz3A17NJUbFvRH64VVxDrwMM5QiNNFZaCC38Z3LZraO X-Received: by 2002:a9d:6f10:0:b0:6dd:e021:51df with SMTP id n16-20020a9d6f10000000b006dde02151dfmr2472632otq.9.1706725446681; Wed, 31 Jan 2024 10:24:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706725446; cv=pass; d=google.com; s=arc-20160816; b=ewFYiIGt2z7QK4+vWHEMBe5f9Hw1Ic0hG7xJjNgmQTlEnbiKrjRV9kTtvwuMwEnIso taObk/3tJo3o3+K9HEc37Ms/Ae+otRyE6NiB5a63Q97+2MGAkpHbHrQDac6Kbq1dYGiW xz+x2D5uTgBQX4Yv7gVf5Fwm7R9NgrfPwgUINt+f3KKymXN+r01SBIgqtwoAqRVtWIEt mceimC6lhPcgnkJj5bHy8o8tWzTFluCcXlIVah3QQEJRCATu1XjtqeZ30/VdzBHl1vWo hNeeTgRmwqPo8HBgi3pn2V5PNz+udwRVHBEawcj/sMF22k1TlzWXAaKspLnKdMaEYn+h 89GA== 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=ViW1i65vm/GmeuEmdkseKBAnxadv61XtJDHh5VDzIMU=; b=UCPVn5XfCA4CXn4RDBvrkwwELozOCV7LZFlpAv3IBOKpYYzVPASjWLeZeAVIelsk6U ZnxXot9WtmuURm9O0fJWSqxMvO17pr+GkUJ5JFv4jxODY4o3QOfP052CSoxUM7ABeeYw 606yDG9W+zXExt+Ns43AgtScrnMuCXAZ5luOA61EKsYGQfElHJzJR0Ab+53SieuOVPZW ehKY7cMVlcKTBmOTXDcfkxYFjoTp/0Z3Ji2E+2YytM+Up/G5MtCCugP2TFEgHM1pUmnW wBlvJoehZ27XHH+EoQPdycqphjTO5TpkN6WliLn8VuJheMF81Or3/AXzo3XKdWbn6hae l9dg==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCXaM/4+Y/irxCC1/slnkSdX4BmSYwpR8bumXLED13zdQgxKPumNJTEWpSqX0/ayJmjIHBr8VRIUd9jfNnOKeJrZEWd73xk5oh7GgD3U7w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r18-20020aa79892000000b006dde46a8a1asi10041341pfl.243.2024.01.31.10.24.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 10:24:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46959-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46959-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CFA4B28FC88 for ; Wed, 31 Jan 2024 18:14:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B183312FF91; Wed, 31 Jan 2024 18:14:53 +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 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: 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"