On Tue, 12 Apr 2022 at 11:45, Alex Bennée <alex.ben...@linaro.org> wrote: > > When accessing HW via the gdbstub we can't easily figure out what the > cpu_index is. The canonical case is current_cpu but for some cases > that will be NULL. For debug accesses we can overload requester_id and > make the GIC a bit smarter about fishing that out. > > [AJB: very much a PoC hack for now but interested if this makes sense. > We could encode cpu_index in another field but that would grow > MxTxAttrs even more.] > > Signed-off-by: Alex Bennée <alex.ben...@linaro.org> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/124 > --- > include/exec/memattrs.h | 2 +- > hw/core/cpu-sysemu.c | 15 +++++++++++---- > hw/intc/arm_gic.c | 33 +++++++++++++++++++-------------- > 3 files changed, 31 insertions(+), 19 deletions(-) > > diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h > index 9fb98bc1ef..1333a34cb3 100644 > --- a/include/exec/memattrs.h > +++ b/include/exec/memattrs.h > @@ -43,7 +43,7 @@ typedef struct MemTxAttrs { > * (see MEMTX_ACCESS_ERROR). > */ > unsigned int memory:1; > - /* Requester ID (for MSI for example) */ > + /* Requester ID (for MSI for example) or cpu_index for debug */ > unsigned int requester_id:16;
If we want to provide a requester ID for memory transactions we should provide it always, not just for debug. That way gic_get_current_cpu() and similar code can unconditionally use requester_id and never needs to look at current_cpu. (We would also need to figure out how we want to parcel out requester_ids in the system, so that PCI requester IDs don't clash with CPU requester IDs.) -- PMM