aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2025-04-23 16:04:10 +0800
committerSong Gao <gaosong@loongson.cn>2025-04-24 09:59:23 +0800
commita8d1b5bca5d234bfeaf215c079696735e5aafe71 (patch)
treea6261b5ca3691e1816a22150c4c6318a55d9fcb8
parent4ac7eecb7439f6a978b44a0504a446c95f1bcc76 (diff)
downloadqemu-a8d1b5bca5d234bfeaf215c079696735e5aafe71.zip
qemu-a8d1b5bca5d234bfeaf215c079696735e5aafe71.tar.gz
qemu-a8d1b5bca5d234bfeaf215c079696735e5aafe71.tar.bz2
target/loongarch: Add function loongarch_get_addr_from_tlb
Function loongarch_get_addr_from_tlb() is added to get physical address from TLB tables. TLB table only works in TCG mode, in future this function will be moved to TCG directory. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20250423080417.3739809-3-maobibo@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
-rw-r--r--target/loongarch/cpu_helper.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/target/loongarch/cpu_helper.c b/target/loongarch/cpu_helper.c
index 930466c..a326859 100644
--- a/target/loongarch/cpu_helper.c
+++ b/target/loongarch/cpu_helper.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "system/tcg.h"
#include "cpu.h"
#include "internals.h"
#include "cpu-csr.h"
@@ -141,6 +142,21 @@ bool loongarch_tlb_search(CPULoongArchState *env, target_ulong vaddr,
return false;
}
+static int loongarch_get_addr_from_tlb(CPULoongArchState *env, hwaddr *physical,
+ int *prot, target_ulong address,
+ MMUAccessType access_type, int mmu_idx)
+{
+ int index, match;
+
+ match = loongarch_tlb_search(env, address, &index);
+ if (match) {
+ return loongarch_map_tlb_entry(env, physical, prot,
+ address, access_type, index, mmu_idx);
+ }
+
+ return TLBRET_NOMATCH;
+}
+
static int loongarch_page_table_walker(CPULoongArchState *env, hwaddr *physical,
int *prot, target_ulong address)
{
@@ -221,13 +237,17 @@ static int loongarch_map_address(CPULoongArchState *env, hwaddr *physical,
MMUAccessType access_type, int mmu_idx,
int is_debug)
{
- int index, match;
+ int ret;
- match = loongarch_tlb_search(env, address, &index);
- if (match) {
- return loongarch_map_tlb_entry(env, physical, prot,
- address, access_type, index, mmu_idx);
- } else if (is_debug) {
+ if (tcg_enabled()) {
+ ret = loongarch_get_addr_from_tlb(env, physical, prot, address,
+ access_type, mmu_idx);
+ if (ret != TLBRET_NOMATCH) {
+ return ret;
+ }
+ }
+
+ if (is_debug) {
/*
* For debugger memory access, we want to do the map when there is a
* legal mapping, even if the mapping is not yet in TLB. return 0 if