From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013036.outbound.protection.outlook.com [40.107.201.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3D3E331211 for ; Mon, 1 Dec 2025 18:20:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.36 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764613257; cv=fail; b=Y9qyXOfSt3fGWi2YHILSJnye3HXQ6U0u5VzdnhSkRkthDaRoEONmy7RfNK27crEdXSVCSyje2XwZ4U5YvjDR1T7QCXshFCHW8N4eyvnx1aEx2m1k3ZHpsQoG2tEQt97AcXimjh9c2Pw0UMxQFnxXvmYE4yu/XXVeVFUA8zWsx70= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764613257; c=relaxed/simple; bh=WwM7/zMEoJXFfSF4F8Er/oXzNl38rjunj1k+bogyoJA=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=KMf/nZxdSO6caqC++o6z3TllBeb4/SbWIkmWV77RFvdiOLLfOZvoOg2vjqPoXVkcnPu2ZH1pbTkZjVun56NF5prG2lSyteCGc1bYOXsc/Ftxukjxy6vRNcwt5zV78ZL05Azo/OhiS+/j1vm4hSRi36T3J3Gvtd7nLFpSYyXrbf0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pmhWN4QR; arc=fail smtp.client-ip=40.107.201.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pmhWN4QR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FEOF4oz3QZ93rQQqLCdqepRsU6E2mTxvxn4aQDrdxQPxBsVCvKxSzZpii6JTxwm8jM85Bu+kxwJDxBm9frLtDYSCCCQ36qJHe2SseRlGsH+QCo3bt8W6I2JDQlQ3mz1msIfWxSnoudTAldlUoEzsJh3p1lu5rHHe+EdPoWaNAECEDGG/yWtujlyFrRweG/sYLaDpOUZXOeW5D++JNuZA7SZpMFA58IthnFK2QbZDiReewdWhzJfUNxGBMhLj3+TY0vkf4XkpXnC9yFi0UC2kMXYucc/QKT68psVKjtR5prp+vk/4AuLSZ0UgCG2LfSdPNaX3TnP007Duood9Nhn3og== 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=I52DyuTMlAwzXRPy6YzI1itobKzOSJLCLxnFKBFnQTQ=; b=EyyWRruGmCYqkOuWKIk4DDtKMpF36hZt6UMh7u55PL7M7OVZBWxP/VitinL0rl6xk36HSQa1nYzTUOsZ/bDXOMYj6x0kMagygD5P51kx6v9JRyUWsKsZVa9fLSD2oT4Lx1Um1ZCGZKSkP+gnV7vIGPrDk7pL/OGkJv87FMUS97koZ+twXepdh+VEQx3J/wg/40yLi9mHqDipIUxBk7nSZzDMjH5n8iRefjEqQWgZaY1OUu3vbHFIgZepQMEEopeRq30r3WnEFHX5rQAvYoxAksEkLhmsdcpu0woHVfUtuVulnbxBP8YL/+i4lmB/EuWMLgp87sOI+ktF+t6DHsvOCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=invisiblethingslab.com 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=I52DyuTMlAwzXRPy6YzI1itobKzOSJLCLxnFKBFnQTQ=; b=pmhWN4QRX1Lh6bu3P5Bzi7BltIK6Z8nRlDziILcIMcJ9w3mXZ8H+4rcjhUtoHDG0UqhME59bdEwfjABrFCwvTJIGIyG/xKvh7gOHw+nlMeOzIhstJf0tXRWWzifbxBcmtzXogA7In9XDbFayYs25WyRU7IhMXrt08rRJxRI2lI4= Received: from MN2PR04CA0028.namprd04.prod.outlook.com (2603:10b6:208:d4::41) by SA0PR12MB4416.namprd12.prod.outlook.com (2603:10b6:806:99::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9366.17; Mon, 1 Dec 2025 18:20:51 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:d4:cafe::9c) by MN2PR04CA0028.outlook.office365.com (2603:10b6:208:d4::41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9366.17 via Frontend Transport; Mon, 1 Dec 2025 18:20:54 +0000 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 (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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9388.8 via Frontend Transport; Mon, 1 Dec 2025 18:20:50 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Mon, 1 Dec 2025 12:20:48 -0600 Received: from [172.31.77.70] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Mon, 1 Dec 2025 10:20:47 -0800 Message-ID: Date: Mon, 1 Dec 2025 13:20:40 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] xenbus: Use .freeze/.thaw to handle xenbus devices To: =?UTF-8?Q?Marek_Marczykowski-G=C3=B3recki?= CC: Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Yann Sionneau , , References: <20251119224731.61497-1-jason.andryuk@amd.com> <20251119224731.61497-2-jason.andryuk@amd.com> Content-Language: en-US From: Jason Andryuk In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E64:EE_|SA0PR12MB4416:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ab1479c-3fbc-41c0-9a33-08de31065b7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|30052699003|376014|82310400026|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RzVBUkNOUy9MWUdRc0ZEQlBXdDZ5WkxUbFIrRWJOQ0tVTkNCUWtXdUVjVWdJ?= =?utf-8?B?Ym9RRTkybUpvV1pnSmRZb0NwT1lk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-8?B?Y2d3bEZPampEYjlOWlNLY1JEMHZSN25FYk9jRTZBR0FjYjBLY29lWXQzQXRI?= =?utf-8?B?NVpLSEpMbXl4R3pWSjltOE11bXZReEx6c2hqZlhCK2ExcGZnWFVmR0RMUnNs?= =?utf-8?B?alRtK3ZDQmFCbC9qa1FKOVdsSnRSY3B5YWFGVjdubEkyVzVFVWZ5Q1FEMitz?= =?utf-8?Q?pA7pnp?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(30052699003)(376014)(82310400026)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2025 18:20:50.7077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ab1479c-3fbc-41c0-9a33-08de31065b7a 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4416 On 2025-11-29 21:03, Marek Marczykowski-Górecki wrote: > On Wed, Nov 19, 2025 at 05:47:29PM -0500, Jason Andryuk wrote: >> The goal is to fix s2idle and S3 for Xen PV devices. > > Can you give a little more context of this? We do have working S3 in > qubes with no need for such change. We trigger it via the toolstack (libxl_domain_suspend_only()). > Are you talking about guest-initiated suspend here? This is intended to help domU s2idle/S3 and resume. I guess that is what you mean by guest-initiated? The domU can use 'echo mem > /sys/power/state' to enter s2idle/S3. We also have the domU react to the ACPI sleep button from `xl trigger $dom sleep`. AIUI, libxl_domain_suspend_only() triggers xenstore writes which Linux drivers/xen/manage.c:do_suspend() acts on. `xl save/suspend/migrate` all use this path. The terminology gets confusing. Xen uses "suspend" for save/suspend/migrate, but the Linux power management codes uses freeze/thaw/restore. AIUI, Linux's PMSG_SUSPEND/.suspend is for runtime power management. When you call libxl_domain_suspend_only()/libxl_domain_resume(), you pass suspend_cancel==1. * 1. (fast=1) Resume the guest without resetting the domain environment. * The guests's call to SCHEDOP_shutdown(SHUTDOWN_suspend) will return 1. That ends up in Linux do_suspend() as si.cancelled = 1, which calls PMSG_THAW -> .thaw -> xenbus_dev_cancel() which is a no-op. So it does not change the PV devices. We needed guest user space to perform actions before entering s2idle. libxl_domain_suspend_only() triggers the Linux kernel path which does not notify user space. The ACPI power buttons let user space perform actions (lock and blank the screen) before entering the idle state. > We also have kinda working (host) s2idle. You may want to take a look at this > work (some/most of it was posted upstream, but not all got > committed/reviewed): > https://github.com/QubesOS/qubes-issues/issues/6411#issuecomment-1538089344 > https://github.com/QubesOS/qubes-linux-kernel/pull/910 (some patches > changed since that PR, see the current main too). This would not affect host s2idle - it changes PV frontend devices. Do you libxl_domain_suspend_only() all domUs and then put dom0 into s0ix? >> A domain resuming >> from s3 or s2idle disconnects its PV devices during resume. The >> backends are not expecting this and do not reconnect. >> >> b3e96c0c7562 ("xen: use freeze/restore/thaw PM events for suspend/ >> resume/chkpt") changed xen_suspend()/do_suspend() from >> PMSG_SUSPEND/PMSG_RESUME to PMSG_FREEZE/PMSG_THAW/PMSG_RESTORE, but the >> suspend/resume callbacks remained. >> >> .freeze/restore are used with hiberation where Linux restarts in a new >> place in the future. .suspend/resume are useful for runtime power >> management for the duration of a boot. >> >> The current behavior of the callbacks works for an xl save/restore or >> live migration where the domain is restored/migrated to a new location >> and connecting to a not-already-connected backend. >> >> Change xenbus_pm_ops to use .freeze/thaw/restore and drop the >> .suspend/resume hook. This matches the use in drivers/xen/manage.c for >> save/restore and live migration. With .suspend/resume empty, PV devices >> are left connected during s2idle and s3, so PV devices are not changed >> and work after resume. > > Is that intended? While it might work for suspend by a chance(*), I'm > pretty sure not disconnecting + re-reconnecting PV devices across > save/restore/live migration will break them. save/restore/live migration keep using .freeze/thaw/restore, which disconnects and reconnects today. Nothing changes there as xen_suspend()/do_suspend() call the power management code with PMSG_FREEZE/PMSG_THAW/PMSG_RESTORE. This patches makes .suspend/resume no-ops for PMSG_SUSPEND/PMSG_RESUME. When a domU goes into s2idle/S3, the backend state remains connected. With this patch, when the domU wakes up, the frontends do nothing and remain connected. > (*) and even that I'm not sure - with driver domains, depending on > suspend order this feels like might result in a deadlock... I'm not sure. I don't think this patch changes anything with respect to them. Thanks for testing. Maybe the commit messages should change to highlight this is for domU PV devices? struct xen_bus_type xenbus_backend does not define dev_pm_ops. Regards, Jason >> Signed-off-by: Jason Andryuk >> --- >> drivers/xen/xenbus/xenbus_probe_frontend.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c >> index 6d1819269cbe..199917b6f77c 100644 >> --- a/drivers/xen/xenbus/xenbus_probe_frontend.c >> +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c >> @@ -148,11 +148,9 @@ static void xenbus_frontend_dev_shutdown(struct device *_dev) >> } >> >> static const struct dev_pm_ops xenbus_pm_ops = { >> - .suspend = xenbus_dev_suspend, >> - .resume = xenbus_frontend_dev_resume, >> .freeze = xenbus_dev_suspend, >> .thaw = xenbus_dev_cancel, >> - .restore = xenbus_dev_resume, >> + .restore = xenbus_frontend_dev_resume, >> }; >> >> static struct xen_bus_type xenbus_frontend = { >> -- >> 2.34.1 >> >> >