From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, maobibo@loongson.cn,
yangxiaojuan@loongson.cn
Subject: Re: [PATCH 2/3] hw/intc: Add NULL pointer check on LoongArch ipi device
Date: Thu, 11 May 2023 21:03:05 +0200 [thread overview]
Message-ID: <0de07b1e-1371-9bad-11e0-e57d8fb379fe@linaro.org> (raw)
In-Reply-To: <20230406100052.3355632-2-gaosong@loongson.cn>
On 6/4/23 12:00, Song Gao wrote:
> When ipi mailbox is used, cpu index is decoded from iocsr register.
> cpu maybe does not exist. This patch adss NULL pointer check on
> ipi device.
How can that happens from a guest vcpu context?
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
> hw/intc/loongarch_ipi.c | 31 +++++++++++++++++++------------
> 1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c
> index 0563d83a35..39e899df46 100644
> --- a/hw/intc/loongarch_ipi.c
> +++ b/hw/intc/loongarch_ipi.c
> @@ -86,11 +86,12 @@ static void ipi_send(uint64_t val)
> /* IPI status vector */
> data = 1 << (val & 0x1f);
> cs = qemu_get_cpu(cpuid);
> - cpu = LOONGARCH_CPU(cs);
> - env = &cpu->env;
> - address_space_stl(&env->address_space_iocsr, 0x1008,
> - data, MEMTXATTRS_UNSPECIFIED, NULL);
> -
> + if (cs) {
> + cpu = LOONGARCH_CPU(cs);
> + env = &cpu->env;
> + address_space_stl(&env->address_space_iocsr, 0x1008,
> + data, MEMTXATTRS_UNSPECIFIED, NULL);
> + }
Is that the hardware behavior?
Could logging the invalid cpuid request be useful?
else {
//log or trace event here
}
> }
next prev parent reply other threads:[~2023-05-11 19:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 10:00 [PATCH 1/3] hw/loongarch/virt: Modify ipi as percpu device Song Gao
2023-04-06 10:00 ` [PATCH 2/3] hw/intc: Add NULL pointer check on LoongArch ipi device Song Gao
2023-04-26 1:37 ` Song Gao
2023-05-11 19:03 ` Philippe Mathieu-Daudé [this message]
2023-05-12 3:01 ` Song Gao
2023-05-12 3:45 ` Philippe Mathieu-Daudé
2023-05-12 6:29 ` Song Gao
2023-04-06 10:00 ` [PATCH 3/3] hw/loongarch/virt: Set max 256 cpus support on loongarch virt machine Song Gao
2023-04-26 1:37 ` Song Gao
2023-05-08 2:11 ` Song Gao
2023-05-10 10:12 ` Richard Henderson
2023-05-11 12:22 ` Song Gao
2023-05-11 19:07 ` Philippe Mathieu-Daudé
2023-04-26 1:38 ` [PATCH 1/3] hw/loongarch/virt: Modify ipi as percpu device Song Gao
2023-05-11 19:11 ` Philippe Mathieu-Daudé
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=0de07b1e-1371-9bad-11e0-e57d8fb379fe@linaro.org \
--to=philmd@linaro.org \
--cc=gaosong@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yangxiaojuan@loongson.cn \
/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).