From nobody Sat Oct 4 22:15:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1759413392; cv=pass; d=zohomail.com; s=zohoarc; b=dlQt1/iZNmTV8W4zCU7f0+/vM2pA3Lv3UQzrvnXoQ1JQi2FpcS0jSD0KFL/Le4/EDybaP4wXvG41gFr8hbnA2Lr9Rqlucmg5gkJC+V9BpYpdtz/sAewla0BINQYOjg21y9J0gndo+oNQznqGNchcYHSANCtn/bYz3ZliqzLMFHI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759413392; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1F0c76oApIucIy9Rt+2Zft8XHzgKLKIorNjQ2faBZ/Y=; b=MwttDzdf5OQBW2jXCPdUNBWVDaCCKgy0bphcG5YPzZf2WHd7CSzryGAhAotmeACOmTOKyXl2Ia0XHnR9VSH4mWGpVHbELjAEJgxNY92yRXrxQXHjWq+dLw7uUe2zx9c4Z162uz5maQZw6QDRiIHXnRpmKasyilavmvitU2PsAQY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1759413392855474.20727867267385; Thu, 2 Oct 2025 06:56:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1135861.1472798 (Exim 4.92) (envelope-from ) id 1v4Jn2-0000q5-8S; Thu, 02 Oct 2025 13:56:12 +0000 Received: by outflank-mailman (output) from mailman id 1135861.1472798; Thu, 02 Oct 2025 13:56:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v4Jn2-0000py-5V; Thu, 02 Oct 2025 13:56:12 +0000 Received: by outflank-mailman (input) for mailman id 1135861; Thu, 02 Oct 2025 13:56:11 +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 1v4Jn1-0000cT-6h for xen-devel@lists.xenproject.org; Thu, 02 Oct 2025 13:56:11 +0000 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azlp170100009.outbound.protection.outlook.com [2a01:111:f403:c107::9]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8c0e1c1d-9f97-11f0-9d14-b5c5bf9af7f9; Thu, 02 Oct 2025 15:56:10 +0200 (CEST) Received: from PH8PR15CA0006.namprd15.prod.outlook.com (2603:10b6:510:2d2::14) by BL1PR12MB5803.namprd12.prod.outlook.com (2603:10b6:208:393::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9160.18; Thu, 2 Oct 2025 13:55:59 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:510:2d2:cafe::6a) by PH8PR15CA0006.outlook.office365.com (2603:10b6:510:2d2::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9182.15 via Frontend Transport; Thu, 2 Oct 2025 13:55:58 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SA2PEPF000015C6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9182.15 via Frontend Transport; Thu, 2 Oct 2025 13:55:58 +0000 Received: from xcbagarciav01.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 2 Oct 2025 06:55:57 -0700 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 8c0e1c1d-9f97-11f0-9d14-b5c5bf9af7f9 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cZLtZfWDRKa8v9HpEldTju8eCwK4exQsf3AfskLna6HD68ovCnV7HAkGOHGeh0yeHtdQod465NDFK6FkYpFKltOkgtk9Qvaa/JyLqxaWaX8JgPzcKRGzjEUJF3sJAfxRDGEjFdYrwi7fstLqtAf0k00k2hvwEABQbH41mSd4+wvKmUy5BrLuFJTw7/wIA73HmNsRsYVmn405YAg44B42cqJZh+qeC3wNzUr9VoNfZbbz0ivGOfHUOA5xVYiOkfeQN0hwyC44HHcoQQqzabeSI6YtG8qPhN9Zw+G7USHbT5euvCgrkEcEJq7p8XstUIJqoOBpLhUKyRrVWkXW+sM/ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=1F0c76oApIucIy9Rt+2Zft8XHzgKLKIorNjQ2faBZ/Y=; b=vZQhe06Bvx6iYa+LGyRArT7a3hF7qVQ4A2hALc8QojlGKWTMu74cNSbUKy8geIHYsC40Z5a2Ptue5WO4gxcYSTBRZzzocLHXByZq2IFSyuHTerWZE2tR5Di0IGd4Lu9k9GyU4NuJj/ZzEj68b3wNk4PLNJ0ma8G6ONnIazS5soRoQvMrCfAWRLZSxoNS+ny0gVxdSgLtbp0bHTRJRkvTJ+uwS8RQ0SJc1s8sbcqhJPX8XkvWxrwTE+kHIBohnf1ft10Sdol7CPzzcNCdo9i0JqgyTY1EhAUtp7wHC8o2C4T1TGy/e3soyOZxAjr5nPQrLtBqACDyvJqaLu0Ps11/Qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1F0c76oApIucIy9Rt+2Zft8XHzgKLKIorNjQ2faBZ/Y=; b=Tc1STqXlGx7otBPZDoofrF6b9lH4b6zSXxT3mgMxtG8Gx9Ou5I7v8K2aMTnCLjgNHmFTEfZGakbxqcY1hcs56f2HAt9eUx7aCOx7HZimOqyoNUhwfN+w3JE0L+fyQ4AabX8fTCaZcyPzBGwQGy+3EBr2Td4hPpd3S59gVksaGHQ= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Alejandro Vallejo To: CC: Alejandro Vallejo , Andrew Cooper Subject: [XTF PATCH v2 1/2] x86: Remove Xen as a hard requirement to run XTF. Date: Thu, 2 Oct 2025 15:55:33 +0200 Message-ID: <20251002135542.28076-2-alejandro.garciavallejo@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251002135542.28076-1-alejandro.garciavallejo@amd.com> References: <20251002135542.28076-1-alejandro.garciavallejo@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C6:EE_|BL1PR12MB5803:EE_ X-MS-Office365-Filtering-Correlation-Id: a48b341b-12cd-4ac5-43d3-08de01bb6a53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?kkDOQS7n4zSgdmOcIVm12qHyqcKVMOg3xwbewrsThAPvASCuHCl6N6XcEHDn?= =?us-ascii?Q?M+7mOfUeBo0qwP4MmaBTlzDO8VWmk888o4r3TSMbStQMfZ4ZJba75hDgLkGb?= =?us-ascii?Q?Vn5tQ1JU6h/DPwwimMB7P2d60qt8eyeTlbtv4AeTxoLssKZg+Acs6YlTSLq3?= =?us-ascii?Q?6zIu01uRJ+6K0kzLQqNmND3o5yrLtOds+q/IaaHH4fKuT5X9eelbjRkvHDWP?= =?us-ascii?Q?h1A4+30KU0SaHtthVIIN2P7GpsLGyiPwOYFLbj2U6tUesLmZaEE2mgA3qwGT?= =?us-ascii?Q?yrUjzfcZZZyS2DP/iC9MgWzhanomXKLYexnL/VxsQBozsO53e/8UV7Tu9fkT?= =?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Ff17W2Nc8iW/BSa13K6XxO+H5p4?= =?us-ascii?Q?GqxHJkD31cF/6K9Kvq5XbTKU90X9emddo9m6C0sHaTnLMaRMzk8Gvlbs3ScI?= =?us-ascii?Q?vvUOvptcAv2Jj46Y8CCCTOwDgQnjatQYeIg9Bj/Lxnmr+c7ziWRjVvzwgoa9?= =?us-ascii?Q?31gdKUufS2XjdrchRpxh3c1GACRHlYVc9POcExdhgPSAWposoaX5+fMMndCH?= =?us-ascii?Q?Fd4UXoB+2LK9syYUBKmvFzOCYzT7u75BTq+jgcd4y9RmXMoDO+VBBU9IyTkl?= =?us-ascii?Q?tlWpHMB2en4Yx18Y+8rdiclbtFlWxFIk0myjQoof7cqvtDYEq9bvBYFI9n1+?= =?us-ascii?Q?uBrfJLESYKwmxBZ7sc4=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2025 13:55:58.6889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a48b341b-12cd-4ac5-43d3-08de01bb6a53 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5803 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1759413395108116600 Content-Type: text/plain; charset="utf-8" If Xen isn't detected on CPUID, then: * Skip setting up Xenbus/PV-console/shared_info/hypercalls/qemu-debug. * Register COM1 as an output callback. * Attempt a QEMU exit via the ISA debug exit device This patch enables running XTF on QEMU-TCG/KVM out of the box. And a minor tweaks to set up baud rate make it work on real hardware too. Signed-off-by: Alejandro Vallejo --- I can't really integrate the checks on find_xen_leaves() as I intended beca= use many functions just don't need it (prepping xenbus, for instance), so I've = left things as they were in v1. It does work this way. v2: * Use new now available rep_outsb() helper for the com1 writer * Make find_xen_leaves() fallible, and add an extra boolean to preserve the panic behaviour where it still matters. --- arch/x86/setup.c | 53 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/arch/x86/setup.c b/arch/x86/setup.c index ba6f9c3..be42c84 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -102,12 +102,13 @@ static void collect_cpuid(cpuid_count_fn_t cpuid_fn) * Find the Xen CPUID leaves. They may be at 0x4000_0000, or at 0x4000_01= 00 * if Xen is e.g. providing a viridian interface to the guest too. */ -static unsigned int find_xen_leaves(void) +static unsigned int find_xen_leaves(bool assert_found) { +#define XEN_LEAVES_NOT_FOUND (-1U) static unsigned int leaves; =20 if ( leaves ) - return leaves; + goto out; =20 for ( unsigned int l =3D XEN_CPUID_FIRST_LEAF; l < XEN_CPUID_FIRST_LEAF + 0x10000; l +=3D 0x100 ) @@ -126,7 +127,13 @@ static unsigned int find_xen_leaves(void) } } =20 - panic("Unable to locate Xen CPUID leaves\n"); + leaves =3D XEN_LEAVES_NOT_FOUND; + +out: + if ( assert_found && (leaves =3D=3D XEN_LEAVES_NOT_FOUND) ) + panic("Unable to locate Xen CPUID leaves\n"); + + return leaves; } =20 /* @@ -140,7 +147,7 @@ static void init_hypercalls(void) if ( IS_DEFINED(CONFIG_HVM) ) { uint32_t eax, ebx, ecx, edx; - unsigned int base =3D find_xen_leaves(); + unsigned int base =3D find_xen_leaves(true); =20 cpuid(base + 2, &eax, &ebx, &ecx, &edx); wrmsr(ebx, _u(hypercall_page)); @@ -248,6 +255,11 @@ static void qemu_console_write(const char *buf, size_t= len) rep_outsb(buf, len, 0x12); } =20 +static void com1_console_write(const char *buf, size_t len) +{ + rep_outsb(buf, len, 0x3f8); +} + static void xen_console_write(const char *buf, size_t len) { hypercall_console_write(buf, len); @@ -255,10 +267,18 @@ static void xen_console_write(const char *buf, size_t= len) =20 void arch_setup(void) { - if ( IS_DEFINED(CONFIG_HVM) && !pvh_start_info ) - register_console_callback(qemu_console_write); + bool has_xen_hypervisor =3D + find_xen_leaves(IS_DEFINED(CONFIG_PV)) !=3D XEN_LEAVES_NOT_FOUND; =20 - register_console_callback(xen_console_write); + if ( has_xen_hypervisor ) + { + if ( IS_DEFINED(CONFIG_HVM) && !pvh_start_info ) + register_console_callback(qemu_console_write); + + register_console_callback(xen_console_write); + } + else + register_console_callback(com1_console_write); =20 collect_cpuid(IS_DEFINED(CONFIG_PV) ? pv_cpuid_count : cpuid_count); =20 @@ -266,15 +286,18 @@ void arch_setup(void) =20 arch_init_traps(); =20 - init_hypercalls(); - - if ( !is_initdomain() ) + if ( has_xen_hypervisor ) { - setup_pv_console(); - setup_xenbus(); - } + init_hypercalls(); =20 - map_shared_info(); + if ( !is_initdomain() ) + { + setup_pv_console(); + setup_xenbus(); + } + + map_shared_info(); + } } =20 int arch_get_domid(void) @@ -282,7 +305,7 @@ int arch_get_domid(void) if ( IS_DEFINED(CONFIG_HVM) ) { uint32_t eax, ebx, ecx, edx; - unsigned int base =3D find_xen_leaves(); + unsigned int base =3D find_xen_leaves(true); =20 cpuid_count(base + 4, 0, &eax, &ebx, &ecx, &edx); =20 --=20 2.43.0 From nobody Sat Oct 4 22:15:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1759413391; cv=pass; d=zohomail.com; s=zohoarc; b=ip4qbOZ74aZztTqGxnd7noeMh9GPBZ4qwwMhvRqRaX2XZMn2HJEScFrXcNmRS1uffXIjOQd9Vabk7EjnNrwmu5umYNC2gEivwYFiGK/eAlx9EdegtWthq0JgTOmSHdHk9Tj/szbe/FOJpECh5zyxSH5yTxjaVN9s9GeUNPiuaaw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759413391; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zrkCPxfsenLoTP5XQkO+LdpiBn8mkFqedF7ORoCKf2s=; b=iomIhODsiNP7XJE1Ss6R0pUsOXZCTXXLaS2BmGIHbWa5JzPPuOUz8Mvn9R1McGUUeiajUzZ7AAEFQ8lH4gKi7SNSvITGCsetMkpF3DDrWmsX5t0j+4UUPmdf3qceZpRmooUmbyKFIw04xl/lQhao3AsO3kinOkj8ZpApQF0Hj0A= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1759413391653580.964794049796; Thu, 2 Oct 2025 06:56:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1135860.1472788 (Exim 4.92) (envelope-from ) id 1v4Jn1-0000cb-1Q; Thu, 02 Oct 2025 13:56:11 +0000 Received: by outflank-mailman (output) from mailman id 1135860.1472788; Thu, 02 Oct 2025 13:56:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v4Jn0-0000cU-UM; Thu, 02 Oct 2025 13:56:10 +0000 Received: by outflank-mailman (input) for mailman id 1135860; Thu, 02 Oct 2025 13:56:09 +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 1v4Jmz-0000cN-9R for xen-devel@lists.xenproject.org; Thu, 02 Oct 2025 13:56:09 +0000 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azlp170110003.outbound.protection.outlook.com [2a01:111:f403:c107::3]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8ab7b49f-9f97-11f0-9809-7dc792cee155; Thu, 02 Oct 2025 15:56:06 +0200 (CEST) Received: from PH8PR15CA0024.namprd15.prod.outlook.com (2603:10b6:510:2d2::9) by SA1PR12MB7443.namprd12.prod.outlook.com (2603:10b6:806:2b7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9160.18; Thu, 2 Oct 2025 13:56:01 +0000 Received: from SA2PEPF000015C6.namprd03.prod.outlook.com (2603:10b6:510:2d2:cafe::59) by PH8PR15CA0024.outlook.office365.com (2603:10b6:510:2d2::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9182.16 via Frontend Transport; Thu, 2 Oct 2025 13:55:56 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SA2PEPF000015C6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9182.15 via Frontend Transport; Thu, 2 Oct 2025 13:55:59 +0000 Received: from xcbagarciav01.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 2 Oct 2025 06:55:58 -0700 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 8ab7b49f-9f97-11f0-9809-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SNjBg9Jpx4GLSlXc556qp9c3MhlFWqwMsa+JV2lJ4fjm/Sv4Aig/8tDHj7d9hVPz+myrRywKjDn4lV4oqVBcA6vj1RHcZN1HLGR7wmLkbpJsnnxndafLI+w/nXFr8mMXIrxL57L7K7FhkHCnsfzn53v9zaG4EaizBTSoEtUHoMbwFLs1sU2oyDouINtwF/twfCS6IhEdBiNstJeccT4nBhDlVC5I4PuOr/9/1qWZNe9V/9vxmR5ZNkQsBm7HI+eXGU7NCPjltN2PVRr2ck61RzRu86zqJmbmot5pi5JL5d6VMFnwb/n0E9BoLeoZrj/FiQZiiU0LPsPk6I+ZFTGLsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zrkCPxfsenLoTP5XQkO+LdpiBn8mkFqedF7ORoCKf2s=; b=Uw5Z5gPwDrgw3D5jDdUzRTdPsk5KtacZJ7GSBv/0bLM8Ac7/v72Gkwp3037+5oZhyvcno2rf86NY2xkd8x5cF+ZrMuVHxXytEiFqUmLBt6Bn+5jxFI8XxQiXEFIhdMWbB3dLHwEcKusyOY/Qij33EhBdSOb8TycmcaEqwCObQxb7Zh4OrNqDMAbhtRq6nbXfacEKJTb/WNhBbdr4CLZ1KcQU1tp1GEeEq8NrZjaID5L9dLS+QUnIfqWSnvBy4JZ/ydBGmRK4Q/CZpgbxmJa1PgU/6d6Ud52ZPnEXQ64rbSHOk2slMWjUib/SLfYv8rK1fTSSiuNOEojiAkjSmK7Euw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zrkCPxfsenLoTP5XQkO+LdpiBn8mkFqedF7ORoCKf2s=; b=OYzlkeFl4ehuJexp+crh27d0ZI5ZuvMMQYeoD8QErchKlEtNwrm8K/e6z/zeCcgbFPAEFHViscL2dYAPeeacEpPOqWWBp9Tk2fzaVXXD3/zt7k5ZGAWW5TcxGnBdECHCaN751chKW7WCRllWlE21G1vVEMZTifbGPX1oME1KJIc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Alejandro Vallejo To: CC: Alejandro Vallejo , Andrew Cooper Subject: [XTF PATCH v2 2/2] x86: Allow exiting QEMU in TCG/QEMU Date: Thu, 2 Oct 2025 15:55:34 +0200 Message-ID: <20251002135542.28076-3-alejandro.garciavallejo@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251002135542.28076-1-alejandro.garciavallejo@amd.com> References: <20251002135542.28076-1-alejandro.garciavallejo@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C6:EE_|SA1PR12MB7443:EE_ X-MS-Office365-Filtering-Correlation-Id: 0aff8f9e-fbf2-4020-1174-08de01bb6b0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lrgJx0jf1+QZ5U+TCVf1mHoSFhHtqcJqH49WR/nBH3RKWxSwsb2DIEEVuxZp?= =?us-ascii?Q?9buocV0ibyeufybfFY5MjVGnsC88O+LK9rjsQgOVt6O9BRcuxlAFizyOEbvX?= =?us-ascii?Q?k8cFVuS14FDuX+MjwWHwg89Jzb0DWJRLgvfBfYIelRdWnwj5VSiZCYX/5AST?= =?us-ascii?Q?CghlOSMw+ASGPPNh6exs7BPYE8xexE/o+xHNnFGmTEz3uAH3XMidQv+47zYn?= =?us-ascii?Q?QFkqGaGFppXaeokRY2+wHDMctKFgb3ZYJbM2J/BkfPawcDt7lLWtxXz0gRcU?= =?us-ascii?Q?vbLS2HQrTduuy9PXIPulK+RGaNtKNQiAr/E+01QNPmR5HlnSDi+PVEjVw6zB?= =?us-ascii?Q?x96MzHvAAFGMFGHA+f43M4VgpSl5Hjn8PfYB6EKyI6dNAHSdSQVlhNJ8HOxN?= =?us-ascii?Q?IjE0Dpqw4L25vRQOG/4X/VfwN9qXKtkQJ6KBNq3DfneS+mNs2bvPHJScc9mS?= =?us-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0msv1oThe?= =?us-ascii?Q?FyVwzR/X5NgiNnUlwv5xJVadKvKqqArcEDfmTSKkeYusyRfk0fb1Gjc+vX5E?= =?us-ascii?Q?+ElUf4nrXT1okzFHRuislPhcRUfAVT7bWeBs7dim5+/sQrmh6R7zu+2+KJ3l?= =?us-ascii?Q?le15rDXSfsWZaQzR+PvJDIrs5tbxLXcgh6kUaODvEGQOVTNEolP8W5K5jsJ9?= =?us-ascii?Q?7oKo7/dH/3mWrAdDxiQ=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2025 13:55:59.9131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0aff8f9e-fbf2-4020-1174-08de01bb6b0e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7443 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1759413393260116600 Content-Type: text/plain; charset="utf-8" If QEMU has a debug isa-debug-exit device, we can simply write to it to exit rather than spinning after a failed hypercall. While at it, reorder an out-of-order include. Signed-off-by: Alejandro Vallejo --- arch/x86/hvm/traps.c | 16 +++++++++++++++- arch/x86/pv/traps.c | 5 +++++ common/lib.c | 2 +- common/report.c | 8 +++++--- include/xtf/framework.h | 3 +++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/x86/hvm/traps.c b/arch/x86/hvm/traps.c index ad7b8cb..b8c4d0c 100644 --- a/arch/x86/hvm/traps.c +++ b/arch/x86/hvm/traps.c @@ -1,5 +1,6 @@ -#include +#include #include +#include =20 #include #include @@ -139,6 +140,19 @@ void arch_init_traps(void) virt_to_gfn(__end_user_bss)); } =20 +void arch_shutdown(unsigned int reason) +{ + hypercall_shutdown(reason); + + /* + * Not running under Xen. Attempt exit via the QEMU ISA debug exit dev= ice on + * its default port. + * + * QEMU's rc is (reason << 1) | 1, if "-device isa-debug-exit" is set. + */ + outb(reason, 0x501); +} + void __noreturn arch_crash_hard(void) { /* diff --git a/arch/x86/pv/traps.c b/arch/x86/pv/traps.c index 66ef40e..913bab2 100644 --- a/arch/x86/pv/traps.c +++ b/arch/x86/pv/traps.c @@ -206,6 +206,11 @@ void arch_init_traps(void) panic("Failed to unmap page at NULL: %d\n", rc); } =20 +void arch_shutdown(unsigned int reason) +{ + hypercall_shutdown(reason); +} + void __noreturn arch_crash_hard(void) { /* diff --git a/common/lib.c b/common/lib.c index 7f1813f..f4de22e 100644 --- a/common/lib.c +++ b/common/lib.c @@ -25,7 +25,7 @@ void __noreturn panic(const char *fmt, ...) =20 printk("******************************\n"); =20 - hypercall_shutdown(SHUTDOWN_crash); + arch_shutdown(SHUTDOWN_crash); arch_crash_hard(); } =20 diff --git a/common/report.c b/common/report.c index ffdf098..158876e 100644 --- a/common/report.c +++ b/common/report.c @@ -1,6 +1,8 @@ +#include #include #include -#include + +#include =20 enum test_status { STATUS_RUNNING, /**< Test not yet completed. */ @@ -124,8 +126,8 @@ bool xtf_status_reported(void) void xtf_exit(void) { xtf_report_status(); - hypercall_shutdown(SHUTDOWN_poweroff); - panic("xtf_exit(): hypercall_shutdown(SHUTDOWN_poweroff) returned\n"); + arch_shutdown(SHUTDOWN_poweroff); + panic("xtf_exit(): arch_shutdown(SHUTDOWN_poweroff) returned\n"); } =20 /* diff --git a/include/xtf/framework.h b/include/xtf/framework.h index 95de195..e852882 100644 --- a/include/xtf/framework.h +++ b/include/xtf/framework.h @@ -16,6 +16,9 @@ void arch_setup(void); /* Set up test-specific configuration. */ void test_setup(void); =20 +/* Stop the machine. See SHUTDOWN_poweroff et al for reasons */ +void arch_shutdown(unsigned int reason); + /* * In the case that normal shutdown actions have failed, contain execution= as * best as possible. --=20 2.43.0