From patchwork Fri Feb 18 14:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12751454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26D1BC433F5 for ; Fri, 18 Feb 2022 14:35:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.275510.471425 (Exim 4.92) (envelope-from ) id 1nL4LC-0000Ho-NC; Fri, 18 Feb 2022 14:34:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 275510.471425; Fri, 18 Feb 2022 14:34:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nL4LC-0000Hh-Jv; Fri, 18 Feb 2022 14:34:34 +0000 Received: by outflank-mailman (input) for mailman id 275510; Fri, 18 Feb 2022 14:34:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nL4LB-0008Sp-9I for xen-devel@lists.xenproject.org; Fri, 18 Feb 2022 14:34:33 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e21f6463-90c7-11ec-8723-dd0c611c5f35; Fri, 18 Feb 2022 15:34:32 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e21f6463-90c7-11ec-8723-dd0c611c5f35 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1645194872; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=OBvd7Te7RVC9tLWUnRCr7dexqEAV0RltpksYs1SPDnw=; b=R3aKWenWhiUGNwfuWyF4iX3s5Ek/OpvQFD9sd4CbtEfwC9SNZlHQpyt7 usjz4oB3QZKxy0g0duz8yRZcEQ7Dh/6HuEZOUeqtZtmw3BP/sHDBDd6P9 9YA4aR0dzSiZW9Nn2Xi4Gm7FPKArv4mzUjNSPBEE9F81Ds5C6UNuBRiZm A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com X-SBRS: 5.1 X-MesageID: 63960496 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:yaHGUKnBiORX9doYGzCHIh7o5gyWJkRdPkR7XQ2eYbSJt1+Wr1Gzt xIXCmzXOv+CMWX9KNt1Ooq/9khTsZSEzIUxHQtrrX82EiMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BCpC48T8kk/vgqoPUUIYoAAgoLeNfYHpn2UILd9IR2NYy24DjWlPV4 7senuWEULOb828sWo4rw/rrRCNH5JwebxtB4zTSzdgS1LPvvyF94KA3fMldHFOhKmVgJcaoR v6r8V2M1jixEyHBqD+Suu2TnkUiGtY+NOUV45Zcc/DKbhNq/kTe3kunXRa1hIg+ZzihxrhMJ NtxWZOYRxsUI4nDx/0kUD5pHj5UI6tnv5rLPi3q2SCT5xWun3rExvxvCAc9PJEC+/YxCmZLn RAaAGlTNFbZ3bvwme/lDLk37iggBJCD0Ic3oHZvwCufFf87aZvCX7/L9ZlT2zJYasVmQ62PO ZJFOGQHgBLobx9RNH0qKJIFhe6tmHrnXxgGq0+Euv9ii4TU5FMoi+W8WDbPQfSVQe1Fk0Deo XjJl0z7CBwHMN2UyRKe72mhwOTImEvTSI8UUbG16PNuqFmS3XAITg0bU0Ohpvu0gVL4XMhQQ 3H44QJ38/J0rhbyCICgAVvo+xZooyLwRfJeD9AnzA7S05PXxDeUGUIaSB8GTdA54ZpeqSMR6 neFmNbgBDpKubKTSG6A+rr8kQ5eKRT5PkdZO3ZaEFJtD83L5dhq00mRFooL/Lud04WtcQwc1 Qxmu8TXa187qccQn5u28lnc695HjsiYF1Vljuk7s4/M0++YWGJHT9D5gbQ4xawZRGp8crVnl CFV8yR5xLpTZaxhbATXHI0w8EiBvp5pygH0j191BIUG/D+w4XOldo04yGggeBowaJpcKGO3O RW7VeZtCHl7ZSrCgUhfOd/ZNijX5fK4SYSNug78NbKinaSdhCfYpXozNCZ8LkjmkVQ2kLFXB HtoWZ3EMJruMow+lGDeb75EidcDn3lirUuOFcGT50n2itK2OS/KIYrpxXPTN4jVGovf+16Lm zueXuPXoyhivBrWOHePqtdLdQhQRZX5bLivw/Fqmie4ClMOMEkqCuPLwKNnfIpgnq9PkfzP8 G37UUhdoGcTT1WdQelWQhiPsI/SYKs= IronPort-HdrOrdr: A9a23:DCiLMq1pvVo0VBtwcJTw4wqjBLYkLtp133Aq2lEZdPUzSL3+qy nOpoV+6faQsl0ssR4b9exoVJPufZq+z/5ICOsqU4tKNTOO0AHEEGgI1+rf6gylNyri9vNMkY dMGpIObeEY1GIK7voSNjPIceod/A== X-IronPort-AV: E=Sophos;i="5.88,379,1635220800"; d="scan'208";a="63960496" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a6Ixpo+AY8qOybEFDFwVrdOw0xtCGDyypGF3c9qnd6BdCokqebGcxViWDiO/AZpIvaJxzsxjVv7F4OFEApxNWlsoFfqckp0wiKFxhXNHDfRaLOheyhM+u390rnLvahl7cl32cElkC/JTA57H+WUEDQC+8WLhPCRD7PHUBjqEsjvbH75zlPPxmSqwLbrL/90nj7Qt1Z/65iHtTAg0ZQKis4VzE2jBMhUeZyuYhxcAlMDjRxRx5L+B5MuKcZTxHGXOVaTLYouw3QnOuLY+766setZxV1/ezMUCU2gbPyGgYXUDgcnJ03gdbF6URC2UQtBAP5wUY3gZHhXxJSB4PhR68A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q5KrC8FlxtiywlEQxR4J2fdDfBJ+V23D+gnQTYifv1I=; b=SvzvLa3xJlK2Ze10l26a9mBsji+99lxl0KXdAA1A54PNadroUZtoFQQdnCKkIK6exy79VMU1ArJCKAUv/x40AyKWYFy/TE0Sf4uLln1IEGwCububjOhEUTnV/wSGOTcZLyeQvVwnE7lrSOn0AOmCgt7dSPmdIZ/yCg/YhbSv3OadT/DGrZ9qr/CnaeU+24GEWoRQa8WQTzojF3k7Q7X7iEm4icVINdx7yn0d3rIr+M5iI7iRomYmb1P5gP4rfmddLF65Bw/i5f3wWAQu4GbWbZ0U426P37ur17bGQUiUaE2ne/SplGgY+SugMTQ9rS53m8b8iqeCcMSAMw4A369zGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q5KrC8FlxtiywlEQxR4J2fdDfBJ+V23D+gnQTYifv1I=; b=pFBYwqcI67c6kf8R2NxFy978xltcIrZMpZZSzQ711f6YTPjPr0gBESzYSN4Ae4sNj/pBtA9K7F+kvDuKT/UFoYgjzf191mBkfoE/InEjPVD/EArrrODzhxDvVB8C0uYrhP74uZASU7Qc9X4YPaXPJLgTHe9rE+Kwrl7IvzjrGOY= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v3 1/3] x86/retpoline: split retpoline compiler support into separate option Date: Fri, 18 Feb 2022 15:34:14 +0100 Message-ID: <20220218143416.34475-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218143416.34475-1-roger.pau@citrix.com> References: <20220218143416.34475-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0223.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a6::12) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 658147a6-596c-4729-b009-08d9f2ebc3ea X-MS-TrafficTypeDiagnostic: DS7PR03MB5543:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aafhI/N//VXt5Qo4d/Rv2WkKL3iGB6LsF5mGo/OE083fZv1nxot1DZf5BFZ1pwjxOQXY8e7ap5K6vBOhShqLwva0BlS7FgkDBrufMq4QWzI/HfvafnRlKQRzT+c+dxtE1Mhur6SGlBakTSnQRblbK0X9b4JKCjR+mTgsW+wKBw88yyYvq5YLqa0x6AFggPdxcnjHDWaSKY1shgPZMWJxZbF3W/RyZDMOYiwh4P9mIwlT6XLuUlokKMFjeN1VlGkkN2zSBWOFjFvu6Uh6N1jkUFr9t18tvJ0g65kr+7Xa/tD5dKZBEwKp6OUuXK++8a+o1wzCNd6OnG0qkH4jf8XtGFVEDKDuN8kf8YcRagbfvzqGaW0NZ2CJvnyNA6mjmlEgdzdyMobLVJK/hCTF6PO1BEh0qQfuVf0xXpeNqJdWsTzwBxMANagZaSKdBTawLmMIoBsjNmZTuutJ9kYLp4xiFOccoyHPqGTnwbql0NX7CNEn93nMGuvfO9GPwDM5+4YULuTuNCxP+K/lv0r2Y+bDUIDAGuIzyGP7kkjJmoVb3AcFCWOd5z4Yo2QSvbF/XWQz0JhxuxTUBLcJMXVRReRtP+1FTvk1KaANgkH42I2T8ZL4ObZhXZ3n20Pt0RNVY46xnJ/l22brrjg4uYS9F7Gukw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(6512007)(36756003)(82960400001)(8936002)(26005)(1076003)(6486002)(8676002)(6666004)(6916009)(2616005)(66946007)(5660300002)(2906002)(54906003)(66476007)(316002)(66556008)(83380400001)(4326008)(508600001)(6506007)(186003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WIHUJbTvfomEGu7r0swFBn/CA+Ol?= =?utf-8?q?3egKUIhsDPBP9btI3Ua4m8ZRoQy6Vt2JnidihPHaDZG4OunNpuqv7y0bECg6Bejl4?= =?utf-8?q?RF6iD9TKN+R8i1psIqd48GIlYrXMPa5CXsQzR3eg4mZUSRV7TQtJOe5v6yCcgMcmo?= =?utf-8?q?u89xt9MwohUdIxkPAPcku/UZAw2BSjUC+EL254TjZxtndNNagLgt8akNqYXqtbUKK?= =?utf-8?q?3a89m2icB7Rh76ml+j7OINDPoG8BfAHB/CSmve0hfzNbTH+SSeIjfT0dHa31c8F7x?= =?utf-8?q?5yr6LOqd9bnEeZVh1Lfsgr6vwhihSXdcxfFY2B2WVWMHzcHeIVXDKOaFUn8qYJ1ii?= =?utf-8?q?spjZmNbU1WWSdnguk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0ow+2FGvD2z3jAwVZ3VBPGio3Sqw3TOUNeRC?= =?utf-8?q?TvOQI7+S3GB//gn5NH8mVxc1/6qdpZgiJxHUjNB4iDyCu9QxDV2nyvWDR5QXFANTM?= =?utf-8?q?SYwy03kdO7TVu89OYCUBN48JNSmDcBP+NO6IEZm23TLSai+pBaDP44kzv57DQZqvo?= =?utf-8?q?yedHU2epi/39K8us1TIgL7voSwNgT7ozq9R6RDIdlu7USlkM8APOWOyeplCPdiLR1?= =?utf-8?q?sVXzh54fyL3QUhFkAJuv0GyngrKZ6fzX4Pp1F2k8vfSKnQ4DPXfDoq244vnzH0HwT?= =?utf-8?q?wbv3ozGLKjBDZVkHk9IN3gfT5VQXGeXcNTacOkrg/5ejpy3hWky5yjI=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 658147a6-596c-4729-b009-08d9f2ebc3ea X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2022 14:34:27.0322 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rgqKvh1TK6+p4i07OBiG71NfQaU2dSjc4dHThmA4mq+B0v+x2g79x5FZnixLS5i99cxMJIzMxvSGTWgJtLpYAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5543 X-OriginatorOrg: citrix.com Keep the previous option as a way to signal generic retpoline support regardless of the underlying compiler, while introducing a new CC_INDIRECT_THUNK that signals whether the underlying compiler supports retpoline. No functional change intended. Signed-off-by: Roger Pau Monné --- Changes since v2: - Make the compiler option check generic instead of GCC only. Changes since v1: - Put def_bool before depend on. --- xen/arch/x86/Kconfig | 6 +++++- xen/arch/x86/arch.mk | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index b4abfca46f..a1a90da4fc 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -32,9 +32,13 @@ config ARCH_DEFCONFIG string default "arch/x86/configs/x86_64_defconfig" -config INDIRECT_THUNK +config CC_INDIRECT_THUNK def_bool $(cc-option,-mindirect-branch-register) +config INDIRECT_THUNK + def_bool y + depends on CC_INDIRECT_THUNK + config HAS_AS_CET_SS # binutils >= 2.29 or LLVM >= 6 def_bool $(as-instr,wrssq %rax$(comma)0;setssbsy) diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index fa7cf38443..6388b1d93f 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -42,10 +42,12 @@ CFLAGS += -mno-red-zone -fpic # SSE setup for variadic function calls. CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup) -# Compile with thunk-extern, indirect-branch-register if avaiable. -CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch=thunk-extern -CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch-register -CFLAGS-$(CONFIG_INDIRECT_THUNK) += -fno-jump-tables +ifeq ($(CONFIG_INDIRECT_THUNK),y) +# Compile with gcc thunk-extern, indirect-branch-register if available. +CFLAGS-$(CONFIG_CC_IS_GCC) += -mindirect-branch=thunk-extern +CFLAGS-$(CONFIG_CC_IS_GCC) += -mindirect-branch-register +CFLAGS-$(CONFIG_CC_IS_GCC) += -fno-jump-tables +endif # If supported by the compiler, reduce stack alignment to 8 bytes. But allow # this to be overridden elsewhere. From patchwork Fri Feb 18 14:34:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12751455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC456C433FE for ; Fri, 18 Feb 2022 14:35:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.275511.471436 (Exim 4.92) (envelope-from ) id 1nL4LH-0000aX-Ve; Fri, 18 Feb 2022 14:34:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 275511.471436; Fri, 18 Feb 2022 14:34:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nL4LH-0000aQ-SW; Fri, 18 Feb 2022 14:34:39 +0000 Received: by outflank-mailman (input) for mailman id 275511; Fri, 18 Feb 2022 14:34:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nL4LG-0000ZM-Q1 for xen-devel@lists.xenproject.org; Fri, 18 Feb 2022 14:34:38 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e499195e-90c7-11ec-8eb8-a37418f5ba1a; Fri, 18 Feb 2022 15:34:37 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e499195e-90c7-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1645194877; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=7VTNoFVDNGcjQfdLiA7ylnRk9qV10cync6xBOedRTiw=; b=QAHd+gsoAw/iMz+t84iot3A745iHxzYdbqmthlOJvVu7WZUG5fX8gOhB XJHJof/AGucrSBrXURnrrQoH0yLhU5KoJEy/NihkHRnlObo+tMqV5MQY0 49IZd+SiNwJPHPTuXssIVbOQzbNzYx+NSfMxQwRWEp4S0QoCK8H4dqVF2 s=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com X-SBRS: 5.1 X-MesageID: 64417970 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:q3HvnaKNiG8yTkHxFE+RxpUlxSXFcZb7ZxGr2PjKsXjdYENS3jAOm GQXWmnXOPiKM2SgL4pzOt+zoEwD7cLTzoUyGVNlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh2Nc42YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 NRQmsaQVD4jAqeSh+M2SQhYLS1FGbITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTNd9Gls2pkRTKmGD yYfQRRhcBudew9+AWwKC7khrMatn3rmVzIN/Tp5ooJoujOOnWSdyoPFL979atGMA8JPkS6wp GjL4mD4CREyL8GExHyO9XfErv/Cm2b3VZwfEJW89+V2mxuDy2oLEhoUWFCn5/6jhSaDt8l3c hJOvHB09O5rqRLtHoKVswCETGCsvwMzAfpNKucG4l+SzYHO8ganClMgUWsUADA5j/Me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HqInc2omRCek1Jd0J6d P8bG8= X-IronPort-AV: E=Sophos;i="5.88,379,1635220800"; d="scan'208";a="64417970" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=af74N8QXH5MqPxnqegTCdHwz1KfVlQYKl/XzcAuBz2/MJLVnuQ0agrWyM9qDgklh55++k3WdNOU6m2OFrmMX7UsLITenguiduGXcFd7cSFgXbSqQxln2pQ5iXFW4hb5lFlmEqDoQ9txbyISkYi+GwxQbE/Gd5sGz0O5icr2ZqJblgRRA94tECSAd3Nff5BeeY2cGWTktXQy2HNKdf7aEW/XQxSlC54PfTsn3zmC4XGENysXgevQIUa0zlX36IwA53IBHPT8+TlJj3MbhJy5/4RbDfo2zRM3NXJfdH/DftWS0nqCSM1PfQ3DH1M9B6teostxVfQFJSAEAn+G+H4vhbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nv6gW1Mlt7VQSuRHTBBB8hz+ff/2S3H03ut9wK9Gkqs=; b=kpzao6FfhQcuy/b+7ONocd+T5NG8jtvpAitOq7L7WyqC3XwvxAfWxPCa/3MY0NGVQ4RjkIVtt+VEsNEsaJuEywTaaDC4VbZ44XwSd6R2K99e30yK4h34DvTeq+5VLD0Mo+sY6wI5NZw64W+PbbS7EzotrfoJ6NUNoe8kl44MeRBeMvjDwGjlv9esJuSNsu8sO5d5zJHYf3ZR0Nqjgs8QfZ1ybSPRHLfkCUkDCd7C6ji2ca+u/oQYdhKMSQzlYvEt5RVYmF6tCjbWaevHvy1hlTOaYBiWO5a5n/dXHoFrOpCFx8EquPR8GRkAscBO7+SbOzWFmZuIGAY9niCtHEfJ/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nv6gW1Mlt7VQSuRHTBBB8hz+ff/2S3H03ut9wK9Gkqs=; b=wiO8WYATf5WL+xKwB+hhSYdeF16pHxycMC0cnrJvzFUVI6cfVBL916dGEd771LEzy6YMl9aVAolB0zvXDyJ1Zzk6sEWYeIJY2n9KGg4jFlq5dgbm88TEJ5fioVHMJlG4auMw9excVLvfp0zp+yRw3hde8l4FBVqFAGVqHMMmSBI= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v3 2/3] x86/clang: add retpoline support Date: Fri, 18 Feb 2022 15:34:15 +0100 Message-ID: <20220218143416.34475-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218143416.34475-1-roger.pau@citrix.com> References: <20220218143416.34475-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0299.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:196::16) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb99fa3f-f0f6-4ab6-9992-08d9f2ebc6b8 X-MS-TrafficTypeDiagnostic: DS7PR03MB5543:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: afrksBiQhL2DSkJ+wcpQZ6SYNWJCdbFz2QXClNnywRbQt3SDSU8DqUJOMt4xAg84JocBim3vzsNlsE9hQmQ+ibaxOBGC1NjJr2X4+hO5F7jEdx+MbUOTxqn8bODZQnHPdq3OWbkL6IEA3dAzaCLUhBFRqC6Ip3tSaKXnXm7x+T7f+CxRx9RCwnUR4mJ90L+6CwUtMflYPUAyoKIV/7SJ71uCezF87vEKcrd2yQ3rL8iHI64gZ3ZTDU67QtxkFHMvS1rI/FWm5FXRUgsYKaCOKauT93j+ZLIJnuSioKitLUEMuzZ8w8R8/YF8tIxMx8It7Pw3lMECPgrZ7uTLdIrml4TaRUrD0d4D+4PMN/BfdoIu2iq4jgnAWImyQTV3JNmGg4TqFPe82iCFo9188mZ2ZMktm/1iOkEmwuGBvOMcxOGWl4b2K0JojEOowMA0L3fUMI1Rprg5YI+zdnqMFbrEiRfJlFDmymwgY9WGs/WeLj1fNd181WFZLfz+I1Yzq14sYyg5FdXLQtgJNrIK53SUCQcG/yxaqB/YCUeM1LycAxUt5J6v7hZzoYS8IIVOlnBRVE4vve7Dc8bKzKKuKTRfrrhsS3S/5BPq2dIHn3EfaRtEFnl+WFjsAeO4lDsUUwKt732q3Efwm251ZH5tsFuJWw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(6512007)(36756003)(82960400001)(8936002)(26005)(1076003)(6486002)(8676002)(6666004)(6916009)(2616005)(66946007)(5660300002)(2906002)(54906003)(66476007)(316002)(66556008)(83380400001)(4326008)(508600001)(6506007)(186003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?MkgEfadS5LBzI/XpwEpcH5oi2N6A?= =?utf-8?q?Cyn4BMr7giSLfCZyfNawhtRiGXk91kNy/TRonq+Ge/EjPMO7b9hQta3QoB8oE5vmT?= =?utf-8?q?qUG+yWQZawafCTFQRIglDSLxtaV9zG0FhP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9oe2N/FOYqCrj7qm1zO?= =?utf-8?q?xr4xbN+EhysxFuam3yLJYjc7ltexHkJdQ+p56WG/XVjeZx0MQHr9He5FJ8+RPjSju?= =?utf-8?q?6VOY2Fwk3zc3BuPG1/7YqsPG1NMKfFhuEhLNhNL4UWOLlu4pXZHbFwEoq9kMbw87N?= =?utf-8?q?N277Q8Fy2+5xkSx0i+KjMKgQUALAOvazbYaY8axj/Cy+uQnWYOjtg9DHrOAEuK0jt?= =?utf-8?q?ULZGulSozJEQ7fesWm+cCPAWZ9xA5SyZxrcYYPfu70qo/112ywGPnjivRS9yybaKq?= =?utf-8?q?vpz2VRUsNwcmrz404+NkcWQNuyJt7hd6nEj3R5ehOUQCbXkhDHMxlx9DiYHhk5Ulz?= =?utf-8?q?+KI+1DOTeIgc4+HRqXyB0MDDoXDIr7ugR8bS0CLJjYzWA3+GdQ+Mfzm0rREBa/3S2?= =?utf-8?q?O/6s48nFnIRANxUAsohC61im2cQdrhrS6PwN0/C5Yit8MgwrtbE3kLaaQ6MX4PV40?= =?utf-8?q?mLSENRDGO4ewLfaT2vpBhKnW3EW5JlsxeC91BEbsX8a47yIal1B/LB9koR/ultWOj?= =?utf-8?q?6tG4+3Zerb+Cz2vECwDo92907fAiSyJtIKq6xAPMDC3jJRlBxxrCb7M=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: fb99fa3f-f0f6-4ab6-9992-08d9f2ebc6b8 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2022 14:34:31.6421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IJpOkLrqsXkA6RLDZT+oEdkAjcvwZ7v4mVJTBmDqS4LrebmlAU3dJqfW5Qw5FkdLCS/2iufT62x+xbFJtMFXhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5543 X-OriginatorOrg: citrix.com Detect whether the compiler supports clang retpoline option and enable by default if available, just like it's done for gcc. Note clang already disables jump tables when retpoline is enabled, so there's no need to also pass the fno-jump-tables parameter. Also clang already passes the return address on a register always on amd64, so there's no need for any equivalent mindirect-branch-register parameter. Reported-by: Andrew Cooper Signed-off-by: Roger Pau Monné --- xen/arch/x86/Kconfig | 4 +++- xen/arch/x86/arch.mk | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index a1a90da4fc..f8dca4dc85 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -33,7 +33,9 @@ config ARCH_DEFCONFIG default "arch/x86/configs/x86_64_defconfig" config CC_INDIRECT_THUNK - def_bool $(cc-option,-mindirect-branch-register) + def_bool $(cc-option,-mindirect-branch-register) || \ + $(cc-option,-mretpoline-external-thunk) + config INDIRECT_THUNK def_bool y diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index 6388b1d93f..066d749ba0 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -47,6 +47,9 @@ ifeq ($(CONFIG_INDIRECT_THUNK),y) CFLAGS-$(CONFIG_CC_IS_GCC) += -mindirect-branch=thunk-extern CFLAGS-$(CONFIG_CC_IS_GCC) += -mindirect-branch-register CFLAGS-$(CONFIG_CC_IS_GCC) += -fno-jump-tables + +# Enable clang retpoline support if available. +CFLAGS-$(CONFIG_CC_IS_CLANG) += -mretpoline-external-thunk endif # If supported by the compiler, reduce stack alignment to 8 bytes. But allow From patchwork Fri Feb 18 14:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12751457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CA47C433F5 for ; Fri, 18 Feb 2022 14:35:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.275512.471446 (Exim 4.92) (envelope-from ) id 1nL4LS-00011S-CF; Fri, 18 Feb 2022 14:34:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 275512.471446; Fri, 18 Feb 2022 14:34:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nL4LS-00011J-8z; Fri, 18 Feb 2022 14:34:50 +0000 Received: by outflank-mailman (input) for mailman id 275512; Fri, 18 Feb 2022 14:34:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nL4LQ-0008Sp-Ey for xen-devel@lists.xenproject.org; Fri, 18 Feb 2022 14:34:48 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id eb23284e-90c7-11ec-8723-dd0c611c5f35; Fri, 18 Feb 2022 15:34:47 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: eb23284e-90c7-11ec-8723-dd0c611c5f35 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1645194887; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=NkHFymHkeKgIK++83ZytrpXL1OQuo5Mz+mG7P3n6lX8=; b=eYr40jb/Q4yoOV2Aiqy7dZ+RgYsjMOt+5L6kFyJFuKN7FWgMv1q0bHkS yBNY1LrQYpsYiMWod/LOclTA5IYH9ch/67hggz4pG9lA7pyS11A/q18UY hJqGUO85ti+kvVEh3CMsZrqEogGuSHhMikiRvVxtwRgAt0OOkgI47zd9c I=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com X-SBRS: 5.1 X-MesageID: 66766320 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:2ooFoKlhSxozIqs+EIFfKXno5gy+JkRdPkR7XQ2eYbSJt1+Wr1Gzt xJKWj/VPfeDZmHwcoh0Ot7i/E4AsMfUn95mTQdkrng2HiMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BCpC48T8kk/vgqoPUUIYoAAgoLeNfYHpn2UILd9IR2NYy24DjWlPV4 7senuWEULOb828sWo4rw/rrRCNH5JwebxtB4zTSzdgS1LPvvyF94KA3fMldHFOhKmVgJcaoR v6r8V2M1jixEyHBqD+Suu2TnkUiGtY+NOUV45Zcc/DKbhNq/kTe3kunXRa1hIg+ZzihxrhMJ NtxWZOYcl4HYYLntL4ndUdCPyslPqx85r/7GC3q2SCT5xWun3rExvxvCAc9PJEC+/YxCmZLn RAaAGlTNFbZ3bvwme/lDLk37iggBJCD0Ic3oHZvwCufFf87aZvCX7/L9ZlT2zJYasVmQ6iBO ZRCM2IHgBLoXC1RAhQFI9UEntiv2VT1SA1KkQu2qv9ii4TU5FMoi+W8WDbPQfSIWMFUk0Cwt m/AuWPjDXkyL8eDwDCI9natgO7nni7hXo8WUrqi+ZZCn1m71mEVThoMWjOTsfS/z0KzRd9bA 0gV4TY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cYa pT5fznlbRrmQvwVQGdgoAv+q3iYp0LJGbHfqBY0fbllwS/nxhCvj0lLYIk7zA9HakGOut5Dt L/Q9NVfYF1P7wrhJ1GdZI8qLOMexfwqDL3QSqvyAfcZeo600ykke+C3Fxy3pDtRKA1 X-IronPort-AV: E=Sophos;i="5.88,379,1635220800"; d="scan'208";a="66766320" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emWtRwsxU7T1YMq73bIaGzJPvnSVff4MgVOJ12ttDX0iLJUiwMGEIxm/dJhkSkYiDgPpFjLcSp+T5jRrb5B1eLXywsKHcl/L698FajttlBMKCP4Jhhpp7JYaqpluzqd2FY2BIXAgKs6An24etLVZlJdP+ql6whfZRcxkE0yNp9LYZDtgiPIE8AiKEsEetgimCULRXFkxfNMz6Vwsrd6bhwgxm5ecHho+z6JjnrbmJ4H6Lhx11uHKHE37k9lgW3tm6u5Lbw9u1CCjBUBG3LeDfAxv2lBVAEYLleziAOWpmVH1m3K6mRNuXmZjJ6OAa1v5FkdabRN9ssugkEkygDJMMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wycz5DnGVIywU467a7gmql8uL29FYGmIDOKp8zvRFgg=; b=CWzoWqGcBUOfARhVL9hJFFlgYUq0hlf7yf27x4m11i/0Z8IIevFDMnwds7BkkkFtHwO78XCBKJQTKvsY4gaY0Rpt9bPOrLSq4gcNMSSp8sstAmqXcStNdMCASWpdG9Mbugcp1lJ8YMdR+u9MkdSRIR/psl6eaJLWFPD4Xi49a+qiWw2LuoN8Z8sgB84Vpe/Eh/cu93VYETdDdPwj82EhlCofpsZ8CSPl5LKKi6D+j2yb1t5cWZbF4i685b7YhaEj7fW5+G59yRUQGP+c9V3/zkF0CNvBK/C16jgdIBRxHQ+ovWEZmf0MBth24RPG3EmRbvL6e2ByleJka+3cHUBG+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wycz5DnGVIywU467a7gmql8uL29FYGmIDOKp8zvRFgg=; b=o30pPP/T9AT+7fPAjAGOnK9z4Ku7naPI+SNVlxoapVk5buIFfAyn3zs3ozLyuJZJqKqI73BzYVLNmmLOaR7youE5e8g4fsfTIjCKDnZpuZ6LKZJXHO6n1Bb8fkYUyDGesa2U6VKljquO1A7T2r170xQnolMo8v9aVZ+wJKjR8fM= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu , "George Dunlap" , Julien Grall , "Stefano Stabellini" Subject: [PATCH v3 3/3] x86/Kconfig: introduce option to select retpoline usage Date: Fri, 18 Feb 2022 15:34:16 +0100 Message-ID: <20220218143416.34475-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218143416.34475-1-roger.pau@citrix.com> References: <20220218143416.34475-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0260.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:194::13) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53b7cb76-8d17-4e83-7eae-08d9f2ebc9a5 X-MS-TrafficTypeDiagnostic: DS7PR03MB5543:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TyQkV81lnCAkpdI5B+Z8R7wYQFiYppun/JrNeq+P67tgyWk0Z9yCPiciyvIBy+UjbbeacuBrFjUrKkcIkNpy32gWNJk9vswWsu+uZ2Bfa5PZfBC/DAItgZeh4YwzhoUayYY2WnLPrC8a2cOAPKAdBdCWhJ9HMUuqO6u5I6qx0LAYYnt0dW+rGKdZ9dnAlNWWmC+ZKCwdshaJ36GNhfN+HKnPOHK94YIrsN+klxfEYJaVjOUg6fJl6xK6t1s+EXCyLt/xH9QAFAH7ghpZYnnArokq1rNHPj8ymTg3xq5gZa8ktdWUQ75cTB/FLVpumXNauAjxYGCxzEwSEqDFKhpmFYBe0AtFgkw+9AN9enm/U3SsmkATUDNtvXu277KmeNgSWBQW9YMcEg1A+33YQnQ/W58LlH7A9HkSIVh/kI2jTELeo4i4zY6i2b1r01nwRGbDjOUuWjG7wkNmPXWkczvaX5UnHs6jl9Re1PTCjibVfIxewVrGFyg7/+8vX7Lnamt77ENyZioE9/IiCsMVPqIWOq2v2Gunx+cz0Cp9oH8Ll+b+VjF3cV08g82k4XKew8hIEGZOzY6ZgoRNmFe8u29mKYuh1izvBuYcL2HZdEeJXwmjy8DV+XYRUmo5nt/SOaihYyaUKr6Yc5gzH1RThvQeYQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(6512007)(36756003)(82960400001)(8936002)(26005)(1076003)(6486002)(8676002)(6666004)(6916009)(2616005)(66946007)(5660300002)(2906002)(54906003)(66476007)(316002)(66556008)(83380400001)(4326008)(508600001)(6506007)(186003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?N85oz+KY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?= =?utf-8?q?iOWOA9VQa1HJRkwi/5x9pAYuE9TLC7Zhc6VlfgxPGydQ9fFFdYX2A+rFTCtQi9Fcy?= =?utf-8?q?VloioIryQyMAhSyBJfkXbNWsWo2O4MEJ38OEEgwgOtiq0Bz/FNjJ+gv04aT+E8fb5?= =?utf-8?q?QJL+BrucF+Fj8/ACqthOEG+Iq27OCu+iSmV66Vbb6+wzJEXrJDoG19jh69cQCUVdP?= =?utf-8?q?sWfRKeiCe7hO1P9iwb312RXRTtQRq9umErJVdxmsudcxt6tpC+dJW1iKcwpzfZpzB?= =?utf-8?q?d2ttfaha0WGzJeLLdUDn6cHW3I/RTzUb+38GUWtMvKo0NnbOgb3DRsV3T3W49vJLk?= =?utf-8?q?BrbRc0jipKc8C/QmEroea49owsXs0rj064zHztAi+ItUfj1PJQK0nwDBg46gmjAqd?= =?utf-8?q?rZiWn/7ZG2BzS488/5JKis9xaqq6FZofesbNmDGnP7/9RF30jDbc5bhiyMH+6+/p3?= =?utf-8?q?mWsRSFiCT2m7hu9mgHFan/flAiV0M9MWbusEjE5fOA6geg8qvA+tZbDdXALbxV/vW?= =?utf-8?q?SsSvtjgyYxI57JUlI6+tK8l3YdLuujYyRRj4094jMxcJSRwqHC7W+30D3yyUpw9kD?= =?utf-8?q?sYsLcCG4SJH0sBwZgX0QqwZZaXQJ1YUFRSPRRGDN3IZ2DphZE4ykj2Ka13vjJqf3W?= =?utf-8?q?NtsCPt9PMvv6Wotha8uW3eVVvaSxMs8QRKwyVlX99s/eqoDfspJOZcE=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 53b7cb76-8d17-4e83-7eae-08d9f2ebc9a5 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2022 14:34:36.7843 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 734ro5G1d620ojDR8cd6Qn96yFTe1tRmMMeyd1kNENBudn6iOvgy0NwEDUBnO0RFf/VZCa3apAmZhbOQwdm+qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5543 X-OriginatorOrg: citrix.com Add a new Kconfig option under the "Speculative hardening" section that allows selecting whether to enable retpoline. This depends on the underlying compiler having retpoline support. Requested-by: Andrew Cooper Signed-off-by: Roger Pau Monné --- Changes since v2: - Place first in the section. - Remove "If unsure". Changes since v1: - Fix description of option to use indirect branches instead of indirect calls. --- xen/arch/x86/Kconfig | 5 ----- xen/common/Kconfig | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index f8dca4dc85..eb4d1a949f 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -36,11 +36,6 @@ config CC_INDIRECT_THUNK def_bool $(cc-option,-mindirect-branch-register) || \ $(cc-option,-mretpoline-external-thunk) - -config INDIRECT_THUNK - def_bool y - depends on CC_INDIRECT_THUNK - config HAS_AS_CET_SS # binutils >= 2.29 or LLVM >= 6 def_bool $(as-instr,wrssq %rax$(comma)0;setssbsy) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index db687b1785..533b8f33e6 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -85,6 +85,20 @@ config STATIC_MEMORY menu "Speculative hardening" +config INDIRECT_THUNK + bool "Speculative Branch Target Injection Protection" + depends on CC_INDIRECT_THUNK + default y + help + Contemporary processors may use speculative execution as a + performance optimisation, but this can potentially be abused by an + attacker to leak data via speculative sidechannels. + + One source of data leakage is via branch target injection. + + When enabled, indirect branches are implemented using a new construct + called "retpoline" that prevents speculation. + config SPECULATIVE_HARDEN_ARRAY bool "Speculative Array Hardening" default y