From patchwork Tue Jun 4 12:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 13685239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E43AC25B78 for ; Tue, 4 Jun 2024 12:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eW1qgueYiSMWPtEh/CvqklqTAjWcbXYO1F5EPWpnXWI=; b=BOdo7Jct7xN9ix fhz1fbjIXmrt1b4BnmuWiRreYmrZdxR5s2N3u7Wb+U/pi8YFFD6J9IrQiWHEFsotTy2kwu13usLSf upC97FV4Mu0Ix/Wl3pnYrvcALNUTU5+qh+QCpnzYO2dYr2tPozYEksQy9cWWcyUdaNCTsog8TBcYT 3e1QadLzQO2MD7seVriRiFud1s//70WN/VGAkZckWf9PHum3YY73ii79ZfFLopc5MZGQccYGsBZG9 xXFyc/LPnXQlrtF0K+JYNIexLDN81H2jegT5EXo/GfTbfPFJxJiUbvA8Xmut/DR87enx3bBu1vSC/ mXXPx+VerKYsb7vK+B3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sETYP-00000002LAM-15KY; Tue, 04 Jun 2024 12:46:17 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sETYL-00000002L91-1i0M for linux-riscv@lists.infradead.org; Tue, 04 Jun 2024 12:46:15 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1f64b60a937so718875ad.3 for ; Tue, 04 Jun 2024 05:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1717505170; x=1718109970; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RlFfGyvlYpwu5mumxxHK+PtmO5s3+buvtb+SvPxc6V0=; b=GvUxTDPOvSLes+m0OyyvCm+hvTVv24iKkBVlhkzgqqeIcvH8aK+M2spURMzalmOciM 5r9GzmsffY+9VArfSQCYEM6om7GLlB7pRnFkiiE0dphfaHYNgEHo4/Yzm+sbpxJUVUlY BBOjG3ZGVR5le/GkpDte4E8eeYUEGLCWpRuRmxXQKylhtWP/QhG0W5VrFM0gU0KmQwcQ DNvkaYPCul4UdeiI6oJV8Qcf4XEEV+27cHUXDH2Fl04zLclmv64vAhA2o4+Go4iyFLhT YrtLQbIzm97Ph+e+EtFQN6DWBTGVy3l9e7Ua1wrIozaAUIqWYXLYXadpVCVDYW1D/PcV xEeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717505170; x=1718109970; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RlFfGyvlYpwu5mumxxHK+PtmO5s3+buvtb+SvPxc6V0=; b=uI64vANI9DkK2BYF4YriefDmyrnQw1gAsV1d4hEUk7qoAnL+tf1JcH5KjTpLxY29QC YM6opWr67Li1MV2xqTVEPB7+K2V//hLFeBYXPDuSCIP44gyVYwu7br6SY7H6c+YPO+rG pg5VNr+CKERR+6MW6SvcUFcxamumPp4GzIGeiZjkM+Um7hT79laYcBN2cVrEYmUsI3Y7 hiKcG7eAD1veH/DeGP28QpHruhU0RswkGksQ3iRq1rqATrNd6tQug1ZHjDDPejlUJI44 YrRqNX4pEgn7b0jGUlwoMUo5b+dzJdHDqqBfc63vlrFSbjooPy4m7OCzZha5rVJNAjlv z8jA== X-Forwarded-Encrypted: i=1; AJvYcCX9kH0STvyvHD9bryqxxrZPRiQPu9nPzHE2M6UFTJlM/xgD+5hOPSGeWtH+3iaz5s7EEO34Qd3Z3nceQJndjbhbGeJ75xz7sMZlMsYCqGRV X-Gm-Message-State: AOJu0YyQCzK4kFc+fVGVzGby0GfLYrosCt/iXC8bY/DsYaMsXY4YqOt6 0aUhwKKWShMFiBSAFSGZPlmpeiIO0ePpEB63thKwCIVybBEJd0jXLvgzKUAjqzTNn8rlfm6Pvlj 28zI= X-Google-Smtp-Source: AGHT+IHYa0Aw6/ZCoGM1K6W/t5DQ4yQlSVhFECl9FxLx/IWFviwLhyvqWExcUz4B81YUgol+CdCuQw== X-Received: by 2002:a17:902:ea0e:b0:1f2:fbc8:643c with SMTP id d9443c01a7336-1f6370f2847mr137326235ad.3.1717505170463; Tue, 04 Jun 2024 05:46:10 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:327b:5ba3:8154:37ed]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6323ebc69sm83042885ad.211.2024.06.04.05.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 05:46:09 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Anup Patel , Shuah Khan Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org Subject: [PATCH v6 00/16] Add support for a few Zc* extensions, Zcmop and Zimop Date: Tue, 4 Jun 2024 14:45:32 +0200 Message-ID: <20240604124550.3214710-1-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240604_054613_704675_BC02523D X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add support for (yet again) more RVA23U64 missing extensions. Add support for Zimop, Zcmop, Zca, Zcf, Zcd and Zcb extensions ISA string parsing, hwprobe and kvm support. Zce, Zcmt and Zcmp extensions have been left out since they target microcontrollers/embedded CPUs and are not needed by RVA23U64. Since Zc* extensions states that C implies Zca, Zcf (if F and RV32), Zcd (if D), this series modifies the way ISA string is parsed and now does it in two phases. First one parses the string and the second one validates it for the final ISA description. Link: https://lore.kernel.org/linux-riscv/20240404103254.1752834-1-cleger@rivosinc.com/ [1] Link: https://lore.kernel.org/all/20240409143839.558784-1-cleger@rivosinc.com/ [2] --- v6: - Rebased on riscv/for-next - Remove ternary operator to use 'if()' instead in extension checks - v5: https://lore.kernel.org/all/20240517145302.971019-1-cleger@rivosinc.com/ v5: - Merged in Zimop to avoid any uneeded series dependencies - Rework dependency resolution loop to loop on source isa first rather than on all extension. - Disabled extensions in source isa once set in resolved isa - Rename riscv_resolve_isa() parameters - v4: https://lore.kernel.org/all/20240429150553.625165-1-cleger@rivosinc.com/ v4: - Modify validate() callbacks to return 0, -EPROBEDEFER or another error. - v3: https://lore.kernel.org/all/20240423124326.2532796-1-cleger@rivosinc.com/ v3: - Fix typo "exists" -> "exist" - Remove C implies Zca, Zcd, Zcf, dt-bindings rules - Rework ISA string resolver to handle dependencies - v2: https://lore.kernel.org/all/20240418124300.1387978-1-cleger@rivosinc.com/ v2: - Add Zc* dependencies validation in dt-bindings - v1: https://lore.kernel.org/lkml/20240410091106.749233-1-cleger@rivosinc.com/ Clément Léger (16): dt-bindings: riscv: add Zimop ISA extension description riscv: add ISA extension parsing for Zimop riscv: hwprobe: export Zimop ISA extension RISC-V: KVM: Allow Zimop extension for Guest/VM KVM: riscv: selftests: Add Zimop extension to get-reg-list test dt-bindings: riscv: add Zca, Zcf, Zcd and Zcb ISA extension description riscv: add ISA extensions validation callback riscv: add ISA parsing for Zca, Zcf, Zcd and Zcb riscv: hwprobe: export Zca, Zcf, Zcd and Zcb ISA extensions RISC-V: KVM: Allow Zca, Zcf, Zcd and Zcb extensions for Guest/VM KVM: riscv: selftests: Add some Zc* extensions to get-reg-list test dt-bindings: riscv: add Zcmop ISA extension description riscv: add ISA extension parsing for Zcmop riscv: hwprobe: export Zcmop ISA extension RISC-V: KVM: Allow Zcmop extension for Guest/VM KVM: riscv: selftests: Add Zcmop extension to get-reg-list test Documentation/arch/riscv/hwprobe.rst | 28 ++ .../devicetree/bindings/riscv/extensions.yaml | 95 ++++++ arch/riscv/include/asm/cpufeature.h | 1 + arch/riscv/include/asm/hwcap.h | 7 +- arch/riscv/include/uapi/asm/hwprobe.h | 6 + arch/riscv/include/uapi/asm/kvm.h | 6 + arch/riscv/kernel/cpufeature.c | 278 ++++++++++++------ arch/riscv/kernel/sys_hwprobe.c | 6 + arch/riscv/kvm/vcpu_onereg.c | 12 + .../selftests/kvm/riscv/get-reg-list.c | 24 ++ 10 files changed, 375 insertions(+), 88 deletions(-)