qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-8.1 v2 00/26] target/riscv: rework CPU extensions validation
@ 2023-03-14 16:49 Daniel Henrique Barboza
  2023-03-14 16:49 ` [PATCH for-8.1 v2 01/26] target/riscv/cpu.c: add riscv_cpu_validate_v() Daniel Henrique Barboza
                   ` (25 more replies)
  0 siblings, 26 replies; 37+ messages in thread
From: Daniel Henrique Barboza @ 2023-03-14 16:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-riscv, alistair.francis, bmeng, liweiwei, zhiwei_liu, palmer,
	Daniel Henrique Barboza

Hello,

In this v2 the most notable changes were done after Liu Zhiwei review in
[1], in particular the comments made in patch 17. To allow for
write_misa() validation, without the need to store and restore cpu->cfg
state, more design changes were required in the existing validation
logic.

The validation code was split in three stages: validate misa_ext,
validate cpu config and commit cpu config. riscv_cpu_validate_misa_ext()
handles all validations related exclusively to env->misa_ext bits.
riscv_cpu_validate_extensions() does the remaining validations with the
named extensions we have. riscv_cpu_commit_cpu_cfg() is the last step,
only executed after all the previous validations were ok.

All validations are done using a tentative misa_ext val, instead of
env->misa_ext or cpu->cfg.ext_N props. write_misa() is then able to
validate a misa_ext without having to change cpu->cfg needlesly. 

Another change is that now we're forcing a sync between env->misa_ext
and cpu->cfg. This was needed to allow for the validation split
mentioned above. It'll also give more consistency throughout the code,
granting that we're always getting the same information whether we're
using cpu->cfg or an API such as riscv_has_ext().

All other premises from v1 are kept. All code changes suggested in v1
were implemented.

Patches are based on Alistair's riscv-to-apply.next.


Changes from v1:
- patch 14 ("target/riscv/cpu.c: do not allow RVE to be set"): dropped 
- patch 4:
  - PRIV_VERSION_LATEST is now an enum value instead of a macro
- patch 5:
  - merged env->priv_ver cond assignment to the previous if clause
- a handful of patches added to allow for validate_set_extensions() to
  be split in three functions
- validation in write_misa() does not require commit changes to cpu->cfg
  beforehand
- v1 link: https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg03219.html

[1] https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg03219.html

Daniel Henrique Barboza (26):
  target/riscv/cpu.c: add riscv_cpu_validate_v()
  target/riscv/cpu.c: remove set_vext_version()
  target/riscv/cpu.c: remove set_priv_version()
  target/riscv: add PRIV_VERSION_LATEST
  target/riscv/cpu.c: add priv_spec validate/disable_exts helpers
  target/riscv/cpu.c: add riscv_cpu_validate_misa_mxl()
  target/riscv: move pmp and epmp validations to
    validate_set_extensions()
  target/riscv/cpu.c: validate extensions before riscv_timer_init()
  target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()
  target/riscv/cpu.c: avoid set_misa() in validate_set_extensions()
  target/riscv/cpu.c: set cpu config in set_misa()
  target/riscv/cpu.c: redesign register_cpu_props()
  target/riscv: put env->misa_ext <-> cpu->cfg code into helpers
  target/riscv: add RVG
  target/riscv: do not allow RVG in write_misa()
  target/riscv/cpu.c: split RVG code from validate_set_extensions()
  target/riscv: write env->misa_ext* in register_generic_cpu_props()
  target/risc/cpu.c: add riscv_cpu_validate_misa_ext()
  target/riscv/cpu:c add misa_ext V-> D & F dependency
  target/riscv: move riscv_cpu_validate_v() to validate_misa_ext()
  target/riscv: validate_misa_ext() now validates a misa_ext val
  target/riscv: error out on priv failure for RVH
  target/riscv: split riscv_cpu_validate_set_extensions()
  target/riscv: use misa_ext val in riscv_cpu_validate_extensions()
  target/riscv: rework write_misa()
  target/riscv: update cpu->cfg misa bits in commit_cpu_cfg()

 target/riscv/cpu.c | 661 ++++++++++++++++++++++++++++-----------------
 target/riscv/cpu.h |  14 +-
 target/riscv/csr.c |  47 ++--
 3 files changed, 448 insertions(+), 274 deletions(-)

-- 
2.39.2



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

end of thread, other threads:[~2023-03-17 11:55 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-14 16:49 [PATCH for-8.1 v2 00/26] target/riscv: rework CPU extensions validation Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 01/26] target/riscv/cpu.c: add riscv_cpu_validate_v() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 02/26] target/riscv/cpu.c: remove set_vext_version() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 03/26] target/riscv/cpu.c: remove set_priv_version() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 04/26] target/riscv: add PRIV_VERSION_LATEST Daniel Henrique Barboza
2023-03-14 17:36   ` Richard Henderson
2023-03-14 16:49 ` [PATCH for-8.1 v2 05/26] target/riscv/cpu.c: add priv_spec validate/disable_exts helpers Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 06/26] target/riscv/cpu.c: add riscv_cpu_validate_misa_mxl() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 07/26] target/riscv: move pmp and epmp validations to validate_set_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 08/26] target/riscv/cpu.c: validate extensions before riscv_timer_init() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 09/26] target/riscv/cpu.c: remove cfg setup from riscv_cpu_init() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 10/26] target/riscv/cpu.c: avoid set_misa() in validate_set_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 11/26] target/riscv/cpu.c: set cpu config in set_misa() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 12/26] target/riscv/cpu.c: redesign register_cpu_props() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 13/26] target/riscv: put env->misa_ext <-> cpu->cfg code into helpers Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 14/26] target/riscv: add RVG Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 15/26] target/riscv: do not allow RVG in write_misa() Daniel Henrique Barboza
2023-03-15  3:52   ` liweiwei
2023-03-14 16:49 ` [PATCH for-8.1 v2 16/26] target/riscv/cpu.c: split RVG code from validate_set_extensions() Daniel Henrique Barboza
2023-03-15  4:43   ` liweiwei
2023-03-15 13:50     ` Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 17/26] target/riscv: write env->misa_ext* in register_generic_cpu_props() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 18/26] target/risc/cpu.c: add riscv_cpu_validate_misa_ext() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 19/26] target/riscv/cpu:c add misa_ext V-> D & F dependency Daniel Henrique Barboza
2023-03-15  4:51   ` liweiwei
2023-03-14 16:49 ` [PATCH for-8.1 v2 20/26] target/riscv: move riscv_cpu_validate_v() to validate_misa_ext() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 21/26] target/riscv: validate_misa_ext() now validates a misa_ext val Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 22/26] target/riscv: error out on priv failure for RVH Daniel Henrique Barboza
2023-03-15  5:07   ` liweiwei
2023-03-14 16:49 ` [PATCH for-8.1 v2 23/26] target/riscv: split riscv_cpu_validate_set_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 24/26] target/riscv: use misa_ext val in riscv_cpu_validate_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 25/26] target/riscv: rework write_misa() Daniel Henrique Barboza
2023-03-15  5:25   ` liweiwei
2023-03-15 20:37     ` Daniel Henrique Barboza
2023-03-17  3:04       ` liweiwei
2023-03-17 11:54         ` Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 26/26] target/riscv: update cpu->cfg misa bits in commit_cpu_cfg() Daniel Henrique Barboza

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