mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
tcg: Introduce target-specific page data for user-only
This data can be allocated by page_alloc_target_data() and released by page_set_flags(start, end, prot | PAGE_RESET). This data will be used to hold tag memory for AArch64 MTE. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210212184902.1251044-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
8ba4bca570
commit
d9c5858570
4 changed files with 69 additions and 9 deletions
|
@ -114,6 +114,7 @@ typedef struct PageDesc {
|
|||
unsigned int code_write_count;
|
||||
#else
|
||||
unsigned long flags;
|
||||
void *target_data;
|
||||
#endif
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
QemuSpin lock;
|
||||
|
@ -2740,6 +2741,7 @@ int page_get_flags(target_ulong address)
|
|||
void page_set_flags(target_ulong start, target_ulong end, int flags)
|
||||
{
|
||||
target_ulong addr, len;
|
||||
bool reset_target_data;
|
||||
|
||||
/* This function should never be called with addresses outside the
|
||||
guest address space. If this assert fires, it probably indicates
|
||||
|
@ -2754,6 +2756,8 @@ void page_set_flags(target_ulong start, target_ulong end, int flags)
|
|||
if (flags & PAGE_WRITE) {
|
||||
flags |= PAGE_WRITE_ORG;
|
||||
}
|
||||
reset_target_data = !(flags & PAGE_VALID) || (flags & PAGE_RESET);
|
||||
flags &= ~PAGE_RESET;
|
||||
|
||||
for (addr = start, len = end - start;
|
||||
len != 0;
|
||||
|
@ -2767,10 +2771,34 @@ void page_set_flags(target_ulong start, target_ulong end, int flags)
|
|||
p->first_tb) {
|
||||
tb_invalidate_phys_page(addr, 0);
|
||||
}
|
||||
if (reset_target_data && p->target_data) {
|
||||
g_free(p->target_data);
|
||||
p->target_data = NULL;
|
||||
}
|
||||
p->flags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
void *page_get_target_data(target_ulong address)
|
||||
{
|
||||
PageDesc *p = page_find(address >> TARGET_PAGE_BITS);
|
||||
return p ? p->target_data : NULL;
|
||||
}
|
||||
|
||||
void *page_alloc_target_data(target_ulong address, size_t size)
|
||||
{
|
||||
PageDesc *p = page_find(address >> TARGET_PAGE_BITS);
|
||||
void *ret = NULL;
|
||||
|
||||
if (p->flags & PAGE_VALID) {
|
||||
ret = p->target_data;
|
||||
if (!ret) {
|
||||
p->target_data = ret = g_malloc0(size);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int page_check_range(target_ulong start, target_ulong len, int flags)
|
||||
{
|
||||
PageDesc *p;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue