From patchwork Fri Jul 1 13:16:46 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: 12903293 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 D539BC433EF for ; Fri, 1 Jul 2022 13:17:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.359010.588403 (Exim 4.92) (envelope-from ) id 1o7GWi-0001Zc-8q; Fri, 01 Jul 2022 13:17:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 359010.588403; Fri, 01 Jul 2022 13:17:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o7GWi-0001ZV-5q; Fri, 01 Jul 2022 13:17:40 +0000 Received: by outflank-mailman (input) for mailman id 359010; Fri, 01 Jul 2022 13:17:39 +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 1o7GWg-0001Gx-VU for xen-devel@lists.xenproject.org; Fri, 01 Jul 2022 13:17:39 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2c05b488-f940-11ec-bd2d-47488cf2e6aa; Fri, 01 Jul 2022 15:17:37 +0200 (CEST) Received: from mail-bn8nam12lp2168.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.168]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Jul 2022 09:17:25 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by SJ0PR03MB5693.namprd03.prod.outlook.com (2603:10b6:a03:2de::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Fri, 1 Jul 2022 13:17:23 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::40af:d5f4:95eb:d534]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::40af:d5f4:95eb:d534%7]) with mapi id 15.20.5395.017; Fri, 1 Jul 2022 13:17: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: 2c05b488-f940-11ec-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1656681457; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=1CEJiaivUyqrXZRdB2bbG35oJ0UdQJFYd4ZZZCv6hM8=; b=SYWE5niCsbsbC/rNvoa9FFkqIEGUHldoCva/S8SWC9UQCkos+XcLe6qN 37PQAtocwhiujjQBXNO8meK+TI+pmrgkzqldNFt+dVfGC59sJ1K4hISGF dcZtKrvuNOCs8TY92jN6ab9sCjlqGzEMaSmVz+11gcWCm/bO+zxKW/rGt E=; X-IronPort-RemoteIP: 104.47.55.168 X-IronPort-MID: 77459718 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:urJXZKgWLbLjr62xh01/iSjZX161ehEKZh0ujC45NGQN5FlHY01je htvW2rTOPiMMDOjeo1w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OKcSQgow+KynqiCyveIN9Mofy9AwdkaWK0hIHgd PMqxAvM4Ba7G7QRHi8pV/X1wzpwF8Vmgvf4G7dpUGmjd3yRTo8BcYEr5leaAHl500pu8w5+L 5X3kqC3qAnQi/orWDY3ZzlRhtqnk27rT4JiugIlUFSVoMYdft4sZEfxkVIC50NdRiKpLzPKN MeTf002cwmMW9zNxvizypSKZ2XLzkO9y69MwY/Upf/6UkVoJh7p3FosfD30E1wsa7VcKM0lt gsAp4Y6o2mcfVmHZ6VfN1xJ/dfKla9Ni4kY1jiV2jPJeUgB0/njaLRzfEc2NyKEaZ4vqfa3q 6xGm9liQ== X-IronPort-AV: E=Sophos;i="5.92,237,1650945600"; d="scan'208";a="77459718" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fo/QXDFi4GWnJVaRWfqdHPnXMUNAfG6RTdr0lSkV04bXHk+pGPPlO3d+/oObzOpukiUVlX093O+pitVgSNLvyinVilP5ci4GGiJxGREEcU5n5MHPbHhMAC3szbeS5tcxSahuKBaGple7krhSyCPjOuQg8Ft9LQLKTCRhTySVbLs+A2aB2jZR7jv3RdtzYiWExK/Y1KHgwFh6YfYuHlBM/HZPNiGDkCeWO63pwVLZrK65LekTUBG4G7YlKqEFg8lX9y4omcAlrykeTJIbfZSdXQ6LcCQbAnXp/rCiLbNPKAsI7SKy7MVsmdqTroFsaOzUgtsYN8gqdB4Cl9QmNsjj1w== 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=uziEhWz0IVen09NpiCSfuedX9CMVUDdY/Qb7fXmqvOY=; b=Pu7/KF+n2UCjVXUMU18o47yctZhmUe00b1tbXT8FC5Q7wNfikCOuNBKxvwMTEfquEYWWt+Uygz4vVldrZ6DArr8lAaUWtbu5P2JUmhY9ppo1U6kvzlULJ1AuOQYTPYTv4jK7k+IoZ/MMGRQBRvFLHA6YjWOeMXqX5UXMskDagV95BEONakJjsDNUgWRKXMsiwRtSMQmzbmFkpMuR4TV+E3IfA+G5yf520Z2ICSA0nkZSLLpfMx5PNMaBK3aETjlBm3LoctGWFODHzly85H32CHOav8dvb+DtpG1FKSgnvCskLMtWlMw96gI6h+8Ufb2prDV3/Le3XKW3nH68MKLeoA== 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=uziEhWz0IVen09NpiCSfuedX9CMVUDdY/Qb7fXmqvOY=; b=RKdJQmGPRzroloUkWG3M/YtCOCDMQRTmuIUBnTE47t+4nAzQgVcQVuwBG5lvx1k0o03iJvt7ylhP0U4ftBImoAPZ+z4i+3uJVdFtS5pjQ95GemlUxselTCPfLpwI+iY5GgUhif4BbxqwNieXxsNFnSmfVksQT/HkiTFk8AY4Xnc= 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: Roger Pau Monne , Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v3 1/3] x86/vmx: implement VMExit based guest Bus Lock detection Date: Fri, 1 Jul 2022 15:16:46 +0200 Message-Id: <20220701131648.34292-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220701131648.34292-1-roger.pau@citrix.com> References: <20220701131648.34292-1-roger.pau@citrix.com> X-ClientProxiedBy: LO2P265CA0094.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::34) 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: 9f6f9143-42c0-4d7f-9f94-08da5b6408ec X-MS-TrafficTypeDiagnostic: SJ0PR03MB5693:EE_ X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZBVauaUFwthmuKZRyO2A5PgS0Nh11H27SMxYuehvLpcYJBCPELCPHFTU96rLOi7n5pWmL9YxjSCP1C4KbyL7UxYzIsk60fdgG728wPoNvzgZM2q82ShsW0DeQTuKKxAMRu6yN49p3hrPnCgt13hwBJcFztT1pn4ut+F0P5REuSMe15xPHs7YHMIYeN5Dolsa+Ym50qqiqNp3GfLKZ69vHgX2An6pL1OaMN69YLGu2ToVn6eEtPDa7Avbf6XzR5XOalNcCjtqB6fJfhQZYuwCsHKxWGcI0P6W0SaRBwvWxR7cth5WwQ4/vEYEixgsaz3GzJ0BejYxb20Z+NAoxOolcmA0DVzRAm/DdG35ieWDZZvaTGlvQ+IqrHacYONyxsp0C1v0y6gu9O62eCN+kHI5oclKCKlxl9UBMWIjgOYnnX5PwrvPPXVBaePH/POA2ANiNR7PYgOldD8V4zBvWduMXkg4prYjzl9zpTzTaEQXDULni0iMnmghYO6/Te/yoiVqVUDw0fvjX5Q0o8y5tmeqcM8D3UlfaU9acoxgfLbYWs2c+p8pb48js3ie+b8/T8j4lReEW1qykJYQcfUmgiqt12KIWyBOA0NRsNn0sFZgu4TygNA7W53+wy5d7hak9BAdAzamABTugebPfV39tRGW/xmi/HR5tOGgcNgdsHewUsABr1vAVFFSVb9xjwqGwnfgnYoaKuExGi6m5jsZj8co2MMSsrY6DJ5JPCy5mi43astZtBfFmdZ86Iip4cR1Xz3+9t/Z3n1tnVgEYGRsystzGQ== 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:(13230016)(4636009)(376002)(346002)(396003)(39860400002)(136003)(366004)(38100700002)(66476007)(316002)(82960400001)(54906003)(6916009)(8676002)(66946007)(4326008)(66556008)(2906002)(478600001)(6512007)(186003)(41300700001)(6486002)(1076003)(6666004)(26005)(36756003)(86362001)(8936002)(83380400001)(2616005)(6506007)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?74oDq0vGm4EQ0i4NKkSA+WJvKTIM?= =?utf-8?q?H5wibsDyX9lkvQaD37FNV/tydd0MXdWRZssHyikPRvM7elSGjvRF73+Pi+PoGG3ue?= =?utf-8?q?7gLDUkccYgIIxM2mW40B2DT5+WYeLROxTXqUDQzvkzJtZr9m+t5zQed8RWieWPJPM?= =?utf-8?q?ENafnc2WR1OTeSHMqSASagrfmO/4cd3B+Qzfb0GK3ThBBzXBKwR/Eqp1MwVQ1Pd2k?= =?utf-8?q?vOhlIYC/tvxizytEz7odBer/8KLgD3PwzRbvvIQKbKWkEoUPNIEc+5h4qyxqsVm4R?= =?utf-8?q?f6Y7PowXCjm9bh7l0ptqiJTNKfBo3dlrakDQYQ1Y0nvJqoOy+H39b9RO/LBHc5Iil?= =?utf-8?q?MwBJhVoy7cezXV19OSFBPeN6BdO5P2mNaa7PddUL6k0vZu7h9iplncnthgjIromvs?= =?utf-8?q?CMWBvoK2NsGtml+wJwltZTvyL4YuJ03kZbWwAhM6DeTGijAVUCN9LGjX/YDOogfHp?= =?utf-8?q?+ofxZD/f99A7c9ER2sMm/XMZvahaFI08N8U74zJw2jIkuYMUJMq7QKHxDDjSdovvM?= =?utf-8?q?vbEZen7ruPmvzXp3F04696pZhQE7ZjIKWhM1DH17zENwgM+R8hDijV9no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p9M9BQ?= =?utf-8?q?UhkyLr/x7ggxbnkDl8tuhoqAAw3SMosH7/vW5aAA7dVrNLTVLH1Zt7lMbm1q40hoW?= =?utf-8?q?ZUeMsnpUB0KZRgFabAHyp6O34NB5FjKRCQ=3D=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f6f9143-42c0-4d7f-9f94-08da5b6408ec X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2022 13:17:23.2178 (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: JZZAUZth4xT0SnvsnTp5k3+H+xpBrCNIyFy76SpYozpiQOefHAg6OFRv/qy6ym6qBbNXM6W1OTbhw3nfp0RmAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5693 Add support for enabling guest Bus Lock Detection on Intel systems. Such detection works by triggering a vmexit, which ought to be enough of a pause to prevent a guest from abusing of the Bus Lock. Add an extra Xen perf counter to track the number of Bus Locks detected. This is done because Bus Locks can also be reported by setting the bit 26 in the exit reason field, so also account for those. Note EXIT_REASON_BUS_LOCK VMExits will always have bit 26 set in exit_reason, and hence the performance counter doesn't need to be increased for EXIT_REASON_BUS_LOCK handling. Suggested-by: Andrew Cooper Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich Reviewed-by: Andrew Cooper --- Changes since v2: - Subject/commit log adjustments. - Simply logic given bit 26 will always be set. Changes since v1: - Adjust commit message. --- xen/arch/x86/hvm/vmx/vmcs.c | 4 +++- xen/arch/x86/hvm/vmx/vmx.c | 14 ++++++++++++++ xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 3 +++ xen/arch/x86/include/asm/hvm/vmx/vmx.h | 2 ++ xen/arch/x86/include/asm/perfc_defn.h | 4 +++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 56fed2db03..d388e6729c 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -209,6 +209,7 @@ static void __init vmx_display_features(void) P(cpu_has_vmx_virt_exceptions, "Virtualisation Exceptions"); P(cpu_has_vmx_pml, "Page Modification Logging"); P(cpu_has_vmx_tsc_scaling, "TSC Scaling"); + P(cpu_has_vmx_bus_lock_detection, "Bus Lock Detection"); #undef P if ( !printed ) @@ -318,7 +319,8 @@ static int vmx_init_vmcs_config(bool bsp) SECONDARY_EXEC_ENABLE_VM_FUNCTIONS | SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS | SECONDARY_EXEC_XSAVES | - SECONDARY_EXEC_TSC_SCALING); + SECONDARY_EXEC_TSC_SCALING | + SECONDARY_EXEC_BUS_LOCK_DETECTION); if ( _vmx_misc_cap & VMX_MISC_VMWRITE_ALL ) opt |= SECONDARY_EXEC_ENABLE_VMCS_SHADOWING; if ( opt_vpid_enabled ) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index f08a00dcbb..853f3a9111 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -4065,6 +4065,11 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) if ( unlikely(exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) ) return vmx_failed_vmentry(exit_reason, regs); + if ( unlikely(exit_reason & VMX_EXIT_REASONS_BUS_LOCK) ) + { + perfc_incr(buslock); + exit_reason &= ~VMX_EXIT_REASONS_BUS_LOCK; + } if ( v->arch.hvm.vmx.vmx_realmode ) { @@ -4561,6 +4566,15 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) vmx_handle_descriptor_access(exit_reason); break; + case EXIT_REASON_BUS_LOCK: + /* + * Nothing to do: just taking a vmexit should be enough of a pause to + * prevent a VM from crippling the host with bus locks. Note + * EXIT_REASON_BUS_LOCK will always have bit 26 set in exit_reason, and + * hence the perf counter is already increased. + */ + break; + case EXIT_REASON_VMX_PREEMPTION_TIMER_EXPIRED: case EXIT_REASON_INVPCID: /* fall through */ diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h index 9119aa8536..5d3edc1642 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -266,6 +266,7 @@ extern u32 vmx_vmentry_control; #define SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS 0x00040000 #define SECONDARY_EXEC_XSAVES 0x00100000 #define SECONDARY_EXEC_TSC_SCALING 0x02000000 +#define SECONDARY_EXEC_BUS_LOCK_DETECTION 0x40000000 extern u32 vmx_secondary_exec_control; #define VMX_EPT_EXEC_ONLY_SUPPORTED 0x00000001 @@ -345,6 +346,8 @@ extern u64 vmx_ept_vpid_cap; (vmx_secondary_exec_control & SECONDARY_EXEC_XSAVES) #define cpu_has_vmx_tsc_scaling \ (vmx_secondary_exec_control & SECONDARY_EXEC_TSC_SCALING) +#define cpu_has_vmx_bus_lock_detection \ + (vmx_secondary_exec_control & SECONDARY_EXEC_BUS_LOCK_DETECTION) #define VMCS_RID_TYPE_MASK 0x80000000 diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/asm/hvm/vmx/vmx.h index 8eedf59155..03995701a1 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -159,6 +159,7 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc) * Exit Reasons */ #define VMX_EXIT_REASONS_FAILED_VMENTRY 0x80000000 +#define VMX_EXIT_REASONS_BUS_LOCK (1u << 26) #define EXIT_REASON_EXCEPTION_NMI 0 #define EXIT_REASON_EXTERNAL_INTERRUPT 1 @@ -219,6 +220,7 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc) #define EXIT_REASON_PML_FULL 62 #define EXIT_REASON_XSAVES 63 #define EXIT_REASON_XRSTORS 64 +#define EXIT_REASON_BUS_LOCK 74 /* Remember to also update VMX_PERF_EXIT_REASON_SIZE! */ /* diff --git a/xen/arch/x86/include/asm/perfc_defn.h b/xen/arch/x86/include/asm/perfc_defn.h index b07063b7d8..d6eb661940 100644 --- a/xen/arch/x86/include/asm/perfc_defn.h +++ b/xen/arch/x86/include/asm/perfc_defn.h @@ -6,7 +6,7 @@ PERFCOUNTER_ARRAY(exceptions, "exceptions", 32) #ifdef CONFIG_HVM -#define VMX_PERF_EXIT_REASON_SIZE 65 +#define VMX_PERF_EXIT_REASON_SIZE 75 #define VMEXIT_NPF_PERFC 143 #define SVM_PERF_EXIT_REASON_SIZE (VMEXIT_NPF_PERFC + 1) PERFCOUNTER_ARRAY(vmexits, "vmexits", @@ -125,4 +125,6 @@ PERFCOUNTER(realmode_exits, "vmexits from realmode") PERFCOUNTER(pauseloop_exits, "vmexits from Pause-Loop Detection") +PERFCOUNTER(buslock, "Bus Locks Detected") + /*#endif*/ /* __XEN_PERFC_DEFN_H__ */