From 1ae8e5f53ae0563d4145b4364c89dd4a82a071de Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Fri, 12 Jul 2024 12:14:42 +0300 Subject: [PATCH] e2k: disable probe page cache by default --- linux-user/e2k/cpu_loop.c | 4 +++- target/e2k/cpu.c | 1 + target/e2k/cpu.h | 3 +++ target/e2k/helper_sm.c | 13 +++++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux-user/e2k/cpu_loop.c b/linux-user/e2k/cpu_loop.c index d3bf98b027..60b0a65fd6 100644 --- a/linux-user/e2k/cpu_loop.c +++ b/linux-user/e2k/cpu_loop.c @@ -130,7 +130,9 @@ void cpu_loop(CPUE2KState *env) } if (ret == 0) { - e2k_clear_probe_page_cache(num); + if (env->enable_pagecache) { + e2k_clear_probe_page_cache(num); + } ret = do_syscall(env, num, args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); } diff --git a/target/e2k/cpu.c b/target/e2k/cpu.c index 2e935cdf44..1e8a40b689 100644 --- a/target/e2k/cpu.c +++ b/target/e2k/cpu.c @@ -262,6 +262,7 @@ static struct TCGCPUOps e2k_tcg_ops = { static Property e2k_cpu_properties[] = { DEFINE_PROP_BOOL("force_save_alc_dst", E2KCPU, env.force_save_alc_dst, false), DEFINE_PROP_BOOL("tags", E2KCPU, env.enable_tags, false), + DEFINE_PROP_BOOL("pagecache", E2KCPU, env.enable_pagecache, false), DEFINE_PROP_END_OF_LIST() }; diff --git a/target/e2k/cpu.h b/target/e2k/cpu.h index 93977e0bed..d78e4ba039 100644 --- a/target/e2k/cpu.h +++ b/target/e2k/cpu.h @@ -936,6 +936,9 @@ typedef struct CPUArchState { /* Enable tags handling. * Default: false */ bool enable_tags; + /* Enable page cache for speculative memory accesses. + * Default: false */ + bool enable_pagecache; struct e2k_def_t def; diff --git a/target/e2k/helper_sm.c b/target/e2k/helper_sm.c index 81793f82af..52d86fafeb 100644 --- a/target/e2k/helper_sm.c +++ b/target/e2k/helper_sm.c @@ -20,15 +20,20 @@ static bool e2k_probe_access_cached(CPUE2KState *env, target_ulong page, int flags) { int index = (page >> TARGET_PAGE_BITS) & (TARGET_PROBE_CACHE_SIZE - 1); + uint8_t page_flags; - if (env->probe_cache_page[index] == page) { + if (env->enable_pagecache && env->probe_cache_page[index] == page) { return (env->probe_cache_flags[index] & flags) == flags; } - env->probe_cache_page[index] = page; - env->probe_cache_flags[index] = page_get_flags(page); + page_flags = page_get_flags(page); - return (env->probe_cache_flags[index] & flags) == flags; + if (env->enable_pagecache) { + env->probe_cache_page[index] = page; + env->probe_cache_flags[index] = page_flags; + } + + return (page_flags & flags) == flags; } static bool e2k_probe_access(CPUE2KState *env, target_ulong addr, int size, int flags)