Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1714738ybe; Fri, 13 Sep 2019 23:48:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV99/qWVgdpbZBC8nho7aw5sed/Yb+7vpLfP1Q5Hm2ALofCip6b+M997PEiCYV7h1B8diX X-Received: by 2002:a17:906:cf81:: with SMTP id um1mr43132001ejb.257.1568443683340; Fri, 13 Sep 2019 23:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568443683; cv=none; d=google.com; s=arc-20160816; b=0X3MAZjRCOBCgg3zAsvt4VJXcXRNT0NLehUGMZzbQA0VmN4pJr91ymAPUqIWd0lxhj aZIOERPRYGV8nYhpClLOtAWUDCX3m11kA9QzPvYb0JDLuLfzIwHAEOOAK6Omo/e/WADp tDzOcnu3v9Fb9KDxQChIEpXfp1jIVYzowBSxZ6T8MSoF+i5VPCUFV5NTdYwpvcK92tmM ojupwmEXWojPyCCxLmQtN8XlZ8WHWkMptY7rgmEndB5BAB0axfjuHowFDS0+NDuH2xXG IqTjx8NBz3IYxnDT+E/acLKH+hZFpepML/RXlj2YAxYHGvSZm1ITR647czNsbxP+EM6h TCdQ== 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:mime-version :message-id:to:from:cc:in-reply-to:subject:date; bh=J8WZu8kPZWoeeQELgw+yQTV+q40PZLs/qmgDReqeZXk=; b=pvGb/hoNU207Kp/zJ9Qfk9lmsw55ze3WYNH9bMViZZ44c+FFJ/J3ep1idvy1tABfhe oXf6SrdwODtjbI8BC/fcO/f7Y2Aq2tcH8cGOpYEATwz7LiwA5djX9r0bmTYjBIocFN6N mk/7fKzvTABKnp8Png9ZEDy902ovNsMxGp0kTvc2j03SycudfdAq0oPWVE9ghIkNBv+N XCH5rDPrjseYd7+shHD/BzUE5FdUj23dXh5IL9LTT0jvAgSfWj8bo1MjoDds4XKqAq/X cbHQ7Z+IAyEa1sfXlXAFhGMysnH8hmewfJ6TkZGvkKoZUTfdZ7XItbS6hDTFdt25OSVp 8zXQ== ARC-Authentication-Results: i=1; mx.google.com; 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 x8si19731783edd.282.2019.09.13.23.47.40; Fri, 13 Sep 2019 23:48:03 -0700 (PDT) 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; 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 S1730629AbfIMTEf (ORCPT + 99 others); Fri, 13 Sep 2019 15:04:35 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43313 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730539AbfIMTEf (ORCPT ); Fri, 13 Sep 2019 15:04:35 -0400 Received: by mail-pf1-f196.google.com with SMTP id d15so18624402pfo.10 for ; Fri, 13 Sep 2019 12:04:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=J8WZu8kPZWoeeQELgw+yQTV+q40PZLs/qmgDReqeZXk=; b=QHwZq/eKg6glENi4dOHryZED/oeEsGRUFXRu8f96DULCF43CvTNoSfpZLFhF7p0K6y WNFhz2VveOLsfGGRl9pPHERQpxUR0Dy/sSUDHfwLVUldD4zWRQ9v73x1WHL1uA74OeXB YejPsmSAukVf2rPAn6CO5LZD3puboTekCwndl15Iox6jFavx2NMSAmmW3JxhrL9d6QeZ OezJQX6xu1jLpSMLPINl7U/wg0lgRC2BP2Z6X8lEVwOQSeqVUGv8QJpd3W1GTyPsxC4O vYTd0wRlC98TVsf899aoZrG0MYgAOOI/g0NczenON893/hlUX6Nr+bnukSvi0luMf6+e q98g== X-Gm-Message-State: APjAAAVb9KCpgrM0u9YjFFI9FWYHG5XIo/PhNQgTega2DofZ4j3QKyjA uB2ik/NssxMVWzWBSqp1swtlMg== X-Received: by 2002:a63:188:: with SMTP id 130mr44264209pgb.231.1568401473606; Fri, 13 Sep 2019 12:04:33 -0700 (PDT) Received: from localhost (amx-tls3.starhub.net.sg. [203.116.164.13]) by smtp.gmail.com with ESMTPSA id p68sm56933518pfp.9.2019.09.13.12.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 12:04:32 -0700 (PDT) Date: Fri, 13 Sep 2019 12:04:32 -0700 (PDT) X-Google-Original-Date: Fri, 13 Sep 2019 10:15:26 PDT (-0700) Subject: Re: arch/riscv: disable too many harts before pick main boot hart In-Reply-To: CC: Paul Walmsley , aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, citypw@hardenedlinux.org From: Palmer Dabbelt To: merle@hardenedlinux.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 05 Sep 2019 23:51:15 PDT (-0700), merle@hardenedlinux.org wrote: > From 12300865d1103618c9d4c375f7d7fbe601b6618c Mon Sep 17 00:00:00 2001 > From: Xiang Wang > Date: Fri, 6 Sep 2019 11:56:09 +0800 > Subject: [PATCH] arch/riscv: disable too many harts before pick main boot hart > > These harts with id greater than or equal to CONFIG_NR_CPUS need to be disabled. > But pick the main Hart can choose any one. So, before pick the main hart, you > need to disable the hart with id greater than or equal to CONFIG_NR_CPUS. > > Signed-off-by: Xiang Wang > --- > arch/riscv/kernel/head.S | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S > index 0f1ba17e476f..cfffea38eb17 100644 > --- a/arch/riscv/kernel/head.S > +++ b/arch/riscv/kernel/head.S > @@ -63,6 +63,11 @@ _start_kernel: > li t0, SR_FS > csrc sstatus, t0 > > +#ifdef CONFIG_SMP > + li t0, CONFIG_NR_CPUS > + bgeu a0, t0, .Lsecondary_park > +#endif > + > /* Pick one hart to run the main boot sequence */ > la a3, hart_lottery > li a2, 1 > @@ -154,9 +159,6 @@ relocate: > > .Lsecondary_start: > #ifdef CONFIG_SMP > - li a1, CONFIG_NR_CPUS > - bgeu a0, a1, .Lsecondary_park > - > /* Set trap vector to spin forever to help debug */ > la a3, .Lsecondary_park > csrw CSR_STVEC, a3 It would be better to decouple the hart masks from NR_CPUS, as there's really no reason for these to be the same. Reviewed-by: Palmer Dabbelt