From patchwork Mon Sep 18 16:02:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 724152 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1772310wro; Mon, 18 Sep 2023 09:03:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7SxmvJOsKjQ1W82BkUa9yyNkT+sOGmj8fEkQjtLYz7VLRnK6NiUl+XGzIU8fB6AiCrsqK X-Received: by 2002:a05:620a:31a4:b0:773:d203:4441 with SMTP id bi36-20020a05620a31a400b00773d2034441mr2943229qkb.22.1695053031684; Mon, 18 Sep 2023 09:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695053031; cv=none; d=google.com; s=arc-20160816; b=v8/Sz3k4R82IflaU61hpkRNZ3zBoXfuBMd5wsckFBYNBdexG92mnW/YoDfgEBfy0Va jwBJoeVQAmLrdEQH4PR30dqzG1tuZvRBrpP/rpGgQssFB0khSIEG6NTVqNeWvxN8uUA/ evzL/tbKpxwt8KTViktBJ8HeqCaxCOG/jhZlgBKfrwNE83Qfgi6g4Aqw2xHCrc+wwf6T HS9/FNIQBC4jRBy9IiUuVOSDQCxCd/fHSDyrKgM+sTPSP1/IHIEz/wYFyHr3ffBbi+XU 78ltBcllWyRvvrapua73ik9bEtTvV4hF8TNmrWc4kXRN4bNQlK3QuJSzISc7r843LHyv Ifcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YY2zRc5UQ1ttBDAhQdzUYI1/2Fa0E28wpiBNWWnnf1g=; fh=AIYNAcrfQPdTp+tiOBYg2bCy2NfWRbXD73JV9SLWbpM=; b=t5CRZQt3RGS1eNA90W3wtTdbDOTjg1DIzqlY4NCs5OgyM3rJd04vGX/vmaiEc376nb 1O4Z/VFIYI8ijZnvC6WZ0VroO9XAsKIny1AIqVx3On/kcoFXhFGuaRlJiAeEbdIOutVU tihhhBnbJnkhXFNT3e0xl1b+eO/6rwcKJBdux3GTscA2uo6sQik4QO68xUamgoF78l1b jDtJhcgBTtJ9lsas8Ccy1mCAwXy+9GtZn1evWuUDML3h5LEyDiqDE+/NfjpmFvFagUjx B+Ixg7IvPkTDJDybD0YgWSZWjuBx73Q2PSY9PzzfGez4cA+4rnKTUzHTQ8ZkMm3zt8qI Macw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FnnUy8p3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y7-20020a05620a09c700b00770753a1153si6142502qky.25.2023.09.18.09.03.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Sep 2023 09:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FnnUy8p3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiGiM-00065H-P3; Mon, 18 Sep 2023 12:03:10 -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 1qiGiK-00062t-CG for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:03:08 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiGiI-0003uv-Kk for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:03:08 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2bfb17435e4so75837221fa.0 for ; Mon, 18 Sep 2023 09:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695052984; x=1695657784; 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=FnnUy8p3UJEhNf0ABVOTbmAvW/NjVrDPuQRIETuh6xi+sd7KoJnS0V0fmh350uZ8j3 e+YCFUHELkYRTAQMXhJJsfCtqeiAKHxf2xvQg1yb94SdFqwcNfPv4Rv51gTwsUr/bz/J kmlWAvlcV0xx5Ox2tlB8agxLfS/Peh7dFqvjYRr3mldvEWrObHza9AB09fpObl0wMPT+ kBm0OLzyjM0aDrxn7lKF4P4tranS5iM5CjJsg643qrPk5aOgxzdAcbmK0b1/1OPNYnrO a5J8loslnssAjGn2PU4SvQZ4BJUZcLMZyPrbtn5yJklISX+MhmIntiyVgI2DA4ZowckQ TBiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695052984; x=1695657784; 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=EsrSt1Nj01xLfPxdjyy+Q6keN93imahCmn9HGRXQBnC5yI59LqvSvoro+NIHbMN/bw mb1cFlBFeSXa/i5nV50NpkzbPDdOuEwtEkOsh+41RZUHYuRhWVihBb3+nagz8giRerRS xhmiQZTcqL0CjfPeMLCFshgBNFaGZ6UCb1sJAvDWd9cycXvs97fwkwmxk+5vLQA6V7me C2kkkzkgjD6YMLTt+xC++hLdofoTkIGboJ0wqAH9PEMGfMrXP7xGYyFEeLk9siFCf15R yktYj/n0ZdSUJwYMFzJii3EE+Qd1qEC9OSnrcQE+ZF7zKR+BZpoXiwOeRttO1vYsLRc9 mQyg== X-Gm-Message-State: AOJu0Yz/BxnLW+63+3mnoUJ9wK5R4ToxIeDu1XOhwaaQ9ReN+uY0mzrw jxc1itLnTunzV5/vXdSIm1ldxlnI95061iIAYjWWOBqb X-Received: by 2002:a2e:3614:0:b0:2b9:f27f:e491 with SMTP id d20-20020a2e3614000000b002b9f27fe491mr9068179lja.42.1695052984526; Mon, 18 Sep 2023 09:03:04 -0700 (PDT) Received: from localhost.localdomain (static-212-193-78-212.thenetworkfactory.nl. [212.78.193.212]) by smtp.gmail.com with ESMTPSA id x5-20020a1709065ac500b00993664a9987sm6574017ejs.103.2023.09.18.09.03.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 09:03:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , Max Filippov , David Hildenbrand , Peter Xu , Anton Johansson , Peter Maydell , kvm@vger.kernel.org, Marek Vasut , David Gibson , Brian Cain , Yoshinori Sato , "Edgar E . Iglesias" , Claudio Fontana , Daniel Henrique Barboza , Artyom Tarasenko , Marcelo Tosatti , qemu-ppc@nongnu.org, Liu Zhiwei , Aurelien Jarno , Ilya Leoshkevich , Daniel Henrique Barboza , Bastian Koppelmann , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Alistair Francis , Alessandro Di Federico , Song Gao , Marcel Apfelbaum , Chris Wulff , "Michael S. Tsirkin" , Alistair Francis , Fabiano Rosas , qemu-s390x@nongnu.org, Yanan Wang , Luc Michel , Weiwei Li , Bin Meng , Stafford Horne , Xiaojuan Yang , "Daniel P . Berrange" , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Jiaxun Yang , Richard Henderson , Aleksandar Rikalo , Bernhard Beschow , Mark Cave-Ayland , qemu-riscv@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Nicholas Piggin , Greg Kurz , Michael Rolnik , Eduardo Habkost , Markus Armbruster , Palmer Dabbelt Subject: [PATCH 01/22] target/i386: Only realize existing APIC device Date: Mon, 18 Sep 2023 18:02:34 +0200 Message-ID: <20230918160257.30127-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918160257.30127-1-philmd@linaro.org> References: <20230918160257.30127-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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é --- 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);