From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH 01/22] target/i386: Only realize existing APIC device
Date: Fri, 29 Sep 2023 13:57:58 -0700 [thread overview]
Message-ID: <a6d0175f-a343-4b1f-232f-280786e7dce3@linaro.org> (raw)
In-Reply-To: <20230918160257.30127-2-philmd@linaro.org>
On 9/18/23 09:02, Philippe Mathieu-Daudé wrote:
> 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);
Ok.
> 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;
> + }
I'm not keen on the replication of the condition. Testing whether the apic object was
created seems reasonable. It probably is clearer with the IF in the caller, as you do.
r~
next prev parent reply other threads:[~2023-09-29 20:58 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 16:02 [PATCH 00/22] exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize() Philippe Mathieu-Daudé
2023-09-18 16:02 ` [PATCH 01/22] target/i386: Only realize existing APIC device Philippe Mathieu-Daudé
2023-09-29 20:57 ` Richard Henderson [this message]
2023-11-28 15:32 ` Igor Mammedov
2023-09-18 16:02 ` [PATCH 02/22] hw/intc/apic: Pass CPU using QOM link property Philippe Mathieu-Daudé
2023-09-29 21:01 ` Richard Henderson
2023-11-28 15:34 ` Igor Mammedov
2023-09-18 16:02 ` [PATCH 03/22] target/i386/kvm: Correct comment in kvm_cpu_realize() Philippe Mathieu-Daudé
2023-09-29 21:01 ` Richard Henderson
2023-11-28 15:50 ` Igor Mammedov
2023-09-18 16:02 ` [RFC PATCH 04/22] exec/cpu: Never call cpu_reset() before cpu_realize() Philippe Mathieu-Daudé
2023-09-29 21:03 ` Richard Henderson
2023-11-28 16:00 ` Igor Mammedov
2023-09-18 16:02 ` [PATCH 05/22] exec/cpu: Call qemu_init_vcpu() once in cpu_common_realize() Philippe Mathieu-Daudé
2023-09-29 21:04 ` Richard Henderson
2023-11-28 16:12 ` Igor Mammedov
2023-09-18 16:02 ` [PATCH 06/22] exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize() Philippe Mathieu-Daudé
2023-09-29 21:06 ` Richard Henderson
2023-11-28 16:42 ` Igor Mammedov
2025-01-16 18:05 ` Philippe Mathieu-Daudé
2025-01-16 19:02 ` Philippe Mathieu-Daudé
2025-01-22 14:20 ` Igor Mammedov
2023-09-18 16:02 ` [PATCH 07/22] exec/cpu: Introduce the CPU address space destruction function Philippe Mathieu-Daudé
2023-09-29 21:09 ` Richard Henderson
2023-10-02 11:03 ` Salil Mehta via
2023-10-02 11:03 ` Salil Mehta
2023-09-18 16:02 ` [PATCH 08/22] exec/cpu: RFC Destroy vCPU address spaces in cpu_common_unrealize() Philippe Mathieu-Daudé
2023-09-29 21:10 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 09/22] target/arm: Create timers *after* accelerator vCPU is realized Philippe Mathieu-Daudé
2023-09-29 21:17 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 10/22] target/hppa: Create timer " Philippe Mathieu-Daudé
2023-09-29 21:19 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 11/22] target/nios2: Create IRQs " Philippe Mathieu-Daudé
2023-09-29 21:20 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 12/22] target/mips: Create clock " Philippe Mathieu-Daudé
2023-09-29 21:20 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 13/22] target/xtensa: Create IRQs " Philippe Mathieu-Daudé
2023-09-29 21:21 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 14/22] target/sparc: Init CPU environment " Philippe Mathieu-Daudé
2023-09-29 21:21 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 15/22] exec/cpu: Introduce CPUClass::verify_accel_features() Philippe Mathieu-Daudé
2023-09-29 21:22 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 16/22] target/arm: Extract verify_accel_features() from cpu_realize() Philippe Mathieu-Daudé
2023-09-29 21:25 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 17/22] target/i386: " Philippe Mathieu-Daudé
2023-09-18 16:02 ` [PATCH 18/22] target/s390x: Call s390_cpu_realize_sysemu from s390_realize_cpu_model Philippe Mathieu-Daudé
2023-09-18 16:34 ` David Hildenbrand
2023-09-18 16:02 ` [PATCH 19/22] target/s390x: Have s390_realize_cpu_model() return a boolean Philippe Mathieu-Daudé
2023-09-18 16:02 ` [PATCH 20/22] target/s390x: Use s390_realize_cpu_model() as verify_accel_features() Philippe Mathieu-Daudé
2023-09-18 16:02 ` [PATCH 21/22] exec/cpu: Have cpu_exec_realize() return a boolean Philippe Mathieu-Daudé
2023-09-29 21:28 ` Richard Henderson
2023-09-18 16:02 ` [PATCH 22/22] exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize() Philippe Mathieu-Daudé
2023-09-29 21:31 ` 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=a6d0175f-a343-4b1f-232f-280786e7dce3@linaro.org \
--to=richard.henderson@linaro.org \
--cc=philmd@linaro.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).