From patchwork Sun Jan 12 21:58:26 2025 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: 856760 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1173397wrc; Sun, 12 Jan 2025 14:00:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX12arHm7bNypSw/7TbTMaOgvG1iuSwzRsW9sEpBNPw+uIUm6E1VsacvwCN68bD/2uYG3QHnA==@linaro.org X-Google-Smtp-Source: AGHT+IEnF2suXPT/c3sJJABJnaOUXibeAjrHGq7N5YvyTrgpuQ/bxNItEoKR2dPgnjUF7wVXeAKm X-Received: by 2002:a05:620a:4310:b0:7b6:ecbb:592 with SMTP id af79cd13be357-7bcd97c4225mr3527084585a.54.1736719235865; Sun, 12 Jan 2025 14:00:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736719235; cv=none; d=google.com; s=arc-20240605; b=FnrqZm02xQQwb2TV5i82sf2LBkFeFZMI+bbbdnkhsYtZYZAHXn3Gb4fOkrBKNz+DUe HkOSu3t3AgtF16dn6khbKnN7WJQIBaNcLWKB10wTNZKNAiu8PliIEAvxXRKRjsLWiLry n8nu98khQ/DScPaeXR0EoKAeFnMhjbGI4snGpFx/f5gYJ/LlHSsvlgp0NSKtP+Y0T6d6 sOOER9w3V9A8tiOIecQi68wrX5Ktjtd1l8C82v4GdyuSM5VCxQX5m0ByVhV83UTOTWsM 1mQR/e5al567ezjrWCWnvumhUxklvCpze1I6UP6fpor0ODgTajXWbvz5Q5Wv8TYnJBhJ GIFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=BYtEthfQnNCOi+UxhhX8J2P0h82CeZqIE84msWKC75k=; fh=Ihmr/tTuI9LlTMRH7V2YLRHtHGMzXPi1O/i78pP9Xl4=; b=ePBhN7K6rbB2C3vo0KEh3QFTwipyqFUsTiWvhZ5v9HI1R3FSxu7Z9gf8NPoBKeLTZS YsPNJivT82x830t5yjYivt3Oh3g96FwTA0ZtJH+Gp+Kt66n1dUxqemhLzo6aFC0jExdb 28h0IKDkzWJOir418VyK9K3u5T6Tlzjyo7zLCqoWAvPuUIdT0chvH8AWzZHJJ7pVkzhK eegtW/MHJ5iwTTr2gax9CvBrCQOPVri2Qiaf1yBe10kT24B1aT17WvY7PXOygHgv3MlY YDdUIil+PdrdjbtcXo081RRP2RTm6gs+P6O/EdfpOHMYFJEPCzKfHPN83FzLFqdQZYaf g/Uw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MmO003ih; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7bce3508df8si936695585a.547.2025.01.12.14.00.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Jan 2025 14:00:35 -0800 (PST) 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=MmO003ih; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tX5yv-0005Ik-9X; Sun, 12 Jan 2025 16:58:53 -0500 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 1tX5yt-0005IG-D9 for qemu-devel@nongnu.org; Sun, 12 Jan 2025 16:58:51 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tX5yr-0003lo-Mm for qemu-devel@nongnu.org; Sun, 12 Jan 2025 16:58:51 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361c705434so26096655e9.3 for ; Sun, 12 Jan 2025 13:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736719128; x=1737323928; 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=BYtEthfQnNCOi+UxhhX8J2P0h82CeZqIE84msWKC75k=; b=MmO003ihHQMrDgoW6ZWQi+x8wpry2njg2/YHzE31KW/Hqmhqk/5x3PRgso4o0XAcgn qhGGQLJgujVnMCf0SSrbYsrc22yBipPb+7O9bNANdtor60+3535o2GHsAt8jhDqjCoTA ddORZKFTOLCUYbIqkGxYLE+pmo68BquUsjajPWPXcMYFPXVC/Q8rC1cu7wHk3ujegaNr ZU0ra8dd/vJ/JOYQKnXL30kOmrQXobFryPMUF4qYByv92YBkqEWWfT4R6UXu/xz5U+IJ 3c2rT2Cp677VvK8GeJddSoTQkfDMctCw5fH8BBoRFqu7eAIwPOw63+yh0GnCj+OpHUwT ZRlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736719128; x=1737323928; 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=BYtEthfQnNCOi+UxhhX8J2P0h82CeZqIE84msWKC75k=; b=KLiREg3nxh3ZjtmItnkuU8W987wfJaC0suXpY2r+39fd5jVtFuKHOqakCzruiTpteN I46cl42usymRE27pDJUx5XNBEwbWDAbcKzK20jF9C56wCelhCshCGBqcarR8x2WF0xQJ ON5ZvdgsQIdgGKfZ8G4QrgNmqYvgiXdc5fhJfm+OHFYGaabujuCj5/t3cgHw/nlbzDXr wTQLLyREDM7DKBFTkQMVWh9wV7V+BN1GVUwmxnUJA6FuObpMYwqxK0w9WJU6nEEdy4RC XyGRmHds7i1yfrJXyQjavxayqpwqqflOFzjI5hGo43p6LQoDi/qmYy8gUaXdebcLr2Mn /VVA== X-Gm-Message-State: AOJu0YzttOuZ7gmpMKZMp28ix/PfMTVIrzgqlCPM4DTpXSp14g9lomkj Yp8FqX665lUJ9u2swFtnoLe7updsIQBAOwJrxF8sNiZk5/3uhxdQp2XjcRMDr6iAT3ZY6RRSHLX b6JU= X-Gm-Gg: ASbGnctkLjvJw1SUjxMMEXxCPFXfJVjUobQ0WvUcZ/pcBTeVfKhRUuK9xggG/6RbVJZ Jwg4LTJk1At17Js4bwkUc8bUBeilJ1vBwc7gdVWwsglq/AyRV68P0XPAso9rTzWWz+8npYRam1a taldA3pJxzp0877iGycxWsrAChj3umXIhvKnRkmawGB0xVtEqcfV6iIz1rFHFq0YtsRLBP1Diqp NOlf1oaN5+Yti1Gc7TqI4HMtcT+WjEOMEugXv1a+gdmmS6/IZgRyLan0+Qe9vsKuqo8aSTlo+Wn 0UCeqjPosRx3aNlbjuduNCIS0IOTVaU= X-Received: by 2002:a05:6000:154f:b0:386:373f:47c4 with SMTP id ffacd0b85a97d-38a873579b3mr15575811f8f.49.1736719127908; Sun, 12 Jan 2025 13:58:47 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b81d7sm10567949f8f.73.2025.01.12.13.58.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 12 Jan 2025 13:58:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Huacai Chen , Jiaxun Yang Subject: [PATCH 02/11] hw/mips/loongson3_virt: Keep reference of vCPUs in machine_init() Date: Sun, 12 Jan 2025 22:58:26 +0100 Message-ID: <20250112215835.29320-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250112215835.29320-1-philmd@linaro.org> References: <20250112215835.29320-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Keep references of all vCPUs created. That allows to directly access the first vCPU without using the &first_cpu global. Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/loongson3_virt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 47d112981a2..4b19941c1dc 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -492,9 +492,8 @@ static void mips_loongson3_virt_init(MachineState *machine) { int i; long bios_size; - MIPSCPU *cpu; + g_autofree MIPSCPU **cpus = NULL; Clock *cpuclk; - CPUMIPSState *env; DeviceState *liointc; DeviceState *ipi = NULL; char *filename; @@ -569,13 +568,16 @@ static void mips_loongson3_virt_init(MachineState *machine) cpuclk = clock_new(OBJECT(machine), "cpu-refclk"); clock_set_hz(cpuclk, DEF_LOONGSON3_FREQ); + cpus = g_new(MIPSCPU *, machine->smp.cpus); for (i = 0; i < machine->smp.cpus; i++) { + MIPSCPU *cpu; int node = i / LOONGSON3_CORE_PER_NODE; int core = i % LOONGSON3_CORE_PER_NODE; int ip; /* init CPUs */ cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk, false); + cpus[i] = cpu; /* Init internal devices */ cpu_mips_irq_init_cpu(cpu); @@ -609,7 +611,6 @@ static void mips_loongson3_virt_init(MachineState *machine) pin, cpu->env.irq[ip + 2]); } } - env = &MIPS_CPU(first_cpu)->env; /* Allocate RAM/BIOS, 0x00000000~0x10000000 is alias of 0x80000000~0x90000000 */ memory_region_init_rom(bios, NULL, "loongson3.bios", @@ -640,7 +641,7 @@ static void mips_loongson3_virt_init(MachineState *machine) loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; - loaderparams.kernel_entry = load_kernel(env); + loaderparams.kernel_entry = load_kernel(&cpus[0]->env); init_boot_rom(); init_boot_param();