Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp758503pxb; Tue, 9 Feb 2021 11:36:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI953+yE60+NYSjaKbCddFKOe72kutiIzx0mDDjFFkeeBs5bUPn3pLx6ohGE/vFQnIMD0r X-Received: by 2002:a50:9d0b:: with SMTP id v11mr25264244ede.308.1612899402491; Tue, 09 Feb 2021 11:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612899402; cv=none; d=google.com; s=arc-20160816; b=qHc83WTsN+yAi8OTQ8mVsQzv4FO7N4ZzV6SP/Q19KftoMP6Z6hfIS6pYidqdFtBPaq 1J9DIZob0J3wzStR9VOfPBcrLWvkl1sSJv2UdWvnAAA9goVJmJHigNBzzbCGbQq02bNz nrzG1CnDwREGSK7L8w2cnez/NIdksyP7+6t9vgckLZIc4fqobYGWmmrbeyVFzmAI8Bn9 5XtGnwex4S2UYdh9kXuofuOwdiDSvnqEm9jmSwhKOHMTxbyeFVqCmIPDXiaHe7sMeVqi j4TZz8zwOkxLBzdEotOTqyO+Pj6bFf7mrb2BVdNZIBWwZgBt9nVCSw7eMUB2Rd6QWPCK /SaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=SIhiOlxvhfineW7So0v1igp3PfXVi703Gg5cl8pbyyA=; b=bVoUBCn/C6UGWSpAzNznpAtQZxBwYrGgzMtXnOLzH1hmm2T6BQNnnaJHKXaqYOQruP 03KZMwPlLNDCgKjquesSFQcXBLRJGbhswf3dD30INVKsZ16FRsKKcCNtrooN46WyMerr yN3cIIf9lH7VtuVx/jD7U29v7STsDUrzi42d5zPxD8C93zlwHxyb4SVc7fwA8FOu+lYt oXHVn/WEkU/P1Xk6rNbMCePe3qolU44TvYi6kWcf/Mz7VokO1dCS70VB5zt7SqMmTyop th0zLO3CLGZf1f7W24RBPbt9d8GN+xkLu314Kq1CpAtWSsY8tsH+6JgOoShvTMGdEa+v 17DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si14787617edh.496.2021.02.09.11.35.59; Tue, 09 Feb 2021 11:36:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233672AbhBITdh (ORCPT + 99 others); Tue, 9 Feb 2021 14:33:37 -0500 Received: from foss.arm.com ([217.140.110.172]:55150 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233175AbhBISRv (ORCPT ); Tue, 9 Feb 2021 13:17:51 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 30A251042; Tue, 9 Feb 2021 10:15:43 -0800 (PST) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E3E9B3F73B; Tue, 9 Feb 2021 10:15:29 -0800 (PST) Subject: Re: How can a userspace program tell if the system supports the ACPI S4 state (Suspend-to-Disk)? To: Dexuan Cui Cc: "Rafael J. Wysocki" , "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , Michael Kelley , Leandro Pereira References: From: James Morse Message-ID: <204fa040-115e-552a-5fc1-5520f10bc402@arm.com> Date: Tue, 9 Feb 2021 18:15:17 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dexuan, On 05/02/2021 19:36, Dexuan Cui wrote: >> From: Rafael J. Wysocki >> Sent: Friday, February 5, 2021 5:06 AM >> To: Dexuan Cui >> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; >> linux-hyperv@vger.kernel.org; Michael Kelley >> Subject: Re: How can a userspace program tell if the system supports the ACPI >> S4 state (Suspend-to-Disk)? >> >> On Sat, Dec 12, 2020 at 2:22 AM Dexuan Cui wrote: >>> >>> Hi all, >>> It looks like Linux can hibernate even if the system does not support the ACPI >>> S4 state, as long as the system can shut down, so "cat /sys/power/state" >>> always contains "disk", unless we specify the kernel parameter "nohibernate" >>> or we use LOCKDOWN_HIBERNATION. >>> In some scenarios IMO it can still be useful if the userspace is able to detect >>> if the ACPI S4 state is supported or not, e.g. when a Linux guest runs on >>> Hyper-V, Hyper-V uses the virtual ACPI S4 state as an indicator of the proper >>> support of the tool stack on the host, i.e. the guest is discouraged from >>> trying hibernation if the state is not supported. What goes wrong? This sounds like a funny way of signalling hypervisor policy. >>> I know we can check the S4 state by 'dmesg': >>> >>> # dmesg |grep ACPI: | grep support >>> [ 3.034134] ACPI: (supports S0 S4 S5) >>> >>> But this method is unreliable because the kernel msg buffer can be filled >>> and overwritten. Is there any better method? If not, do you think if the >>> below patch is appropriate? Thanks! >> >> Sorry for the delay. >> >> If ACPI S4 is supported, /sys/power/disk will list "platform" as one >> of the options (and it will be the default one then). Otherwise, >> "platform" is not present in /sys/power/disk, because ACPI is the only >> user of hibernation_ops. > This works on x86. Thanks a lot! > > BTW, does this also work on ARM64? Not today. The S4/S5 stuff is part of 'ACPI_SYSTEM_POWER_STATES_SUPPORT', which arm64 doesn't enable as it has a firmware mechanism that covers this on both DT and ACPI systems. That code is what calls hibernation_set_ops() to enable ACPI's platform mode. Regardless: hibernate works fine. What does your hypervisor do that causes problems? (I think all we expect from firmware is it doesn't randomise the placement of the ACPI tables as they aren't necessarily part of the hibernate image) Thanks, James