mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-24 02:21:52 -06:00
accel/tcg: Move TARGET_TAGGED_ADDRESSES to TCGCPUOps.untagged_addr
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
7804c84a56
commit
2c0b261fcd
5 changed files with 40 additions and 41 deletions
|
@ -157,6 +157,13 @@ struct TCGCPUOps {
|
||||||
*/
|
*/
|
||||||
void (*record_sigbus)(CPUState *cpu, vaddr addr,
|
void (*record_sigbus)(CPUState *cpu, vaddr addr,
|
||||||
MMUAccessType access_type, uintptr_t ra);
|
MMUAccessType access_type, uintptr_t ra);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* untagged_addr: Remove an ignored tag from an address
|
||||||
|
* @cpu: cpu context
|
||||||
|
* @addr: tagged guest address
|
||||||
|
*/
|
||||||
|
vaddr (*untagged_addr)(CPUState *cs, vaddr addr);
|
||||||
#else
|
#else
|
||||||
/** @do_interrupt: Callback for interrupt handling. */
|
/** @do_interrupt: Callback for interrupt handling. */
|
||||||
void (*do_interrupt)(CPUState *cpu);
|
void (*do_interrupt)(CPUState *cpu);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#include "exec/vaddr.h"
|
#include "exec/vaddr.h"
|
||||||
#include "user/guest-base.h"
|
#include "user/guest-base.h"
|
||||||
#include "cpu.h"
|
#include "accel/tcg/cpu-ops.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If non-zero, the guest virtual address space is a contiguous subset
|
* If non-zero, the guest virtual address space is a contiguous subset
|
||||||
|
@ -29,12 +29,14 @@ extern unsigned long reserved_va;
|
||||||
*/
|
*/
|
||||||
extern unsigned long guest_addr_max;
|
extern unsigned long guest_addr_max;
|
||||||
|
|
||||||
#ifndef TARGET_TAGGED_ADDRESSES
|
|
||||||
static inline vaddr cpu_untagged_addr(CPUState *cs, vaddr x)
|
static inline vaddr cpu_untagged_addr(CPUState *cs, vaddr x)
|
||||||
{
|
{
|
||||||
|
const TCGCPUOps *tcg_ops = cs->cc->tcg_ops;
|
||||||
|
if (tcg_ops->untagged_addr) {
|
||||||
|
return tcg_ops->untagged_addr(cs, x);
|
||||||
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* All direct uses of g2h and h2g need to go away for usermode softmmu. */
|
/* All direct uses of g2h and h2g need to go away for usermode softmmu. */
|
||||||
static inline void *g2h_untagged(vaddr x)
|
static inline void *g2h_untagged(vaddr x)
|
||||||
|
|
|
@ -17,14 +17,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
# ifdef TARGET_AARCH64
|
# if defined(TARGET_AARCH64) && defined(CONFIG_LINUX)
|
||||||
# define TARGET_TAGGED_ADDRESSES
|
|
||||||
# ifdef __FreeBSD__
|
|
||||||
# define TARGET_PAGE_BITS 12
|
|
||||||
# else
|
|
||||||
/* Allow user-only to vary page size from 4k */
|
/* Allow user-only to vary page size from 4k */
|
||||||
# define TARGET_PAGE_BITS_VARY
|
# define TARGET_PAGE_BITS_VARY
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define TARGET_PAGE_BITS 12
|
# define TARGET_PAGE_BITS 12
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -2671,7 +2671,31 @@ static const char *arm_gdb_get_core_xml_file(CPUState *cs)
|
||||||
return "arm-core.xml";
|
return "arm-core.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
|
/**
|
||||||
|
* aarch64_untagged_addr:
|
||||||
|
*
|
||||||
|
* Remove any address tag from @x. This is explicitly related to the
|
||||||
|
* linux syscall TIF_TAGGED_ADDR setting, not TBI in general.
|
||||||
|
*
|
||||||
|
* There should be a better place to put this, but we need this in
|
||||||
|
* include/exec/cpu_ldst.h, and not some place linux-user specific.
|
||||||
|
*
|
||||||
|
* Note that arm-*-user will never set tagged_addr_enable.
|
||||||
|
*/
|
||||||
|
static vaddr aarch64_untagged_addr(CPUState *cs, vaddr x)
|
||||||
|
{
|
||||||
|
CPUARMState *env = cpu_env(cs);
|
||||||
|
if (env->tagged_addr_enable) {
|
||||||
|
/*
|
||||||
|
* TBI is enabled for userspace but not kernelspace addresses.
|
||||||
|
* Only clear the tag if bit 55 is clear.
|
||||||
|
*/
|
||||||
|
x &= sextract64(x, 0, 56);
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
#else
|
||||||
#include "hw/core/sysemu-cpu-ops.h"
|
#include "hw/core/sysemu-cpu-ops.h"
|
||||||
|
|
||||||
static const struct SysemuCPUOps arm_sysemu_ops = {
|
static const struct SysemuCPUOps arm_sysemu_ops = {
|
||||||
|
@ -2702,6 +2726,7 @@ static const TCGCPUOps arm_tcg_ops = {
|
||||||
#ifdef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
.record_sigsegv = arm_cpu_record_sigsegv,
|
.record_sigsegv = arm_cpu_record_sigsegv,
|
||||||
.record_sigbus = arm_cpu_record_sigbus,
|
.record_sigbus = arm_cpu_record_sigbus,
|
||||||
|
.untagged_addr = aarch64_untagged_addr,
|
||||||
#else
|
#else
|
||||||
.tlb_fill_align = arm_cpu_tlb_fill_align,
|
.tlb_fill_align = arm_cpu_tlb_fill_align,
|
||||||
.cpu_exec_interrupt = arm_cpu_exec_interrupt,
|
.cpu_exec_interrupt = arm_cpu_exec_interrupt,
|
||||||
|
|
|
@ -783,12 +783,9 @@ typedef struct CPUArchState {
|
||||||
#else /* CONFIG_USER_ONLY */
|
#else /* CONFIG_USER_ONLY */
|
||||||
/* For usermode syscall translation. */
|
/* For usermode syscall translation. */
|
||||||
bool eabi;
|
bool eabi;
|
||||||
#endif /* CONFIG_USER_ONLY */
|
|
||||||
|
|
||||||
#ifdef TARGET_TAGGED_ADDRESSES
|
|
||||||
/* Linux syscall tagged address support */
|
/* Linux syscall tagged address support */
|
||||||
bool tagged_addr_enable;
|
bool tagged_addr_enable;
|
||||||
#endif
|
#endif /* CONFIG_USER_ONLY */
|
||||||
} CPUARMState;
|
} CPUARMState;
|
||||||
|
|
||||||
static inline void set_feature(CPUARMState *env, int feature)
|
static inline void set_feature(CPUARMState *env, int feature)
|
||||||
|
@ -3217,34 +3214,7 @@ extern const uint64_t pred_esz_masks[5];
|
||||||
#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)
|
#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)
|
||||||
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
|
|
||||||
#define TARGET_PAGE_DATA_SIZE (TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1))
|
#define TARGET_PAGE_DATA_SIZE (TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1))
|
||||||
|
|
||||||
#ifdef TARGET_TAGGED_ADDRESSES
|
|
||||||
/**
|
|
||||||
* cpu_untagged_addr:
|
|
||||||
* @cs: CPU context
|
|
||||||
* @x: tagged address
|
|
||||||
*
|
|
||||||
* Remove any address tag from @x. This is explicitly related to the
|
|
||||||
* linux syscall TIF_TAGGED_ADDR setting, not TBI in general.
|
|
||||||
*
|
|
||||||
* There should be a better place to put this, but we need this in
|
|
||||||
* include/exec/cpu_ldst.h, and not some place linux-user specific.
|
|
||||||
*/
|
|
||||||
static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x)
|
|
||||||
{
|
|
||||||
CPUARMState *env = cpu_env(cs);
|
|
||||||
if (env->tagged_addr_enable) {
|
|
||||||
/*
|
|
||||||
* TBI is enabled for userspace but not kernelspace addresses.
|
|
||||||
* Only clear the tag if bit 55 is clear.
|
|
||||||
*/
|
|
||||||
x &= sextract64(x, 0, 56);
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
#endif /* TARGET_TAGGED_ADDRESSES */
|
|
||||||
#endif /* CONFIG_USER_ONLY */
|
#endif /* CONFIG_USER_ONLY */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue