2024-04-12 08:06:29

by David Woodhouse

[permalink] [raw]
Subject: [PATCH v2 0/2] Support clean reboot after hibernate on Arm64

When the hardware signature in the ACPI FACS changes, the OS is supposed
to perform a clean reboot instead of attempting to resume on a changed
platform.

Although these patches have a functional dependency, they could be merged
separately. The second patch just won't *see* a FACS table if the ACPICA
fix isn't present.

v2: Now that the ACPICA patch is merged upstream, note its commit ID

David Woodhouse (2):
ACPICA: Detect FACS even for hardware reduced platforms
arm64: acpi: Honour firmware_signature field of FACS, if it exists

arch/arm64/kernel/acpi.c | 10 ++++++++++
drivers/acpi/acpica/tbfadt.c | 30 +++++++++++++-----------------
drivers/acpi/acpica/tbutils.c | 7 +------
3 files changed, 24 insertions(+), 23 deletions(-)


2024-04-12 11:04:12

by David Woodhouse

[permalink] [raw]
Subject: [PATCH v2 2/2] arm64: acpi: Honour firmware_signature field of FACS, if it exists

From: David Woodhouse <[email protected]>

If the firmware_signature changes then OSPM should not attempt to resume
from hibernate, but should instead perform a clean reboot. Set the global
swsusp_hardware_signature to allow the generic code to include the value
in the swsusp header on disk, and perform the appropriate check on resume.

Signed-off-by: David Woodhouse <[email protected]>
Acked-by: Sudeep Holla <[email protected]>
---
arch/arm64/kernel/acpi.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index dba8fcec7f33..e0e7b93c16cc 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -26,6 +26,7 @@
#include <linux/libfdt.h>
#include <linux/smp.h>
#include <linux/serial_core.h>
+#include <linux/suspend.h>
#include <linux/pgtable.h>

#include <acpi/ghes.h>
@@ -227,6 +228,15 @@ void __init acpi_boot_table_init(void)
if (earlycon_acpi_spcr_enable)
early_init_dt_scan_chosen_stdout();
} else {
+#ifdef CONFIG_HIBERNATION
+ struct acpi_table_header *facs = NULL;
+ acpi_get_table(ACPI_SIG_FACS, 1, &facs);
+ if (facs) {
+ swsusp_hardware_signature =
+ ((struct acpi_table_facs *)facs)->hardware_signature;
+ acpi_put_table(facs);
+ }
+#endif
acpi_parse_spcr(earlycon_acpi_spcr_enable, true);
if (IS_ENABLED(CONFIG_ACPI_BGRT))
acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
--
2.44.0


2024-04-12 11:04:35

by David Woodhouse

[permalink] [raw]
Subject: [PATCH v2 1/2] ACPICA: Detect FACS even for hardware reduced platforms

From: David Woodhouse <[email protected]>

ACPICA commit 44fc328a1a14b097d92b8be83989e4bf69b6e6cb

The FACS is optional even on hardware reduced platforms, and may exist
for the purpose of communicating the hardware_signature field to provoke
a clean reboot instead of a resume from hibernation.

Signed-off-by: David Woodhouse <[email protected]>
---
drivers/acpi/acpica/tbfadt.c | 30 +++++++++++++-----------------
drivers/acpi/acpica/tbutils.c | 7 +------
2 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 44267a92bce5..3c126c6d306b 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -315,23 +315,19 @@ void acpi_tb_parse_fadt(void)
ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
NULL, FALSE, TRUE, &acpi_gbl_dsdt_index);

- /* If Hardware Reduced flag is set, there is no FACS */
-
- if (!acpi_gbl_reduced_hardware) {
- if (acpi_gbl_FADT.facs) {
- acpi_tb_install_standard_table((acpi_physical_address)
- acpi_gbl_FADT.facs,
- ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
- NULL, FALSE, TRUE,
- &acpi_gbl_facs_index);
- }
- if (acpi_gbl_FADT.Xfacs) {
- acpi_tb_install_standard_table((acpi_physical_address)
- acpi_gbl_FADT.Xfacs,
- ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
- NULL, FALSE, TRUE,
- &acpi_gbl_xfacs_index);
- }
+ if (acpi_gbl_FADT.facs) {
+ acpi_tb_install_standard_table((acpi_physical_address)
+ acpi_gbl_FADT.facs,
+ ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+ NULL, FALSE, TRUE,
+ &acpi_gbl_facs_index);
+ }
+ if (acpi_gbl_FADT.Xfacs) {
+ acpi_tb_install_standard_table((acpi_physical_address)
+ acpi_gbl_FADT.Xfacs,
+ ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+ NULL, FALSE, TRUE,
+ &acpi_gbl_xfacs_index);
}
}

diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index bb4a56e5673a..15fa68a5ea6e 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -36,12 +36,7 @@ acpi_status acpi_tb_initialize_facs(void)
{
struct acpi_table_facs *facs;

- /* If Hardware Reduced flag is set, there is no FACS */
-
- if (acpi_gbl_reduced_hardware) {
- acpi_gbl_FACS = NULL;
- return (AE_OK);
- } else if (acpi_gbl_FADT.Xfacs &&
+ if (acpi_gbl_FADT.Xfacs &&
(!acpi_gbl_FADT.facs
|| !acpi_gbl_use32_bit_facs_addresses)) {
(void)acpi_get_table_by_index(acpi_gbl_xfacs_index,
--
2.44.0


2024-04-12 14:05:29

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Support clean reboot after hibernate on Arm64

On Mon, Mar 11, 2024 at 12:19:14PM +0000, David Woodhouse wrote:
> When the hardware signature in the ACPI FACS changes, the OS is supposed
> to perform a clean reboot instead of attempting to resume on a changed
> platform.
>
> Although these patches have a functional dependency, they could be merged
> separately. The second patch just won't *see* a FACS table if the ACPICA
> fix isn't present.
>
> v2: Now that the ACPICA patch is merged upstream, note its commit ID
>
> David Woodhouse (2):
> ACPICA: Detect FACS even for hardware reduced platforms
> arm64: acpi: Honour firmware_signature field of FACS, if it exists
>
> arch/arm64/kernel/acpi.c | 10 ++++++++++
> drivers/acpi/acpica/tbfadt.c | 30 +++++++++++++-----------------
> drivers/acpi/acpica/tbutils.c | 7 +------

Rafael, how would you like the handle this series? The arm64 part has
been Acked-by Sudeep, so I'm happy with it.

Will

2024-04-12 14:18:47

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Support clean reboot after hibernate on Arm64

On Fri, 2024-04-12 at 15:05 +0100, Will Deacon wrote:
> On Mon, Mar 11, 2024 at 12:19:14PM +0000, David Woodhouse wrote:
> > When the hardware signature in the ACPI FACS changes, the OS is supposed
> > to perform a clean reboot instead of attempting to resume on a changed
> > platform.
> >
> > Although these patches have a functional dependency, they could be merged
> > separately. The second patch just won't *see* a FACS table if the ACPICA
> > fix isn't present.
> >
> > v2: Now that the ACPICA patch is merged upstream, note its commit ID
> >
> > David Woodhouse (2):
> >       ACPICA: Detect FACS even for hardware reduced platforms
> >       arm64: acpi: Honour firmware_signature field of FACS, if it exists
> >
> >  arch/arm64/kernel/acpi.c      | 10 ++++++++++
> >  drivers/acpi/acpica/tbfadt.c  | 30 +++++++++++++-----------------
> >  drivers/acpi/acpica/tbutils.c |  7 +------
>
> Rafael, how would you like the handle this series? The arm64 part has
> been Acked-by Sudeep, so I'm happy with it.

Thanks, Will.

Similar question for Rafael on the guest side of the PSCI SYSTEM_OFF2
series, in particular
https://lore.kernel.org/kvm/[email protected]/#Z31kernel:power:hibernate.c
which sets the entering_platform_hibernation flag around the call to
the standard kernel_power_off() function when invoking it for
HIBERNATION_SHUTDOWN.


Attachments:
smime.p7s (5.83 kB)

2024-04-12 19:25:22

by Wysocki, Rafael J

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Support clean reboot after hibernate on Arm64

On 4/12/2024 4:18 PM, David Woodhouse wrote:
> On Fri, 2024-04-12 at 15:05 +0100, Will Deacon wrote:
>> On Mon, Mar 11, 2024 at 12:19:14PM +0000, David Woodhouse wrote:
>>> When the hardware signature in the ACPI FACS changes, the OS is supposed
>>> to perform a clean reboot instead of attempting to resume on a changed
>>> platform.
>>>
>>> Although these patches have a functional dependency, they could be merged
>>> separately. The second patch just won't *see* a FACS table if the ACPICA
>>> fix isn't present.
>>>
>>> v2: Now that the ACPICA patch is merged upstream, note its commit ID
>>>
>>> David Woodhouse (2):
>>>       ACPICA: Detect FACS even for hardware reduced platforms
>>>       arm64: acpi: Honour firmware_signature field of FACS, if it exists
>>>
>>>  arch/arm64/kernel/acpi.c      | 10 ++++++++++
>>>  drivers/acpi/acpica/tbfadt.c  | 30 +++++++++++++-----------------
>>>  drivers/acpi/acpica/tbutils.c |  7 +------
>> Rafael, how would you like the handle this series? The arm64 part has
>> been Acked-by Sudeep, so I'm happy with it.
> Thanks, Will.
>
> Similar question for Rafael on the guest side of the PSCI SYSTEM_OFF2
> series, in particular
> https://lore.kernel.org/kvm/[email protected]/#Z31kernel:power:hibernate.c
> which sets the entering_platform_hibernation flag around the call to
> the standard kernel_power_off() function when invoking it for
> HIBERNATION_SHUTDOWN.

In both cases, please feel free to route the patches as it is convenient
and add

Acked-by: Rafael J. Wysocki <[email protected]>

to both of them.



2024-04-19 15:33:47

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Support clean reboot after hibernate on Arm64

On Mon, 11 Mar 2024 12:19:14 +0000, David Woodhouse wrote:
> When the hardware signature in the ACPI FACS changes, the OS is supposed
> to perform a clean reboot instead of attempting to resume on a changed
> platform.
>
> Although these patches have a functional dependency, they could be merged
> separately. The second patch just won't *see* a FACS table if the ACPICA
> fix isn't present.
>
> [...]

Applied to arm64 (for-next/acpi), thanks!

[1/2] ACPICA: Detect FACS even for hardware reduced platforms
https://git.kernel.org/arm64/c/bc5b492ac305
[2/2] arm64: acpi: Honour firmware_signature field of FACS, if it exists
https://git.kernel.org/arm64/c/fbaad243b536

Cheers,
--
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

2024-04-19 15:40:09

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Support clean reboot after hibernate on Arm64

On Fri, 2024-04-19 at 16:32 +0100, Will Deacon wrote:
> On Mon, 11 Mar 2024 12:19:14 +0000, David Woodhouse wrote:
> > When the hardware signature in the ACPI FACS changes, the OS is supposed
> > to perform a clean reboot instead of attempting to resume on a changed
> > platform.
> >
> > Although these patches have a functional dependency, they could be merged
> > separately. The second patch just won't *see* a FACS table if the ACPICA
> > fix isn't present.
> >
> > [...]
>
> Applied to arm64 (for-next/acpi), thanks!
>
> [1/2] ACPICA: Detect FACS even for hardware reduced platforms
>       https://git.kernel.org/arm64/c/bc5b492ac305
> [2/2] arm64: acpi: Honour firmware_signature field of FACS, if it exists
>       https://git.kernel.org/arm64/c/fbaad243b536

Thanks. I've rebased the remaining SYSTEM_OFF2 patches on top of that:
https://git.infradead.org/users/dwmw2/linux.git/shortlog/refs/heads/psci-hibernate

I've added Rafael's Acked-by: to the last commit in that series too.

Will repost them when the final version of the PSCI 1.3 spec is published.


Attachments:
smime.p7s (5.83 kB)