Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp193630imj; Thu, 14 Feb 2019 18:23:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IZtMXPkLlMaNoqpis4rnQIq+cywRkZgSGPm404GL67hUZcy9s9QO7J2aYQVPJdt6RVuvx7S X-Received: by 2002:a63:9144:: with SMTP id l65mr3074047pge.396.1550197408991; Thu, 14 Feb 2019 18:23:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197408; cv=none; d=google.com; s=arc-20160816; b=IP/Y7qdNQuS5Hzz5utirbQCsEGRShsWFknroCzKO5N9kqdPWkpg8LFWZ7DTzF7DL80 uDcwTmWujFRKPDSDZeXeYpNABKHyTmKyu1E50Q1al9SqPncdoE8PNOgxA7+gQtNR6KU0 JZ1GuV3ucI/wKoMUPYDZN2cTCxxTFAy7c5Bk1zNQnCABgO8nYMbObFuIbZ0lnBmjSX7+ ZoimvEPke7kXhT5ZbAGxZkOX0v52zoxVzyjLnaBmZc8pB6t06guw/h2FOmM9fUPxwTLv NWpCgKIqGeQdT0XUSczAcwLlVdXDBew9Gzg/UrS6DfP50MAK77MJVhnwPQAFunZXwErX ezWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=5eW6Rb/ZV3o664BUI35xYRvFlJktQaJDFJ1BH+cqsZ8=; b=NgKUkgj3SgZ+dMwhYgGGEAtgBFSpHrpePLl9Bsj2kCnss7Aag/2WtHWJOuUubQu7kO FuQ0cu/eJukPGgH2H2jevBkRwjH1323yMTH+Zh0sMsxfLPSEqQxyZtRhIGx0bXzzEhBe tagzptLAf7GGsys8kpRM/1S7g77P68nmTyCKVrPaHfplKRzBBCd3iqOm+8W5zgWCUPYB r+6G16DUQLqLEKuUOooxQ5K6BQfpUdsFyOfUyqid1oK1ZFefrcVyiksFLvjFYYyzDgdl M8RQ6AOIJ0uMfAZFjlNAAzxVd1uIGQCB0fBAOzQzHkm3icp+B83NuwP/sQvfASQePBU+ PQ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=d1lx9p1x; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si4061506pgg.306.2019.02.14.18.23.13; Thu, 14 Feb 2019 18:23:28 -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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=d1lx9p1x; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729102AbfBNXdZ (ORCPT + 99 others); Thu, 14 Feb 2019 18:33:25 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46954 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfBNXdY (ORCPT ); Thu, 14 Feb 2019 18:33:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1550187242; x=1581723242; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=JyIuzoahJhXItXaoaLO0BZt6YCodUNR0jk/suO+uHRY=; b=d1lx9p1xNhPUcOUpT5KUuwKP/eP3etWnkG5SlGujAzVX+cyte5audf3/ 6BzFk0rMd5JPpFg6bsInNB8+ZgKg3qyheDVPRSKg78WaRuUSALlG/RXTq Ty7iHqyiwgCZpp2CEmpVZaZ2uHeMPYt1rElF4ZV2xeHSKTEQrogJFmukY B/sNxJ27eib3OeyZ6ECFIxRq66jYqqeKdzgsRDZVcu1x69Ka4BC/HF8J5 5A1kNSMqJLeZlpqFWo+x2MjipAFPalsPBbkWq+27uVguP2nFJph8TExlA wNuwLwjeKagXVJjA19d8UPWMcXBP3yXmAf7Mq7qfFgNPeyyp4tXDuJdYc w==; X-IronPort-AV: E=Sophos;i="5.58,370,1544457600"; d="scan'208";a="199529650" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2019 07:34:01 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 14 Feb 2019 15:13:56 -0800 Received: from c02v91rdhtd5.sdcorp.global.sandisk.com (HELO [10.111.66.47]) ([10.111.66.47]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Feb 2019 15:33:23 -0800 Subject: Re: [v5 PATCH 5/8] RISC-V: Compare cpuid with NR_CPUS before mapping. To: Christopher Lameter Cc: "linux-riscv@lists.infradead.org" , Albert Ou , Jason Cooper , Alan Kao , Dmitriy Cherkasov , Anup Patel , Daniel Lezcano , Johan Hovold , "linux-kernel@vger.kernel.org" , Palmer Dabbelt , Paul Walmsley , Andreas Schwab , Marc Zyngier , Thomas Gleixner , Guenter Roeck References: <1550089092-28783-1-git-send-email-atish.patra@wdc.com> <1550089092-28783-6-git-send-email-atish.patra@wdc.com> <01000168ed298ba3-fea3ca2b-436b-4ce6-a0df-cebe727bf55c-000000@email.amazonses.com> From: Atish Patra Message-ID: Date: Thu, 14 Feb 2019 15:33:22 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <01000168ed298ba3-fea3ca2b-436b-4ce6-a0df-cebe727bf55c-000000@email.amazonses.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/14/19 9:59 AM, Christopher Lameter wrote: > On Wed, 13 Feb 2019, Atish Patra wrote: > >> --- a/arch/riscv/kernel/smpboot.c >> +++ b/arch/riscv/kernel/smpboot.c >> @@ -66,6 +66,11 @@ void __init setup_smp(void) >> found_boot_cpu = 1; >> continue; >> } >> + if (cpuid >= NR_CPUS) { > > Use nr_cpu_ids instead? Its initialized to NR_CPUS but can be restricted > if we can determine on boot how many processor we truly have. > nr_cpu_ids can be modified by nr_cpus in boot command line. If nr_cpus is set to a value less than number of cpus described in the DT, kernel may not boot depending on the boot hartid. This happens because we break out of the while loop and BUG_ON(!found_boot_cpu). As the required fix will be different from the current fix, I would like to do this in a follow up patch if that's ok. Btw, thanks for bringing this up. Regards, Atish