RISC-V: Support debug and float CSR as the unprivileged ones.

Message ID 1591600406-11907-1-git-send-email-nelson.chu@sifive.com
State New
Headers show
Series
  • RISC-V: Support debug and float CSR as the unprivileged ones.
Related show

Commit Message

Nelson Chu June 8, 2020, 7:13 a.m.
The unprivileged CSR should be controlled by other specific specs rather
than the privileged spec.  For example, the debug CSR should be controlled
by the debug spec, and the float CSR should be controlled by the float
spec.  User may use assembler options to choose what the debug and other
specs they want, or may encode the versions of specs into the architecture
string directly.  Since we haven't decided which one is better, I set the
defined and aborted versions of unprivileged CSR as PRIV_SPEC_CLASS_NONE
in the include/opcode/riscv-opc.h, to tell assembler don't check versions
for them.

I also add the missing debug CSR which are mentioned in the debug spec
rather than the privileged spec.  One minor thing is that, there are some
debug CSR have the same address, but have differnet names in the same debug
spec version.  I don't know which one should be dumped by disassembler,
so I choose to dump the first defined one in the spec.

	gas/
	* config/tc-riscv.c (riscv_csr_class_check): Removed.  Move the
	checking into riscv_csr_address.
	(riscv_csr_version_check): Likewise.
	(riscv_csr_address): New function.  Return the suitable CSR address
	after checking the ISA dependency and versions.  Issue warnings	if
	we find any conflict and -mcsr-check is set.  CSR_CLASS_F and
	CSR_CLASS_DEBUG are unprivileged CSR for now, so don't check the
	priv spec versions for them.
	(reg_csr_lookup_internal): Call riscv_csr_address to find the
	suitable CSR address.

	* testsuite/gas/riscv/priv-reg-fail-fext.l:  We don't care the
	priv spec warnings here.  These warnings are added to this testcase
	by accident.  Remove them and only focus on the ISA dependency
	warnings.
	* testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Updated since
	dscratch0 and dscratch1 are regarded as the unprivileged CSR rather
	than the privileged ones.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
	* testsuite/gas/riscv/priv-reg.s: Likewise and add missing debug CSR.
	* testsuite/gas/riscv/priv-reg-version-1p9.d: Likewise.
	* testsuite/gas/riscv/priv-reg-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/priv-reg-version-1p10.d: Likewise.
	* testsuite/gas/riscv/priv-reg-version-1p11.d: Likewise.

	include/
	* opcode/riscv-opc.h: Support the unprivileged CSR.  The versions
	of the unprivileged CSR should be PRIV_SPEC_CLASS_NONE for now.
	* opcode/riscv.h (enum riscv_csr_class): Add CSR_CLASS_DEBUG.

	opcodes/
	* riscv-dis.c (print_insn_args, case 'E'): Updated.  Let the
	unprivileged CSR can also be initialized.
---
 gas/config/tc-riscv.c                              |  50 ++++-----
 gas/testsuite/gas/riscv/priv-reg-fail-fext.l       |  27 +----
 .../gas/riscv/priv-reg-fail-read-only-01.l         |  27 +----
 gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l  |  27 +----
 .../gas/riscv/priv-reg-fail-version-1p10.l         |   2 -
 .../gas/riscv/priv-reg-fail-version-1p11.l         |   1 -
 .../gas/riscv/priv-reg-fail-version-1p9.l          |   2 -
 .../gas/riscv/priv-reg-fail-version-1p9p1.l        |   2 -
 gas/testsuite/gas/riscv/priv-reg-version-1p10.d    |  62 ++++++++---
 gas/testsuite/gas/riscv/priv-reg-version-1p11.d    |  62 ++++++++---
 gas/testsuite/gas/riscv/priv-reg-version-1p9.d     |  62 ++++++++---
 gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d   |  62 ++++++++---
 gas/testsuite/gas/riscv/priv-reg.s                 |  71 ++++++++++---
 include/opcode/riscv-opc.h                         | 114 ++++++++++++++++-----
 include/opcode/riscv.h                             |   1 +
 opcodes/riscv-dis.c                                |   9 +-
 16 files changed, 381 insertions(+), 200 deletions(-)

-- 
2.7.4

Comments

Nelson Chu June 9, 2020, 2:24 a.m. | #1
Hi binutils,

I got the feedback recently that updating the CSR may cause the
compatibility issue for GDB and QEMU...  So please ignore this patch
for now, I will figure out how to resolve the compatibility issue, and
then give a better solution.  Please feel free to contact me if you
have any suggestions and ideas.

Thank you very much
Nelson

On Mon, Jun 8, 2020 at 3:13 PM Nelson Chu <nelson.chu@sifive.com> wrote:
>

> The unprivileged CSR should be controlled by other specific specs rather

> than the privileged spec.  For example, the debug CSR should be controlled

> by the debug spec, and the float CSR should be controlled by the float

> spec.  User may use assembler options to choose what the debug and other

> specs they want, or may encode the versions of specs into the architecture

> string directly.  Since we haven't decided which one is better, I set the

> defined and aborted versions of unprivileged CSR as PRIV_SPEC_CLASS_NONE

> in the include/opcode/riscv-opc.h, to tell assembler don't check versions

> for them.

>

> I also add the missing debug CSR which are mentioned in the debug spec

> rather than the privileged spec.  One minor thing is that, there are some

> debug CSR have the same address, but have differnet names in the same debug

> spec version.  I don't know which one should be dumped by disassembler,

> so I choose to dump the first defined one in the spec.

>

>         gas/

>         * config/tc-riscv.c (riscv_csr_class_check): Removed.  Move the

>         checking into riscv_csr_address.

>         (riscv_csr_version_check): Likewise.

>         (riscv_csr_address): New function.  Return the suitable CSR address

>         after checking the ISA dependency and versions.  Issue warnings if

>         we find any conflict and -mcsr-check is set.  CSR_CLASS_F and

>         CSR_CLASS_DEBUG are unprivileged CSR for now, so don't check the

>         priv spec versions for them.

>         (reg_csr_lookup_internal): Call riscv_csr_address to find the

>         suitable CSR address.

>

>         * testsuite/gas/riscv/priv-reg-fail-fext.l:  We don't care the

>         priv spec warnings here.  These warnings are added to this testcase

>         by accident.  Remove them and only focus on the ISA dependency

>         warnings.

>         * testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.

>         * testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.

>         * testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Updated since

>         dscratch0 and dscratch1 are regarded as the unprivileged CSR rather

>         than the privileged ones.

>         * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.

>         * testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.

>         * testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.

>         * testsuite/gas/riscv/priv-reg.s: Likewise and add missing debug CSR.

>         * testsuite/gas/riscv/priv-reg-version-1p9.d: Likewise.

>         * testsuite/gas/riscv/priv-reg-version-1p9p1.d: Likewise.

>         * testsuite/gas/riscv/priv-reg-version-1p10.d: Likewise.

>         * testsuite/gas/riscv/priv-reg-version-1p11.d: Likewise.

>

>         include/

>         * opcode/riscv-opc.h: Support the unprivileged CSR.  The versions

>         of the unprivileged CSR should be PRIV_SPEC_CLASS_NONE for now.

>         * opcode/riscv.h (enum riscv_csr_class): Add CSR_CLASS_DEBUG.

>

>         opcodes/

>         * riscv-dis.c (print_insn_args, case 'E'): Updated.  Let the

>         unprivileged CSR can also be initialized.

> ---

>  gas/config/tc-riscv.c                              |  50 ++++-----

>  gas/testsuite/gas/riscv/priv-reg-fail-fext.l       |  27 +----

>  .../gas/riscv/priv-reg-fail-read-only-01.l         |  27 +----

>  gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l  |  27 +----

>  .../gas/riscv/priv-reg-fail-version-1p10.l         |   2 -

>  .../gas/riscv/priv-reg-fail-version-1p11.l         |   1 -

>  .../gas/riscv/priv-reg-fail-version-1p9.l          |   2 -

>  .../gas/riscv/priv-reg-fail-version-1p9p1.l        |   2 -

>  gas/testsuite/gas/riscv/priv-reg-version-1p10.d    |  62 ++++++++---

>  gas/testsuite/gas/riscv/priv-reg-version-1p11.d    |  62 ++++++++---

>  gas/testsuite/gas/riscv/priv-reg-version-1p9.d     |  62 ++++++++---

>  gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d   |  62 ++++++++---

>  gas/testsuite/gas/riscv/priv-reg.s                 |  71 ++++++++++---

>  include/opcode/riscv-opc.h                         | 114 ++++++++++++++++-----

>  include/opcode/riscv.h                             |   1 +

>  opcodes/riscv-dis.c                                |   9 +-

>  16 files changed, 381 insertions(+), 200 deletions(-)

>

> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c

> index cc77dbf..5ebe31c 100644

> --- a/gas/config/tc-riscv.c

> +++ b/gas/config/tc-riscv.c

> @@ -720,51 +720,46 @@ riscv_init_csr_hash (const char *name,

>

>  /* Check wether the CSR is valid according to the ISA.  */

>

> -static void

> -riscv_csr_class_check (const char *s,

> -                      enum riscv_csr_class csr_class)

> +static unsigned int

> +riscv_csr_address (const char *csr_name,

> +                  struct riscv_csr_extra *entry)

>  {

> +  struct riscv_csr_extra *saved_entry = entry;

> +  enum riscv_csr_class csr_class = entry->csr_class;

> +  bfd_boolean need_check_version = TRUE;

>    bfd_boolean result = TRUE;

>

> -  /* Don't check the ISA dependency when -mcsr-check isn't set.  */

> -  if (!riscv_opts.csr_check)

> -    return;

> -

>    switch (csr_class)

>      {

>      case CSR_CLASS_I:

>        result = riscv_subset_supports ("i");

>        break;

> +    case CSR_CLASS_I_32:

> +      result = (xlen == 32 && riscv_subset_supports ("i"));

> +      break;

>      case CSR_CLASS_F:

>        result = riscv_subset_supports ("f");

> +      need_check_version = FALSE;

>        break;

> -    case CSR_CLASS_I_32:

> -      result = (xlen == 32 && riscv_subset_supports ("i"));

> +    case CSR_CLASS_DEBUG:

> +      need_check_version = FALSE;

>        break;

>      default:

>        as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);

>      }

>

> -  if (!result)

> -    as_warn (_("Invalid CSR `%s' for the current ISA"), s);

> -}

> -

> -/* Check and find the CSR address according to the privilege spec version.  */

> -

> -static void

> -riscv_csr_version_check (const char *csr_name,

> -                        struct riscv_csr_extra **entryP)

> -{

> -  struct riscv_csr_extra *entry = *entryP;

> +  /* Don't report the ISA conflict when -mcsr-check isn't set.  */

> +  if (riscv_opts.csr_check && !result)

> +    as_warn (_("Invalid CSR `%s' for the current ISA"), csr_name);

>

>    while (entry != NULL)

>      {

> -      if (default_priv_spec >= entry->define_version

> -         && default_priv_spec < entry->abort_version)

> +      if (!need_check_version

> +         || (default_priv_spec >= entry->define_version

> +             && default_priv_spec < entry->abort_version))

>         {

>           /* Find the suitable CSR according to the specific version.  */

> -         *entryP = entry;

> -         return;

> +         return entry->address;

>         }

>        entry = entry->next;

>      }

> @@ -781,6 +776,8 @@ riscv_csr_version_check (const char *csr_name,

>         as_warn (_("Invalid CSR `%s' for the privilege spec `%s'"),

>                  csr_name, priv_name);

>      }

> +

> +  return saved_entry->address;

>  }

>

>  /* Once the CSR is defined, including the old privilege spec, then we call

> @@ -803,10 +800,7 @@ reg_csr_lookup_internal (const char *s)

>       will regard it as a "Unknown CSR" and report error.  If user use number

>       to set the CSR, but over the range (> 0xfff), then assembler will report

>       "Improper CSR" error for it.  */

> -  riscv_csr_class_check (s, r->csr_class);

> -  riscv_csr_version_check (s, &r);

> -

> -  return r->address;

> +  return riscv_csr_address (s, r);

>  }

>

>  static unsigned int

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.l b/gas/testsuite/gas/riscv/priv-reg-fail-fext.l

> index d74863e..2ee0dae 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-fext.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-fext.l

> @@ -1,29 +1,6 @@

>  .*Assembler messages:

> +#...

>  .*Warning: Invalid CSR `fflags' for the current ISA

>  .*Warning: Invalid CSR `frm' for the current ISA

>  .*Warning: Invalid CSR `fcsr' for the current ISA

> -

> -.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hie' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hip' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'

> +#...

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l

> index 2dc82f4..305cd17 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l

> @@ -1,4 +1,5 @@

>  .*Assembler messages:

> +#...

>  .*Warning: Read-only CSR is written `csrw cycle,a1'

>  .*Warning: Read-only CSR is written `csrw time,a1'

>  .*Warning: Read-only CSR is written `csrw instret,a1'

> @@ -67,28 +68,4 @@

>  .*Warning: Read-only CSR is written `csrw marchid,a1'

>  .*Warning: Read-only CSR is written `csrw mimpid,a1'

>  .*Warning: Read-only CSR is written `csrw mhartid,a1'

> -

> -.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hie' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hip' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'

> +#...

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l

> index 19f13a0..5dec50f 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l

> @@ -1,4 +1,5 @@

>  .*Assembler messages:

> +#...

>  .*Warning: Invalid CSR `cycleh' for the current ISA

>  .*Warning: Invalid CSR `timeh' for the current ISA

>  .*Warning: Invalid CSR `instreth' for the current ISA

> @@ -64,28 +65,4 @@

>  .*Warning: Invalid CSR `mhpmcounter29h' for the current ISA

>  .*Warning: Invalid CSR `mhpmcounter30h' for the current ISA

>  .*Warning: Invalid CSR `mhpmcounter31h' for the current ISA

> -

> -.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hie' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `hip' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'

> +#...

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l

> index 4146174..983f593 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l

> @@ -1,7 +1,5 @@

>  .*Assembler messages:

>  .*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.10'

> -.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.10'

> -.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.10'

>  .*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.10'

>  .*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.10'

>  .*Warning: Invalid CSR `sptbr' for the privilege spec `1.10'

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l

> index eadcb5c..0e036e4 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l

> @@ -4,7 +4,6 @@

>  .*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'

>  .*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'

>  .*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'

> -.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'

>  .*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'

>  .*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'

>  .*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l

> index d7cee80..3630a19 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l

> @@ -26,5 +26,3 @@

>  .*Warning: Invalid CSR `pmpaddr14' for the privilege spec `1.9'

>  .*Warning: Invalid CSR `pmpaddr15' for the privilege spec `1.9'

>  .*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.9'

> -.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.9'

> -.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.9'

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l

> index 907ed73..8a8126a 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l

> @@ -26,5 +26,3 @@

>  .*Warning: Invalid CSR `pmpaddr14' for the privilege spec `1.9.1'

>  .*Warning: Invalid CSR `pmpaddr15' for the privilege spec `1.9.1'

>  .*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.9.1'

> -.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.9.1'

> -.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.9.1'

> diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p10.d b/gas/testsuite/gas/riscv/priv-reg-version-1p10.d

> index 0071f75..588c145 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-version-1p10.d

> +++ b/gas/testsuite/gas/riscv/priv-reg-version-1p10.d

> @@ -16,9 +16,6 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+04202573[     ]+csrr[         ]+a0,ucause

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,utval

>  [      ]+[0-9a-f]+:[   ]+04402573[     ]+csrr[         ]+a0,uip

> -[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> -[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> -[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0002573[     ]+rdcycle[      ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0102573[     ]+rdtime[       ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0202573[     ]+rdinstret[    ]+a0

> @@ -223,20 +220,11 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+33d02573[     ]+csrr[         ]+a0,mhpmevent29

>  [      ]+[0-9a-f]+:[   ]+33e02573[     ]+csrr[         ]+a0,mhpmevent30

>  [      ]+[0-9a-f]+:[   ]+33f02573[     ]+csrr[         ]+a0,mhpmevent31

> -[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> -[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> -[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> -[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> -[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> -[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch

> -[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,0x7b3

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,utval

>  [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,stval

>  [      ]+[0-9a-f]+:[   ]+18002573[     ]+csrr[         ]+a0,satp

>  [      ]+[0-9a-f]+:[   ]+34302573[     ]+csrr[         ]+a0,mtval

>  [      ]+[0-9a-f]+:[   ]+32002573[     ]+csrr[         ]+a0,0x320

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch

>  [      ]+[0-9a-f]+:[   ]+20002573[     ]+csrr[         ]+a0,0x200

>  [      ]+[0-9a-f]+:[   ]+20202573[     ]+csrr[         ]+a0,0x202

>  [      ]+[0-9a-f]+:[   ]+20302573[     ]+csrr[         ]+a0,0x203

> @@ -255,3 +243,53 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+38502573[     ]+csrr[         ]+a0,0x385

>  [      ]+[0-9a-f]+:[   ]+32102573[     ]+csrr[         ]+a0,0x321

>  [      ]+[0-9a-f]+:[   ]+32202573[     ]+csrr[         ]+a0,0x322

> +[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> +[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> +[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01202573[     ]+csrr[         ]+a0,hartinfo

> +[      ]+[0-9a-f]+:[   ]+01402573[     ]+csrr[         ]+a0,hawindowsel

> +[      ]+[0-9a-f]+:[   ]+01502573[     ]+csrr[         ]+a0,hawindow

> +[      ]+[0-9a-f]+:[   ]+01602573[     ]+csrr[         ]+a0,abstractcs

> +[      ]+[0-9a-f]+:[   ]+01702573[     ]+csrr[         ]+a0,command

> +[      ]+[0-9a-f]+:[   ]+01802573[     ]+csrr[         ]+a0,abstractauto

> +[      ]+[0-9a-f]+:[   ]+01902573[     ]+csrr[         ]+a0,confstrptr0

> +[      ]+[0-9a-f]+:[   ]+01d02573[     ]+csrr[         ]+a0,nextdm

> +[      ]+[0-9a-f]+:[   ]+00402573[     ]+csrr[         ]+a0,uie

> +[      ]+[0-9a-f]+:[   ]+02002573[     ]+csrr[         ]+a0,progbuf0

> +[      ]+[0-9a-f]+:[   ]+03002573[     ]+csrr[         ]+a0,authdata

> +[      ]+[0-9a-f]+:[   ]+04002573[     ]+csrr[         ]+a0,uscratch

> +[      ]+[0-9a-f]+:[   ]+01302573[     ]+csrr[         ]+a0,haltsum1

> +[      ]+[0-9a-f]+:[   ]+03402573[     ]+csrr[         ]+a0,haltsum2

> +[      ]+[0-9a-f]+:[   ]+03502573[     ]+csrr[         ]+a0,haltsum3

> +[      ]+[0-9a-f]+:[   ]+03802573[     ]+csrr[         ]+a0,sbcs

> +[      ]+[0-9a-f]+:[   ]+03902573[     ]+csrr[         ]+a0,sbaddress0

> +[      ]+[0-9a-f]+:[   ]+03a02573[     ]+csrr[         ]+a0,sbaddress1

> +[      ]+[0-9a-f]+:[   ]+03b02573[     ]+csrr[         ]+a0,sbaddress2

> +[      ]+[0-9a-f]+:[   ]+03702573[     ]+csrr[         ]+a0,sbaddress3

> +[      ]+[0-9a-f]+:[   ]+03c02573[     ]+csrr[         ]+a0,sbdata0

> +[      ]+[0-9a-f]+:[   ]+03d02573[     ]+csrr[         ]+a0,sbdata1

> +[      ]+[0-9a-f]+:[   ]+03e02573[     ]+csrr[         ]+a0,sbdata2

> +[      ]+[0-9a-f]+:[   ]+03f02573[     ]+csrr[         ]+a0,sbdata3

> +[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> +[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,dscratch1

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a402573[     ]+csrr[         ]+a0,tinfo

> +[      ]+[0-9a-f]+:[   ]+7a502573[     ]+csrr[         ]+a0,tcontrol

> +[      ]+[0-9a-f]+:[   ]+7a802573[     ]+csrr[         ]+a0,mcontext

> +[      ]+[0-9a-f]+:[   ]+7aa02573[     ]+csrr[         ]+a0,scontext

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p11.d b/gas/testsuite/gas/riscv/priv-reg-version-1p11.d

> index 225f4c4..82b26d0 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-version-1p11.d

> +++ b/gas/testsuite/gas/riscv/priv-reg-version-1p11.d

> @@ -16,9 +16,6 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+04202573[     ]+csrr[         ]+a0,ucause

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,utval

>  [      ]+[0-9a-f]+:[   ]+04402573[     ]+csrr[         ]+a0,uip

> -[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> -[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> -[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0002573[     ]+rdcycle[      ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0102573[     ]+rdtime[       ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0202573[     ]+rdinstret[    ]+a0

> @@ -223,20 +220,11 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+33d02573[     ]+csrr[         ]+a0,mhpmevent29

>  [      ]+[0-9a-f]+:[   ]+33e02573[     ]+csrr[         ]+a0,mhpmevent30

>  [      ]+[0-9a-f]+:[   ]+33f02573[     ]+csrr[         ]+a0,mhpmevent31

> -[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> -[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> -[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> -[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> -[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> -[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> -[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,dscratch1

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,utval

>  [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,stval

>  [      ]+[0-9a-f]+:[   ]+18002573[     ]+csrr[         ]+a0,satp

>  [      ]+[0-9a-f]+:[   ]+34302573[     ]+csrr[         ]+a0,mtval

>  [      ]+[0-9a-f]+:[   ]+32002573[     ]+csrr[         ]+a0,mcountinhibit

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

>  [      ]+[0-9a-f]+:[   ]+20002573[     ]+csrr[         ]+a0,0x200

>  [      ]+[0-9a-f]+:[   ]+20202573[     ]+csrr[         ]+a0,0x202

>  [      ]+[0-9a-f]+:[   ]+20302573[     ]+csrr[         ]+a0,0x203

> @@ -255,3 +243,53 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+38502573[     ]+csrr[         ]+a0,0x385

>  [      ]+[0-9a-f]+:[   ]+32102573[     ]+csrr[         ]+a0,0x321

>  [      ]+[0-9a-f]+:[   ]+32202573[     ]+csrr[         ]+a0,0x322

> +[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> +[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> +[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01202573[     ]+csrr[         ]+a0,hartinfo

> +[      ]+[0-9a-f]+:[   ]+01402573[     ]+csrr[         ]+a0,hawindowsel

> +[      ]+[0-9a-f]+:[   ]+01502573[     ]+csrr[         ]+a0,hawindow

> +[      ]+[0-9a-f]+:[   ]+01602573[     ]+csrr[         ]+a0,abstractcs

> +[      ]+[0-9a-f]+:[   ]+01702573[     ]+csrr[         ]+a0,command

> +[      ]+[0-9a-f]+:[   ]+01802573[     ]+csrr[         ]+a0,abstractauto

> +[      ]+[0-9a-f]+:[   ]+01902573[     ]+csrr[         ]+a0,confstrptr0

> +[      ]+[0-9a-f]+:[   ]+01d02573[     ]+csrr[         ]+a0,nextdm

> +[      ]+[0-9a-f]+:[   ]+00402573[     ]+csrr[         ]+a0,uie

> +[      ]+[0-9a-f]+:[   ]+02002573[     ]+csrr[         ]+a0,progbuf0

> +[      ]+[0-9a-f]+:[   ]+03002573[     ]+csrr[         ]+a0,authdata

> +[      ]+[0-9a-f]+:[   ]+04002573[     ]+csrr[         ]+a0,uscratch

> +[      ]+[0-9a-f]+:[   ]+01302573[     ]+csrr[         ]+a0,haltsum1

> +[      ]+[0-9a-f]+:[   ]+03402573[     ]+csrr[         ]+a0,haltsum2

> +[      ]+[0-9a-f]+:[   ]+03502573[     ]+csrr[         ]+a0,haltsum3

> +[      ]+[0-9a-f]+:[   ]+03802573[     ]+csrr[         ]+a0,sbcs

> +[      ]+[0-9a-f]+:[   ]+03902573[     ]+csrr[         ]+a0,sbaddress0

> +[      ]+[0-9a-f]+:[   ]+03a02573[     ]+csrr[         ]+a0,sbaddress1

> +[      ]+[0-9a-f]+:[   ]+03b02573[     ]+csrr[         ]+a0,sbaddress2

> +[      ]+[0-9a-f]+:[   ]+03702573[     ]+csrr[         ]+a0,sbaddress3

> +[      ]+[0-9a-f]+:[   ]+03c02573[     ]+csrr[         ]+a0,sbdata0

> +[      ]+[0-9a-f]+:[   ]+03d02573[     ]+csrr[         ]+a0,sbdata1

> +[      ]+[0-9a-f]+:[   ]+03e02573[     ]+csrr[         ]+a0,sbdata2

> +[      ]+[0-9a-f]+:[   ]+03f02573[     ]+csrr[         ]+a0,sbdata3

> +[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> +[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,dscratch1

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a402573[     ]+csrr[         ]+a0,tinfo

> +[      ]+[0-9a-f]+:[   ]+7a502573[     ]+csrr[         ]+a0,tcontrol

> +[      ]+[0-9a-f]+:[   ]+7a802573[     ]+csrr[         ]+a0,mcontext

> +[      ]+[0-9a-f]+:[   ]+7aa02573[     ]+csrr[         ]+a0,scontext

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p9.d b/gas/testsuite/gas/riscv/priv-reg-version-1p9.d

> index fd2a56b..d54acc0 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-version-1p9.d

> +++ b/gas/testsuite/gas/riscv/priv-reg-version-1p9.d

> @@ -16,9 +16,6 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+04202573[     ]+csrr[         ]+a0,ucause

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,ubadaddr

>  [      ]+[0-9a-f]+:[   ]+04402573[     ]+csrr[         ]+a0,uip

> -[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> -[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> -[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0002573[     ]+rdcycle[      ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0102573[     ]+rdtime[       ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0202573[     ]+rdinstret[    ]+a0

> @@ -223,20 +220,11 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+33d02573[     ]+csrr[         ]+a0,mhpmevent29

>  [      ]+[0-9a-f]+:[   ]+33e02573[     ]+csrr[         ]+a0,mhpmevent30

>  [      ]+[0-9a-f]+:[   ]+33f02573[     ]+csrr[         ]+a0,mhpmevent31

> -[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> -[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> -[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> -[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> -[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> -[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch

> -[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,0x7b3

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,ubadaddr

>  [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,sbadaddr

>  [      ]+[0-9a-f]+:[   ]+18002573[     ]+csrr[         ]+a0,sptbr

>  [      ]+[0-9a-f]+:[   ]+34302573[     ]+csrr[         ]+a0,mbadaddr

>  [      ]+[0-9a-f]+:[   ]+32002573[     ]+csrr[         ]+a0,mucounteren

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch

>  [      ]+[0-9a-f]+:[   ]+20002573[     ]+csrr[         ]+a0,hstatus

>  [      ]+[0-9a-f]+:[   ]+20202573[     ]+csrr[         ]+a0,hedeleg

>  [      ]+[0-9a-f]+:[   ]+20302573[     ]+csrr[         ]+a0,hideleg

> @@ -255,3 +243,53 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+38502573[     ]+csrr[         ]+a0,mdbound

>  [      ]+[0-9a-f]+:[   ]+32102573[     ]+csrr[         ]+a0,mscounteren

>  [      ]+[0-9a-f]+:[   ]+32202573[     ]+csrr[         ]+a0,mhcounteren

> +[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> +[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> +[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01202573[     ]+csrr[         ]+a0,hartinfo

> +[      ]+[0-9a-f]+:[   ]+01402573[     ]+csrr[         ]+a0,hawindowsel

> +[      ]+[0-9a-f]+:[   ]+01502573[     ]+csrr[         ]+a0,hawindow

> +[      ]+[0-9a-f]+:[   ]+01602573[     ]+csrr[         ]+a0,abstractcs

> +[      ]+[0-9a-f]+:[   ]+01702573[     ]+csrr[         ]+a0,command

> +[      ]+[0-9a-f]+:[   ]+01802573[     ]+csrr[         ]+a0,abstractauto

> +[      ]+[0-9a-f]+:[   ]+01902573[     ]+csrr[         ]+a0,confstrptr0

> +[      ]+[0-9a-f]+:[   ]+01d02573[     ]+csrr[         ]+a0,nextdm

> +[      ]+[0-9a-f]+:[   ]+00402573[     ]+csrr[         ]+a0,uie

> +[      ]+[0-9a-f]+:[   ]+02002573[     ]+csrr[         ]+a0,progbuf0

> +[      ]+[0-9a-f]+:[   ]+03002573[     ]+csrr[         ]+a0,authdata

> +[      ]+[0-9a-f]+:[   ]+04002573[     ]+csrr[         ]+a0,uscratch

> +[      ]+[0-9a-f]+:[   ]+01302573[     ]+csrr[         ]+a0,haltsum1

> +[      ]+[0-9a-f]+:[   ]+03402573[     ]+csrr[         ]+a0,haltsum2

> +[      ]+[0-9a-f]+:[   ]+03502573[     ]+csrr[         ]+a0,haltsum3

> +[      ]+[0-9a-f]+:[   ]+03802573[     ]+csrr[         ]+a0,sbcs

> +[      ]+[0-9a-f]+:[   ]+03902573[     ]+csrr[         ]+a0,sbaddress0

> +[      ]+[0-9a-f]+:[   ]+03a02573[     ]+csrr[         ]+a0,sbaddress1

> +[      ]+[0-9a-f]+:[   ]+03b02573[     ]+csrr[         ]+a0,sbaddress2

> +[      ]+[0-9a-f]+:[   ]+03702573[     ]+csrr[         ]+a0,sbaddress3

> +[      ]+[0-9a-f]+:[   ]+03c02573[     ]+csrr[         ]+a0,sbdata0

> +[      ]+[0-9a-f]+:[   ]+03d02573[     ]+csrr[         ]+a0,sbdata1

> +[      ]+[0-9a-f]+:[   ]+03e02573[     ]+csrr[         ]+a0,sbdata2

> +[      ]+[0-9a-f]+:[   ]+03f02573[     ]+csrr[         ]+a0,sbdata3

> +[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> +[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,dscratch1

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a402573[     ]+csrr[         ]+a0,tinfo

> +[      ]+[0-9a-f]+:[   ]+7a502573[     ]+csrr[         ]+a0,tcontrol

> +[      ]+[0-9a-f]+:[   ]+7a802573[     ]+csrr[         ]+a0,mcontext

> +[      ]+[0-9a-f]+:[   ]+7aa02573[     ]+csrr[         ]+a0,scontext

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d b/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d

> index 6162803..6df04aa 100644

> --- a/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d

> +++ b/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d

> @@ -16,9 +16,6 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+04202573[     ]+csrr[         ]+a0,ucause

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,ubadaddr

>  [      ]+[0-9a-f]+:[   ]+04402573[     ]+csrr[         ]+a0,uip

> -[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> -[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> -[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0002573[     ]+rdcycle[      ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0102573[     ]+rdtime[       ]+a0

>  [      ]+[0-9a-f]+:[   ]+c0202573[     ]+rdinstret[    ]+a0

> @@ -223,20 +220,11 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+33d02573[     ]+csrr[         ]+a0,mhpmevent29

>  [      ]+[0-9a-f]+:[   ]+33e02573[     ]+csrr[         ]+a0,mhpmevent30

>  [      ]+[0-9a-f]+:[   ]+33f02573[     ]+csrr[         ]+a0,mhpmevent31

> -[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> -[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> -[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> -[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> -[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> -[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch

> -[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,0x7b3

>  [      ]+[0-9a-f]+:[   ]+04302573[     ]+csrr[         ]+a0,ubadaddr

>  [      ]+[0-9a-f]+:[   ]+14302573[     ]+csrr[         ]+a0,sbadaddr

>  [      ]+[0-9a-f]+:[   ]+18002573[     ]+csrr[         ]+a0,sptbr

>  [      ]+[0-9a-f]+:[   ]+34302573[     ]+csrr[         ]+a0,mbadaddr

>  [      ]+[0-9a-f]+:[   ]+32002573[     ]+csrr[         ]+a0,mucounteren

> -[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch

>  [      ]+[0-9a-f]+:[   ]+20002573[     ]+csrr[         ]+a0,hstatus

>  [      ]+[0-9a-f]+:[   ]+20202573[     ]+csrr[         ]+a0,hedeleg

>  [      ]+[0-9a-f]+:[   ]+20302573[     ]+csrr[         ]+a0,hideleg

> @@ -255,3 +243,53 @@ Disassembly of section .text:

>  [      ]+[0-9a-f]+:[   ]+38502573[     ]+csrr[         ]+a0,mdbound

>  [      ]+[0-9a-f]+:[   ]+32102573[     ]+csrr[         ]+a0,mscounteren

>  [      ]+[0-9a-f]+:[   ]+32202573[     ]+csrr[         ]+a0,mhcounteren

> +[      ]+[0-9a-f]+:[   ]+00102573[     ]+frflags[      ]+a0

> +[      ]+[0-9a-f]+:[   ]+00202573[     ]+frrm[         ]+a0

> +[      ]+[0-9a-f]+:[   ]+00302573[     ]+frcsr[        ]+a0

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01202573[     ]+csrr[         ]+a0,hartinfo

> +[      ]+[0-9a-f]+:[   ]+01402573[     ]+csrr[         ]+a0,hawindowsel

> +[      ]+[0-9a-f]+:[   ]+01502573[     ]+csrr[         ]+a0,hawindow

> +[      ]+[0-9a-f]+:[   ]+01602573[     ]+csrr[         ]+a0,abstractcs

> +[      ]+[0-9a-f]+:[   ]+01702573[     ]+csrr[         ]+a0,command

> +[      ]+[0-9a-f]+:[   ]+01802573[     ]+csrr[         ]+a0,abstractauto

> +[      ]+[0-9a-f]+:[   ]+01902573[     ]+csrr[         ]+a0,confstrptr0

> +[      ]+[0-9a-f]+:[   ]+01d02573[     ]+csrr[         ]+a0,nextdm

> +[      ]+[0-9a-f]+:[   ]+00402573[     ]+csrr[         ]+a0,uie

> +[      ]+[0-9a-f]+:[   ]+02002573[     ]+csrr[         ]+a0,progbuf0

> +[      ]+[0-9a-f]+:[   ]+03002573[     ]+csrr[         ]+a0,authdata

> +[      ]+[0-9a-f]+:[   ]+04002573[     ]+csrr[         ]+a0,uscratch

> +[      ]+[0-9a-f]+:[   ]+01302573[     ]+csrr[         ]+a0,haltsum1

> +[      ]+[0-9a-f]+:[   ]+03402573[     ]+csrr[         ]+a0,haltsum2

> +[      ]+[0-9a-f]+:[   ]+03502573[     ]+csrr[         ]+a0,haltsum3

> +[      ]+[0-9a-f]+:[   ]+03802573[     ]+csrr[         ]+a0,sbcs

> +[      ]+[0-9a-f]+:[   ]+03902573[     ]+csrr[         ]+a0,sbaddress0

> +[      ]+[0-9a-f]+:[   ]+03a02573[     ]+csrr[         ]+a0,sbaddress1

> +[      ]+[0-9a-f]+:[   ]+03b02573[     ]+csrr[         ]+a0,sbaddress2

> +[      ]+[0-9a-f]+:[   ]+03702573[     ]+csrr[         ]+a0,sbaddress3

> +[      ]+[0-9a-f]+:[   ]+03c02573[     ]+csrr[         ]+a0,sbdata0

> +[      ]+[0-9a-f]+:[   ]+03d02573[     ]+csrr[         ]+a0,sbdata1

> +[      ]+[0-9a-f]+:[   ]+03e02573[     ]+csrr[         ]+a0,sbdata2

> +[      ]+[0-9a-f]+:[   ]+03f02573[     ]+csrr[         ]+a0,sbdata3

> +[      ]+[0-9a-f]+:[   ]+7b002573[     ]+csrr[         ]+a0,dcsr

> +[      ]+[0-9a-f]+:[   ]+7b102573[     ]+csrr[         ]+a0,dpc

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7b302573[     ]+csrr[         ]+a0,dscratch1

> +[      ]+[0-9a-f]+:[   ]+7b202573[     ]+csrr[         ]+a0,dscratch0

> +[      ]+[0-9a-f]+:[   ]+7a002573[     ]+csrr[         ]+a0,tselect

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a202573[     ]+csrr[         ]+a0,tdata2

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a402573[     ]+csrr[         ]+a0,tinfo

> +[      ]+[0-9a-f]+:[   ]+7a502573[     ]+csrr[         ]+a0,tcontrol

> +[      ]+[0-9a-f]+:[   ]+7a802573[     ]+csrr[         ]+a0,mcontext

> +[      ]+[0-9a-f]+:[   ]+7aa02573[     ]+csrr[         ]+a0,scontext

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a102573[     ]+csrr[         ]+a0,tdata1

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+7a302573[     ]+csrr[         ]+a0,tdata3

> +[      ]+[0-9a-f]+:[   ]+01002573[     ]+csrr[         ]+a0,dmcontrol

> +[      ]+[0-9a-f]+:[   ]+01102573[     ]+csrr[         ]+a0,dmstatus

> diff --git a/gas/testsuite/gas/riscv/priv-reg.s b/gas/testsuite/gas/riscv/priv-reg.s

> index 8353f70..4d0f887 100644

> --- a/gas/testsuite/gas/riscv/priv-reg.s

> +++ b/gas/testsuite/gas/riscv/priv-reg.s

> @@ -13,10 +13,6 @@

>         csr utval               # Added in 1.10

>         csr uip

>

> -       csr fflags

> -       csr frm

> -       csr fcsr

> -

>         csr cycle

>         csr time

>         csr instret

> @@ -231,23 +227,12 @@

>         csr mhpmevent30

>         csr mhpmevent31

>

> -       csr tselect

> -       csr tdata1

> -       csr tdata2

> -       csr tdata3

> -

> -       csr dcsr

> -       csr dpc

> -       csr dscratch0           # Added in 1.11

> -       csr dscratch1           # Added in 1.11

> -

>         # Supported in previous priv spec, but dropped now.

>         csr ubadaddr            # 0x043 in 1.9.1, but the value is utval since 1.10

>         csr sbadaddr            # 0x143 in 1.9.1, but the value is stval since 1.10

>         csr sptbr               # 0x180 in 1.9.1, but the value is satp since 1.10

>         csr mbadaddr            # 0x343 in 1.9.1, but the value is mtval since 1.10

>         csr mucounteren         # 0x320 in 1.9.1, dropped in 1.10, but the value is mcountinhibit since 1.11

> -       csr dscratch            # 0x7b2 in 1.10,  but the value is dscratch0 since 1.11

>

>         csr hstatus             # 0x200, dropped in 1.10

>         csr hedeleg             # 0x202, dropped in 1.10

> @@ -267,3 +252,59 @@

>         csr mdbound             # 0x385, dropped in 1.10

>         csr mscounteren         # 0x321, dropped in 1.10

>         csr mhcounteren         # 0x322, dropped in 1.10

> +

> +       # Unprivileged CSR which are not controlled by privilege spec.

> +

> +       # Float

> +       csr fflags

> +       csr frm

> +       csr fcsr

> +

> +       # Debug

> +       csr dmstatus

> +       csr dmcontrol

> +       csr hartinfo

> +       csr hawindowsel

> +       csr hawindow

> +       csr abstractcs

> +       csr command

> +       csr abstractauto

> +       csr confstrptr0

> +       csr nextdm

> +       csr data0               # 0x4, alias to uie

> +       csr progbuf0

> +       csr authdata

> +       csr haltsum0            # 0x40, alias to uscratch

> +       csr haltsum1

> +       csr haltsum2

> +       csr haltsum3

> +       csr sbcs

> +       csr sbaddress0

> +       csr sbaddress1

> +       csr sbaddress2

> +       csr sbaddress3

> +       csr sbdata0

> +       csr sbdata1

> +       csr sbdata2

> +       csr sbdata3

> +       csr dcsr

> +       csr dpc

> +       csr dscratch0

> +       csr dscratch1

> +       csr dscratch            # 0x7b2, alias to dscratch0

> +       csr tselect

> +       csr tdata1

> +       csr tdata2

> +       csr tdata3

> +       csr tinfo

> +       csr tcontrol

> +       csr mcontext

> +       csr scontext

> +       csr mcontrol            # 0x7a1, alias to tdata1

> +       csr icount              # 0x7a1, alias to tdata1

> +       csr itrigger            # 0x7a1, alias to tdata1

> +       csr etrigger            # 0x7a1, alias to tdata1

> +       csr textra32            # 0x7a3, alias to tdata3

> +       csr textra64            # 0x7a3, alias to tdata3

> +       csr dtmcs               # 0x10, alias to dmcontrol

> +       csr dmi                 # 0x11, alias to dmstatus

> diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h

> index a6a5de3..ff2b02e 100644

> --- a/include/opcode/riscv-opc.h

> +++ b/include/opcode/riscv-opc.h

> @@ -584,9 +584,6 @@

>  #define CSR_UCAUSE 0x42

>  #define CSR_UTVAL 0x43

>  #define CSR_UIP 0x44

> -#define CSR_FFLAGS 0x1

> -#define CSR_FRM 0x2

> -#define CSR_FCSR 0x3

>  #define CSR_CYCLE 0xc00

>  #define CSR_TIME 0xc01

>  #define CSR_INSTRET 0xc02

> @@ -791,14 +788,6 @@

>  #define CSR_MHPMEVENT29 0x33d

>  #define CSR_MHPMEVENT30 0x33e

>  #define CSR_MHPMEVENT31 0x33f

> -#define CSR_TSELECT 0x7a0

> -#define CSR_TDATA1 0x7a1

> -#define CSR_TDATA2 0x7a2

> -#define CSR_TDATA3 0x7a3

> -#define CSR_DCSR 0x7b0

> -#define CSR_DPC 0x7b1

> -#define CSR_DSCRATCH0 0x7b2

> -#define CSR_DSCRATCH1 0x7b3

>  #define CSR_HSTATUS 0x200

>  #define CSR_HEDELEG 0x202

>  #define CSR_HIDELEG 0x203

> @@ -817,7 +806,46 @@

>  #define CSR_MDBOUND 0x385

>  #define CSR_MSCOUNTEREN 0x321

>  #define CSR_MHCOUNTEREN 0x322

> -

> +/* Support the unprivileged CSR.  */

> +#define CSR_FFLAGS 0x1

> +#define CSR_FRM 0x2

> +#define CSR_FCSR 0x3

> +#define CSR_DMSTATUS 0x11

> +#define CSR_DMCONTROL 0x10

> +#define CSR_HARTINFO 0x12

> +#define CSR_HAWINDOWSEL 0x14

> +#define CSR_HAWINDOW 0x15

> +#define CSR_ABSTRACTCS 0x16

> +#define CSR_COMMAND 0x17

> +#define CSR_ABSTRACTAUTO 0x18

> +#define CSR_CONFSTRPTR0 0x19

> +#define CSR_NEXTDM 0x1d

> +#define CSR_PROGBUF0 0x20

> +#define CSR_AUTHDATA 0x30

> +#define CSR_HALTSUM1 0x13

> +#define CSR_HALTSUM2 0x34

> +#define CSR_HALTSUM3 0x35

> +#define CSR_SBCS 0x38

> +#define CSR_SBADDRESS0 0x39

> +#define CSR_SBADDRESS1 0x3a

> +#define CSR_SBADDRESS2 0x3b

> +#define CSR_SBADDRESS3 0x37

> +#define CSR_SBDATA0 0x3c

> +#define CSR_SBDATA1 0x3d

> +#define CSR_SBDATA2 0x3e

> +#define CSR_SBDATA3 0x3f

> +#define CSR_DCSR 0x7b0

> +#define CSR_DPC 0x7b1

> +#define CSR_DSCRATCH0 0x7b2

> +#define CSR_DSCRATCH1 0x7b3

> +#define CSR_TSELECT 0x7a0

> +#define CSR_TDATA1 0x7a1

> +#define CSR_TDATA2 0x7a2

> +#define CSR_TDATA3 0x7a3

> +#define CSR_TINFO 0x7a4

> +#define CSR_TCONTROL 0x7a5

> +#define CSR_MCONTEXT 0x7a8

> +#define CSR_SCONTEXT 0x7aa

>  #define CAUSE_MISALIGNED_FETCH 0x0

>  #define CAUSE_FAULT_FETCH 0x1

>  #define CAUSE_ILLEGAL_INSTRUCTION 0x2

> @@ -1125,9 +1153,6 @@ DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DR

>  DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> @@ -1332,14 +1357,6 @@ DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV

>  DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)

> -DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)

>  DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

>  DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

>  DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

> @@ -1358,6 +1375,45 @@ DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLAS

>  DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

>  DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

>  DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

> +DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(dmstatus, CSR_DMSTATUS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(dmcontrol, CSR_DMCONTROL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(hartinfo, CSR_HARTINFO, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(hawindowsel, CSR_HAWINDOWSEL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(hawindow, CSR_HAWINDOW, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(abstractcs, CSR_ABSTRACTCS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(command, CSR_COMMAND, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(abstractauto, CSR_ABSTRACTAUTO, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(confstrptr0, CSR_CONFSTRPTR0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(nextdm, CSR_NEXTDM, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(progbuf0, CSR_PROGBUF0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(authdata, CSR_AUTHDATA, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(haltsum1, CSR_HALTSUM1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(haltsum2, CSR_HALTSUM2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(haltsum3, CSR_HALTSUM3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbcs, CSR_SBCS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbaddress0, CSR_SBADDRESS0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbaddress1, CSR_SBADDRESS1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbaddress2, CSR_SBADDRESS2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbaddress3, CSR_SBADDRESS3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbdata0, CSR_SBDATA0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbdata1, CSR_SBDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbdata2, CSR_SBDATA2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(sbdata3, CSR_SBDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(tinfo, CSR_TINFO, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(tcontrol, CSR_TCONTROL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(mcontext, CSR_MCONTEXT, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR(scontext, CSR_SCONTEXT, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

>  #endif

>  #ifdef DECLARE_CSR_ALIAS

>  DECLARE_CSR_ALIAS(misa, 0xf10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P9P1)

> @@ -1366,7 +1422,17 @@ DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SP

>  DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

>  DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

>  DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

> -DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P11)

> +DECLARE_CSR_ALIAS(data0, CSR_UIE, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(haltsum0, CSR_USCRATCH, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(mcontrol, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(icount, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(itrigger, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(etrigger, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(textra32, CSR_TDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(textra64, CSR_TDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(dtmcs, CSR_DMCONTROL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

> +DECLARE_CSR_ALIAS(dmi, CSR_DMSTATUS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)

>  #endif

>  #ifdef DECLARE_CAUSE

>  DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)

> diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h

> index fecf410..e342eee 100644

> --- a/include/opcode/riscv.h

> +++ b/include/opcode/riscv.h

> @@ -373,6 +373,7 @@ enum riscv_csr_class

>    CSR_CLASS_I,

>    CSR_CLASS_I_32,      /* rv32 only */

>    CSR_CLASS_F,         /* f-ext only */

> +  CSR_CLASS_DEBUG      /* debug CSR */

>  };

>

>  /* The current supported privilege spec versions.  */

> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c

> index f26a46e..5f46a49 100644

> --- a/opcodes/riscv-dis.c

> +++ b/opcodes/riscv-dis.c

> @@ -376,9 +376,12 @@ print_insn_args (const char *d, insn_t l, bfd_vma pc, disassemble_info *info)

>                 if (default_priv_spec == PRIV_SPEC_CLASS_NONE)

>                   default_priv_spec = PRIV_SPEC_CLASS_DRAFT - 1;

>

> -#define DECLARE_CSR(name, num, class, define_version, abort_version) \

> -               if (default_priv_spec >= define_version              \

> -                   && default_priv_spec < abort_version)            \

> +#define DECLARE_CSR(name, num, class, define_version, abort_version)   \

> +               if (riscv_csr_hash[num] == NULL                         \

> +                   && ((define_version == PRIV_SPEC_CLASS_NONE         \

> +                        && abort_version == PRIV_SPEC_CLASS_NONE)      \

> +                       || (default_priv_spec >= define_version         \

> +                           && default_priv_spec < abort_version)))     \

>                   riscv_csr_hash[num] = #name;

>  #define DECLARE_CSR_ALIAS(name, num, class, define_version, abort_version) \

>                 DECLARE_CSR (name, num, class, define_version, abort_version)

> --

> 2.7.4

>
Jim Wilson June 9, 2020, 5:29 a.m. | #2
On Mon, Jun 8, 2020 at 7:24 PM Nelson Chu <nelson.chu@sifive.com> wrote:>
> I got the feedback recently that updating the CSR may cause the

> compatibility issue for GDB and QEMU...  So please ignore this patch

> for now, I will figure out how to resolve the compatibility issue, and

> then give a better solution.  Please feel free to contact me if you

> have any suggestions and ideas.


It was the csr version update to 1.11 that is the problem, as we
didn't update qemu to use 1.11 csr register names, and gdb doesn't
support aliases for 1.10 and 1.9.1 register names.  Otherwise, the csr
versioning stuff, and adding the debug csrs, isn't the problem here.
qemu supports multiple priv spec versions, so in theory it should have
multiple xml register lists for different priv spec versions, but
currently it only has one list which is either 1.9.1 or 1.10 based.
And gdb should support the previous priv spec version aliases.  That
is how it should work long term, but for now I think we only have a
problem with one register, the dscratch to dscratch0 rename and Andrew
Burgess has a suggested workaround for that.

Jim

Patch

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index cc77dbf..5ebe31c 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -720,51 +720,46 @@  riscv_init_csr_hash (const char *name,
 
 /* Check wether the CSR is valid according to the ISA.  */
 
-static void
-riscv_csr_class_check (const char *s,
-		       enum riscv_csr_class csr_class)
+static unsigned int
+riscv_csr_address (const char *csr_name,
+		   struct riscv_csr_extra *entry)
 {
+  struct riscv_csr_extra *saved_entry = entry;
+  enum riscv_csr_class csr_class = entry->csr_class;
+  bfd_boolean need_check_version = TRUE;
   bfd_boolean result = TRUE;
 
-  /* Don't check the ISA dependency when -mcsr-check isn't set.  */
-  if (!riscv_opts.csr_check)
-    return;
-
   switch (csr_class)
     {
     case CSR_CLASS_I:
       result = riscv_subset_supports ("i");
       break;
+    case CSR_CLASS_I_32:
+      result = (xlen == 32 && riscv_subset_supports ("i"));
+      break;
     case CSR_CLASS_F:
       result = riscv_subset_supports ("f");
+      need_check_version = FALSE;
       break;
-    case CSR_CLASS_I_32:
-      result = (xlen == 32 && riscv_subset_supports ("i"));
+    case CSR_CLASS_DEBUG:
+      need_check_version = FALSE;
       break;
     default:
       as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);
     }
 
-  if (!result)
-    as_warn (_("Invalid CSR `%s' for the current ISA"), s);
-}
-
-/* Check and find the CSR address according to the privilege spec version.  */
-
-static void
-riscv_csr_version_check (const char *csr_name,
-			 struct riscv_csr_extra **entryP)
-{
-  struct riscv_csr_extra *entry = *entryP;
+  /* Don't report the ISA conflict when -mcsr-check isn't set.  */
+  if (riscv_opts.csr_check && !result)
+    as_warn (_("Invalid CSR `%s' for the current ISA"), csr_name);
 
   while (entry != NULL)
     {
-      if (default_priv_spec >= entry->define_version
-	  && default_priv_spec < entry->abort_version)
+      if (!need_check_version
+	  || (default_priv_spec >= entry->define_version
+	      && default_priv_spec < entry->abort_version))
        {
          /* Find the suitable CSR according to the specific version.  */
-         *entryP = entry;
-         return;
+         return entry->address;
        }
       entry = entry->next;
     }
@@ -781,6 +776,8 @@  riscv_csr_version_check (const char *csr_name,
 	as_warn (_("Invalid CSR `%s' for the privilege spec `%s'"),
 		 csr_name, priv_name);
     }
+
+  return saved_entry->address;
 }
 
 /* Once the CSR is defined, including the old privilege spec, then we call
@@ -803,10 +800,7 @@  reg_csr_lookup_internal (const char *s)
      will regard it as a "Unknown CSR" and report error.  If user use number
      to set the CSR, but over the range (> 0xfff), then assembler will report
      "Improper CSR" error for it.  */
-  riscv_csr_class_check (s, r->csr_class);
-  riscv_csr_version_check (s, &r);
-
-  return r->address;
+  return riscv_csr_address (s, r);
 }
 
 static unsigned int
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.l b/gas/testsuite/gas/riscv/priv-reg-fail-fext.l
index d74863e..2ee0dae 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-fext.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-fext.l
@@ -1,29 +1,6 @@ 
 .*Assembler messages:
+#...
 .*Warning: Invalid CSR `fflags' for the current ISA
 .*Warning: Invalid CSR `frm' for the current ISA
 .*Warning: Invalid CSR `fcsr' for the current ISA
-
-.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
-.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
+#...
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l
index 2dc82f4..305cd17 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l
@@ -1,4 +1,5 @@ 
 .*Assembler messages:
+#...
 .*Warning: Read-only CSR is written `csrw cycle,a1'
 .*Warning: Read-only CSR is written `csrw time,a1'
 .*Warning: Read-only CSR is written `csrw instret,a1'
@@ -67,28 +68,4 @@ 
 .*Warning: Read-only CSR is written `csrw marchid,a1'
 .*Warning: Read-only CSR is written `csrw mimpid,a1'
 .*Warning: Read-only CSR is written `csrw mhartid,a1'
-
-.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
-.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
+#...
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l
index 19f13a0..5dec50f 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l
@@ -1,4 +1,5 @@ 
 .*Assembler messages:
+#...
 .*Warning: Invalid CSR `cycleh' for the current ISA
 .*Warning: Invalid CSR `timeh' for the current ISA
 .*Warning: Invalid CSR `instreth' for the current ISA
@@ -64,28 +65,4 @@ 
 .*Warning: Invalid CSR `mhpmcounter29h' for the current ISA
 .*Warning: Invalid CSR `mhpmcounter30h' for the current ISA
 .*Warning: Invalid CSR `mhpmcounter31h' for the current ISA
-
-.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
-.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
-.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
+#...
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l
index 4146174..983f593 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l
@@ -1,7 +1,5 @@ 
 .*Assembler messages:
 .*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.10'
-.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.10'
-.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.10'
 .*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.10'
 .*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.10'
 .*Warning: Invalid CSR `sptbr' for the privilege spec `1.10'
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l
index eadcb5c..0e036e4 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l
@@ -4,7 +4,6 @@ 
 .*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
 .*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
 .*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
-.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
 .*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
 .*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
 .*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l
index d7cee80..3630a19 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l
@@ -26,5 +26,3 @@ 
 .*Warning: Invalid CSR `pmpaddr14' for the privilege spec `1.9'
 .*Warning: Invalid CSR `pmpaddr15' for the privilege spec `1.9'
 .*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.9'
-.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.9'
-.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.9'
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l
index 907ed73..8a8126a 100644
--- a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l
@@ -26,5 +26,3 @@ 
 .*Warning: Invalid CSR `pmpaddr14' for the privilege spec `1.9.1'
 .*Warning: Invalid CSR `pmpaddr15' for the privilege spec `1.9.1'
 .*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.9.1'
-.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.9.1'
-.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.9.1'
diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p10.d b/gas/testsuite/gas/riscv/priv-reg-version-1p10.d
index 0071f75..588c145 100644
--- a/gas/testsuite/gas/riscv/priv-reg-version-1p10.d
+++ b/gas/testsuite/gas/riscv/priv-reg-version-1p10.d
@@ -16,9 +16,6 @@  Disassembly of section .text:
 [ 	]+[0-9a-f]+:[  	]+04202573[    	]+csrr[        	]+a0,ucause
 [ 	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,utval
 [ 	]+[0-9a-f]+:[  	]+04402573[    	]+csrr[        	]+a0,uip
-[ 	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[ 	]+a0
-[ 	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
-[ 	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
 [ 	]+[0-9a-f]+:[  	]+c0002573[    	]+rdcycle[ 	]+a0
 [ 	]+[0-9a-f]+:[  	]+c0102573[    	]+rdtime[      	]+a0
 [ 	]+[0-9a-f]+:[  	]+c0202573[    	]+rdinstret[   	]+a0
@@ -223,20 +220,11 @@  Disassembly of section .text:
 [ 	]+[0-9a-f]+:[  	]+33d02573[    	]+csrr[        	]+a0,mhpmevent29
 [ 	]+[0-9a-f]+:[  	]+33e02573[    	]+csrr[        	]+a0,mhpmevent30
 [ 	]+[0-9a-f]+:[  	]+33f02573[    	]+csrr[        	]+a0,mhpmevent31
-[ 	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
-[ 	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
-[ 	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
-[ 	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
-[ 	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
-[ 	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
-[ 	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch
-[ 	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,0x7b3
 [ 	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,utval
 [ 	]+[0-9a-f]+:[  	]+14302573[    	]+csrr[        	]+a0,stval
 [ 	]+[0-9a-f]+:[  	]+18002573[    	]+csrr[        	]+a0,satp
 [ 	]+[0-9a-f]+:[  	]+34302573[    	]+csrr[        	]+a0,mtval
 [ 	]+[0-9a-f]+:[  	]+32002573[    	]+csrr[        	]+a0,0x320
-[ 	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch
 [ 	]+[0-9a-f]+:[  	]+20002573[    	]+csrr[        	]+a0,0x200
 [ 	]+[0-9a-f]+:[  	]+20202573[    	]+csrr[        	]+a0,0x202
 [ 	]+[0-9a-f]+:[  	]+20302573[    	]+csrr[        	]+a0,0x203
@@ -255,3 +243,53 @@  Disassembly of section .text:
 [ 	]+[0-9a-f]+:[  	]+38502573[    	]+csrr[        	]+a0,0x385
 [ 	]+[0-9a-f]+:[  	]+32102573[    	]+csrr[        	]+a0,0x321
 [ 	]+[0-9a-f]+:[  	]+32202573[    	]+csrr[        	]+a0,0x322
+[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
+[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
+[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01202573[    	]+csrr[        	]+a0,hartinfo
+[     	]+[0-9a-f]+:[  	]+01402573[    	]+csrr[        	]+a0,hawindowsel
+[     	]+[0-9a-f]+:[  	]+01502573[    	]+csrr[        	]+a0,hawindow
+[     	]+[0-9a-f]+:[  	]+01602573[    	]+csrr[        	]+a0,abstractcs
+[     	]+[0-9a-f]+:[  	]+01702573[    	]+csrr[        	]+a0,command
+[     	]+[0-9a-f]+:[  	]+01802573[    	]+csrr[        	]+a0,abstractauto
+[     	]+[0-9a-f]+:[  	]+01902573[    	]+csrr[        	]+a0,confstrptr0
+[     	]+[0-9a-f]+:[  	]+01d02573[    	]+csrr[        	]+a0,nextdm
+[     	]+[0-9a-f]+:[  	]+00402573[    	]+csrr[        	]+a0,uie
+[     	]+[0-9a-f]+:[  	]+02002573[    	]+csrr[        	]+a0,progbuf0
+[     	]+[0-9a-f]+:[  	]+03002573[    	]+csrr[        	]+a0,authdata
+[     	]+[0-9a-f]+:[  	]+04002573[    	]+csrr[        	]+a0,uscratch
+[     	]+[0-9a-f]+:[  	]+01302573[    	]+csrr[        	]+a0,haltsum1
+[     	]+[0-9a-f]+:[  	]+03402573[    	]+csrr[        	]+a0,haltsum2
+[     	]+[0-9a-f]+:[  	]+03502573[    	]+csrr[        	]+a0,haltsum3
+[     	]+[0-9a-f]+:[  	]+03802573[    	]+csrr[        	]+a0,sbcs
+[     	]+[0-9a-f]+:[  	]+03902573[    	]+csrr[        	]+a0,sbaddress0
+[     	]+[0-9a-f]+:[  	]+03a02573[    	]+csrr[        	]+a0,sbaddress1
+[     	]+[0-9a-f]+:[  	]+03b02573[    	]+csrr[        	]+a0,sbaddress2
+[     	]+[0-9a-f]+:[  	]+03702573[    	]+csrr[        	]+a0,sbaddress3
+[     	]+[0-9a-f]+:[  	]+03c02573[    	]+csrr[        	]+a0,sbdata0
+[     	]+[0-9a-f]+:[  	]+03d02573[    	]+csrr[        	]+a0,sbdata1
+[     	]+[0-9a-f]+:[  	]+03e02573[    	]+csrr[        	]+a0,sbdata2
+[     	]+[0-9a-f]+:[  	]+03f02573[    	]+csrr[        	]+a0,sbdata3
+[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
+[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,dscratch1
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a402573[    	]+csrr[        	]+a0,tinfo
+[     	]+[0-9a-f]+:[  	]+7a502573[    	]+csrr[        	]+a0,tcontrol
+[     	]+[0-9a-f]+:[  	]+7a802573[    	]+csrr[        	]+a0,mcontext
+[     	]+[0-9a-f]+:[  	]+7aa02573[    	]+csrr[        	]+a0,scontext
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p11.d b/gas/testsuite/gas/riscv/priv-reg-version-1p11.d
index 225f4c4..82b26d0 100644
--- a/gas/testsuite/gas/riscv/priv-reg-version-1p11.d
+++ b/gas/testsuite/gas/riscv/priv-reg-version-1p11.d
@@ -16,9 +16,6 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+04202573[    	]+csrr[        	]+a0,ucause
 [     	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,utval
 [     	]+[0-9a-f]+:[  	]+04402573[    	]+csrr[        	]+a0,uip
-[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
-[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
-[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
 [     	]+[0-9a-f]+:[  	]+c0002573[    	]+rdcycle[     	]+a0
 [     	]+[0-9a-f]+:[  	]+c0102573[    	]+rdtime[      	]+a0
 [     	]+[0-9a-f]+:[  	]+c0202573[    	]+rdinstret[   	]+a0
@@ -223,20 +220,11 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+33d02573[    	]+csrr[        	]+a0,mhpmevent29
 [     	]+[0-9a-f]+:[  	]+33e02573[    	]+csrr[        	]+a0,mhpmevent30
 [     	]+[0-9a-f]+:[  	]+33f02573[    	]+csrr[        	]+a0,mhpmevent31
-[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
-[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
-[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
-[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
-[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
-[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
-[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
-[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,dscratch1
 [     	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,utval
 [     	]+[0-9a-f]+:[  	]+14302573[    	]+csrr[        	]+a0,stval
 [     	]+[0-9a-f]+:[  	]+18002573[    	]+csrr[        	]+a0,satp
 [     	]+[0-9a-f]+:[  	]+34302573[    	]+csrr[        	]+a0,mtval
 [     	]+[0-9a-f]+:[  	]+32002573[    	]+csrr[        	]+a0,mcountinhibit
-[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
 [     	]+[0-9a-f]+:[  	]+20002573[    	]+csrr[        	]+a0,0x200
 [     	]+[0-9a-f]+:[  	]+20202573[    	]+csrr[        	]+a0,0x202
 [     	]+[0-9a-f]+:[  	]+20302573[    	]+csrr[        	]+a0,0x203
@@ -255,3 +243,53 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+38502573[    	]+csrr[        	]+a0,0x385
 [     	]+[0-9a-f]+:[  	]+32102573[    	]+csrr[        	]+a0,0x321
 [     	]+[0-9a-f]+:[  	]+32202573[    	]+csrr[        	]+a0,0x322
+[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
+[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
+[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01202573[    	]+csrr[        	]+a0,hartinfo
+[     	]+[0-9a-f]+:[  	]+01402573[    	]+csrr[        	]+a0,hawindowsel
+[     	]+[0-9a-f]+:[  	]+01502573[    	]+csrr[        	]+a0,hawindow
+[     	]+[0-9a-f]+:[  	]+01602573[    	]+csrr[        	]+a0,abstractcs
+[     	]+[0-9a-f]+:[  	]+01702573[    	]+csrr[        	]+a0,command
+[     	]+[0-9a-f]+:[  	]+01802573[    	]+csrr[        	]+a0,abstractauto
+[     	]+[0-9a-f]+:[  	]+01902573[    	]+csrr[        	]+a0,confstrptr0
+[     	]+[0-9a-f]+:[  	]+01d02573[    	]+csrr[        	]+a0,nextdm
+[     	]+[0-9a-f]+:[  	]+00402573[    	]+csrr[        	]+a0,uie
+[     	]+[0-9a-f]+:[  	]+02002573[    	]+csrr[        	]+a0,progbuf0
+[     	]+[0-9a-f]+:[  	]+03002573[    	]+csrr[        	]+a0,authdata
+[     	]+[0-9a-f]+:[  	]+04002573[    	]+csrr[        	]+a0,uscratch
+[     	]+[0-9a-f]+:[  	]+01302573[    	]+csrr[        	]+a0,haltsum1
+[     	]+[0-9a-f]+:[  	]+03402573[    	]+csrr[        	]+a0,haltsum2
+[     	]+[0-9a-f]+:[  	]+03502573[    	]+csrr[        	]+a0,haltsum3
+[     	]+[0-9a-f]+:[  	]+03802573[    	]+csrr[        	]+a0,sbcs
+[     	]+[0-9a-f]+:[  	]+03902573[    	]+csrr[        	]+a0,sbaddress0
+[     	]+[0-9a-f]+:[  	]+03a02573[    	]+csrr[        	]+a0,sbaddress1
+[     	]+[0-9a-f]+:[  	]+03b02573[    	]+csrr[        	]+a0,sbaddress2
+[     	]+[0-9a-f]+:[  	]+03702573[    	]+csrr[        	]+a0,sbaddress3
+[     	]+[0-9a-f]+:[  	]+03c02573[    	]+csrr[        	]+a0,sbdata0
+[     	]+[0-9a-f]+:[  	]+03d02573[    	]+csrr[        	]+a0,sbdata1
+[     	]+[0-9a-f]+:[  	]+03e02573[    	]+csrr[        	]+a0,sbdata2
+[     	]+[0-9a-f]+:[  	]+03f02573[    	]+csrr[        	]+a0,sbdata3
+[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
+[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,dscratch1
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a402573[    	]+csrr[        	]+a0,tinfo
+[     	]+[0-9a-f]+:[  	]+7a502573[    	]+csrr[        	]+a0,tcontrol
+[     	]+[0-9a-f]+:[  	]+7a802573[    	]+csrr[        	]+a0,mcontext
+[     	]+[0-9a-f]+:[  	]+7aa02573[    	]+csrr[        	]+a0,scontext
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p9.d b/gas/testsuite/gas/riscv/priv-reg-version-1p9.d
index fd2a56b..d54acc0 100644
--- a/gas/testsuite/gas/riscv/priv-reg-version-1p9.d
+++ b/gas/testsuite/gas/riscv/priv-reg-version-1p9.d
@@ -16,9 +16,6 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+04202573[    	]+csrr[        	]+a0,ucause
 [     	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,ubadaddr
 [     	]+[0-9a-f]+:[  	]+04402573[    	]+csrr[        	]+a0,uip
-[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
-[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
-[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
 [     	]+[0-9a-f]+:[  	]+c0002573[    	]+rdcycle[     	]+a0
 [     	]+[0-9a-f]+:[  	]+c0102573[    	]+rdtime[      	]+a0
 [     	]+[0-9a-f]+:[  	]+c0202573[    	]+rdinstret[   	]+a0
@@ -223,20 +220,11 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+33d02573[    	]+csrr[        	]+a0,mhpmevent29
 [     	]+[0-9a-f]+:[  	]+33e02573[    	]+csrr[        	]+a0,mhpmevent30
 [     	]+[0-9a-f]+:[  	]+33f02573[    	]+csrr[        	]+a0,mhpmevent31
-[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
-[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
-[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
-[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
-[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
-[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
-[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch
-[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,0x7b3
 [     	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,ubadaddr
 [     	]+[0-9a-f]+:[  	]+14302573[    	]+csrr[        	]+a0,sbadaddr
 [     	]+[0-9a-f]+:[  	]+18002573[    	]+csrr[        	]+a0,sptbr
 [     	]+[0-9a-f]+:[  	]+34302573[    	]+csrr[        	]+a0,mbadaddr
 [     	]+[0-9a-f]+:[  	]+32002573[    	]+csrr[        	]+a0,mucounteren
-[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch
 [     	]+[0-9a-f]+:[  	]+20002573[    	]+csrr[        	]+a0,hstatus
 [     	]+[0-9a-f]+:[  	]+20202573[    	]+csrr[        	]+a0,hedeleg
 [     	]+[0-9a-f]+:[  	]+20302573[    	]+csrr[        	]+a0,hideleg
@@ -255,3 +243,53 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+38502573[    	]+csrr[        	]+a0,mdbound
 [     	]+[0-9a-f]+:[  	]+32102573[    	]+csrr[        	]+a0,mscounteren
 [     	]+[0-9a-f]+:[  	]+32202573[    	]+csrr[        	]+a0,mhcounteren
+[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
+[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
+[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01202573[    	]+csrr[        	]+a0,hartinfo
+[     	]+[0-9a-f]+:[  	]+01402573[    	]+csrr[        	]+a0,hawindowsel
+[     	]+[0-9a-f]+:[  	]+01502573[    	]+csrr[        	]+a0,hawindow
+[     	]+[0-9a-f]+:[  	]+01602573[    	]+csrr[        	]+a0,abstractcs
+[     	]+[0-9a-f]+:[  	]+01702573[    	]+csrr[        	]+a0,command
+[     	]+[0-9a-f]+:[  	]+01802573[    	]+csrr[        	]+a0,abstractauto
+[     	]+[0-9a-f]+:[  	]+01902573[    	]+csrr[        	]+a0,confstrptr0
+[     	]+[0-9a-f]+:[  	]+01d02573[    	]+csrr[        	]+a0,nextdm
+[     	]+[0-9a-f]+:[  	]+00402573[    	]+csrr[        	]+a0,uie
+[     	]+[0-9a-f]+:[  	]+02002573[    	]+csrr[        	]+a0,progbuf0
+[     	]+[0-9a-f]+:[  	]+03002573[    	]+csrr[        	]+a0,authdata
+[     	]+[0-9a-f]+:[  	]+04002573[    	]+csrr[        	]+a0,uscratch
+[     	]+[0-9a-f]+:[  	]+01302573[    	]+csrr[        	]+a0,haltsum1
+[     	]+[0-9a-f]+:[  	]+03402573[    	]+csrr[        	]+a0,haltsum2
+[     	]+[0-9a-f]+:[  	]+03502573[    	]+csrr[        	]+a0,haltsum3
+[     	]+[0-9a-f]+:[  	]+03802573[    	]+csrr[        	]+a0,sbcs
+[     	]+[0-9a-f]+:[  	]+03902573[    	]+csrr[        	]+a0,sbaddress0
+[     	]+[0-9a-f]+:[  	]+03a02573[    	]+csrr[        	]+a0,sbaddress1
+[     	]+[0-9a-f]+:[  	]+03b02573[    	]+csrr[        	]+a0,sbaddress2
+[     	]+[0-9a-f]+:[  	]+03702573[    	]+csrr[        	]+a0,sbaddress3
+[     	]+[0-9a-f]+:[  	]+03c02573[    	]+csrr[        	]+a0,sbdata0
+[     	]+[0-9a-f]+:[  	]+03d02573[    	]+csrr[        	]+a0,sbdata1
+[     	]+[0-9a-f]+:[  	]+03e02573[    	]+csrr[        	]+a0,sbdata2
+[     	]+[0-9a-f]+:[  	]+03f02573[    	]+csrr[        	]+a0,sbdata3
+[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
+[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,dscratch1
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a402573[    	]+csrr[        	]+a0,tinfo
+[     	]+[0-9a-f]+:[  	]+7a502573[    	]+csrr[        	]+a0,tcontrol
+[     	]+[0-9a-f]+:[  	]+7a802573[    	]+csrr[        	]+a0,mcontext
+[     	]+[0-9a-f]+:[  	]+7aa02573[    	]+csrr[        	]+a0,scontext
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
diff --git a/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d b/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d
index 6162803..6df04aa 100644
--- a/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d
+++ b/gas/testsuite/gas/riscv/priv-reg-version-1p9p1.d
@@ -16,9 +16,6 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+04202573[    	]+csrr[        	]+a0,ucause
 [     	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,ubadaddr
 [     	]+[0-9a-f]+:[  	]+04402573[    	]+csrr[        	]+a0,uip
-[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
-[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
-[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
 [     	]+[0-9a-f]+:[  	]+c0002573[    	]+rdcycle[     	]+a0
 [     	]+[0-9a-f]+:[  	]+c0102573[    	]+rdtime[      	]+a0
 [     	]+[0-9a-f]+:[  	]+c0202573[    	]+rdinstret[   	]+a0
@@ -223,20 +220,11 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+33d02573[    	]+csrr[        	]+a0,mhpmevent29
 [     	]+[0-9a-f]+:[  	]+33e02573[    	]+csrr[        	]+a0,mhpmevent30
 [     	]+[0-9a-f]+:[  	]+33f02573[    	]+csrr[        	]+a0,mhpmevent31
-[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
-[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
-[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
-[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
-[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
-[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
-[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch
-[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,0x7b3
 [     	]+[0-9a-f]+:[  	]+04302573[    	]+csrr[        	]+a0,ubadaddr
 [     	]+[0-9a-f]+:[  	]+14302573[    	]+csrr[        	]+a0,sbadaddr
 [     	]+[0-9a-f]+:[  	]+18002573[    	]+csrr[        	]+a0,sptbr
 [     	]+[0-9a-f]+:[  	]+34302573[    	]+csrr[        	]+a0,mbadaddr
 [     	]+[0-9a-f]+:[  	]+32002573[    	]+csrr[        	]+a0,mucounteren
-[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch
 [     	]+[0-9a-f]+:[  	]+20002573[    	]+csrr[        	]+a0,hstatus
 [     	]+[0-9a-f]+:[  	]+20202573[    	]+csrr[        	]+a0,hedeleg
 [     	]+[0-9a-f]+:[  	]+20302573[    	]+csrr[        	]+a0,hideleg
@@ -255,3 +243,53 @@  Disassembly of section .text:
 [     	]+[0-9a-f]+:[  	]+38502573[    	]+csrr[        	]+a0,mdbound
 [     	]+[0-9a-f]+:[  	]+32102573[    	]+csrr[        	]+a0,mscounteren
 [     	]+[0-9a-f]+:[  	]+32202573[    	]+csrr[        	]+a0,mhcounteren
+[     	]+[0-9a-f]+:[  	]+00102573[    	]+frflags[     	]+a0
+[     	]+[0-9a-f]+:[  	]+00202573[    	]+frrm[        	]+a0
+[     	]+[0-9a-f]+:[  	]+00302573[    	]+frcsr[       	]+a0
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01202573[    	]+csrr[        	]+a0,hartinfo
+[     	]+[0-9a-f]+:[  	]+01402573[    	]+csrr[        	]+a0,hawindowsel
+[     	]+[0-9a-f]+:[  	]+01502573[    	]+csrr[        	]+a0,hawindow
+[     	]+[0-9a-f]+:[  	]+01602573[    	]+csrr[        	]+a0,abstractcs
+[     	]+[0-9a-f]+:[  	]+01702573[    	]+csrr[        	]+a0,command
+[     	]+[0-9a-f]+:[  	]+01802573[    	]+csrr[        	]+a0,abstractauto
+[     	]+[0-9a-f]+:[  	]+01902573[    	]+csrr[        	]+a0,confstrptr0
+[     	]+[0-9a-f]+:[  	]+01d02573[    	]+csrr[        	]+a0,nextdm
+[     	]+[0-9a-f]+:[  	]+00402573[    	]+csrr[        	]+a0,uie
+[     	]+[0-9a-f]+:[  	]+02002573[    	]+csrr[        	]+a0,progbuf0
+[     	]+[0-9a-f]+:[  	]+03002573[    	]+csrr[        	]+a0,authdata
+[     	]+[0-9a-f]+:[  	]+04002573[    	]+csrr[        	]+a0,uscratch
+[     	]+[0-9a-f]+:[  	]+01302573[    	]+csrr[        	]+a0,haltsum1
+[     	]+[0-9a-f]+:[  	]+03402573[    	]+csrr[        	]+a0,haltsum2
+[     	]+[0-9a-f]+:[  	]+03502573[    	]+csrr[        	]+a0,haltsum3
+[     	]+[0-9a-f]+:[  	]+03802573[    	]+csrr[        	]+a0,sbcs
+[     	]+[0-9a-f]+:[  	]+03902573[    	]+csrr[        	]+a0,sbaddress0
+[     	]+[0-9a-f]+:[  	]+03a02573[    	]+csrr[        	]+a0,sbaddress1
+[     	]+[0-9a-f]+:[  	]+03b02573[    	]+csrr[        	]+a0,sbaddress2
+[     	]+[0-9a-f]+:[  	]+03702573[    	]+csrr[        	]+a0,sbaddress3
+[     	]+[0-9a-f]+:[  	]+03c02573[    	]+csrr[        	]+a0,sbdata0
+[     	]+[0-9a-f]+:[  	]+03d02573[    	]+csrr[        	]+a0,sbdata1
+[     	]+[0-9a-f]+:[  	]+03e02573[    	]+csrr[        	]+a0,sbdata2
+[     	]+[0-9a-f]+:[  	]+03f02573[    	]+csrr[        	]+a0,sbdata3
+[     	]+[0-9a-f]+:[  	]+7b002573[    	]+csrr[        	]+a0,dcsr
+[     	]+[0-9a-f]+:[  	]+7b102573[    	]+csrr[        	]+a0,dpc
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7b302573[    	]+csrr[        	]+a0,dscratch1
+[     	]+[0-9a-f]+:[  	]+7b202573[    	]+csrr[        	]+a0,dscratch0
+[     	]+[0-9a-f]+:[  	]+7a002573[    	]+csrr[        	]+a0,tselect
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a202573[    	]+csrr[        	]+a0,tdata2
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a402573[    	]+csrr[        	]+a0,tinfo
+[     	]+[0-9a-f]+:[  	]+7a502573[    	]+csrr[        	]+a0,tcontrol
+[     	]+[0-9a-f]+:[  	]+7a802573[    	]+csrr[        	]+a0,mcontext
+[     	]+[0-9a-f]+:[  	]+7aa02573[    	]+csrr[        	]+a0,scontext
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a102573[    	]+csrr[        	]+a0,tdata1
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+7a302573[    	]+csrr[        	]+a0,tdata3
+[     	]+[0-9a-f]+:[  	]+01002573[    	]+csrr[        	]+a0,dmcontrol
+[     	]+[0-9a-f]+:[  	]+01102573[    	]+csrr[        	]+a0,dmstatus
diff --git a/gas/testsuite/gas/riscv/priv-reg.s b/gas/testsuite/gas/riscv/priv-reg.s
index 8353f70..4d0f887 100644
--- a/gas/testsuite/gas/riscv/priv-reg.s
+++ b/gas/testsuite/gas/riscv/priv-reg.s
@@ -13,10 +13,6 @@ 
 	csr utval		# Added in 1.10
 	csr uip
 
-	csr fflags
-	csr frm
-	csr fcsr
-
 	csr cycle
 	csr time
 	csr instret
@@ -231,23 +227,12 @@ 
 	csr mhpmevent30
 	csr mhpmevent31
 
-	csr tselect
-	csr tdata1
-	csr tdata2
-	csr tdata3
-
-	csr dcsr
-	csr dpc
-	csr dscratch0		# Added in 1.11
-	csr dscratch1		# Added in 1.11
-
 	# Supported in previous priv spec, but dropped now.
 	csr ubadaddr		# 0x043 in 1.9.1, but the value is utval since 1.10
 	csr sbadaddr		# 0x143 in 1.9.1, but the value is stval since 1.10
 	csr sptbr		# 0x180 in 1.9.1, but the value is satp since 1.10
 	csr mbadaddr		# 0x343 in 1.9.1, but the value is mtval since 1.10
 	csr mucounteren		# 0x320 in 1.9.1, dropped in 1.10, but the value is mcountinhibit since 1.11
-	csr dscratch		# 0x7b2 in 1.10,  but the value is dscratch0 since 1.11
 
 	csr hstatus		# 0x200, dropped in 1.10
 	csr hedeleg		# 0x202, dropped in 1.10
@@ -267,3 +252,59 @@ 
 	csr mdbound		# 0x385, dropped in 1.10
 	csr mscounteren		# 0x321, dropped in 1.10
 	csr mhcounteren		# 0x322, dropped in 1.10
+
+	# Unprivileged CSR which are not controlled by privilege spec.
+
+	# Float
+	csr fflags
+	csr frm
+	csr fcsr
+
+	# Debug
+	csr dmstatus
+	csr dmcontrol
+	csr hartinfo
+	csr hawindowsel
+	csr hawindow
+	csr abstractcs
+	csr command
+	csr abstractauto
+	csr confstrptr0
+	csr nextdm
+	csr data0		# 0x4, alias to uie
+	csr progbuf0
+	csr authdata
+	csr haltsum0		# 0x40, alias to uscratch
+	csr haltsum1
+	csr haltsum2
+	csr haltsum3
+	csr sbcs
+	csr sbaddress0
+	csr sbaddress1
+	csr sbaddress2
+	csr sbaddress3
+	csr sbdata0
+	csr sbdata1
+	csr sbdata2
+	csr sbdata3
+	csr dcsr
+	csr dpc
+	csr dscratch0
+	csr dscratch1
+	csr dscratch		# 0x7b2, alias to dscratch0
+	csr tselect
+	csr tdata1
+	csr tdata2
+	csr tdata3
+	csr tinfo
+	csr tcontrol
+	csr mcontext
+	csr scontext
+	csr mcontrol		# 0x7a1, alias to tdata1
+	csr icount		# 0x7a1, alias to tdata1
+	csr itrigger		# 0x7a1, alias to tdata1
+	csr etrigger		# 0x7a1, alias to tdata1
+	csr textra32		# 0x7a3, alias to tdata3
+	csr textra64		# 0x7a3, alias to tdata3
+	csr dtmcs		# 0x10, alias to dmcontrol
+	csr dmi			# 0x11, alias to dmstatus
diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
index a6a5de3..ff2b02e 100644
--- a/include/opcode/riscv-opc.h
+++ b/include/opcode/riscv-opc.h
@@ -584,9 +584,6 @@ 
 #define CSR_UCAUSE 0x42
 #define CSR_UTVAL 0x43
 #define CSR_UIP 0x44
-#define CSR_FFLAGS 0x1
-#define CSR_FRM 0x2
-#define CSR_FCSR 0x3
 #define CSR_CYCLE 0xc00
 #define CSR_TIME 0xc01
 #define CSR_INSTRET 0xc02
@@ -791,14 +788,6 @@ 
 #define CSR_MHPMEVENT29 0x33d
 #define CSR_MHPMEVENT30 0x33e
 #define CSR_MHPMEVENT31 0x33f
-#define CSR_TSELECT 0x7a0
-#define CSR_TDATA1 0x7a1
-#define CSR_TDATA2 0x7a2
-#define CSR_TDATA3 0x7a3
-#define CSR_DCSR 0x7b0
-#define CSR_DPC 0x7b1
-#define CSR_DSCRATCH0 0x7b2
-#define CSR_DSCRATCH1 0x7b3
 #define CSR_HSTATUS 0x200
 #define CSR_HEDELEG 0x202
 #define CSR_HIDELEG 0x203
@@ -817,7 +806,46 @@ 
 #define CSR_MDBOUND 0x385
 #define CSR_MSCOUNTEREN 0x321
 #define CSR_MHCOUNTEREN 0x322
-
+/* Support the unprivileged CSR.  */
+#define CSR_FFLAGS 0x1
+#define CSR_FRM 0x2
+#define CSR_FCSR 0x3
+#define CSR_DMSTATUS 0x11
+#define CSR_DMCONTROL 0x10
+#define CSR_HARTINFO 0x12
+#define CSR_HAWINDOWSEL 0x14
+#define CSR_HAWINDOW 0x15
+#define CSR_ABSTRACTCS 0x16
+#define CSR_COMMAND 0x17
+#define CSR_ABSTRACTAUTO 0x18
+#define CSR_CONFSTRPTR0 0x19
+#define CSR_NEXTDM 0x1d
+#define CSR_PROGBUF0 0x20
+#define CSR_AUTHDATA 0x30
+#define CSR_HALTSUM1 0x13
+#define CSR_HALTSUM2 0x34
+#define CSR_HALTSUM3 0x35
+#define CSR_SBCS 0x38
+#define CSR_SBADDRESS0 0x39
+#define CSR_SBADDRESS1 0x3a
+#define CSR_SBADDRESS2 0x3b
+#define CSR_SBADDRESS3 0x37
+#define CSR_SBDATA0 0x3c
+#define CSR_SBDATA1 0x3d
+#define CSR_SBDATA2 0x3e
+#define CSR_SBDATA3 0x3f
+#define CSR_DCSR 0x7b0
+#define CSR_DPC 0x7b1
+#define CSR_DSCRATCH0 0x7b2
+#define CSR_DSCRATCH1 0x7b3
+#define CSR_TSELECT 0x7a0
+#define CSR_TDATA1 0x7a1
+#define CSR_TDATA2 0x7a2
+#define CSR_TDATA3 0x7a3
+#define CSR_TINFO 0x7a4
+#define CSR_TCONTROL 0x7a5
+#define CSR_MCONTEXT 0x7a8
+#define CSR_SCONTEXT 0x7aa
 #define CAUSE_MISALIGNED_FETCH 0x0
 #define CAUSE_FAULT_FETCH 0x1
 #define CAUSE_ILLEGAL_INSTRUCTION 0x2
@@ -1125,9 +1153,6 @@  DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DR
 DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
@@ -1332,14 +1357,6 @@  DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV
 DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
@@ -1358,6 +1375,45 @@  DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLAS
 DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
+DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(dmstatus, CSR_DMSTATUS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(dmcontrol, CSR_DMCONTROL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hartinfo, CSR_HARTINFO, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hawindowsel, CSR_HAWINDOWSEL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hawindow, CSR_HAWINDOW, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(abstractcs, CSR_ABSTRACTCS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(command, CSR_COMMAND, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(abstractauto, CSR_ABSTRACTAUTO, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(confstrptr0, CSR_CONFSTRPTR0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(nextdm, CSR_NEXTDM, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(progbuf0, CSR_PROGBUF0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(authdata, CSR_AUTHDATA, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(haltsum1, CSR_HALTSUM1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(haltsum2, CSR_HALTSUM2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(haltsum3, CSR_HALTSUM3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbcs, CSR_SBCS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbaddress0, CSR_SBADDRESS0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbaddress1, CSR_SBADDRESS1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbaddress2, CSR_SBADDRESS2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbaddress3, CSR_SBADDRESS3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbdata0, CSR_SBDATA0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbdata1, CSR_SBDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbdata2, CSR_SBDATA2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(sbdata3, CSR_SBDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(tinfo, CSR_TINFO, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(tcontrol, CSR_TCONTROL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mcontext, CSR_MCONTEXT, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(scontext, CSR_SCONTEXT, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 #endif
 #ifdef DECLARE_CSR_ALIAS
 DECLARE_CSR_ALIAS(misa, 0xf10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P9P1)
@@ -1366,7 +1422,17 @@  DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SP
 DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
-DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P11)
+DECLARE_CSR_ALIAS(data0, CSR_UIE, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(haltsum0, CSR_USCRATCH, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(mcontrol, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(icount, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(itrigger, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(etrigger, CSR_TDATA1, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(textra32, CSR_TDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(textra64, CSR_TDATA3, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(dtmcs, CSR_DMCONTROL, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR_ALIAS(dmi, CSR_DMSTATUS, CSR_CLASS_DEBUG, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 #endif
 #ifdef DECLARE_CAUSE
 DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
index fecf410..e342eee 100644
--- a/include/opcode/riscv.h
+++ b/include/opcode/riscv.h
@@ -373,6 +373,7 @@  enum riscv_csr_class
   CSR_CLASS_I,
   CSR_CLASS_I_32,      /* rv32 only */
   CSR_CLASS_F,         /* f-ext only */
+  CSR_CLASS_DEBUG      /* debug CSR */
 };
 
 /* The current supported privilege spec versions.  */
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index f26a46e..5f46a49 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -376,9 +376,12 @@  print_insn_args (const char *d, insn_t l, bfd_vma pc, disassemble_info *info)
 		if (default_priv_spec == PRIV_SPEC_CLASS_NONE)
 		  default_priv_spec = PRIV_SPEC_CLASS_DRAFT - 1;
 
-#define DECLARE_CSR(name, num, class, define_version, abort_version) \
-		if (default_priv_spec >= define_version		     \
-		    && default_priv_spec < abort_version)	     \
+#define DECLARE_CSR(name, num, class, define_version, abort_version)	\
+		if (riscv_csr_hash[num] == NULL 			\
+		    && ((define_version == PRIV_SPEC_CLASS_NONE 	\
+			 && abort_version == PRIV_SPEC_CLASS_NONE)	\
+			|| (default_priv_spec >= define_version 	\
+			    && default_priv_spec < abort_version)))	\
 		  riscv_csr_hash[num] = #name;
 #define DECLARE_CSR_ALIAS(name, num, class, define_version, abort_version) \
 		DECLARE_CSR (name, num, class, define_version, abort_version)