Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2343322rdb; Mon, 25 Dec 2023 06:50:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDmUAU+ENnmCxr+EdlGbFKlAnVEnNt/MX1TlNz5SX5R0asYpWjSTQpEt8I/OckfeLxkysB X-Received: by 2002:a50:d702:0:b0:54c:6d39:b152 with SMTP id t2-20020a50d702000000b0054c6d39b152mr3646023edi.3.1703515856693; Mon, 25 Dec 2023 06:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703515856; cv=none; d=google.com; s=arc-20160816; b=1Cam+in6MbGIU51BFND8IHzfZMYx7taJEg4mbm5FyVg7yJAMijUdZZh+ruNw0hIpfs Yj++AqxljNlPDnQSiz7l0F0iydWubzkY0BQPjBZnnU9amu+l24w5wp094QlJLLVnKp/F dBuRgbJBP/Cns0nl8mT1BkDp0lDf9l39JiGCaNxLx43CvcT2Fi0mNFpLM3rhNDYgBOE5 ohJlSfFYYfC0m/qoLbQpnpmXcWKI9blsJjSLjqGxNopq7+/9FnZQ5x0GJ8fjnCkeQ4CI wZzT8oDg3xsF1H5FyzL+jG8IvxOmFyIKVXiNMGjxVEmcJ2Q0hfhrtj1yDPGfPy5iKD62 1rug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=TzZpJaFM2t/qYbIOihx1bcdMlYrSy3lEHAU4/Rturzc=; fh=y7VKX694VLH2eb03/y0ljujQLJGtNdYVa6lu5bfy0Mc=; b=00YiX7tL+nYssXhPVJwJMvgEBRMSYnwVbwYsGcrC5qRsSTM10R46EcQfRnTuBE/Iay Y3mezdU0AJbFoYGQLkWroxMkDZIQzy+WQfKCsDFMdqGjFw4+2VccKANwWhpybVqhzMRR +MzlGdIjp8s3vg0J1BiPch78llg0hPBrv1c71sJhxrc4bQ0P58XMwIzGA/jM9NZvQBis XJS94axaEZXpgTUTNISeBZPhjf4sk0DTmcRfd/HN+1o+wgtL5MbPpXf+B1eHQPyS6t8v o5Zqgmk6A9XSYi5o/HwjPgUoLWgyN+OgPrv57r2WageatG9s8AyRPJeqvh8JrNbY6/S+ kA0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11090-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11090-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z11-20020a056402274b00b0055417c6a82dsi4439563edd.476.2023.12.25.06.50.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 06:50:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11090-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11090-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11090-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AF32B1F223BF for ; Mon, 25 Dec 2023 14:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8029F5103F; Mon, 25 Dec 2023 14:50:48 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 110DA52F62; Mon, 25 Dec 2023 14:50:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 070CBC433C7; Mon, 25 Dec 2023 14:50:43 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen Subject: [PATCH V2] LoongArch: Let cores_io_master cover the largest NR_CPUS Date: Mon, 25 Dec 2023 22:50:23 +0800 Message-Id: <20231225145023.1505439-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now loongson_system_configuration::cores_io_master only covers 64 cpus, if NR_CPUS > 64 there will be memory corruption. So let cores_io_master cover the largest NR_CPUS (256). Signed-off-by: Huacai Chen --- arch/loongarch/include/asm/bootinfo.h | 6 ++++-- arch/loongarch/kernel/acpi.c | 2 +- arch/loongarch/kernel/smp.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h index c60796869b2b..6d5846dd075c 100644 --- a/arch/loongarch/include/asm/bootinfo.h +++ b/arch/loongarch/include/asm/bootinfo.h @@ -24,13 +24,15 @@ struct loongson_board_info { const char *board_vendor; }; +#define NR_WORDS DIV_ROUND_UP(NR_CPUS, BITS_PER_LONG) + struct loongson_system_configuration { int nr_cpus; int nr_nodes; int boot_cpu_id; int cores_per_node; int cores_per_package; - unsigned long cores_io_master; + unsigned long cores_io_master[NR_WORDS]; unsigned long suspend_addr; const char *cpuname; }; @@ -42,7 +44,7 @@ extern struct loongson_system_configuration loongson_sysconf; static inline bool io_master(int cpu) { - return test_bit(cpu, &loongson_sysconf.cores_io_master); + return test_bit(cpu, loongson_sysconf.cores_io_master); } #endif /* _ASM_BOOTINFO_H */ diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c index 8e00a754e548..b6b097bbf866 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -119,7 +119,7 @@ acpi_parse_eio_master(union acpi_subtable_headers *header, const unsigned long e return -EINVAL; core = eiointc->node * CORES_PER_EIO_NODE; - set_bit(core, &(loongson_sysconf.cores_io_master)); + set_bit(core, loongson_sysconf.cores_io_master); return 0; } diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index 5bca12d16e06..33e583303652 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -208,7 +208,7 @@ static void __init fdt_smp_setup(void) } loongson_sysconf.nr_cpus = num_processors; - set_bit(0, &(loongson_sysconf.cores_io_master)); + set_bit(0, loongson_sysconf.cores_io_master); #endif } -- 2.39.3