Skip to content

Commit 6fd397e

Browse files
yliu80acrnsi
authored andcommitted
HV: Add CLFLUSHOPT instruction.
CLFLUSHOPT is used to invalidate from every level of the cache hierarchy in the cache coherence domain the cache line that contains the linear address specified with memory operand. If that cache line contains modified date at any level of the cache hierarchy, that data is written back to memory. If the platform does not support CLFLUSHOPT instruction, boot will fail. Signed-off-by: Jack Ren <jack.ren@intel.com> Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent d0e0871 commit 6fd397e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

hypervisor/arch/x86/cpu_caps.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ int32_t detect_hardware_support(void)
386386
} else if (!pcpu_has_cap(X86_FEATURE_MTRR)) {
387387
pr_fatal("%s, MTRR not supported\n", __func__);
388388
ret = -ENODEV;
389+
} else if (!pcpu_has_cap(X86_FEATURE_CLFLUSHOPT)) {
390+
pr_fatal("%s, CLFLUSHOPT not supported\n", __func__);
391+
ret = -ENODEV;
389392
} else if (!pcpu_has_cap(X86_FEATURE_PAGE1GB)) {
390393
pr_fatal("%s, not support 1GB page\n", __func__);
391394
ret = -ENODEV;

hypervisor/include/arch/x86/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define X86_FEATURE_INVPCID ((FEAT_7_0_EBX << 5U) + 10U)
7777
#define X86_FEATURE_CAT ((FEAT_7_0_EBX << 5U) + 15U)
7878
#define X86_FEATURE_SMAP ((FEAT_7_0_EBX << 5U) + 20U)
79+
#define X86_FEATURE_CLFLUSHOPT ((FEAT_7_0_EBX << 5U) + 23U)
7980

8081
/* Intel-defined CPU features, CPUID level 0x00000007 (EDX)*/
8182
#define X86_FEATURE_IBRS_IBPB ((FEAT_7_0_EDX << 5U) + 26U)

hypervisor/include/arch/x86/mmu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ static inline void clflush(volatile void *p)
169169
asm volatile ("clflush (%0)" :: "r"(p));
170170
}
171171

172+
static inline void clflushopt(volatile void *p)
173+
{
174+
asm volatile ("clflushopt (%0)" :: "r"(p));
175+
}
176+
172177
/* get PDPT address from CR3 vaule in PAE mode */
173178
static inline uint64_t get_pae_pdpt_addr(uint64_t cr3)
174179
{

0 commit comments

Comments
 (0)