Skip to content

Commit

Permalink
Hardware: Do not flush CPU cache when entering S4 and S5
Browse files Browse the repository at this point in the history
According to ACPI 6.4, Section 16.2, the CPU cache flushing is
required on entering to S1, S2, and S3, but the ACPICA code
flushes the CPU cache regardless of the sleep state.

Blind cache flush on entering S5 causes problems for TDX.

Flushing happens with WBINVD that is not supported in the TDX
environment.

TDX only supports S5 and adjusting ACPICA code to conform to the
spec more strictly fixes the issue.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
kiryl authored and rafaeljw committed Dec 8, 2021
1 parent e6a3723 commit 3dd7e1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion source/components/hardware/hwesleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ AcpiHwExtendedSleep (

/* Flush caches, as per ACPI specification */

ACPI_FLUSH_CPU_CACHE ();
if (SleepState < ACPI_STATE_S4)
{
ACPI_FLUSH_CPU_CACHE ();
}

Status = AcpiOsEnterSleep (SleepState, SleepControl, 0);
if (Status == AE_CTRL_TERMINATE)
Expand Down
5 changes: 4 additions & 1 deletion source/components/hardware/hwsleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ AcpiHwLegacySleep (

/* Flush caches, as per ACPI specification */

ACPI_FLUSH_CPU_CACHE ();
if (SleepState < ACPI_STATE_S4)
{
ACPI_FLUSH_CPU_CACHE ();
}

Status = AcpiOsEnterSleep (SleepState, Pm1aControl, Pm1bControl);
if (Status == AE_CTRL_TERMINATE)
Expand Down
2 changes: 0 additions & 2 deletions source/components/hardware/hwxfsleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ AcpiEnterSleepStateS4bios (
return_ACPI_STATUS (Status);
}

ACPI_FLUSH_CPU_CACHE ();

Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
(UINT32) AcpiGbl_FADT.S4BiosRequest, 8);
if (ACPI_FAILURE (Status))
Expand Down

0 comments on commit 3dd7e1f

Please sign in to comment.