From nobody Fri Oct 18 06:24:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694794915; cv=none; d=zohomail.com; s=zohoarc; b=U7QXDHmkeZpuOGFh/EpzZIWviBqISBNFF4bwbOiTq5qWRr+JH1d1KEiA+mrv0voh+KExGnTKKWru4b2XeAIVMXy3BVsjazuas1bByFHLx9hQOp3SEWefLaikxVYTVI8PQLSq4e3qyibQb+atAfVG84fi2zfKBS9YtDGA9FkPfA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694794915; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YY2zRc5UQ1ttBDAhQdzUYI1/2Fa0E28wpiBNWWnnf1g=; b=Z/2/++vRdNC5yGQxmlA8ITwCbr+vZ9Hfh9zeApzS1+k09mq0xr1xLl5RJlQTF0yxcGlgHisE83flWE7oO9J0G+fSgprD5Ec5lwRSiQQygqp4iVTTOarQ/NEeglLRMufhO48YpP9ykWjuFv+mLWx0UaVP609Ur5QMXxG7BCjJHxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694794915407298.8508860351757; Fri, 15 Sep 2023 09:21:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBYu-0005Wm-FA; Fri, 15 Sep 2023 12:20:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBYt-0005Wb-Fr for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:20:55 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBYr-0000Wa-TL for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:20:55 -0400 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-50078eba7afso3852963e87.0 for ; Fri, 15 Sep 2023 09:20:53 -0700 (PDT) Received: from m1x-phil.lan (6lp61-h01-176-171-209-234.dsl.sta.abo.bbox.fr. [176.171.209.234]) by smtp.gmail.com with ESMTPSA id br20-20020a170906d15400b0098669cc16b2sm2610559ejb.83.2023.09.15.09.20.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Sep 2023 09:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694794852; x=1695399652; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YY2zRc5UQ1ttBDAhQdzUYI1/2Fa0E28wpiBNWWnnf1g=; b=YDitTy0P5i2XWPQTLy1bUaeZtgwTG5MLt1WaxiRAIMCLhofLzNmlvhwj5VA5Tk/pml H9DwZCxaY/OZh/JLsvam/Tkm8bVrVDjWiJq5kK6ydk9S28QVobQxw1UzXoNooXdUEKFX pXPR6jhN/xcKOWOZH9e4gEg1Vle8VPePePzYbVQIZcLKKR9JGxr9gWf7H1T5T0Fe1OcN 5OA9ZXDQ8omWdYfYyk3kxVIXw1maCCPOtCQP164hxeBfA3kLHaNRBhkQG5GZ5E64ThZ3 u+/Q01M+gAX/hF43tpp7ApcgrvgwM7K+Y9337vR4kg9IoeIZfLjIju2AHNgKdlJv1ufv 7N7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694794852; x=1695399652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YY2zRc5UQ1ttBDAhQdzUYI1/2Fa0E28wpiBNWWnnf1g=; b=rztl6vKKO2Rl/yAuz7zaiSGf1N7YenMG69ecPs4XEvi7a3+wHd28SI8D+KYGfJC3Ta Gi6rjmT3Jd/7oK6x7exuDPlx3aTrZ/MrCQOASGDwcY3onOj95Uov54TuCP/IoXky4MBU NQSXe4Z63RRk3olVGT5VRWN3xWsBzxgFHlc+IapMmyknQRJxz2oi6HM9CVVDXWhDWnu3 vdIt2pAuqkIJeKg5b1coSjahYC6P8+xF2WDM92RFdWPUpiIavA/kD2HdIk8REnjNMK47 aJShgRlyo+XashPBXprfLBdTTviDS/SHjGXzC9eCbAKV9al9bFRmxyDb33kmUHS5O8M+ 6sQA== X-Gm-Message-State: AOJu0YxvPUv1U0GDycQ4ype7shbz3mvjvtViYeXljX4V/HYv5igaMq81 +3Fz8URilZBNO9lJRILhPdWCrJWUD6WJ7n+1ggc= X-Google-Smtp-Source: AGHT+IFz3JoD9H/tmIP++pjLx88owh4qoGe3gCA2KTGTNuT/hiSOOjRkcyihrXFxQUvOs7UMsdlzwg== X-Received: by 2002:a05:6512:1193:b0:500:9b7d:ee3c with SMTP id g19-20020a056512119300b005009b7dee3cmr2299624lfr.7.1694794851648; Fri, 15 Sep 2023 09:20:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Bernhard Beschow , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] target/i386: Only realize existing APIC device Date: Fri, 15 Sep 2023 18:20:41 +0200 Message-ID: <20230915162042.55890-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915162042.55890-1-philmd@linaro.org> References: <20230915162042.55890-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=philmd@linaro.org; helo=mail-lf1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694794917173100003 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=C3=A9 --- 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 =3D apic_get_class(errp); =20 - if (!apic_class) { - return; - } + assert(apic_class); =20 cpu->apic_state =3D DEVICE(object_new_with_class(OBJECT_CLASS(apic_cla= ss))); 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; =20 - if (cpu->apic_state =3D=3D NULL) { - return; - } + assert(cpu->apic_state); + qdev_realize(DEVICE(cpu->apic_state), NULL, errp); =20 /* 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, Erro= r **errp) } =20 #ifndef CONFIG_USER_ONLY - x86_cpu_apic_realize(cpu, &local_err); - if (local_err !=3D 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 !=3D NULL) { + goto out; + } } #endif /* !CONFIG_USER_ONLY */ cpu_reset(cs); --=20 2.41.0