arch/intel64: add cache support

Add dcache and icache support for intel64

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
p-szafonimateusz
2024-04-03 11:52:56 +02:00
committed by Petro Karashchenko
parent 30226901c0
commit 530f5cd324
7 changed files with 674 additions and 11 deletions
+2
View File
@@ -30,6 +30,8 @@ config ARCH_INTEL64
select ARCH_HAVE_SSE41
select ARCH_HAVE_SSE42
select ARCH_HAVE_SSE4A
select ARCH_ICACHE
select ARCH_DCACHE
---help---
Intel x86_64 architecture
+25 -8
View File
@@ -135,14 +135,31 @@
/* CPUID Leaf Definitions */
#define X86_64_CPUID_CAP 0x01
# define X86_64_CPUID_01_SSE3 (1 << 0)
# define X86_64_CPUID_01_PCID (1 << 17)
# define X86_64_CPUID_01_X2APIC (1 << 21)
# define X86_64_CPUID_01_TSCDEA (1 << 24)
# define X86_64_CPUID_01_XSAVE (1 << 26)
# define X86_64_CPUID_01_RDRAND (1 << 30)
#define X86_64_CPUID_TSC 0x15
#define X86_64_CPUID_VENDOR 0x00
#define X86_64_CPUID_CAP 0x01
# define X86_64_CPUID_01_SSE3 (1 << 0)
# define X86_64_CPUID_01_SSSE3 (1 << 9)
# define X86_64_CPUID_01_PCID (1 << 17)
# define X86_64_CPUID_01_SSE41 (1 << 19)
# define X86_64_CPUID_01_SSE42 (1 << 20)
# define X86_64_CPUID_01_X2APIC (1 << 21)
# define X86_64_CPUID_01_TSCDEA (1 << 24)
# define X86_64_CPUID_01_XSAVE (1 << 26)
# define X86_64_CPUID_01_RDRAND (1 << 30)
# define X86_64_CPUID_01_APICID(ebx) ((ebx) >> 24)
#define X86_64_CPUID_EXTCAP 0x07
# define X86_64_CPUID_07_AVX2 (1 << 5)
# define X86_64_CPUID_07_AVX512F (1 << 16)
# define X86_64_CPUID_07_AVX512DQ (1 << 17)
# define X86_64_CPUID_07_SMAP (1 << 20)
# define X86_64_CPUID_07_AVX512IFMA (1 << 21)
# define X86_64_CPUID_07_CLWB (1 << 24)
# define X86_64_CPUID_07_AVX512PF (1 << 26)
# define X86_64_CPUID_07_AVX512ER (1 << 27)
# define X86_64_CPUID_07_AVX512CD (1 << 28)
# define X86_64_CPUID_07_AVX512BW (1 << 30)
# define X86_64_CPUID_07_AVX512VL (1 << 31)
#define X86_64_CPUID_TSC 0x15
/* MSR Definitions */
+1
View File
@@ -38,6 +38,7 @@ set(SRCS
intel64_usestack.c
intel64_systemreset.c
intel64_freq.c
intel64_cache.c
intel64_start.c
intel64_handlers.c
intel64_idle.c
+28
View File
@@ -21,6 +21,34 @@ endchoice # "Intel64 Chip Selection"
config ARCH_INTEL64_HAVE_TSC
bool
config ARCH_INTEL64_CACHE_LINESIZE
int "Cache line size (hardcoded)"
depends on ARCH_DCACHE || ARCH_ICACHE
default 64
---help---
Cache line size. If set to 0, we read the value from CPUID,
(Probably) all new Intel CPUs have this value equal to 64.
config ARCH_INTEL64_DCACHE_SIZE
int "Data cache line size (L1d)"
depends on ARCH_DCACHE
default 0
---help---
Data cache line size (L1d). If set to 0, we read the value from CPUID.
config ARCH_INTEL64_ICACHE_SIZE
int "Instruction cache line size (L1i)"
depends on ARCH_ICACHE
default 0
---help---
Instruction cache line size (L1i). If set to 0, we read the value from CPUID.
config ARCH_INTEL64_HAVE_CLWB
bool "CLWB support"
default n
---help---
Select to enable the use of CLWB to write back cache line
choice
prompt "System Timer Source"
default ARCH_INTEL64_TSC_DEADLINE
+1 -1
View File
@@ -25,7 +25,7 @@ CMN_CSRCS += intel64_map_region.c intel64_regdump.c intel64_releasestack.c
CMN_CSRCS += intel64_rtc.c intel64_restore_auxstate.c intel64_savestate.c
CMN_CSRCS += intel64_stackframe.c intel64_schedulesigaction.c
CMN_CSRCS += intel64_sigdeliver.c intel64_usestack.c x86_64_tcbinfo.c
CMN_CSRCS += intel64_systemreset.c intel64_freq.c
CMN_CSRCS += intel64_systemreset.c intel64_freq.c intel64_cache.c
# Required Intel64 files
File diff suppressed because it is too large Load Diff
@@ -56,6 +56,7 @@
void x86_64_check_and_enable_capability(void)
{
unsigned long ebx;
unsigned long ecx;
unsigned long require;
@@ -80,15 +81,33 @@ void x86_64_check_and_enable_capability(void)
#endif
asm volatile("cpuid" : "=c" (ecx) : "a" (X86_64_CPUID_CAP)
: "rbx", "rdx", "memory");
: "rdx", "memory");
/* Check x2APIC availability */
/* Check features availability from ECX */
if ((ecx & require) != require)
{
goto err;
}
/* Extended features */
require = 0;
#ifdef CONFIG_ARCH_INTEL64_HAVE_CLWB
require |= X86_64_CPUID_07_CLWB;
#endif
asm volatile("cpuid" : "=b" (ebx) : "a" (X86_64_CPUID_EXTCAP), "c" (0)
: "rdx", "memory");
/* Check features availability */
if ((ebx & require) != require)
{
goto err;
}
#ifdef CONFIG_ARCH_INTEL64_HAVE_XSAVE
__enable_sse_avx();
#endif
@@ -97,6 +116,11 @@ void x86_64_check_and_enable_capability(void)
__enable_pcid();
#endif
/* Enable I- and D-Caches */
up_enable_icache();
up_enable_dcache();
return;
err: