From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Bernhard Beschow" <shentey@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 1/2] target/i386: Only realize existing APIC device
Date: Fri, 15 Sep 2023 18:20:41 +0200 [thread overview]
Message-ID: <20230915162042.55890-2-philmd@linaro.org> (raw)
In-Reply-To: <20230915162042.55890-1-philmd@linaro.org>
APIC state is created under a certain condition,
use the same condition to realize it.
Having a NULL APIC state is a bug: use assert().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/i386/cpu-sysemu.c | 9 +++------
target/i386/cpu.c | 8 +++++---
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c
index 2375e48178..6a164d3769 100644
--- a/target/i386/cpu-sysemu.c
+++ b/target/i386/cpu-sysemu.c
@@ -272,9 +272,7 @@ void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
APICCommonState *apic;
APICCommonClass *apic_class = apic_get_class(errp);
- if (!apic_class) {
- return;
- }
+ assert(apic_class);
cpu->apic_state = DEVICE(object_new_with_class(OBJECT_CLASS(apic_class)));
object_property_add_child(OBJECT(cpu), "lapic",
@@ -293,9 +291,8 @@ void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)
APICCommonState *apic;
static bool apic_mmio_map_once;
- if (cpu->apic_state == NULL) {
- return;
- }
+ assert(cpu->apic_state);
+
qdev_realize(DEVICE(cpu->apic_state), NULL, errp);
/* Map APIC MMIO area */
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index b2a20365e1..a23d4795e0 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7448,9 +7448,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
}
#ifndef CONFIG_USER_ONLY
- x86_cpu_apic_realize(cpu, &local_err);
- if (local_err != NULL) {
- goto out;
+ if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || ms->smp.cpus > 1) {
+ x86_cpu_apic_realize(cpu, &local_err);
+ if (local_err != NULL) {
+ goto out;
+ }
}
#endif /* !CONFIG_USER_ONLY */
cpu_reset(cs);
--
2.41.0
next prev parent reply other threads:[~2023-09-15 16:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 16:20 [PATCH 0/2] hw/intc/apic: QOM cleanup Philippe Mathieu-Daudé
2023-09-15 16:20 ` Philippe Mathieu-Daudé [this message]
2023-09-15 16:20 ` [PATCH 2/2] hw/intc/apic: Pass CPU using QOM link property Philippe Mathieu-Daudé
2023-10-03 6:45 ` [PATCH 0/2] hw/intc/apic: QOM cleanup Philippe Mathieu-Daudé
2023-10-03 7:07 ` 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=20230915162042.55890-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=shentey@gmail.com \
/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).