@@ -2402,6 +2402,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
}
}
+ /* For MemTxAttrs. */
+ env->requester_id = cpu->requester_id;
+
qemu_init_vcpu(cs);
cpu_reset(cs);
@@ -2439,6 +2442,7 @@ static Property arm_cpu_properties[] = {
mp_affinity, ARM64_AFFINITY_INVALID),
DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID),
DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1),
+ DEFINE_PROP_UINT16("requester-id", ARMCPU, requester_id, 0),
DEFINE_PROP_END_OF_LIST()
};
@@ -774,6 +774,9 @@ typedef struct CPUArchState {
/* Linux syscall tagged address support */
bool tagged_addr_enable;
#endif
+
+ /* For MemTxAttrs. */
+ uint16_t requester_id;
} CPUARMState;
static inline void set_feature(CPUARMState *env, int feature)
@@ -1091,6 +1094,9 @@ struct ArchCPU {
/* Generic timer counter frequency, in Hz */
uint64_t gt_cntfrq_hz;
+
+ /* Requester ID, used in MemTxAttrs. */
+ uint16_t requester_id;
};
typedef struct ARMCPUInfo {
@@ -287,6 +287,7 @@ static bool granule_protection_check(CPUARMState *env, uint64_t paddress,
MemTxAttrs attrs = {
.secure = true,
.space = ARMSS_Root,
+ .requester_id = env->requester_id,
};
ARMCPU *cpu = env_archcpu(env);
uint64_t gpccr = env->cp15.gpccr_el3;
@@ -638,6 +639,7 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw,
MemTxAttrs attrs = {
.space = ptw->out_space,
.secure = arm_space_is_secure(ptw->out_space),
+ .requester_id = env->requester_id,
};
AddressSpace *as = arm_addressspace(cs, attrs);
MemTxResult result = MEMTX_OK;
@@ -684,6 +686,7 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
MemTxAttrs attrs = {
.space = ptw->out_space,
.secure = arm_space_is_secure(ptw->out_space),
+ .requester_id = env->requester_id,
};
AddressSpace *as = arm_addressspace(cs, attrs);
MemTxResult result = MEMTX_OK;
@@ -3306,6 +3309,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
result->f.attrs.space = ptw->in_space;
result->f.attrs.secure = arm_space_is_secure(ptw->in_space);
+ result->f.attrs.requester_id = env->requester_id;
+
switch (mmu_idx) {
case ARMMMUIdx_Phys_S:
case ARMMMUIdx_Phys_NS:
I've seen a few different instances where a CPU or a memory region is behind some sort of IOMMU, and the IOMMU translates (or denies) accesses based on the requester ID of the CPU. This patch only does it on ARM CPUs, because I did not see CPU-agnostic code that added CPU attributes when creating TLBs. Similarly, we add the requester ID during PTW, while populating the rest of the memory attributes. We add the requester ID during GPC and descriptor grabbing as well as PTWs. Signed-off-by: Joe Komlodi <komlodi@google.com> --- target/arm/cpu.c | 4 ++++ target/arm/cpu.h | 6 ++++++ target/arm/ptw.c | 5 +++++ 3 files changed, 15 insertions(+)