Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4687681imu; Tue, 8 Jan 2019 04:41:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN6b8Mdi0HQYowMkrj9xeHLwEZPs6hQL8+uSD3qIaeQqBthBpQI9TUHh0vTF7l42X8Q8PGzo X-Received: by 2002:a62:3943:: with SMTP id g64mr1635380pfa.114.1546951278863; Tue, 08 Jan 2019 04:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546951278; cv=none; d=google.com; s=arc-20160816; b=eIPwkeHQO1t4x6J5Pg7Jj1XSxlGQBGStWs+Vt32aOq1FsBXaZwOmE5gFjgvehKDJN5 tPdZHRBLuIeSRHECaUTGAAOvjPg3BDpGq2wGCAQyBGWhRf+2Mu3i5B9AwE2AILDoLKze 4atULVwf55syOf2Wy6491gNReaXWjjiAiYESW9Rp9zxagBhltrDJPFzg3wtFrmK4TV4S VTAjgEz0FLm5RuVtDonwP9WJb4oDl0wlgWs9b4QyHor1+BffA6nuQNtIybtFYG1Hn3P/ hRuKd65FCpV8ZfO49jFcmekRL8AiRmHGJVQjwCUt7qVmUyA1FQmPX4HZaFQ5SIfovzrG hthA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YU8sH6viOntqgZUUKSU5EN2OBCWmmABCsIsJ/nFFgT8=; b=kgCLvFjtQE1l39yNKFtvpdj3FPByy1uRIUjIn2oV+NqtyApEnXUKUXeQPJaOvWuYAe ZfrFsuksb5Cff/UZavEo/6BFSInbb2rIEgsuOTUzddNWw8otmDHCnveeOUxF9EYSPS8H pvj2jN6Uzml+QEJxOPJOT8y4z/NDFGq8KJI84zzXUN1xZetSw5Gdj8zoIZeS6ls+NkHm izvPJtZ2tI4w4zk8Z0afBARsUUz0+7hcLBwCbXSpd116boXyDkWEHD9wNyW0zVm+1i/C agXUvYfJ0ad+aTLQ/M88bIbzRzmX+YWTq4VVnAhhATaJFast/HbbnmbiaWgspE1/l8AK RTHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=Sjr30I2e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92si3403599pld.84.2019.01.08.04.41.03; Tue, 08 Jan 2019 04:41:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=Sjr30I2e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728828AbfAHLtn (ORCPT + 99 others); Tue, 8 Jan 2019 06:49:43 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39643 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbfAHLtm (ORCPT ); Tue, 8 Jan 2019 06:49:42 -0500 Received: by mail-wr1-f67.google.com with SMTP id t27so3735578wra.6 for ; Tue, 08 Jan 2019 03:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YU8sH6viOntqgZUUKSU5EN2OBCWmmABCsIsJ/nFFgT8=; b=Sjr30I2eXvkoganrTMZz1QEUTpkPkShpdPHN6iyZPeBFV/ENz4RKNh7HZtgIqE1zir STNU1kmJAU7+QjvqTGx8tAxPQtzxIYx4LoTCO7+V74ox+HJRDHtlI0gicNguMnuIm5RF 3yb1We9woWYmnqT0flzKjyBTpCQm6IuxNusK037N+jJbwKiJYYjwUz1DJ8TedvsS9Z7K 4I/AWYpfkIq3qEBKRhKJELhrL2ew0DhCT4oUKXhzZSQMqgEwmhws2i7WCa6UlkRQaKqh KZJibTWr5C1a6ZEFImm4j+zmYti3SHgJXhALEdIvP8VLoROTpIbm+KpRu5G9Pw2YebjH fd3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YU8sH6viOntqgZUUKSU5EN2OBCWmmABCsIsJ/nFFgT8=; b=bY/NnSKMm1/MwFuJnZxQSyWYm6/anXxvnPxvY0v4Jf/+Y7Oe+/h6ihOig5yvVkh3rT J4MjrAvQIFuqj/ynPkn/wKR04QjtnhFCLugUiZaSOYkyQIooGOCvdyoOf/RX2N4JAqBg QoLKZs7JstZpo7DZaFQQnHS1KcwEH4dzBl0aO5VqCoK16L98ZQVBBJ1eB6qay9JxHZpI 1PZ7JTEpBf+XeDZ2oEv+9BLRpWn4/QRULhHiPpJjhYDZ+oz12BL+kGiu/NI4CBkmx7gI 0KCd7inw182zQUMfyP/XyzQN6dcCJ/57CPLgHVB1TLoU4q7waMt4K7CFsbHeZFMDM35I a0Aw== X-Gm-Message-State: AJcUukdAPZ1ca8CMhY522wqPHzM6Vtd5tVe/PLm7+QzD7Z7cdDdeAlVf zQUzXTNiI5prL6GPE9OGECR4TwrkBwyF6GgdEf2M5g== X-Received: by 2002:adf:8506:: with SMTP id 6mr1282487wrh.128.1546948180695; Tue, 08 Jan 2019 03:49:40 -0800 (PST) MIME-Version: 1.0 References: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> <1546940318-9752-6-git-send-email-atish.patra@wdc.com> In-Reply-To: <1546940318-9752-6-git-send-email-atish.patra@wdc.com> From: Anup Patel Date: Tue, 8 Jan 2019 17:19:29 +0530 Message-ID: Subject: Re: [PATCH v2 5/8] RISC-V: Compare cpuid with NR_CPUS before mapping. To: Atish Patra Cc: linux-riscv@lists.infradead.org, Alan Kao , Albert Ou , Andreas Schwab , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , "linux-kernel@vger.kernel.org List" , Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?Q?Patrick_St=C3=A4hlin?= , Thomas Gleixner , Zong Li Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 8, 2019 at 3:08 PM Atish Patra wrote: > > We should never have a cpuid greater that NR_CPUS. Compare > with NR_CPUS before creating the mapping between logical > and physical CPU ids. This is also mandatory as NR_CPUS > check is removed from riscv_of_processor_hartid. > > Signed-off-by: Atish Patra > --- > arch/riscv/kernel/smpboot.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c > index 32e14572..7954470b 100644 > --- a/arch/riscv/kernel/smpboot.c > +++ b/arch/riscv/kernel/smpboot.c > @@ -69,6 +69,11 @@ void __init setup_smp(void) > of_node_put(dn); > continue; > } > + if (cpuid >= NR_CPUS) { > + pr_warn("Invalid cpuid [%d] for hartid [%d]\n", > + cpuid, hart); > + break; > + } > > cpuid_to_hartid_map(cpuid) = hart; > set_cpu_possible(cpuid, true); > -- > 2.7.4 > Looks good to me. Reviewed-by: Anup Patel Regards, Anup