Re: [PATCH] exec: Add RISC-V WorldGuard WID field to MemTxAttrs
Jim Shu <[email protected]> Tue, 21 Jul 2026 14:36:20 +0800
| Newsgroups | org.nongnu.qemu-riscv,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <CALw707rzojpHmatHeP5LJqhEcvd8ZiU=a2+EC23H3nvS=yZf1Q@mail.gmail.com> |
On Fri, Jul 17, 2026 at 4:59 PM Peter Maydell <[email protected]> wrote: > > On Thu, 16 Jul 2026 at 04:12, Jim Shu <[email protected]> wrote: > > > > > > Thanks for mentioning it! I think re-use requester_id is better. > > Then, I think we only need a boolean flag `src_is_cpu` and we can > > rename it to `requester_is_cpu` to match the naming of `requester_id`. > > But, what do you now want it for? If we put the world ID in the > MemTxAttrs, do you still need a CPU ID? (There are some situations > where it might be useful, but if we don't need it right now we > shouldn't put doing that rework in the path of implementing > the worldguard work you want to do.) Yes, Adding the world ID to MemTxAttrs is totally enough for me and the worldguard patch series. I just explain the idea if someone still wants to use CPU ID. Sorry for the confusion. I will try to add a field that combines ARM secure/space and RISC-V World ID bits in the next series. > > > > > The whole plan is to add the following 2 fields > > > > > :: > > > > > unsigned int src_is_cpu:1; > > > > > uint16_t src_cpu_id; > > > > > > > > > > src_cpu_id is the CPU ID from 'CPUState->cpu_index'. src_is_cpu is a boolean flag to check if the transaction is from CPU. > > > > > > > > > > Moreover, I think this idea is extensible. DMA device transactions can also have security attributes like world_id. We can also add src_device field to 'MemTxAttr' to store the 'DeviceState *', so we can get the DeviceState from MemTxAttr to get security attributes. If 'DeviceState *' is too large to add to 'MemTxAttr', re-use requester_id as DMA device ID is another possible method to support this. > > > > > > > > I don't think that having the thing that receives the memory > > > > transaction get or get hold of a pointer to the source of the > > > > transaction that it then uses to get the world ID is a good idea. > > > > (Especially not putting a DeviceState* into MemTxAttrs: the > > > > size of the type needs to be kept small so we can conveniently > > > > pass it around by value: we currently assert that it is 8 bytes.) > > > > OK, I think store the DMA device ID in the `requester_id` is another > > way to keep the small size. > > However, IIUC, the current SysbusDevice doesn't have the concept of a > > device ID. We need to add an additional device ID to the device to > > support this idea. > > What exactly is it that you need a device ID for? Earlier you > suggest that you would want it to get the world ID -- but we > should just put the world ID directly in the MemTxAttrs. Same as previous responce. Adding the world ID is enough for me. Sorry for the confusion. Thanks, Jim