From patchwork Wed Jun 19 11:35:10 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: 13703725 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 4D67FC27C53 for ; Wed, 19 Jun 2024 11:35:45 +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=bHlXne8zF6E+9MlIzekPvhd1x2n3HiPkW7VlbIuksRE=; b=00MjAtxuj+S5WD +XRqTWjssKKxE+xaJQt9qId1n6SkOtlG0bpcCCWqPzh8PsHYYaOfl910M0z8qcxWgnQ+TB3Hmra4F 8LhTSgKpI6OU2I4SPChCvth6p3sT04zJOH5jgkRKDxSujhtI7Nt+W1B0mHOuJmlcehk0gpLY/BoOI 4tRfQy09DoTqzLIinxdDJ3X7ICdzhCV7d5dQ65CSljJTkd5s6J5ydiurpRUok1IQU91nFPgCUHPB8 MmBzjoK5Nf6KK0VG5PGYR2+F3o11lc268vxegtWMwvUlBjw8VCeMfh2K3bwy2p224TRBXcmu2fj/L 4dhPi7LlFKDOzkT385Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJtbI-00000000zda-16XP; Wed, 19 Jun 2024 11:35:40 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJtbF-00000000zbb-0Drc for linux-riscv@lists.infradead.org; Wed, 19 Jun 2024 11:35:39 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ebd590a79cso6505881fa.1 for ; Wed, 19 Jun 2024 04:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1718796935; x=1719401735; 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=R68cnnEZYSz82BBlgeePthLtn1GpI/DDwCMXiGYDPIE=; b=Qu973uFLFYr4mJqDvyoB3g4f6TnRO46F6c0bpe2DsMeMU5pC84uInQnma7LTVe6oIz 1XWwA//65d67HGPK7uF9fTSc23x+IzYqOlC98IytjVVehcgXadnNQNQb9qhCXsV+jbRp r0myvDYudCkkfDXFD3Bl+KompxglsOT3eIdCoNwAOw+94qIhZ6LG8K0Iqf++iLZNW0B6 b7XO45dQosKpksFRa68Y6rne0dPSRKISdRHWTnjRhvxzNC7QDRl40Jo3cXAl5La/A1Xm WgD3r4h9tSl85g3vZBHRSnG8IHWTGLyT5CWvcxPNAwrMP1fxbfbZBP9nn3madWQy3ujR pEyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718796935; x=1719401735; 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=R68cnnEZYSz82BBlgeePthLtn1GpI/DDwCMXiGYDPIE=; b=E4kiSImuZlxrysC9aw9fI2xwWsl2UOl3xdh1Oj5RbyyD+yju39ud14c91EozliaSyo aTW29IrfpUtcWZrufUZ3I4m6rtQ58cFOPGMP7Jonf2qel6iiLITzho/mm4Yn4FI+I/cR 22oMR0MU4m1TTCrnomAxaOb8wl3rBrMrJXSfgZTFCfMKO3BIjfDMp+IRYpPfQTFwjxJx m1kVYJQhSXecXtiFBv8VbjqIxirQJ2JaK2Bnj/tux0vuP8JO89972fBQKJJsAAh2WbNP UUNjOTFlwDyQcEhwBEml2YLl82wOrmQaXLBNzSfryugE3ZeTLTrL48EJhb3A52NTf4rs moOQ== X-Forwarded-Encrypted: i=1; AJvYcCWkmXiyhPaW2Znhr83vujbGc04quu7GfrFly8NL/jjAp1KXjimu8EWC5is2bNBevzkxRNHAhvqGoxIScavlSoPx3G3DNa56k7Ok84t1idMB X-Gm-Message-State: AOJu0YwJAtUZ/vpq8f8kR4TG/QxoRw/8fl4FL26hmrnEKsFubDizQexL KcVjQSnKJZxwPnsaU9kGOic49tDUguTdAyFO/MUrojOn8N+52k+B87+V3elZFho= X-Google-Smtp-Source: AGHT+IFsCC87W4xVADXKP6E1LRVpjwgMonVuzzedwVb0Jp+JNzVJhthcLxSn+Xc6UH4SRMqEmwjj+g== X-Received: by 2002:a2e:a548:0:b0:2ec:3e14:fa1c with SMTP id 38308e7fff4ca-2ec3e14faf7mr12339341fa.5.1718796934705; Wed, 19 Jun 2024 04:35:34 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:e67b:7ea9:5658:701a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-422870e9681sm266192075e9.28.2024.06.19.04.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 04:35:34 -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 v7 00/16] Add support for a few Zc* extensions, Zcmop and Zimop Date: Wed, 19 Jun 2024 13:35:10 +0200 Message-ID: <20240619113529.676940-1-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_043537_273526_99682F95 X-CRM114-Status: GOOD ( 10.31 ) 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] --- v7: - Rebased on riscv/for-next to fix conflicts 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 | 6 + arch/riscv/include/uapi/asm/hwprobe.h | 6 + arch/riscv/include/uapi/asm/kvm.h | 6 + arch/riscv/kernel/cpufeature.c | 277 ++++++++++++------ 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(+), 86 deletions(-)