Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp349076lqo; Wed, 8 May 2024 01:22:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyJaEkZwrlXo+44aYbj7j9rUDcgf8ojVT0ZlMK5/QZyF3sJxgZb9Z85ptK+qABymD+C4ohbcDdsEn1/34BKEdXIVKfgofgRED8EPSK9A== X-Google-Smtp-Source: AGHT+IF+xqVNUYRx7HtbNenR3CNX7i6uKfuOsKYXa5uYVFeJ8vKYY1NjePYouEyNl2A8UMnIoiuL X-Received: by 2002:ad4:5b85:0:b0:6a0:b3ff:1e79 with SMTP id 6a1803df08f44-6a15145394amr23343166d6.22.1715156534535; Wed, 08 May 2024 01:22:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715156534; cv=pass; d=google.com; s=arc-20160816; b=T/KO7fkh1mx7yUWkOtB9ZCAOqjKbXWe77ER7JF72UChLTOhPMrKPFUSLxTJNF4FmPD 57wpFM5bH5SvKu+htkw4SRH7301P2M5FdJduGRV/AoAybZcT1pZit2+8zR94sLKOIYKC d5XMUEuIBSQeBamyGvJ02PeVcXH3N4kkd3vDyAilnCJRvDX0CkbXzx3welwlJCsgfSYw P6y+y0RTnwF8x7p3l1uT+0947kVod8bzLcfJmd+SKXutmH27Vq8JKYIyq4+wMyzrSDtf 5b4w6L5vBC+SDq1Uw7pD5M2r13wkbFMCYbFK6sLeoLM9xQmQq35DVSCYqFlEzalcYKoH qGOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=t+tentO31VDVL/Z5hwv/0ekLp4NqtTVqujXuNpdLcPc=; fh=5mJ0wUBCbuPOi1t0y7RNrDPpcXSFcMAxvH73kklcA/8=; b=K22T8A3j7klk0XnMWHWmKAn0ofJI7E/fw6fzkwZYVsvkpGy7nV4bk0JIT44qnZM/ek F0Cdi0iNhrgycxYegLkaMDGX6om5NzaXvogFz8pyhhxto1aULKtyOLmyOI3Fv+H6Ewiz e45Vv6rB9/gC1Y5dcfHviyZYwpz0Odlg/AAk+5igzMxKwmMs9sjPX0kXHMnOtEcGnMYO +2Ypd443BcLjbFdD5SYJVi99VKDye/A2WI2Krk1IQeT9VXKx+mTrDl2QsYj0AalLt/ht +njf9FBmqw7dJ95XSMfd4H8vaV9BQUkDvEB/CJHw1PU+bbiWmV5BJtgHayDG4JCcnqpQ 7tlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=fib8UQCf; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-172904-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172904-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dv6-20020ad44ee6000000b0069b63f86310si13213127qvb.127.2024.05.08.01.22.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:22:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172904-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=fib8UQCf; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-172904-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172904-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 369091C2149A for ; Wed, 8 May 2024 08:22:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F30B74594A; Wed, 8 May 2024 08:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="fib8UQCf" Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 511753FBBD for ; Wed, 8 May 2024 08:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156525; cv=none; b=GCHN5I/WJ6A0Q7PTmAcGmNAsTH/8sPvtihXjca0B0Ji8R1CakytLw7U+4plSptHFbMROGV+m3MA98MYGXejD6BMASbWdUXkes+8RgbajYd2gIvuFLbmm0d92moiqfU56/7JZiDRQAKeCWQAg/uY8e/IZmO75PTajduILjP4vWQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156525; c=relaxed/simple; bh=VqnPVZobujaIPbHooqjp2g7rnHplNoCBcIs20OnSMiQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MBzU2Xs7ROiF55icU+PFCsqMQQKtySXzdtsWvPFcKx9SXtd+uST2OsEa/6lnfTe5qKVLfBk9RTCkjf4I7Nu4nq8LbwLZDYlFZGL12t3SEKiDtI94YlCi2xNnAyt6f/NW2B3J36F+Yj083Mxo3OYqcGWCO0+ZvFjbMF8Ca8oRx8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=fib8UQCf; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-61be613d903so46590237b3.0 for ; Wed, 08 May 2024 01:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1715156522; x=1715761322; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=t+tentO31VDVL/Z5hwv/0ekLp4NqtTVqujXuNpdLcPc=; b=fib8UQCfJ2Hyzfm/EREULoQtDlG9eszx5eVlzrWvgBPMQtxORztymcZ299Oq3+GOem 4MvzMxgSz+X0mVF1OVPibNFqVKGsPb9UjMghQKaiBY5fXnVqPy9A45YfgDGoJSoJliib A6cIzKaYpcjVxmx8h1UvopT3KG8o5NpQxxh53Lrefh+lwOOKlkUCxrz637M48Pwl6DWM 6POmgBhx6JC5i8f1G7BQITwNNlQmfJkXzoyUrLT1qzUrjZ+rdvTKAsJ1md+U9Pg1h+yX 267TKVIECPNEF1NEMsEFtHtYzGAYC4ZmeA9CWOdsG730QzXSCcZczEmUKsztJDdAJR76 V3CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715156522; x=1715761322; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t+tentO31VDVL/Z5hwv/0ekLp4NqtTVqujXuNpdLcPc=; b=Xne07JhzMuIN+iGqe0OfP34RV7zMb/jFnyUZFfFJ0BGPCL+6HXUJTufhGQ6iMwX0qn RsiqsMB2oDGYBZJCq1BufpyG+okWtj5Locb5l9ICriLr6hG7NOSKKc1SlQm+oK5x7TYS i2bFTjqvaAyLIpKuOqccUA/nnS/k4iMa8eJOxWlkYrUG6h6CHCBG5hWGUzYvQfDLG+cI bEKtQpDRLXfZ50PTItKrY5K4WrhMw3N/yTeyEoOWoW4aiFu9+uhaFvNIszjgoWKKgtZz hewL33yCSo2r1d+tDx22UHHjqIjGmEsESngy68xZac1Daus2u/NmBPMKssPElG1prnj6 pNjA== X-Forwarded-Encrypted: i=1; AJvYcCXb83og1t0AMJozUYnn2EG/ZSMkoBtZ+urXdYJ43uF36VhT/Zxbz9mRIFTUo5ZzL7eoHBKztGBRhVjfjSj47pcIMqe8FN7gj5xqBxxs X-Gm-Message-State: AOJu0YwgCLU5HgGHBlg6qxHSJT4N6JMOnRPBL2qObbBtylO2Jh8fZqKR GXwPM0Th3cET1jblHlHNNLIYrRUevlsl73vl7R7do6wrTl+dxiOTptUS7cOS5/BE43SC5rd1PTq 6bFcBjVA5iDunDX7MKqa9jiplX0al7qOqmonahQ== X-Received: by 2002:a81:8395:0:b0:618:7f3c:cbac with SMTP id 00721157ae682-62085ddbd63mr20603007b3.31.1715156519351; Wed, 08 May 2024 01:21:59 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240412-zve-detection-v4-0-e0c45bb6b253@sifive.com> <20240412-zve-detection-v4-2-e0c45bb6b253@sifive.com> <4acc62d0-d62b-4d42-805b-0bc7f663a81c@ghiti.fr> In-Reply-To: <4acc62d0-d62b-4d42-805b-0bc7f663a81c@ghiti.fr> From: Andy Chiu Date: Wed, 8 May 2024 16:21:47 +0800 Message-ID: Subject: Re: [PATCH v4 2/9] riscv: smp: fail booting up smp if inconsistent vlen is detected To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Heiko Stuebner , Guo Ren , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Evan Green , =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Shuah Khan , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Vincent Chen , Greentime Hu , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 25, 2024 at 4:01=E2=80=AFAM Alexandre Ghiti wro= te: > > Hi Andy, > > On 12/04/2024 08:48, Andy Chiu wrote: > > Currently we only support Vector for SMP platforms, that is, all SMP > > cores have the same vlenb. If we happen to detect a mismatching vlen, i= t > > is better to just fail bootting it up to prevent further race/schedulin= g > > issues. > > > > Also, move .Lsecondary_park forward and chage `tail smp_callin` into a > > regular call in the early assembly. So a core would be parked right > > after a return from smp_callin. Note that a successful smp_callin > > does not return. > > > > Fixes: 7017858eb2d7 ("riscv: Introduce riscv_v_vsize to record size of = Vector context") > > Reported-by: Conor Dooley > > Closes: https://lore.kernel.org/linux-riscv/20240228-vicinity-cornstalk= -4b8eb5fe5730@spud/ > > Signed-off-by: Andy Chiu > > --- > > Changelog v4: > > - update comment also in the assembly code (Yunhui) > > Changelog v2: > > - update commit message to explain asm code change (Conor) > > --- > > arch/riscv/kernel/head.S | 19 ++++++++++++------- > > arch/riscv/kernel/smpboot.c | 14 +++++++++----- > > 2 files changed, 21 insertions(+), 12 deletions(-) > > > > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S > > index 4236a69c35cb..a00f7523cb91 100644 > > --- a/arch/riscv/kernel/head.S > > +++ b/arch/riscv/kernel/head.S > > @@ -165,9 +165,20 @@ secondary_start_sbi: > > #endif > > call .Lsetup_trap_vector > > scs_load_current > > - tail smp_callin > > + call smp_callin > > #endif /* CONFIG_SMP */ > > > > +.align 2 > > +.Lsecondary_park: > > + /* > > + * Park this hart if we: > > + * - have too many harts on CONFIG_RISCV_BOOT_SPINWAIT > > + * - receive an early trap, before setup_trap_vector finished > > + * - fail in smp_callin(), as a successful one wouldn't return > > + */ > > + wfi > > + j .Lsecondary_park > > + > > .align 2 > > .Lsetup_trap_vector: > > /* Set trap vector to exception handler */ > > @@ -181,12 +192,6 @@ secondary_start_sbi: > > csrw CSR_SCRATCH, zero > > ret > > > > -.align 2 > > -.Lsecondary_park: > > - /* We lack SMP support or have too many harts, so park this hart = */ > > - wfi > > - j .Lsecondary_park > > - > > SYM_CODE_END(_start) > > > > SYM_CODE_START(_start_kernel) > > diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c > > index d41090fc3203..673437ccc13d 100644 > > --- a/arch/riscv/kernel/smpboot.c > > +++ b/arch/riscv/kernel/smpboot.c > > @@ -214,6 +214,15 @@ asmlinkage __visible void smp_callin(void) > > struct mm_struct *mm =3D &init_mm; > > unsigned int curr_cpuid =3D smp_processor_id(); > > > > + if (has_vector()) { > > + /* > > + * Return as early as possible so the hart with a mismatc= hing > > + * vlen won't boot. > > + */ > > + if (riscv_v_setup_vsize()) > > + return; > > + } > > + > > /* All kernel threads share the same mm context. */ > > mmgrab(mm); > > current->active_mm =3D mm; > > @@ -226,11 +235,6 @@ asmlinkage __visible void smp_callin(void) > > numa_add_cpu(curr_cpuid); > > set_cpu_online(curr_cpuid, 1); > > > > - if (has_vector()) { > > - if (riscv_v_setup_vsize()) > > - elf_hwcap &=3D ~COMPAT_HWCAP_ISA_V; > > - } > > - > > riscv_user_isa_enable(); > > > > /* > > > > So this should go into -fixes, would you mind sending a single patch for > this fix? I thought it would be magically picked up by a bot as long as we have a fix tag. Am I assuming something wrong? > > Your patch 8 is actually already fixed by Clement's patch > https://lore.kernel.org/linux-riscv/20240409143839.558784-1-cleger@rivosi= nc.com/ Okay, I will drop it at the next revision. > and I already mentioned this one to Palmer. > > Thanks, > > Alex > Thanks, Andy