Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp552068rdb; Mon, 29 Jan 2024 10:07:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEs37RFYJWgoESZHh9PyRh5hdfQkFWlKf34ij1kgj4cs9QdDVPU2A05sBlcTWAxv3bhE/pd X-Received: by 2002:a17:902:c64a:b0:1d8:f977:4159 with SMTP id s10-20020a170902c64a00b001d8f9774159mr1157426pls.4.1706551671767; Mon, 29 Jan 2024 10:07:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706551671; cv=pass; d=google.com; s=arc-20160816; b=KIo+oQQN/xeOyVzu8lqUBJ+nDkK0SQuFhaQyp6vvELGC8ZhLglGMusqVVQFpJVfR14 qwRFq86tFkFF1r6+kwBOBUW23eoT1u3RvU8K88qTqQrrCVvhsUyFqMpMLeztJA3EaMM1 4llC7QGRmzHz2K7pFa2dQ/OZiRz9UQHrLIwGOHPGy8OGKdlAYBMLiSNNN8NXkEtFj4Q1 hh8dUPGseYuvCQ9GuiPkEIWAEfgskAa14oZ/0nQ8WS2LV8jWOjqJsEOwXt5GXOkSGJOO yBT9ZX6sLOzT/HpciUS8Fb8jyAUOYtU4WtopPZhwk1D4pQ7rrSwct47o5qNiwiX0MmHy /Ckg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=VlzuORvF37cHhQgjoovr2a86HYjlNB8YTzXdR4Eq8S8=; fh=fMhMPvo8duafGkM4xZHdH7fULbau3etefTGsKa+Qy7I=; b=nrNuB0rjwAnHcgvp1zrYcuLPu1CVwvk4Qu1gKwhcfzlcZpbH3c06ZLfZwJl+lnNedF 8wk3DVpIj8OUizL9fUdSRLsyDu8dzrL6fzJxxDtecn2ftVz4V1Jy9+o7qAa+WXvVkcg4 HvvUVNfulD2W8K/ZftQ36cX/0IqEqCpKID7CK+gtKyYmqi+wqo/QCIf5AcWoTwQO6KKM SUI3kL4BmbhxGFvpn9M9+ds3QCqW6TRJbLBXBKkyOL+VzlEDJYTtIH9zgCW6awAq9pLN la9pQCDYyFVtzOJz6s1LxUnwy71NW854nLOQ5Ed1CsKFxlbWIsIRT8S9lXrYXf4f0CQH 7hiA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=N5GNZ1+H; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-43270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e2-20020a170902ed8200b001d78c9a13b7si5802215plj.528.2024.01.29.10.07.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 10:07:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43270-linux.lists.archive=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=@google.com header.s=20230601 header.b=N5GNZ1+H; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-43270-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 D9781286929 for ; Mon, 29 Jan 2024 18:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B8B276040; Mon, 29 Jan 2024 18:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="N5GNZ1+H" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 085BB6F07C for ; Mon, 29 Jan 2024 18:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706551539; cv=none; b=J42fLjwjPMGVOan0Vnba4BtPOztaJgnd9uENmnlOXt66KiBTBnylmTnvJave+wJn+/cjgXpEnHYke5v/LNcQyqQK3301eOffaYB+KmW20w5SkwXykHGjfwADJQHlqgLjH31huN49AQE+mOVnxCjkbiAmrYWvCo5VH1gjUUQoSI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706551539; c=relaxed/simple; bh=ksYtquI/zNJoo09z1kn9EIIXegn4h7RVzbkZ+iPv7gQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mPCerUWbYB6ycF1/mm0lcb8wI+odz6RU/HC4eb2i3YrLGQ/fc4ek8pKzCTHqaZHtOQ8QHTXxpv7UAZDWu3iH2OnwoClh2jQIVAl5Vjx0X25dIzQ21h4UmLCUo2PHNVmF7g9iRCBuwsVbR+QKDo7AQ93KTGjFDF5AqctVWz7aCiY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=N5GNZ1+H; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6029c85922dso59735997b3.3 for ; Mon, 29 Jan 2024 10:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706551536; x=1707156336; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VlzuORvF37cHhQgjoovr2a86HYjlNB8YTzXdR4Eq8S8=; b=N5GNZ1+HcdiMDaLoHriuiPIQ11RvN29Xx0ePSgvy2/TcZEUqNV476uWVlc5098jmV3 xp83LLEGPdgFnE8JTCrQrqjrOGwHRLfeJqtwmWg6lYstTdofsuyD/K22sfxFugdgwlWy ZP5uczstj19b0jCTfSyQINffGtO6p/7j/q2d1RNLMUkgmUNxqKYzM+pixGreb1NyhwiV QwFgxKa6LHA9JInQlmzSFjYtq0KdAzM2X9guUTUQ2EzdKy6IbOvJBBRJ1g5dbc3TsZSg bllZHKJrS+mIjlPL9JlSFz/Y+D45PA6aiCRZvfV+zWg5HX0vHs3Le6QcWfnLlu+dS6Al jLRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706551536; x=1707156336; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VlzuORvF37cHhQgjoovr2a86HYjlNB8YTzXdR4Eq8S8=; b=pxiZbgYYwtsXyKRKVITm1pps+gbU58LYny+Nw5A/qxezaDYvPr7vqX43mPomHUluH/ /+mQkVg/1rFFXKPw+nBA6Gf/F7gmbEuWJ/lQ17Z9Zh7nsyJgYDJV1o/ou2Bd2Oauv7Pa wC9luQxKHBA4Rzi3sEXGPBwoGo8HOeJ33qP4RWj6JEpBWyyyHmFLEsp/AfPuEru+lfRl jBavOr4eU4GrBtc72IBSpxtJEeBbUzXB396mOtZXCvcgGnIuM98bYqmMZ08DRmt9WJ17 zFRp6aY87HRHWIgKPwGdkgtLUgHvt+LkmpdPdJN5XiRbPfK/CiT+foalOPgtXaaTDn9Q VAkw== X-Gm-Message-State: AOJu0Yydc5oeaDzPxPgpFUWXtKMxhEuEB2I9BRSjca1Baz04HZVwtY2V auDBn7ChSFb6ugD9iPKAlR8JH+PCctsJ3BTyy2KlDDfq7dtkuHtnRLOO/Avc7ua/+0vwiV2E/gg TE1rIm+bUgx+Z09DD0Yc0EQ1qvTgOariuJq9FSqL95rCDmZSDSshd3rxHtJbO12p+5fPGt4NU/S db+n+dxobKqUKHt0q+1qoaV28/aBhr/Q== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:1b8d:b0:dc2:2f33:bc28 with SMTP id ei13-20020a0569021b8d00b00dc22f33bc28mr2399097ybb.6.1706551536040; Mon, 29 Jan 2024 10:05:36 -0800 (PST) Date: Mon, 29 Jan 2024 19:05:06 +0100 In-Reply-To: <20240129180502.4069817-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 References: <20240129180502.4069817-21-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2268; i=ardb@kernel.org; h=from:subject; bh=TSUaLCMOyIRIkxI+e58H4dzOT8JQVh2xiOSo20k09Yg=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX7i0sznR4wlbbnZirKqb0/tlnidNu/zpjLc3ccECxra OiZErm+o5SFQYyDQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAEzEVpXhD0+FxcHZC/v5WsNe XhTRq9Et+jDvZFyi/tRpcvrJhS3X1zAytLxUqjGVObPST0DFle299G5uPgeeD8eX7t+/rfqL0pE 8BgA= X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240129180502.4069817-24-ardb+git@google.com> Subject: [PATCH v3 03/19] x86/startup_64: Drop long return to initial_code pointer From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Kevin Loughlin , Tom Lendacky , Dionna Glaze , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Justin Stitt , Kees Cook , Brian Gerst , linux-arch@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel Since commit 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 --- 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 d4918d03efb4..4017a49d7b76 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) + int3 SYM_CODE_END(secondary_startup_64) #include "verify_cpu.S" -- 2.43.0.429.g432eaa2c6b-goog