From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id B0DEA3858C33 for ; Wed, 26 Jul 2023 00:47:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0DEA3858C33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3a5ad6087a1so1765898b6e.2 for ; Tue, 25 Jul 2023 17:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20221208.gappssmtp.com; s=20221208; t=1690332437; x=1690937237; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=rwCFiDVwhfYo9ysxOTlveM8JfXk0UvPxMFc/E2I2zrU=; b=jSeEKyrFbaRZIl4oC1Bsiycx16ZmzogFf+TusxinF6JFYnWEn2zlstPcpPT2o2BzpS TGddH6jY2GNsevbFFDmp9+SfIzWIUNz8/I+LdtvjqcU1kz16CLobSLKXO6x8KQfTDEz8 hOJYfPuHINS6cnlDKxOXxJ8apL8qj2BnQcMgU28Stpj5awyNzBppiDGPIZVBCCBDgy8X /p3H/8oD6MBCrLC/+Yp5SneACIaEHECSfSaK+ha7o8qnAcI00MpcpVajAdenJgSxStWW bczkHuoftW1E3U4SjYjUfP8B25N6+wvKokbVG1anPHZYpcEJ2nvLAipRtJhz1VWDFg9r YlSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690332437; x=1690937237; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rwCFiDVwhfYo9ysxOTlveM8JfXk0UvPxMFc/E2I2zrU=; b=cyvjY3a978lZwiu4k4kd8pDXzeBLZJMS3xVqeNBue8eQ/zYH4e2i/D6+Fj1RX7CEGs mZGFDD3ElCXO6UKyTp2+aLbPEGyLP1uhdS3jxC62DGCVABxUtD+9LC/peeutAGr9PxDp fhMPqVyFLJY5EX1cav1BA2lqtjYJXJrZTzQtTUoy8Rv67EM812OKyUaZvUzs9K1aFlS0 IMR178r7z35uVfskOMTLIifeOmqJwYrc4nYuVXqgJGD/KH5G45OJ98CcmjOf3HyrrD1B 4oHOM1s8hSbczMSPakojJqDP98JEG7Qjf6J/kTD9aoAIoGBm/P82XgyN4kz+gC9L/35J 7qLg== X-Gm-Message-State: ABy/qLY2d65geNVoSlmwOuCI+damOjJpnu+Cx/1/9t1IhRJxNbAv9FTJ FMivsESk4qc+PdbyILfGcl3TV1tsVOs6iHNZrHk= X-Google-Smtp-Source: APBJJlFjVLdruLvIAxZFMtAGuslYt/Sm+MQ13DHQ07/SZaJDkaW8Kzskl9uBImYR+K+HVTdkfRwmng== X-Received: by 2002:a05:6808:bd1:b0:3a1:de61:d414 with SMTP id o17-20020a0568080bd100b003a1de61d414mr618771oik.51.1690332437210; Tue, 25 Jul 2023 17:47:17 -0700 (PDT) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id bh20-20020a17090b049400b00268040bbc6asm158861pjb.4.2023.07.25.17.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 17:47:16 -0700 (PDT) Date: Tue, 25 Jul 2023 17:47:16 -0700 (PDT) X-Google-Original-Date: Tue, 25 Jul 2023 17:47:14 PDT (-0700) Subject: Re: [PATCH v4 1/1] RISC-V: Add platform property/capability extensions In-Reply-To: <12c33bfb9533e74b4cba4a0dc5d6b2e4c0756e73.1690329932.git.research_trasio@irq.a4lg.com> CC: research_trasio@irq.a4lg.com, nelson@rivosinc.com, kito.cheng@sifive.com, binutils@sourceware.org From: Palmer Dabbelt To: research_trasio@irq.a4lg.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 25 Jul 2023 17:05:53 PDT (-0700), research_trasio@irq.a4lg.com wrote: > From: Tsukasa OI > > RISC-V Profiles document defines number of "extensions" that indicate > certain platform properties/capabilities just like 'Zkt' extension from the > RISC-V cryptography extensions. > > This commit defines 20 platform property/capability extensions as defined > in the RISC-V Profiles documentation. > > The only exception: 'Ssstateen' extension is defined separately because it > defines a subset (supervisor/hypervisor view) of the 'Smstateen' extension. > > This is based on the ratified version of RISC-V Profiles: > > > [Definition] > > "Main memory regions": > Main memory regions (in contrast to I/O or vacant memory regions) with > both the cacheability and coherence PMAs. > > [New Unprivileged Extensions] > > 1. 'Ziccif' > "Main memory regions" support instruction fetch and any instruction > fetches of naturally aligned power-of-2 sizes up to min(ILEN, XLEN) > are atomic. > 2. 'Ziccrse' > "Main memory regions" provide the eventual success guarantee for > LR/SC sequence (RsrvEventual). > 3. 'Ziccamoa' > "Main memory regions" support all currently-defined AMO operations > including swap, logical and arithmetic operations (AMOArithmetic). > 4. 'Za64rs' > For LR/SC instructions, reservation sets are contiguous, naturally > aligned and at most 64-bytes in size. > 5. 'Za128rs' > Likewise, but reservation sets are at most 128-bytes in size. > 6. 'Zicclsm' > Misaligned loads / stores to "main memory regions" are supported. > Those include both regular scalar and vector accesses but does not > include AMOs and other specialized forms of memory accesses. > 7. 'Zic64b' > Cache blocks are (exactly) 64-bytes in size and naturally aligned. IMO we want to stay away from these extensions that are just defined by a single phrase in the spec. We're still digging out from the first rounds of changed specs, trying to start supporting stuff that's not even been defined is going to just make for another round of headaches. > [New Privileged Extensions] > > 1. 'Svbare' > "satp" mode Bare is supported. > 2. 'Svade' > Page-fault exceptions are raised when a page is accessed when A bit is > clear, or written when D bit is clear. > 3. 'Ssccptr' > "Main memory regions" support hardware page-table reads. > 4. 'Sstvecd' > "stvec" mode Direct is supported. When "stvec" mode is Direct, > "stvec.BASE" is capable of holding any valid 4-byte aligned address. > 5. 'Sstvala' > "stval" is always written with a nonzero value whenever possible as > specified in the Privileged Architecture documentation > (version 20211203: see section 4.1.9). > 6. 'Sscounterenw' > For any "hpmcounter" that is not read-only zero, the corresponding bit > in "scounteren" is writable. > 7. 'Ssu64xl' > "sstatus.UXL" is capable of holding the value 0b10 > (UXLEN==64 is supported). > 8. 'Shcounterenw' > Similar to 'Sscounterenw' but the same rule applies to "hcounteren". > 9. 'Shvstvala' > Similar to 'Sstvala' but the same rule applies to "vstval". > 10. 'Shtvala' > "htval" is written with the faulting guest physical address as long as > permitted by the ISA (a bit similar to 'Sstvala' and 'Shvstvala'). > 11. 'Shvstvecd' > Similar to 'Sstvecd' but the same rule applies to "vstvec". > 12. 'Shvsatpa' > All translation modes supported in "satp" are also supported in "vsatp". > 13. 'Shgatpa' > For each supported virtual memory scheme SvNN supported in "satp", the > corresponding "hgatp" SvNNx4 mode is supported. The "hgatp" mode Bare > is also supported. > > [Implications] > > (Due to reservation set size constraints) > - 'Za64rs' -> 'Za128rs' > > (Due to the fact that a privileged "extension" directly refers a CSR) > - 'Svbare' -> 'Zicsr' > - 'Sstvecd' -> 'Zicsr' > - 'Sstvala' -> 'Zicsr' > - 'Sscounterenw' -> 'Zicsr' > - 'Ssu64xl' -> 'Zicsr' > > (Due to the fact that a privileged "extension" indirectly depends on CSRs) > - 'Svade' -> 'Zicsr' > > (Due to the fact that a privileged "extension" is a hypervisor property) > - 'Shcounterenw' -> 'H' > - 'Shvstvala' -> 'H' > - 'Shtvala' -> 'H' > - 'Shvstvecd' -> 'H' > - 'Shvsatpa' -> 'H' > - 'Shgatpa' -> 'H' > > bfd/ChangeLog: > > * elfxx-riscv.c > (riscv_implicit_subsets): Add 13 implication rules. > Reorder 'H' for new 'Sh*' extensions. > (riscv_supported_std_z_ext) Add 7 property/capability extensions. > (riscv_supported_std_s_ext) Add 13 property/capability extensions. > --- > bfd/elfxx-riscv.c | 35 ++++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > > diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c > index b43d2cfa0fab..47dede91e064 100644 > --- a/bfd/elfxx-riscv.c > +++ b/bfd/elfxx-riscv.c > @@ -1105,7 +1105,6 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = > {"g", "zicsr", check_implicit_always}, > {"g", "zifencei", check_implicit_always}, > {"m", "zmmul", check_implicit_always}, > - {"h", "zicsr", check_implicit_always}, > {"q", "d", check_implicit_always}, > {"v", "d", check_implicit_always}, > {"v", "zve64d", check_implicit_always}, > @@ -1144,6 +1143,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = > {"zhinx", "zhinxmin", check_implicit_always}, > {"zhinxmin", "zfinx", check_implicit_always}, > {"zfinx", "zicsr", check_implicit_always}, > + {"za64rs", "za128rs", check_implicit_always}, > {"zk", "zkn", check_implicit_always}, > {"zk", "zkr", check_implicit_always}, > {"zk", "zkt", check_implicit_always}, > @@ -1179,10 +1179,23 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = > {"smaia", "ssaia", check_implicit_always}, > {"smstateen", "ssstateen", check_implicit_always}, > {"smepmp", "zicsr", check_implicit_always}, > + {"shcounterenw", "h", check_implicit_always}, > + {"shgatpa", "h", check_implicit_always}, > + {"shtvala", "h", check_implicit_always}, > + {"shvsatpa", "h", check_implicit_always}, > + {"shvstvala", "h", check_implicit_always}, > + {"shvstvecd", "h", check_implicit_always}, > + {"h", "zicsr", check_implicit_always}, > {"ssaia", "zicsr", check_implicit_always}, > {"sscofpmf", "zicsr", check_implicit_always}, > + {"sscounterenw", "zicsr", check_implicit_always}, > {"ssstateen", "zicsr", check_implicit_always}, > {"sstc", "zicsr", check_implicit_always}, > + {"sstvala", "zicsr", check_implicit_always}, > + {"sstvecd", "zicsr", check_implicit_always}, > + {"ssu64xl", "zicsr", check_implicit_always}, > + {"svade", "zicsr", check_implicit_always}, > + {"svbare", "zicsr", check_implicit_always}, > {NULL, NULL, NULL} > }; > > @@ -1240,6 +1253,11 @@ static struct riscv_supported_ext riscv_supported_std_ext[] = > > static struct riscv_supported_ext riscv_supported_std_z_ext[] = > { > + {"zic64b", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"ziccamoa", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"ziccif", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"zicclsm", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"ziccrse", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"zicbom", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"zicbop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"zicboz", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > @@ -1250,6 +1268,8 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] = > {"zifencei", ISA_SPEC_CLASS_20190608, 2, 0, 0 }, > {"zihintpause", ISA_SPEC_CLASS_DRAFT, 2, 0, 0 }, > {"zmmul", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"za64rs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"za128rs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"zawrs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"zfa", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 }, > {"zfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > @@ -1318,13 +1338,26 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] = > > static struct riscv_supported_ext riscv_supported_std_s_ext[] = > { > + {"shcounterenw", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"shgatpa", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"shtvala", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"shvsatpa", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"shvstvala", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"shvstvecd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"smaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"smepmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"smstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"ssaia", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"ssccptr", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"sscofpmf", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"sscounterenw", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"ssstateen", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"sstc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"sstvala", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"sstvecd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"ssu64xl", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"svade", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > + {"svbare", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"svinval", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"svnapot", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, > {"svpbmt", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },