qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: mads@ynddal.dk
Cc: qemu-devel@nongnu.org, f4bug@amsat.org,
	Peter Maydell <peter.maydell@linaro.org>,
	"open list:ARM cores" <qemu-arm@nongnu.org>
Subject: Re: [PATCH v1 3/9] hw/intc/gic: use MxTxAttrs to divine accessing CPU
Date: Mon, 26 Sep 2022 12:01:12 +0100	[thread overview]
Message-ID: <87tu4u4coz.fsf@linaro.org> (raw)
In-Reply-To: <85155F4E-0FFF-4DE6-A336-3F9C5B561CDC@ynddal.dk>


mads@ynddal.dk writes:

>> On 22 Sep 2022, at 16.58, Alex Bennée <alex.bennee@linaro.org> 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
>> 
>> ---
>> v2
>>  - update for new field
>>  - bool asserts
>> ---
>> 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..b58d3c4a95 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_is_cpu);
>> +    g_assert(attrs.cpu_index < s->num_cpu);
>> +
>> +    return attrs.requester_id;
>> }
>
> The asserts here abort on macOS, with HVF accelerator:
>
> ERROR:../hw/intc/arm_gic.c:66:gic_get_current_cpu: assertion failed: (attrs.requester_is_cpu)
> Bail out! ERROR:../hw/intc/arm_gic.c:66:gic_get_current_cpu: assertion failed: (attrs.requester_is_cpu)
>
> If I revert the changes inside this function, it seemingly works
> again.

Thanks for testing.

I guess this is because the we have a soft GIC for HVF. Somewhere in the
hvf code path we must encode up an MemTxAttrs when the gic is accessed.

Could you try in the EC_DATAABORT path in
target/arm/hvf/hvf.c:hvf_vcpu_exec:

        if (iswrite) {
            val = hvf_get_reg(cpu, srt);
            address_space_write(&address_space_memory,
                                hvf_exit->exception.physical_address,
                                MEMTXATTRS_CPU(cpu->cpu_index), &val, len);
        } else {
            address_space_read(&address_space_memory,
                               hvf_exit->exception.physical_address,
                               MEMTXATTRS_CPU(cpu->cpu_index), &val, len);
            hvf_set_reg(cpu, srt, val);
        }

if that works I'll cook up a proper patch.

-- 
Alex Bennée


  reply	other threads:[~2022-09-26 11:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 14:58 [PATCH v1 0/9] MemTxAttrs cpu_index and gdbstub/next Alex Bennée
2022-09-22 14:58 ` [PATCH v1 1/9] hw: encode accessing CPU index in MemTxAttrs Alex Bennée
2022-09-25 10:08   ` Richard Henderson
2022-09-25 13:02     ` Alex Bennée
2022-09-26  7:33       ` Richard Henderson
2022-09-22 14:58 ` [PATCH v1 2/9] qtest: make read/write operation appear to be from CPU Alex Bennée
2022-09-22 14:58 ` [PATCH v1 3/9] hw/intc/gic: use MxTxAttrs to divine accessing CPU Alex Bennée
2022-09-25 10:11   ` Richard Henderson
2022-09-26 10:56   ` mads
2022-09-26 11:01     ` Alex Bennée [this message]
2022-09-26 11:20       ` mads
2022-09-22 14:58 ` [PATCH v1 4/9] hw/timer: convert mptimer access to attrs to derive cpu index Alex Bennée
2022-09-25 10:11   ` Richard Henderson
2022-09-22 14:58 ` [PATCH v1 5/9] configure: move detected gdb to TCG's config-host.mak Alex Bennée
2022-09-25 10:11   ` Richard Henderson
2022-09-22 14:58 ` [PATCH v1 6/9] gdbstub: move into its own sub directory Alex Bennée
2022-09-25 10:13   ` Richard Henderson
2022-09-22 14:58 ` [PATCH v1 7/9] gdbstub: move sstep flags probing into AccelClass Alex Bennée
2022-09-22 21:49   ` Philippe Mathieu-Daudé via
2022-09-25 10:14   ` Richard Henderson
2022-09-22 14:58 ` [PATCH v1 8/9] gdbstub: move breakpoint logic to accel ops Alex Bennée
2022-09-25 10:18   ` Richard Henderson
2022-09-22 14:58 ` [PATCH v1 9/9] gdbstub: move guest debug support check to ops Alex Bennée
2022-09-22 21:51   ` Philippe Mathieu-Daudé via
2022-09-25 10:18   ` 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=87tu4u4coz.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=mads@ynddal.dk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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).