From: Andrey Shumilin <shum.sdl@nppct.ru>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Michael Tokarev <mjt@tls.msk.ru>, qemu-devel@nongnu.org
Subject: Re: [sdl-qemu] [PATCH v1] /hw/intc/arm_gic WRONG ARGUMENTS
Date: Mon, 6 May 2024 22:11:39 +0300 [thread overview]
Message-ID: <3e3d3c9c-e8df-4447-91d9-a156712d57ba@nppct.ru> (raw)
In-Reply-To: <8734qvuukl.fsf@draig.linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3191 bytes --]
1. s - This argument passes a pointer to the GICState structure that
contains the state of the interrupt controller. This argument is
passed first and used correctly.
2. regno - This is the register number, which in the context of
gic_cpu_read is calculated as (offset - 0xd0) / 4. In gic_cpu_read
code, this number is used to identify the specific APR register to
be read or modified. In gic_apr_ns_view, this number is also used to
determine which NSAPR register to read or how to compute bits,
implying that it is used as a register index.
3. cpu - This is the CPU number used to address a particular CPU in the
nsapr, apr, and other arrays.
Based on the context, it is important that regno and cpu are passed to
gic_apr_ns_view in the correct order for correct handling of arrays and
indexes within this function. An error in the order of the arguments can
result in incorrect data handling, as arrays are indexed first by CPU
number and then by register number. In the considered call
gic_apr_ns_view the arguments are passed in the wrong order
06.05.2024 13:02, Alex Bennée пишет:
> Andrey Shumilin<shum.sdl@nppct.ru> writes:
>
>> 1 Possibly mismatched call arguments in function 'gic_apr_ns_view': 'cpu' and 'regno' passed in place of 'int regno' and 'int
>> cpu'.
>> 2 Possibly mismatched call arguments in function 'gic_apr_write_ns_view': 'cpu' and 'regno' passed in place of 'int regno' and
>> 'int cpu'.
>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> So this purely a heuristic test based on the parameter names?
>
>> From 23b142f5046ba9d3aec57217f6d8f3127f9bff69 Mon Sep 17 00:00:00 2001
>> From: Andrey Shumilin<shum.sdl@nppct.ru>
>> Date: Sun, 5 May 2024 20:13:40 +0300
>> Subject: [PATCH] Patch hw/intc/arm_gic.c
>>
>> Signed-off-by: Andrey Shumilin<shum.sdl@nppct.ru>
>> ---
>> hw/intc/arm_gic.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
>> index 7a34bc0998..47f01e45e3 100644
>> --- a/hw/intc/arm_gic.c
>> +++ b/hw/intc/arm_gic.c
>> @@ -1658,7 +1658,7 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset,
>> *data = s->h_apr[gic_get_vcpu_real_id(cpu)];
>> } else if (gic_cpu_ns_access(s, cpu, attrs)) {
>> /* NS view of GICC_APR<n> is the top half of GIC_NSAPR<n> */
>> - *data = gic_apr_ns_view(s, regno, cpu);
>> + *data = gic_apr_ns_view(s, cpu, regno);
>> } else {
>> *data = s->apr[regno][cpu];
>> }
>> @@ -1746,7 +1746,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
>> s->h_apr[gic_get_vcpu_real_id(cpu)] = value;
>> } else if (gic_cpu_ns_access(s, cpu, attrs)) {
>> /* NS view of GICC_APR<n> is the top half of GIC_NSAPR<n> */
>> - gic_apr_write_ns_view(s, regno, cpu, value);
>> + gic_apr_write_ns_view(s, cpu, regno, value);
>> } else {
>> s->apr[regno][cpu] = value;
>> }
> Ahh C's lack of strong typing wins again :-/
>
> Reviewed-by: Alex Bennée<alex.bennee@linaro.org>
>
[-- Attachment #2: Type: text/html, Size: 4153 bytes --]
next prev parent reply other threads:[~2024-05-06 19:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-05 17:58 [sdl-qemu] [PATCH v1] /hw/intc/arm_gic WRONG ARGUMENTS Andrey Shumilin
2024-05-05 19:51 ` Michael Tokarev
2024-05-05 19:57 ` Andrey Shumilin
2024-05-06 7:49 ` Philippe Mathieu-Daudé
2024-05-06 10:02 ` Alex Bennée
2024-05-06 19:11 ` Andrey Shumilin [this message]
2024-05-07 4:42 ` Andrey Shumilin
2024-05-07 10:13 ` Peter Maydell
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=3e3d3c9c-e8df-4447-91d9-a156712d57ba@nppct.ru \
--to=shum.sdl@nppct.ru \
--cc=alex.bennee@linaro.org \
--cc=mjt@tls.msk.ru \
--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).