Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3272282lqo; Tue, 21 May 2024 11:37:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMf2gdRB2KacULnLBw/Qkesz6LZPJ5/3HQrnIHUqQMs0XZGl2rPNZ7gAQcUSOVJj2rHI+Yhy+D5b4XIYS1bRCnvZLatb7ysnIMRi/+8A== X-Google-Smtp-Source: AGHT+IFsv5rp93fPnxLTZRT7eiWBT+nYvdu/7kz4WdQBngfZzpXxE802XWAnyy8GQaCS9x3B086x X-Received: by 2002:a05:6358:3417:b0:192:8018:81 with SMTP id e5c5f4694b2df-193bb6243c3mr3322447255d.8.1716316624114; Tue, 21 May 2024 11:37:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716316624; cv=pass; d=google.com; s=arc-20160816; b=goHLBWbpwJLC0/pfGJPbuK5K/DItgm/WwF0bZypH93tBiEqC3R4ELg3p8l6qfbIaj1 +ZIawIBaDgd7usTxlMvY5TloF8VtyRoBC0W4WqivuShNF+Xj824FYOMvRsOvgl5pVUeH 2SrLKMa8CevWwpOBXHaWeqXXvVslQCIr/fX4hCtoRBWT1QgAMfQHeasOe93DUbtnFgFm okj3ciC5cCh6wnOmgbt5SuBoWqw5h4jzDqpQVD4udsMmE/834SABKF5vUog4mhSs7uxE RTSZoWNU5NTAOTS7HISp2Q/hlATz9USBDiAyRmU81TKNCL8o5dNKqwg03Q38tR4navo7 iUNA== 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=CLyU2aNbp4OgiW+TMwuCji93HtnrvdXX6qL+T9597uE=; fh=k0ydrvCAwFI85dzlFik4zVwFPgch3GfxCemTfKdbv0Y=; b=xdGyNiKYq3pTxMPyHW/xaHoVP9VTqTxXuqlMkjtoLNKP56iLzw5UZKotPx8mTkZxIU 1BJt7Ty8YHRE/NTny1cEUdXXmOI1DneoGWTXoE+rEgM2l1kmKmYCHpCKFZLr42c1JI7P cMRmX4WzSkkvbBrRDb8MQMK/EW0mnNMaVRXq1Jn2dY0S3e01IGpZHefmHhx2+ny4Syvc 42yHZjiuSBJ7s6UNCQJJe9VFY6Zc7kVuCAybixz9OirzFX6o6Hx52lDikGF2O5BQjWLQ nj3VXSLSWli3Ild6yPm54KwkFVWLrCcBXC6tHdsyf+j81r2iIR5URQWWhY1pbyoqPPcD cACA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=O9zGi601; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-185331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185331-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ab7415a0d3si19568726d6.20.2024.05.21.11.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 11:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=O9zGi601; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-185331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185331-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BD3C91C21582 for ; Tue, 21 May 2024 18:37:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A75BF148FEB; Tue, 21 May 2024 18:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="O9zGi601" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 3092414882B for ; Tue, 21 May 2024 18:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716316607; cv=none; b=LIYub0/BPRoxRIK4v/JeShuuyqnUP6eVWs+S9S/LctNMpST3XqMY6FSsJ6vUwov5RwE+68GwwJ6unRtBKVgmAxfIAJSDdmNKjqnrd98s9ppCI9lGriXe33z5E12FFHBff72oG229niLFVMkAGFxc/8/G+8TB8iCordyKTk880Us= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716316607; c=relaxed/simple; bh=p9q2M+O7cnAZmwHeM1C7/2qwgRed7uafThFF3nvl9sE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=RUNG7tTZyy1pEBqJVGgFQSpdFxEJVF5f231+n+O6ss9mTBoUjLju2Z0CBUkYY3DHlh1EPAYcZ6/sp9tEsNH2ejfgMqacvU6dyLsAMKbJ/JqQ0FwRneosi1nc1yTxLEp6KNT1Hud6qdN73Tngtf6q8JwRskAXZE5/8lZCgvHOnvo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=O9zGi601; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a59b58fe083so643796466b.0 for ; Tue, 21 May 2024 11:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1716316602; x=1716921402; 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=CLyU2aNbp4OgiW+TMwuCji93HtnrvdXX6qL+T9597uE=; b=O9zGi601uwcyAL0VSIOZXru2Qqf/QZl7aRoVYRafixr0CRBYQLQwTDbKkB1gtUr4UL i+wBiEwHEffX4lui6wPKT8CV+Scm/r7uiQ57pWTVxdbOmwM1uGOqcJPB4rpZHJyDCdHq yLB6khEuh0OE41x5792Sn6NgJHOkeuXW5WcMTL50Zp1ivG33ZNol1EYWC/UYbIPdZ13d WSSBYb2cqQ3H9iNIvH3eh3Igvra6B7JbbzW//ZZ7jX5fdtOsfO87/MuhUn6oWzEgeFuB upZeuhp0y0sP5lzKpNe+FLgy1AdnEc8CsH6OIXQvltiT4J3agxogOlRFSuk0ZfKvmacB GrtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716316602; x=1716921402; 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=CLyU2aNbp4OgiW+TMwuCji93HtnrvdXX6qL+T9597uE=; b=MCA8qYkrWs34ADgM0W/GnFixpTdvLN9FHXl92s+fdq7QMMiAmuIuFNqoTN6ns7adJr vq2c0wNFq5lJmagXWzDHCcc4/a3twH5SNkuIR5fK7kvnZOTIjmf90UACqlhjwa4cc/pc qjsBOb5FvhStTPa1EyzD7IEmE5tfxwy1iBmDAdzJTHrkpwzf3ZjD6nnolv92+7BbtXxk nrMTAy0ZY+S6/QMZZJGWFSvTZv5yx4JhACdTBJzcqhTWJ8qsNiZSuyak9BTYAoczFc4s O9HeX6xKKa9V4ePAGuNLUBK/8+dxC2jNsILLX6qovgjmzFicyTK63SqziKa8/JqZYqwi wk0w== X-Forwarded-Encrypted: i=1; AJvYcCX2AbPNIYvy+DTkxqNn4dYQQZ+ff2Ii6QBiHSQA1d4aT/Zebk8CRNW313i6ZJmTlqgCbIcoGWbbHjxlUkLnGjMlZTFjCSdQZK5sk9oE X-Gm-Message-State: AOJu0YwjCIq8a4MhWH3P/y0MMx9DgB8+WLOgMPPFCkjP8dbUJKXwjL3R 7aHcLUhom7g6wSz76K4lERsay8SN5U7yT071b9rngo3yfLzL1T0FAjx+nzDfu5O0yJDNbo30fSW acl1RZgb5xZ62KDO1j4V3olgWCIBV/o3i527c3w== X-Received: by 2002:a17:906:97c8:b0:a5a:a2b6:ba8b with SMTP id a640c23a62f3a-a5aa2b6bf6fmr1215235666b.0.1716316602491; Tue, 21 May 2024 11:36:42 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Evan Green Date: Tue, 21 May 2024 11:36:06 -0700 Message-ID: Subject: Re: [PATCH 2/2] docs: riscv: hwprobe: Clarify misaligned keys are values not bitmasks To: Yangyu Chen Cc: linux-riscv@lists.infradead.org, Elliott Hughes , Charlie Jenkins , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Conor Dooley , Andrew Jones , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, May 18, 2024 at 9:00=E2=80=AFAM Yangyu Chen wrot= e: > > The original documentation says hwprobe keys are bitmasks, but actually, > they are values. This patch clarifies this to avoid confusion. > > Signed-off-by: Yangyu Chen Hm, we also have this problem in the code, since hwprobe_key_is_bitmask() returns true for KEY_CPUPERF_0. This results in wrong information being returned for queries using the WHICH_CPU flag. If usermode asked for the set of CPUs that was specifically SLOW or EMULATED, the returned cpuset would also include cpus that were FAST. I believe all other queries are okay. The one-liner fix is to just not return true for that key in hwprobe_key_is_bitmask(). But that's technically user-visible: if some software relied on the buggy behavior of FAST cpus being swept up in the query for SLOW or EMULATED cpus, this change would expose that. The grownups-eat-their-vegetables thing to do would be to define a new key that returns this same value, but doesn't return true in hwprobe_key_is_bitmask(). What do people think? -Evan > --- > Documentation/arch/riscv/hwprobe.rst | 31 ++++++++++++++++------------ > 1 file changed, 18 insertions(+), 13 deletions(-) > > diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/ri= scv/hwprobe.rst > index 239be63f5089..4abfa3f9fe44 100644 > --- a/Documentation/arch/riscv/hwprobe.rst > +++ b/Documentation/arch/riscv/hwprobe.rst > @@ -188,25 +188,30 @@ The following keys are defined: > manual starting from commit 95cf1f9 ("Add changes requested by Ve= d > during signoff") > > -* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains perfor= mance > +* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A value that contains performa= nce > information about the selected set of processors. > > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misa= ligned > - scalar accesses is unknown. > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_MASK`: The bitmask of the misalig= ned > + access performance field in the value of key `RISCV_HWPROBE_KEY_CPUP= ERF_0`. > > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned scalar acce= sses are > - emulated via software, either in or below the kernel. These accesse= s are > - always extremely slow. > + The following values (not bitmasks) in this field are defined: > > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned scalar accesses= are > - slower than equivalent byte accesses. Misaligned accesses may be su= pported > - directly in hardware, or trapped and emulated by software. > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of mi= saligned > + scalar accesses is unknown. > > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned scalar accesses= are > - faster than equivalent byte accesses. > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned scalar ac= cesses are > + emulated via software, either in or below the kernel. These acces= ses are > + always extremely slow. > > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned scalar a= ccesses > - are not supported at all and will generate a misaligned address faul= t. > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned scalar access= es are > + slower than equivalent byte accesses. Misaligned accesses may be = supported > + directly in hardware, or trapped and emulated by software. > + > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned scalar access= es are > + faster than equivalent byte accesses. > + > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned scalar= accesses > + are not supported at all and will generate a misaligned address fa= ult. > > * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which > represents the size of the Zicboz block in bytes. > -- > 2.43.0 >