linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] x86/acpi: Preserve ACPI-table override during hibernation
@ 2022-03-29 13:33 Amadeusz Sławiński
  2022-04-13 15:02 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Amadeusz Sławiński @ 2022-03-29 13:33 UTC (permalink / raw)
  To: x86, Rafael J . Wysocki, Len Brown, Pavel Machek,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin
  Cc: Cezary Rojewski, linux-pm, linux-kernel, Amadeusz Sławiński

When overriding NHLT ACPI-table tests show that on some platforms
there is problem that NHLT contains garbage after hibernation/resume
cycle.

Problem stems from the fact that ACPI override performs early memory
allocation using memblock_phys_alloc_range() in
memblock_phys_alloc_range(). This memory block is later being marked as
ACPI memory block in arch_reserve_mem_area(). Later when memory areas
are considered for hibernation it is being marked as nosave in
e820__register_nosave_regions().

Fix this by marking ACPI override memory area as ACPI NVS
(Non-Volatile-Sleeping), which according to specification needs to be
saved on entering S4 and restored when leaving and is implemented as
such in kernel.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
---

Changes in v2:
 * Changed approach as method used in v1 introduced potential for memory
   corruption, which was caught by tests.
 * Adjusted commit message describing above change in approach.

---
 arch/x86/kernel/acpi/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 0d01e7f5078c..2eeca97b730b 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1772,7 +1772,7 @@ int __acpi_release_global_lock(unsigned int *lock)
 
 void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
 {
-	e820__range_add(addr, size, E820_TYPE_ACPI);
+	e820__range_add(addr, size, E820_TYPE_NVS);
 	e820__update_table_print();
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/acpi: Preserve ACPI-table override during hibernation
  2022-03-29 13:33 [PATCH v2] x86/acpi: Preserve ACPI-table override during hibernation Amadeusz Sławiński
@ 2022-04-13 15:02 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2022-04-13 15:02 UTC (permalink / raw)
  To: Amadeusz Sławiński
  Cc: the arch/x86 maintainers, Rafael J . Wysocki, Len Brown,
	Pavel Machek, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H . Peter Anvin, Cezary Rojewski, Linux PM,
	Linux Kernel Mailing List

On Tue, Mar 29, 2022 at 3:34 PM Amadeusz Sławiński
<amadeuszx.slawinski@linux.intel.com> wrote:
>
> When overriding NHLT ACPI-table tests show that on some platforms
> there is problem that NHLT contains garbage after hibernation/resume
> cycle.
>
> Problem stems from the fact that ACPI override performs early memory
> allocation using memblock_phys_alloc_range() in
> memblock_phys_alloc_range(). This memory block is later being marked as
> ACPI memory block in arch_reserve_mem_area(). Later when memory areas
> are considered for hibernation it is being marked as nosave in
> e820__register_nosave_regions().
>
> Fix this by marking ACPI override memory area as ACPI NVS
> (Non-Volatile-Sleeping), which according to specification needs to be
> saved on entering S4 and restored when leaving and is implemented as
> such in kernel.
>
> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
> ---
>
> Changes in v2:
>  * Changed approach as method used in v1 introduced potential for memory
>    corruption, which was caught by tests.
>  * Adjusted commit message describing above change in approach.
>
> ---
>  arch/x86/kernel/acpi/boot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 0d01e7f5078c..2eeca97b730b 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -1772,7 +1772,7 @@ int __acpi_release_global_lock(unsigned int *lock)
>
>  void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
>  {
> -       e820__range_add(addr, size, E820_TYPE_ACPI);
> +       e820__range_add(addr, size, E820_TYPE_NVS);
>         e820__update_table_print();
>  }
>
> --

Given the lack of objections or concerns, applied as 5.19 material, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-13 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 13:33 [PATCH v2] x86/acpi: Preserve ACPI-table override during hibernation Amadeusz Sławiński
2022-04-13 15:02 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).