From patchwork Tue Oct 11 16:02:45 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: 13004133 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 F1BE7C433FE for ; Tue, 11 Oct 2022 16:04:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.420401.665240 (Exim 4.92) (envelope-from ) id 1oiHkJ-0001Pu-IK; Tue, 11 Oct 2022 16:04:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 420401.665240; Tue, 11 Oct 2022 16:04:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oiHkJ-0001Pn-EK; Tue, 11 Oct 2022 16:04:43 +0000 Received: by outflank-mailman (input) for mailman id 420401; Tue, 11 Oct 2022 16:04:42 +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 1oiHkI-0000OR-JZ for xen-devel@lists.xenproject.org; Tue, 11 Oct 2022 16:04:42 +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 680249ba-497e-11ed-91b4-6bf2151ebd3b; Tue, 11 Oct 2022 18:04:39 +0200 (CEST) Received: from mail-bn8nam12lp2169.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.169]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 11 Oct 2022 12:04:26 -0400 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) by MW4PR03MB6378.namprd03.prod.outlook.com (2603:10b6:303:11d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Tue, 11 Oct 2022 16:04:23 +0000 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::861e:b46c:1acc:c576]) by SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::861e:b46c:1acc:c576%6]) with mapi id 15.20.5709.015; Tue, 11 Oct 2022 16:04:23 +0000 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: 680249ba-497e-11ed-91b4-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1665504279; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=meTjvBewTlHBs7LRXzpVInwurZ2rXlIRYOO2HPDbQdU=; b=cpSLawyXFBFYvGSd+2Owa0ryMJwIwHwAImGyP0Men5dENAIcmuyscsbT 7fvqalKheWFldAV8VHhToguQcx/UcUKhQGi/5Q0luCiY9O76G9B4tMs60 wLiG/1FqMbHi+WgaRVrBM7Qh6HqZ7YS5Rukk6/OO/xDXq20h/yOlMaU5J s=; X-IronPort-RemoteIP: 104.47.55.169 X-IronPort-MID: 82116872 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:nuWw4a40B1cA5X/4Q3DuywxRtA/GchMFZxGqfqrLsTDasY5as4F+v mIcUWGCbK3YMWD2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bHOind+i1bfyJEwL8k/2 SAuwvl5p+7u/X+7hPHzWfc47lfhdOk4NpeA86njNQTN1zX+0+VTbUkf4fHkCE+oemp5lpvuN 7Qoy04N8A20H/VdnHdm2qZ5yDQlBIVr1Pyw16RhnXu5ebjQighNsZHjYVFNjPE9ksJprhHoe 529lPck6ASIQLLnSz76dSNfQptjFCIrX0rlvNWp2BDULEZdKRaoeUkjQ5o+a87bWzHAb0cYa hT5Jm23ocXTbraVQGSgoBX+q3iYpxpdS32AXTruaSuokprdT5CvgklLfck7wc9HaIGOud5Dt v/Q9VVfcl1P6krhIJGdZM8qJiMexvwaCOJFl6uCnLaM4xCE07xivfMkcYIDaeRCdc18Kc= X-IronPort-AV: E=Sophos;i="5.95,176,1661832000"; d="scan'208";a="82116872" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIlRJ08G0I0wiTd+qD6Th+7eJGiBY6yDNDzALXLPbDWiSTAu37Lj8zUiNyYmv9qKzYov/yqSfgqN024/yKQ/GKTSeQEx76tss0/K72ceEz2uX/peXuRIBiuBz0GMbpu/8cxr/rxlsFq2BFOGE2/x5ITrFtZZMKBP+cG7ijEiJAQtl0ixZjYu6EMEdR2GKSPDqV1EHqsuJXsrJyGxT7RrK+WA59yXPVpdafzrX2toczlxTVU6JkT/xBVbXpv4Qf9GuukWV1YgZGgAThRB6Mwm71VaZtofS4HqEjH2lRsmssa8s051VSG1h1TwfGuhzYGgj8OTGQXSMBE/v/bjijU7xg== 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=EAuwn7S5ftuN5uITAlZ8x3DI+7/sASR3Tb63nr2Rm4w=; b=c3kuLMxMJEL19KqMsiVIhY38Tqr10qZUYhvjIwO1oGQk6cx+Ldo1aszyh/FjX7BxSKN9ILxGQzeHyj8yRmQDi2NTc0MAQ5IA/jW6B5WEFRbArYsx5j0nCWTZz6WefOi6UhjqXHc1BwvKZU5CBXqHUQhQR3y6bZzL0yoZ7sEDovocbvU92f4Vy3aOKtt3UJUqTgRV4HyQ48U5uEHCg9Vuwz7BWqp7vQc5iQk85w2JPSCkDsAnIymC7CUAJG+h7krZvO9SZaibCc+TZXvfFJu5wpE5I9bBY/Q5Ckzx0Cnm2/CVNjaZjpal7TeLvDWAN5zU258IIvyNGoNcS4E/9yRAfw== 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=EAuwn7S5ftuN5uITAlZ8x3DI+7/sASR3Tb63nr2Rm4w=; b=pYAu3gsdv206AH9vo3Lv5rwnFn75CGgB7XGzkd686JpfKfgbeZjwdEpYil/0t1NCX030kE32mz8P/lj+H8yN50Yokj/0qaMdBLMDVS7pO9F6BBbAX4DOxrQGT8P5WcUlvgQ8Rd8OiGWGg+xPObfS3/ZLfkz3rRPPpBvqEgrXZQo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Henry.Wang@arm.com, Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH 4/4] amd/virt_ssbd: add to max HVM policy when SSB_NO is available Date: Tue, 11 Oct 2022 18:02:45 +0200 Message-Id: <20221011160245.56735-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011160245.56735-1-roger.pau@citrix.com> References: <20221011160245.56735-1-roger.pau@citrix.com> X-ClientProxiedBy: LO6P265CA0004.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:339::20) To SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6360:EE_|MW4PR03MB6378:EE_ X-MS-Office365-Filtering-Correlation-Id: 65229b3a-f6c5-4209-189b-08daaba24380 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +WZT989eOuc2Ww9o8kyCAsCm3zOEE+1tilKOU3yp2zQv1w/UPlvjX6NxnuXVecG30qIyOp3SG9K0Y5EL1B2fz6/6uCuNYWw8T3AkNEjA4C+zGGiIRQjq8V9X6XOPL+QLh0sfI/nMGaYLOdW5LqeAryQEaIZOqwBO7vAt0cWiToPo7Lx8FqiGlqKktRf2OFN3QBgfGxmJgFcrpTvz/jz2Muugqr+TlNU9IJJorfOpKC0+2ePFHhElLBhxt8oAYV/D3OG6ns48NahkR7ezNpibwbMpsD/deGHSwweGVVdb0X9gmZZhGAnwAZAJ7WR+jhxPoPEx1MTOqZ+tXgEVOx4Wg5E9gQ6x4oZiMO/53puU9d0Y7xiOWJSVhk2MpEw+NhjexXserPbvXeUmcYzrEp/yVOz4u12HCvlsTcvmFJnlFp4xYaw3LA0b/g98bcm1SdA7tdh+BHaKcI6quOwP7dhpmOoJ55tetnXIN5OZemHvdUyeQvVqPgBNZJv0bwpTY/7beyCt0NnvtSVXQZ+LYFvNcGN/zg207ItP2efIW1IULg9Bi0bnfR/WOkn/x7gm62uBkVBXQLoMg0w9kemKLnPAhjoT6NwFjS5PlzBckC4av+Aa6L/AqM9/HwWtS0PSh78JBLblQPuKq0mzqFMgJ8Tk6dy5ENxK5kdDobcFHLtsXTyvBg+Lr8GVm4AMCLIFGwfRANsGkFE2ADm640bGg39iKg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6360.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(346002)(396003)(376002)(366004)(451199015)(8676002)(6506007)(41300700001)(6486002)(36756003)(38100700002)(2616005)(1076003)(8936002)(66476007)(186003)(86362001)(26005)(54906003)(478600001)(83380400001)(6916009)(2906002)(6666004)(4326008)(5660300002)(66946007)(82960400001)(6512007)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ft7QxEpaRwOHcAeBJtxxIJAanBww?= =?utf-8?q?kyveCBPW9Ymr5L8YMVxnWw+27Mmf35w3KmtGC+V1qmY6sGwaPRGLiabliZELLA2gq?= =?utf-8?q?g1MgWuAEwbOPl6WmRaEyjVLd3SvO4dpLgWmfu1EZvQ13/oiYoq/LVzn6QgozaLe49?= =?utf-8?q?GHiJFduymp9zDtZBfVvkSvXm6nnWvyiaJb+lai91NmP5PPGfZTe1TD2GuJZSUFihJ?= =?utf-8?q?B4jFg8vT/4GLLIhsv7/nFXyzphslvdlao8YmYUTSaUUKsSfwcOP+XPRdEzy4XLAsn?= =?utf-8?q?i8NoD0s/gJy93wquC5pEyE5Jpo13cfcHYSgHQ5aUv8Zjfj6Hp8RWbzC22s6+NWccS?= =?utf-8?q?wM4RYH4dk2FXBbVrsBAnbQCOw9obfV7vDU66cB9VDtzeqsS8oZk3dyusL29HQ36cJ?= =?utf-8?q?bz6wg/mpT9OkxebZQZY6Ua8Hx8xjMrbn2JxEzcZLOjCitX8UBkRlh7VvrVtb70ZB5?= =?utf-8?q?3O8CFPYFKt1VIvQRiYNfrajqJ/POvkEZQeZeM4cesIYgxLOVCHDeZzFoarIUQ9jM5?= =?utf-8?q?lmnkB2IDwFLLhHYnuymilw+yA4rktVbBolVw0oLlDNfBvsSMaqka7vMnouEWCa7P4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8?q?rVkbiWAellb1Uv0UaJKFqUEbAwlZmyoGpt7KHslRpgie1ScPN8mTt0mRQtwWmyuBx?= =?utf-8?q?iJ/eHpLXPza0?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65229b3a-f6c5-4209-189b-08daaba24380 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6360.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2022 16:04:23.5615 (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: dcIz4EBYZxpUIdCucKI0eQEwFO5xaX9S3+EesBqwDtC3Ouj0r5/glpTV1O3IsLzDUm/JpmIplSjGY6q/9Sl6fQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR03MB6378 Hardware that exposes SSB_NO can implement the setting of SSBD as a no-op because it's not affected by SSB. Take advantage of that and allow exposing VIRT_SPEC_CTRL.SSBD to guest running on hadrware that has SSB_NO. Only set VIRT_SSBD on the max policy though, as the feature is only intended to be used for migration compatibility. Signed-off-by: Roger Pau Monné --- As there's no hardware with SSB_NO so far the patch is untested. Post it for reference if there's hardware with the bit set. --- xen/arch/x86/cpu/amd.c | 4 +++- xen/arch/x86/cpuid.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c index cfeb8d1daf..74cfeffc29 100644 --- a/xen/arch/x86/cpu/amd.c +++ b/xen/arch/x86/cpu/amd.c @@ -814,7 +814,9 @@ void amd_set_ssbd(bool enable) wrmsr(MSR_VIRT_SPEC_CTRL, enable ? SPEC_CTRL_SSBD : 0, 0); else if ( amd_legacy_ssbd ) core_set_legacy_ssbd(enable); - else + else if ( cpu_has_ssb_no ) { + /* Nothing to do. */ + } else ASSERT_UNREACHABLE(); } diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index acc2f606ce..e394dbe669 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -558,11 +558,16 @@ static void __init calculate_hvm_max_policy(void) __clear_bit(X86_FEATURE_IBRSB, hvm_featureset); __clear_bit(X86_FEATURE_IBRS, hvm_featureset); } - else if ( boot_cpu_has(X86_FEATURE_AMD_SSBD) ) + else if ( boot_cpu_has(X86_FEATURE_AMD_SSBD) || + boot_cpu_has(X86_FEATURE_SSB_NO) ) /* * If SPEC_CTRL.SSBD is available VIRT_SPEC_CTRL.SSBD can be exposed * and implemented using the former. Expose in the max policy only as * the preference is for guests to use SPEC_CTRL.SSBD if available. + * + * Allow VIRT_SSBD in the max policy if SSB_NO is exposed for migration + * compatibility reasons. If SSB_NO is present setting + * VIRT_SPEC_CTRL.SSBD is a no-op. */ __set_bit(X86_FEATURE_VIRT_SSBD, hvm_featureset);