Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1695751rdb; Thu, 25 Jan 2024 03:33:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhBexfbdsUyEPhSFOnF0CgDtl95w8tPZSuH+WFnhnaI6QRdCc+mR64AK2IIrWpRnrqmZcH X-Received: by 2002:aa7:c0d5:0:b0:55c:cd99:42de with SMTP id j21-20020aa7c0d5000000b0055ccd9942demr328228edp.58.1706182389022; Thu, 25 Jan 2024 03:33:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706182389; cv=pass; d=google.com; s=arc-20160816; b=bZTrujkySNv6sFGqbFXtv/W1gpHRmUioBK0sitB8bTSYmZv4D0meuM+X1lwdvXdMgb RSX2q7sJ8JORCfpOcvShAqLdcJfwrGELPrSS2Ar1kIaQwFVWokCHWLlsHmvsehsmr5UX uMg6R8PArOOzPm+zvK7NeFHiDP10uoHdsGt9IKUkPZF4TolbmWGYcnkiCzeXxTDpYiF3 i4dIYGptwDr+RiTM36G6RSKj88Hc6PVyrhuISUPfn+Fu7wHdTJPdWH7QWDOX5wx9OqE0 Ju2j7VxUDUQVTs+mCxSd4CGZdcainNTCBdx8LtGg9SELkkLZ6PN0ak5ZGEcHheIz7F52 TuGQ== 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=Mjd69IxHltS/Jba8SYEPy4aDMrScq2KBDxG2XjETtWk=; b=MbQnTmzj9knrhaxwmOendE9Kaze5JSAfoNPRs38PoCApKLJh+K90RpZ3A0yRemBPr2 3FyBrGrIRJ6MvXItBUbZIMjdHIGpqkxfJIFVc7dU0pD1mZuysF+oXN/SDaQxiHAmCNP2 KCBRBGMFRLl3PfvWJM1/aU0PANabcm2BzLbWSFcByyFrjW1yj6CJiUiEram4Vfl0aWkC KNtExMF4OSpVYvNshm3qwaVB0FugVcaa+bsU4xCD68Zc6BQjTXbyNisucHhX28UNmyIS Ax70H7PWrM11MxzPI06GsuUztYBUQOA4lpCysf8NKuIS5jEPAcC4tHfRkEZy2bGxMwsZ ujZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="y9Cdx3//"; 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-38505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 2-20020a508742000000b0055c73d6abfbsi2966400edv.506.2024.01.25.03.33.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:33:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="y9Cdx3//"; 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-38505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38505-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 11CF11F240DA for ; Thu, 25 Jan 2024 11:33:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9425535F0C; Thu, 25 Jan 2024 11:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="y9Cdx3//" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 10FBF2CCAD for ; Thu, 25 Jan 2024 11:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706182363; cv=none; b=FoWSy+FDdTIODBB26JnF7ARLHpRFiNAm3/2lkIx35cdN8q/iuOJzaVGo9aYtEjut2chrunQG3O+ZlHRitlj39wOH+qUzbBitmK4/LlfqOcErObjv3HSMwcHo6k0BVOFJJUDPjuXzQeW3elRSK8kBBGbcBZ/FjVcqye9566FfEzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706182363; c=relaxed/simple; bh=ksYtquI/zNJoo09z1kn9EIIXegn4h7RVzbkZ+iPv7gQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TDa2wLBHY9ulS70450XvmV3x0TS5+CRU3YKsK/9VMxRqQJfKhu1eb5/fsFTDdAyfBx9m2gFVEszIyGmD+UukPkV0HzoDhiTck7hVIUwPt+6c0TnvDgCxChsC3v7XQEMo5xu1gXayn5rhzcV62vb0moES0kprKwB/hLADmERpU20= 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=y9Cdx3//; arc=none smtp.client-ip=209.85.128.74 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-wm1-f74.google.com with SMTP id 5b1f17b1804b1-40eaf5c52d3so34985995e9.1 for ; Thu, 25 Jan 2024 03:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706182360; x=1706787160; 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=y9Cdx3//r/vJpa/ctay760QmH747x6gRelL35ji6SSGpB7W1WT+qbtofUZFip8ilLN Qsj+Wob4Eh++Z+EFqd2glypUpg8sQioa3IcHyxrU3TFcfK4xv2cICDQRTiVpK7JpCA2W Nw5lC+luKKdAXrDKhL6z5b/81pbQk8p9QV2tNJs2PY2rEbeEF+mv7tBUN/W7coa3LiC7 i4WPUl6RRCcNk6cN5QPn2WWufat0n1YCKnNNI4AV185nnOfJ8d1Z6PiX0zfgpQHxhYHG SECQyLJFUBT7I1j4+PLzdPKzROI+KZFd5ite/NN1pRgHVpCUrkEXr5qBpXmj0NISsiKA b3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706182360; x=1706787160; 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=EcepAu1izAUfqiXOEWvwD8HwxUcrLQLJuGTv/lPS16pMU2C1NLVHUyAPezlxeqBp/h AEg/ZOtoMEF1naLUFkYwGa3DzUMrDZLlL6Y7SIxKotbGzGperTjpxzMqbUT92v8QzO+D K/Qvd+R6T7j1C0pkYWdNE9uu9PIpaH9BXIYAN/mPWLqN6PI6qLbabHRjTjTKaEqPtdcY BLV6KO3qhmGN/OmvrwlZZGjUU7UOjREDfKqJ0Uuf9a459XkGLegu4yT8y3EfE8ceuGtg 3yYcIAgxLbzo1zfV8CnPus6xjBjJQdm9YO5imoxkRGJQfxVQu++S4fOdGNe7JK9HzV3V cplQ== X-Gm-Message-State: AOJu0Yw+gorskywOORNKpR9C39vdG7c/kO5Id40qf0HuPq7seIMTgulY QIIgp8uM/fq8xqLnV/kIEXqK3oFoZCXwR2UEB4THh+CJaP9EdxsY/Zbb0jdmIIC68ebpokhnl5d RKATE+tB7YY12+9ItFTKk8ut0Xa6Ym0mZdA9lUkYv2pYB35jtGNXwwi81MVbKf0pYvkYYZUok75 N0glMrZFV/NnE6csR+e/dZdoHacTR3dw== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:600c:c0f:b0:40e:d1ab:3421 with SMTP id fm15-20020a05600c0c0f00b0040ed1ab3421mr5142wmb.5.1706182359900; Thu, 25 Jan 2024 03:32:39 -0800 (PST) Date: Thu, 25 Jan 2024 12:28:20 +0100 In-Reply-To: <20240125112818.2016733-19-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: <20240125112818.2016733-19-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=owGbwMvMwCFmkMcZplerG8N4Wi2JIXWT69WZTg+YSttzMxXl1N4f2yxxuu1fZ8zluTsOCJY1N PRMiVzfUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACaSGcTIsGH3y0MrT1/cVLj5 bzrbMoGWoqPnJwQ3XZov0mO0bfWKo6aMDP+ecz9d8DR0D9NBuZinnFO5PjzMFnn5V+p00feprMs 9g/gA X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240125112818.2016733-20-ardb+git@google.com> Subject: [PATCH v2 01/17] 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 , 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