public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs
@ 2022-10-08  4:32 Tsukasa OI
  2022-10-08  4:32 ` [RFC PATCH 1/1] " Tsukasa OI
  2022-10-14  2:17 ` [RFC PATCH 0/1] " Nelson Chu
  0 siblings, 2 replies; 3+ messages in thread
From: Tsukasa OI @ 2022-10-08  4:32 UTC (permalink / raw)
  To: Tsukasa OI, Nelson Chu, Kito Cheng, Palmer Dabbelt, Andrew Waterman
  Cc: binutils

Hello,

'H', 'Smstateen', 'Sscofpmf' and 'Sstc' are four privileged extensions with
their CSR definitions and 'Smepmp' is a privileged extension with additional
CSR bits.

Volume II: Privileged Architecture of the RISC-V ISA Manual states that the
privileged architecture requires the 'Zicsr' extension.  However, current
GNU Binutils has no direct way whether the program has dependency to the
privileged architecture itself.

As a workaround, we could add implications from privileged extensions that
either add new CSRs, extend existing CSRs or depends on using CSRs.

This patchset adds such implications for existing privileged extensions that
satisfy this condition.

I would like to hear your thoughts.


Thanks,
Tsukasa




Tsukasa OI (1):
  RISC-V: Imply 'Zicsr' from privileged extensions with CSRs

 bfd/elfxx-riscv.c                       | 5 +++++
 gas/testsuite/gas/riscv/march-imply-h.d | 6 ++++++
 2 files changed, 11 insertions(+)
 create mode 100644 gas/testsuite/gas/riscv/march-imply-h.d


base-commit: 4cbfd0daabd68516651ee37a19d0e24ca4789ea3
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH 1/1] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs
  2022-10-08  4:32 [RFC PATCH 0/1] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs Tsukasa OI
@ 2022-10-08  4:32 ` Tsukasa OI
  2022-10-14  2:17 ` [RFC PATCH 0/1] " Nelson Chu
  1 sibling, 0 replies; 3+ messages in thread
From: Tsukasa OI @ 2022-10-08  4:32 UTC (permalink / raw)
  To: Tsukasa OI, Nelson Chu, Kito Cheng, Palmer Dabbelt, Andrew Waterman
  Cc: binutils

'H', 'Smstateen', 'Sscofpmf' and 'Sstc' are four privileged extensions with
their CSR definitions and 'Smepmp' is a privileged extension with additional
CSR bits.

Volume II: Privileged Architecture of the RISC-V ISA Manual states that the
privileged architecture requires the 'Zicsr' extension.  However, current
GNU Binutils has no direct way whether the program has dependency to the
privileged architecture itself.

As a workaround, we should add implications from privileged extensions that
either add new CSRs, extend existing CSRs or depends on using CSRs.

This commit adds such implications for existing privileged extensions that
satisfy this condition.

gas/ChangeLog:

	* testsuite/gas/riscv/march-imply-h.d: New test, at least for 'H'.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add 'Zicsr'
	implicications for privileged extensions 'H', 'Smstateen',
	'Sscofpmf', 'Sstc' and 'Smepmp'.
---
 bfd/elfxx-riscv.c                       | 5 +++++
 gas/testsuite/gas/riscv/march-imply-h.d | 6 ++++++
 2 files changed, 11 insertions(+)
 create mode 100644 gas/testsuite/gas/riscv/march-imply-h.d

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 1bcc6c0acb4..f0c91cc97f7 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1047,6 +1047,7 @@ 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},
@@ -1096,6 +1097,10 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
   {"zks", "zbkx",	check_implicit_always},
   {"zks", "zksed",	check_implicit_always},
   {"zks", "zksh",	check_implicit_always},
+  {"smepmp", "zicsr",		check_implicit_always},
+  {"smstateen", "zicsr",	check_implicit_always},
+  {"sscofpmf", "zicsr",		check_implicit_always},
+  {"sstc", "zicsr",		check_implicit_always},
   {NULL, NULL, NULL}
 };
 
diff --git a/gas/testsuite/gas/riscv/march-imply-h.d b/gas/testsuite/gas/riscv/march-imply-h.d
new file mode 100644
index 00000000000..04ad9f6c0a5
--- /dev/null
+++ b/gas/testsuite/gas/riscv/march-imply-h.d
@@ -0,0 +1,6 @@
+#as: -march=rv32ih -march-attr -misa-spec=20191213 -mpriv-spec=1.12
+#readelf: -A
+#source: empty.s
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: "rv32i2p1_h1p0_zicsr2p0"
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH 0/1] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs
  2022-10-08  4:32 [RFC PATCH 0/1] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs Tsukasa OI
  2022-10-08  4:32 ` [RFC PATCH 1/1] " Tsukasa OI
@ 2022-10-14  2:17 ` Nelson Chu
  1 sibling, 0 replies; 3+ messages in thread
From: Nelson Chu @ 2022-10-14  2:17 UTC (permalink / raw)
  To: Tsukasa OI; +Cc: Kito Cheng, Palmer Dabbelt, Andrew Waterman, binutils

On Sat, Oct 8, 2022 at 12:32 PM Tsukasa OI <research_trasio@irq.a4lg.com> wrote:
>
> Hello,
>
> 'H', 'Smstateen', 'Sscofpmf' and 'Sstc' are four privileged extensions with
> their CSR definitions and 'Smepmp' is a privileged extension with additional
> CSR bits.
>
> Volume II: Privileged Architecture of the RISC-V ISA Manual states that the
> privileged architecture requires the 'Zicsr' extension.

Looking at the privileged spec, makes sense.
https://github.com/riscv/riscv-isa-manual/blob/draft-20221004-28b46de/src/priv-csrs.tex#L9

> However, current
> GNU Binutils has no direct way whether the program has dependency to the
> privileged architecture itself.

Yeah, and we won't have one in the future.  I had heard last time that
the privileged spec should be covered by lots of extensions, F, H, Ss,
Sm, ....

> As a workaround, we could add implications from privileged extensions that
> either add new CSRs, extend existing CSRs or depends on using CSRs.

After seeing the spec, I believe this should be the right way to do
rather than a workaround :-)  Besides, your previous patch, adding
implicit zicsr for v and zkr, should also be the right way to do it
because i no longer implies zicsr since 2.1.  Of course, it is best to
have the rvv and k spec written that they need zicsr, but now I think
keeping the same rule as others (extensions of privileged spec) is
better.

Thanks, so please commit.
Nelson

> This patchset adds such implications for existing privileged extensions that
> satisfy this condition.
>
> I would like to hear your thoughts.
>
>
> Thanks,
> Tsukasa
>
>
>
>
> Tsukasa OI (1):
>   RISC-V: Imply 'Zicsr' from privileged extensions with CSRs
>
>  bfd/elfxx-riscv.c                       | 5 +++++
>  gas/testsuite/gas/riscv/march-imply-h.d | 6 ++++++
>  2 files changed, 11 insertions(+)
>  create mode 100644 gas/testsuite/gas/riscv/march-imply-h.d
>
>
> base-commit: 4cbfd0daabd68516651ee37a19d0e24ca4789ea3
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-14  2:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-08  4:32 [RFC PATCH 0/1] RISC-V: Imply 'Zicsr' from privileged extensions with CSRs Tsukasa OI
2022-10-08  4:32 ` [RFC PATCH 1/1] " Tsukasa OI
2022-10-14  2:17 ` [RFC PATCH 0/1] " Nelson Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).