Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp552523rdb; Mon, 29 Jan 2024 10:08:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLMm0W5VlibDHGOi0KXKJEdkpiAdADzQ0fZjp/ztxCjptaNXX+ybRHhuWysxCzGR6Bud8D X-Received: by 2002:aa7:d50f:0:b0:55e:ec29:75c4 with SMTP id y15-20020aa7d50f000000b0055eec2975c4mr3271236edq.21.1706551716540; Mon, 29 Jan 2024 10:08:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706551716; cv=pass; d=google.com; s=arc-20160816; b=D/wfaVl+jPXpMZ5heyKE/+TvGRxAa8vGtwDvQNfLC1fsp5fOu39zJsG3tM0iAYxZiB IaQMHbZaIAvATC2WOQSbPMnmoVCgclW4lEZeqZNHTwEwK6JKDamKrr4RZIsYXW/4fLrQ InGztSFi8Yt5kqQ9/JieUvNfsed9UKq/sPHbf5KTuxrlCvHjcfes5ubCYP31neKrdIhe iJwzxGC1oC0uhTxa+ZjjB6zqt6TQ+K7VGn8HTErn6BoqSWRAFE/f/ndVdeJgbCqFv6U5 VDznZ0/MNpgizj1SFipAXEAsX6IICVYksF/NVQpa1vuYcRO4cDBfGmoFX3mPdFlhGhT5 Mw8w== 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=usiDcusxejCbluC36Vpk0on80rVNZ7Itzv8e5WwmSQI=; fh=fMhMPvo8duafGkM4xZHdH7fULbau3etefTGsKa+Qy7I=; b=BGFtRSith7KCz2+zqPVDC2Q+8MCVXnnC2Yj9Z77MP1Bv8usKEuqoFdzrp6+D+PhAUR vzY2cBBO8lfcWNCJnwM0JSLJ0Grjg99sCQTE/L6BAB7D8dtlsiGK6Mzs9Xptc0/VWjcF sqFO25CfGdxiX/o+v7Ua6lE+JKSjgReR04/3+J022cMwkgy3j/Sa9qyoVzSKZzbYXjBj BrLl2/tF0UyLUPnQONDFpEwk0LyfWbtSIISWaja59QrJKHzJkP1s73wVgZwdQ9cBcElg R/eW/dGsJUoPudRSb3kDusLSjq47Kbjz6Jkqa6g3PIRJwAuIkqNsF9B5db7Nkezjgnze cdSw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=I1V788Gb; 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-43278-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43278-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. [147.75.80.249]) by mx.google.com with ESMTPS id b34-20020a509f25000000b0055f0fa7d404si822033edf.218.2024.01.29.10.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 10:08:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43278-linux.lists.archive=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=@google.com header.s=20230601 header.b=I1V788Gb; 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-43278-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43278-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 4FFA71F24A70 for ; Mon, 29 Jan 2024 18:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8964815A4AE; Mon, 29 Jan 2024 18:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I1V788Gb" Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 E489515A48D for ; Mon, 29 Jan 2024 18:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706551558; cv=none; b=VNcxnEJenie8z8Njx6ZJdAEON5xw5GAA91w49GwmjxvzsnrHbMuDr8AWQqXlKv0DyMXnBZ2DPXPC6YYzuF82ZLVwkLgIRYCAHxkyjTxeWxMoy7KalnvuEspHZpM5Gf6R1Cnj7UZ1p8e/KR+VLk1J9Hwr5DElpzprhTTwEhF/7GM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706551558; c=relaxed/simple; bh=BHUup4Ao15H5a0x4s+HXfGoWgWU/14gkkZKIK0ZXAdk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hjviLRNptwlypvTGWQrbVtwNlz+riX20FhqoApUHmBhyUp7h+Y4TQoKrTabsFLD6OwXg5U/hx+MPsmGMHY4pLHCQTwmbvZB4fWH1YyWI+/FT6vPkefTskE0PN7W1rZACYzbNGrVfa5hlnhfNxhETbztdIMuEFNP7Vf0QQe/iTao= 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=I1V788Gb; arc=none smtp.client-ip=209.85.128.73 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-f73.google.com with SMTP id 5b1f17b1804b1-40e8810b5f3so25160775e9.3 for ; Mon, 29 Jan 2024 10:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706551555; x=1707156355; 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=usiDcusxejCbluC36Vpk0on80rVNZ7Itzv8e5WwmSQI=; b=I1V788GbqvKtKxxYQnLQzkd87zUujtwsJrEsJtzWQtl7X1BEhozGG3JraJCpp6pEAT wjOnayYq44aWOdRcgjaYdefkwCD532Aw3Awogc8dGVhjbMDxL2/8WiEKC+7ksff3GRkE MYP6U+QivGClA9HEiE4ve+CxSty3BXEGTJZobqd1MIBTcJ9Ewi/mSSFtQ2x/04NjNAN7 xpzk3Xop3BJh3sDvfcM3d3HamVDH7wI4LeemoYRMI5udVyRPe+KUiZF5fX+X8Djjg8hJ qYgUK9VBReJpA0xc/5IbQl4iAijpH1zpSNzcaXHDyuT+OX20QIxmTQ2p1wSt5FED6gJ6 BNBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706551555; x=1707156355; 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=usiDcusxejCbluC36Vpk0on80rVNZ7Itzv8e5WwmSQI=; b=N+Vv9qMVxMiv/0pHvKTg9hhiZlKIKAuowrtvCppM0a5xM2ek/MLl9Gq0uDphQkZfiN 0zc2Kv8j7KxtuJ0LYoqlpvpvCln/GpvrfCXLSF7pCRMmIc2uGYaYYE2bnyHwtO9KW1ML 6s2SUHosBKuCZrDKGKFV3k5MY3WGM4+ZsmueUXyyaydrIoiomT+MqDsRAF6AHUX8xA61 FgR4rT4f4Hkysk25QOsMeZfFwVVcgFO3Wr2YS+0pn64KI1lPI7pFtcLc88xBG3ryhtvX PD6NbiUdLasLXvXSQmpZJahV2Kxy/Cz/ck04joxMesDMLt4HcKCnpNYS3/hvJLwkuSPs PnWg== X-Gm-Message-State: AOJu0YwG3V+lMrGnquMtUhG1hHdg5ApEdOpY09nKSJYnMEvWyo7bwMVO az+2wchLTDw1m22qzC1H23WFkO56L/0aavsyeULxZuGh5RT1CZ4mW3Lf4Z8T4C4huHRXsxA34ay 9lq/SZ/D0joIty1qJPqHsan/SkcsCfaJK6JJxe3Lht89OMIJCtlfS73I6ZQDhzFwWA9DcZteb0y WuGJ2HE/wJYMOtiiW/J/lDvvtIf2a83g== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:600c:1d88:b0:40e:f9fa:14ea with SMTP id p8-20020a05600c1d8800b0040ef9fa14eamr11573wms.6.1706551554793; Mon, 29 Jan 2024 10:05:54 -0800 (PST) Date: Mon, 29 Jan 2024 19:05:14 +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=1335; i=ardb@kernel.org; h=from:subject; bh=+Hn8XwOONyFACfVl0+TV+ToDQrCQwdquUdW+H4YgWKM=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX7i9u7Fp4sj3V7udXtpNY9MXsR10NPBb0cuP92X1ry+ VW5ZJd4RykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZjIfTOG/9We01eGNZ24aN3g GLjUIHZG9EL9Tn/mrwzhRufLA4NNixl+s9z50czfGr3v0OlmYdt8rSt7pp3lK5l6zCp89pbDm8z uswAA X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240129180502.4069817-32-ardb+git@google.com> Subject: [PATCH v3 11/19] x86: Move return_thunk to __pitext section 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 The x86 return thunk will function correctly even when it is called via a different virtual mapping than the one it was linked at, so it can safely be moved to .pi.text. This allows other code in that section to call it. Signed-off-by: Ard Biesheuvel --- arch/x86/kernel/vmlinux.lds.S | 2 +- arch/x86/lib/retpoline.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index a349dbfc6d5a..77262e804250 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -134,7 +134,7 @@ SECTIONS SOFTIRQENTRY_TEXT #ifdef CONFIG_RETPOLINE *(.text..__x86.indirect_thunk) - *(.text..__x86.return_thunk) + *(.pi.text..__x86.return_thunk) #endif STATIC_CALL_TEXT diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index 7b2589877d06..003b35445bbb 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -136,7 +136,7 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) * relocations for same-section JMPs and that breaks the returns * detection logic in apply_returns() and in objtool. */ - .section .text..__x86.return_thunk + .section .pi.text..__x86.return_thunk, "ax" #ifdef CONFIG_CPU_SRSO -- 2.43.0.429.g432eaa2c6b-goog