hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/acenv.h
....@@ -1,12 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * X86 specific ACPICA environments and implementation
34 *
45 * Copyright (C) 2014, Intel Corporation
56 * Author: Lv Zheng <lv.zheng@intel.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #ifndef _ASM_X86_ACENV_H
....@@ -16,7 +13,19 @@
1613
1714 /* Asm macros */
1815
19
-#define ACPI_FLUSH_CPU_CACHE() wbinvd()
16
+/*
17
+ * ACPI_FLUSH_CPU_CACHE() flushes caches on entering sleep states.
18
+ * It is required to prevent data loss.
19
+ *
20
+ * While running inside virtual machine, the kernel can bypass cache flushing.
21
+ * Changing sleep state in a virtual machine doesn't affect the host system
22
+ * sleep state and cannot lead to data loss.
23
+ */
24
+#define ACPI_FLUSH_CPU_CACHE() \
25
+do { \
26
+ if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) \
27
+ wbinvd(); \
28
+} while (0)
2029
2130 int __acpi_acquire_global_lock(unsigned int *lock);
2231 int __acpi_release_global_lock(unsigned int *lock);