Message ID | 1315989802-18753-1-git-send-email-agraf@suse.de |
---|---|
State | New |
Headers | show |
On 14 September 2011 09:42, Alexander Graf <agraf@suse.de> wrote: > The MPIC exports a register set for each CPU connected to it. They can all > be accessed through specific registers or using a shadow page that is mapped > differently depending on which CPU accesses it. > > This patch implements the shadow map, making it possible for guests to access > the CPU local registers using the same address on each CPU. > +static int get_current_cpu(void) > +{ > + return cpu_single_env->cpu_index; > +} This is the standard way of doing this (we use it on ARM as well), but it's pretty clearly a hack. "which master sent this memory transaction" is an attribute that ought to be passed down to the MMIO read/write functions, really (along with other interesting things like "priv or not?" and probably architecture specific attributes like ARM's "secure/non-secure"); this matches how hardware does it where the attributes are passed along as extra signals in the bus fabric. (Sometimes hardware also does this by having buses from the different cores be totally separate paths at the point where this kind of device is connected, before merging together later; we don't really support modelling that either :-)) Not a nak, just an observation while I'm thinking about it. -- PMM
Am 14.09.2011 um 12:07 schrieb Peter Maydell <peter.maydell@linaro.org>: > On 14 September 2011 09:42, Alexander Graf <agraf@suse.de> wrote: >> The MPIC exports a register set for each CPU connected to it. They can all >> be accessed through specific registers or using a shadow page that is mapped >> differently depending on which CPU accesses it. >> >> This patch implements the shadow map, making it possible for guests to access >> the CPU local registers using the same address on each CPU. > >> +static int get_current_cpu(void) >> +{ >> + return cpu_single_env->cpu_index; >> +} > > This is the standard way of doing this (we use it on ARM as well), but > it's pretty clearly a hack. "which master sent this memory transaction" > is an attribute that ought to be passed down to the MMIO read/write > functions, really (along with other interesting things like "priv or > not?" and probably architecture specific attributes like ARM's > "secure/non-secure"); this matches how hardware does it where the > attributes are passed along as extra signals in the bus fabric. > (Sometimes hardware also does this by having buses from the different > cores be totally separate paths at the point where this kind of device > is connected, before merging together later; we don't really support > modelling that either :-)) > > Not a nak, just an observation while I'm thinking about it. Yeah, I tend to agree in general. I'm not 100% sure in this case, as it's almost an in-cpu device. But it would be nice to pass this information on the mmio callbacks. However, right now this is the only way to do it, as we don't have the pretty flexible one implemented yet ;). Alex >
On 2011-09-14 12:07, Peter Maydell wrote: > On 14 September 2011 09:42, Alexander Graf <agraf@suse.de> wrote: >> The MPIC exports a register set for each CPU connected to it. They can all >> be accessed through specific registers or using a shadow page that is mapped >> differently depending on which CPU accesses it. >> >> This patch implements the shadow map, making it possible for guests to access >> the CPU local registers using the same address on each CPU. > >> +static int get_current_cpu(void) >> +{ >> + return cpu_single_env->cpu_index; >> +} > > This is the standard way of doing this (we use it on ARM as well), but > it's pretty clearly a hack. "which master sent this memory transaction" > is an attribute that ought to be passed down to the MMIO read/write > functions, really (along with other interesting things like "priv or > not?" and probably architecture specific attributes like ARM's > "secure/non-secure"); this matches how hardware does it where the > attributes are passed along as extra signals in the bus fabric. > (Sometimes hardware also does this by having buses from the different > cores be totally separate paths at the point where this kind of device > is connected, before merging together later; we don't really support > modelling that either :-)) > > Not a nak, just an observation while I'm thinking about it. Same problem has to be solved on x86. The way the local APIC is hooked up right now is totally broken, just works by chance because normal guests don't seriously stress the architecture. If we start dispatching CPU memory accesses via per-CPU memory roots, the problem can be solved without passing additional source information to the callbacks. Jan
On 09/14/2011 01:22 PM, Jan Kiszka wrote: > > > > This is the standard way of doing this (we use it on ARM as well), but > > it's pretty clearly a hack. "which master sent this memory transaction" > > is an attribute that ought to be passed down to the MMIO read/write > > functions, really (along with other interesting things like "priv or > > not?" and probably architecture specific attributes like ARM's > > "secure/non-secure"); this matches how hardware does it where the > > attributes are passed along as extra signals in the bus fabric. > > (Sometimes hardware also does this by having buses from the different > > cores be totally separate paths at the point where this kind of device > > is connected, before merging together later; we don't really support > > modelling that either :-)) > > > > Not a nak, just an observation while I'm thinking about it. > > Same problem has to be solved on x86. The way the local APIC is hooked > up right now is totally broken, just works by chance because normal > guests don't seriously stress the architecture. That, plus SMRAM. > If we start dispatching CPU memory accesses via per-CPU memory roots, > the problem can be solved without passing additional source information > to the callbacks. For that we need a full conversion.