From patchwork Wed Feb 16 16:21:41 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: 12748741 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 85E5FC433F5 for ; Wed, 16 Feb 2022 16:22:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.274291.469716 (Exim 4.92) (envelope-from ) id 1nKN48-0004RT-18; Wed, 16 Feb 2022 16:22:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 274291.469716; Wed, 16 Feb 2022 16:22:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nKN47-0004PY-Qx; Wed, 16 Feb 2022 16:22:03 +0000 Received: by outflank-mailman (input) for mailman id 274291; Wed, 16 Feb 2022 16:22:02 +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 1nKN46-0004NT-Mm for xen-devel@lists.xenproject.org; Wed, 16 Feb 2022 16:22:02 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 916820ed-8f44-11ec-b215-9bbe72dcb22c; Wed, 16 Feb 2022 17:22:00 +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: 916820ed-8f44-11ec-b215-9bbe72dcb22c DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1645028520; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=JHqA1stN/h7CkLREvasdTybcxRF2lyYLB/1/bAsoRGo=; b=CG7Jkn/Z9mEGgT+r8WvO3T1/+5pGNnJIxpIAwGyaDm22+Bgg/DO6orNx EXE8hOf8d/3fl1/dLmxpxagkZ7tGGPzMKeQ5FVV40wT8rbxxSrIhXC44y cpxFCOjOfaEK9TNGIxWCredYRAHL/pJ/k/W/Pv0AemO3nc65HPTv4vZoR 0=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: LtBb+DVRLzoTfbdBNP60pqhrCZqUsiy1PUemff9wYnqeTFlBBaMXu3QXdvatExslLtS+GsIgdG NOtxvNCTcwZ9FW3sQojB733CYrZdJW9G73ELYnEXAyvyl0EMMw6wv1crZYefKfhSLP/q5aQ1r6 UdEhVcdYVb0JYRV2R6PXviXnyYzpdx5F4htu3WVtAHpa9Q42aC3UG6GyHu6n57feLpK+def49P uuxsZ/GM/dsIC9MmXRKBJxRI92vobPkB34xQIaCW/1HDfEpv8I0IGSNsChcrYpwxkXd5WVonhd BW/NopGiUVJHZkEnovXU9WRi X-SBRS: 5.1 X-MesageID: 64256048 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:KDx1Na6lPxdl9F6X0BcIwQxRtOTAchMFZxGqfqrLsTDasY5as4F+v mUbCjuEO6uCYjT2etx1Ptm0809QusfWm9ZkTANl/Hs8Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FV8MpBsJ00o5wbZj29Aw27BVPivW0 T/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dA6/ ++7zgreTJdaH1ZiAc/aZeiB1VS0uXRByut+U1GReotYeVn28ZgsICv016dlL8YJIBTF5z2by wfJXktI+biT+9c4qYCbi7qFooGlF/pFMnBbR2SLv6yrMST6/3a4xdMSWui/Yj2ABnj//7+vZ LsJwqikYuEHhltDr6F1D61vkfAl/9LqqrJXklZkEXHMYwj5A79sOCDbj8xGt6kLzb5FowqmH EmI/4ACa7mOPcrkFn8XJRYkMbvfha1FxGGK4KRnOlj+6Q924KGDABdbMBS7gSBAKKd4bdE+y uA7tc9KswGyh3LG6DpdYvy4I4hUEkE9bg== IronPort-HdrOrdr: A9a23:pvIjl6rfanF8uPK3pFo3lxwaV5oXeYIsimQD101hICG9Ffbo8/ xG/c5rsCMc5wxhO03I9ergBEDiex3hHPxOkO4s1N6ZNWGN1VdARLsSi7cKqAeQeREWmNQ86U 5ISdkGNDWuZmIQsS+B2maF+nwbsaG6GduT6dvj8w== X-IronPort-AV: E=Sophos;i="5.88,374,1635220800"; d="scan'208";a="64256048" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HhO8ffn98OsJYe7Vbfje5Sd2hy1/bzrzNRago4iq018a8Yhr1dxnOveI3KzMkJuoJ3QZkDb89a5hALzvvsoxYQ1/MEWTwrvSnoIaHXLuOw92l5sLfvBa3rWA6Lj/HwqMRcMsIz0az3Shs62p8ZmiH1I/ti+huF2PPwSi/kZ8QqiAfZVY0U5bkU2wRyCSj3C5aj7Syh81G8rxl+Wh6eCHbTaTY00+fkP8uYXEBKKjRsanwaCE2Z4O54wADuDVKy522Ru5tA/RBbZzkmEGf4JUnOZFj8bDUnjmPeI9yvrwJUNRMUz1183r7BWZZ5KwbF5ucPmgpAdC4PsqQGyCkg2SHg== 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=J/c6eVyHYJXVUlazWNeV+ylcxSqZ5nGqV/mmllNoyMw=; b=av1yU3eMMX5oMtJjsffdN9h1A+PThG1Eh/A+mehnlrTgIZXeOHDOl3QW48/XQVCRr9juOYy6N6y8w3OlMeJNb1zXqNB0pDBSr5ln0zE0eitbYwGXX/qh4y48VARb476AAKhs35H/Wn8lv2AadaMSEKjqFdobJKcdd9qyWNzMgnmiSJWyzwZyZ6CYNlnChL+KHQNkZqOxjQlIeaktbWlztzH5KK2IDWG+0J4pg8ByxoB6E09/NtfSnsIprk5Io+w7/0u/a8KuYChTmIuleZM8DezPtS1aq0kLxoMU0svwJwbOt6oQe3nMTK2nLMRB2eYNRyvWDcZ5lhxZkV8DcuVRYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=J/c6eVyHYJXVUlazWNeV+ylcxSqZ5nGqV/mmllNoyMw=; b=AMUoVtDGYiFfPg6nKjX5uFKnVUpIwfQA8RYaAA5I5drOQH+UPE8w+qP/ScjA1jN5HPIDoYml9JYjiEpaeSUFlpUz1qNOsQ1FJepfn4I0xCsuTUFzVP667ofcInK33ZVot0tPnzpMSYSt/1itwnseTU9JIkY2prQ3joAcBOx6tnQ= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 2/3] x86/clang: add retpoline support Date: Wed, 16 Feb 2022 17:21:41 +0100 Message-ID: <20220216162142.15384-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220216162142.15384-1-roger.pau@citrix.com> References: <20220216162142.15384-1-roger.pau@citrix.com> X-ClientProxiedBy: LO2P265CA0220.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::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: 00291384-75d3-4571-d4ba-08d9f1687419 X-MS-TrafficTypeDiagnostic: SN6PR03MB4143:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lNYh/dr0P2vrPoR+Bd9L+NCodfTQb5J5TTxMBo0Briyz28YMxEe1YkJONZjZkINFnghOqlw85EUlGr6LAirxHLS1Hra7Jsbq6Th7NGmRqNK4ZdRwewTuZQ4qpxV31CuoR2jKRtRpQIkGZttIgPXr1rwjDd3xASeFjW2jxnBOi/wjOnVejrQ+fWt9aCvFmuY1qFQ9l8nGee4J9gPFDI2w8JdGzABB/5bL01ElSYQkGnoP/LSMOIqUI7h7sE+E/H8iep/cxcv7pdCFOS5R8US2LdBaXz5xffoHLMpAHHAWHq/3OCTV6DnU36v1cRap/XYccSV2xrn3jvVXALqRyeh33FDzQFt7jFo7pBaTFHlHMGd3HdgXrEVdgezR0pPRj+JXQwqCn9zT+K23yWfOfgJqXeDItjqz5P94t5UcZACcFQUeFplB1gsaCQQu2bdEzJe8it77ymOLHQB917lxTRCKRJJUu9xh+b9Yk4bGVzlOjyVlKBG2qqFf6kqMeNoX43WPfA2fUzOAG835gqMuFRHzV4qBhAAe/E/ftNJ4NknEXI1b+Y7AWjL25wqHjll4IlLpkQ4OLEJp2MJNx5jq5cqH8jLZtdsspwUP9n8xQ1oYnCSIncB1+h8C+BeLeR/ia0MGlLvhU0xM+WQ0QdMpfXhukw== 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)(6916009)(508600001)(4326008)(86362001)(1076003)(186003)(6506007)(316002)(8676002)(6512007)(66476007)(36756003)(2906002)(54906003)(5660300002)(83380400001)(6486002)(66556008)(2616005)(66946007)(26005)(6666004)(8936002)(38100700002)(82960400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/WpJYK640J50urB4BuIAEZvyzYRa?= =?utf-8?q?k9jF9Dxl8tLwCAhmz9Stgt4ZY2oi5kWEFXBrtIhH8rXgvrwSAqO+uPkSCSu+nQrop?= =?utf-8?q?W27uLHaaG7R09ixz9VmVJX3EvHl8GybRIEz4b2VxEUSeHEmiwjGT4OZnsLWx/cQTd?= =?utf-8?q?75FiNlGvjvPIq6Mo0Kcc5BbX5OGJq4a5Aj2KssrakKICbOmHPDSUuKBZZE0BMBV5w?= =?utf-8?q?VMXrgvhlMfYs1n17wsZJgdY+h2sUS043JzQ3sZ/olR64AjXT1MMaXQEV39JtcaR+p?= =?utf-8?q?WkOU5TPVD1Kmm0wn1l+HSOM62iSzVpRWO3QTZMzUwjZCC1hBOXZkr312sk2RZjytE?= =?utf-8?q?5yACgarESFkrdH6BkYDzr1nFqrEyptZFvthdVnx/EcUi/mQHMZVnv1gFerbH1cKbe?= =?utf-8?q?qIQnkDIXUeT7J9NzEQQVBCYjzBUX9LSjmHYeCzNm/7N3YsZ79hUwMB47Q0mQUJ9Tf?= =?utf-8?q?zwCym3Y72d+0GWn7gk0PpA1pKH7SYFL/4w+kTvETNQn/UHjoAlouif7ha7sK2nhu5?= =?utf-8?q?PhRiRLFsjMFUA/KTY3YJ68p8eSU6sTHLhinWcWY3XVsQNII87eCFf/pBocD9X6Ubj?= =?utf-8?q?eccU894+nK5xuflAsx9Sd/NIpeRgKoLB4P0v8DvYyON0+GYbErFsCUu6vKrDw8jcw?= =?utf-8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=?utf-8?q?1W3LG86n7aAddSVH38Jh7bSpRkLspba1roT3Psx1YWUlIYBt2PLk8yw=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 00291384-75d3-4571-d4ba-08d9f1687419 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 16:21:57.8878 (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: 8hxIRmJ60n3eWgB12EXULdL9jqvJEI+yOE5c2uS1nESGqNK9fGGM1477MdlnZlsr2pWUYoPSEzyH2131NNKecg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4143 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é Reviewed-by: Jan Beulich --- xen/arch/x86/Kconfig | 5 ++++- xen/arch/x86/arch.mk | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 219ef9791d..2fa456292b 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -35,9 +35,12 @@ config ARCH_DEFCONFIG config GCC_INDIRECT_THUNK def_bool $(cc-option,-mindirect-branch-register) +config CLANG_INDIRECT_THUNK + def_bool $(cc-option,-mretpoline-external-thunk) + config INDIRECT_THUNK def_bool y - depends on GCC_INDIRECT_THUNK + depends on GCC_INDIRECT_THUNK || CLANG_INDIRECT_THUNK config HAS_AS_CET_SS # binutils >= 2.29 or LLVM >= 6 diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index 2da4bdb1ed..f2aa2a515f 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -47,6 +47,9 @@ CFLAGS-$(CONFIG_GCC_INDIRECT_THUNK) += -mindirect-branch=thunk-extern CFLAGS-$(CONFIG_GCC_INDIRECT_THUNK) += -mindirect-branch-register CFLAGS-$(CONFIG_GCC_INDIRECT_THUNK) += -fno-jump-tables +# Enable clang retpoline support if available. +CFLAGS-$(CONFIG_CLANG_INDIRECT_THUNK) += -mretpoline-external-thunk + # If supported by the compiler, reduce stack alignment to 8 bytes. But allow # this to be overridden elsewhere. $(call cc-option-add,CFLAGS_stack_boundary,CC,-mpreferred-stack-boundary=3)