From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [RFC PATCH 3/4] hw/intc/gic: use MxTxAttrs to divine accessing CPU
Date: Fri, 16 Sep 2022 16:28:14 +0100 [thread overview]
Message-ID: <871qsb8h9y.fsf@linaro.org> (raw)
In-Reply-To: <6aebb38e-551e-e241-bda7-4b748e672c29@amsat.org>
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> On 15/9/22 10:16, Richard Henderson wrote:
>> On 9/14/22 17:09, Alex Bennée wrote:
>>> Now that MxTxAttrs encodes a CPU we should use that to figure it out.
>>> This solves edge cases like accessing via gdbstub or qtest.
>>>
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/124
>>> ---
>>> hw/intc/arm_gic.c | 39 ++++++++++++++++++++++-----------------
>>> 1 file changed, 22 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
>>> index 492b2421ab..7feedac735 100644
>>> --- a/hw/intc/arm_gic.c
>>> +++ b/hw/intc/arm_gic.c
>>> @@ -56,17 +56,22 @@ static const uint8_t gic_id_gicv2[] = {
>>> 0x04, 0x00, 0x00, 0x00, 0x90, 0xb4, 0x2b, 0x00, 0x0d, 0xf0,
>>> 0x05, 0xb1
>>> };
>>> -static inline int gic_get_current_cpu(GICState *s)
>>> +static inline int gic_get_current_cpu(GICState *s, MemTxAttrs attrs)
>>> {
>>> - if (!qtest_enabled() && s->num_cpu > 1) {
>>> - return current_cpu->cpu_index;
>>> - }
>>> - return 0;
>>> + /*
>>> + * Something other than a CPU accessing the GIC would be a bug as
>>> + * would a CPU index higher than the GICState expects to be
>>> + * handling
>>> + */
>>> + g_assert(attrs.requester_cpu == 1);
>> Better without "== 1" -- this field ought to be boolean.
>
> Boolean so far, but this could get more types (such DMA...).
> Maybe we could already add an enum definitions, i.e.:
>
> typedef enum MemTxRequesterType {
> MEMTXATTRS_CPU,
> MEMTXATTRS_MSI,
> } MemTxRequesterType;
>
> and name the field MemTxAttrs::requester_type.
I pondered boolean but wasn't sure if that would blow up the size of
MemTxAttrs so went for the bitfield. However I can certainly rename to
requester_is_cpu and make a boolean assertion. I'd hold off adding an
enum until we actually have more than two requester types.
--
Alex Bennée
next prev parent reply other threads:[~2022-09-16 15:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 16:09 [RFC PATCH 0/4] use MemTxAttrs to signal cpu index Alex Bennée
2022-09-14 16:09 ` [RFC PATCH 1/4] hw: encode accessing CPU index in MemTxAttrs Alex Bennée
2022-09-15 8:05 ` Richard Henderson
2022-09-16 15:19 ` Peter Maydell
2022-09-14 16:09 ` [RFC PATCH 2/4] qtest: make read/write operation appear to be from CPU Alex Bennée
2022-09-15 8:08 ` Richard Henderson
2022-09-16 14:40 ` Philippe Mathieu-Daudé via
2022-09-14 16:09 ` [RFC PATCH 3/4] hw/intc/gic: use MxTxAttrs to divine accessing CPU Alex Bennée
2022-09-15 8:16 ` Richard Henderson
2022-09-16 14:49 ` Philippe Mathieu-Daudé via
2022-09-16 15:28 ` Alex Bennée [this message]
2022-09-17 8:33 ` Richard Henderson
2022-09-14 16:09 ` [RFC PATCH 4/4] hw/timer: convert mptimer access to attrs to derive cpu index Alex Bennée
2022-09-15 8:17 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qsb8h9y.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=f4bug@amsat.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).