qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	 alistair.francis@wdc.com, bmeng@tinylab.org,
	liweiwei@iscas.ac.cn,  zhiwei_liu@linux.alibaba.com
Subject: Re: [PATCH v3 02/10] target/riscv: always allow write_misa() to write MISA
Date: Thu, 16 Feb 2023 21:30:47 +0800	[thread overview]
Message-ID: <CAEUhbmVGO+ERoBxwVPK4cm4-wrrDc0nyuUoEhHGk6eeMMizedg@mail.gmail.com> (raw)
In-Reply-To: <20230216100758.b7ginht55nzqbehw@orel>

On Thu, Feb 16, 2023 at 6:08 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> On Thu, Feb 16, 2023 at 05:33:55PM +0800, Bin Meng wrote:
> > On Thu, Feb 16, 2023 at 5:29 PM Andrew Jones <ajones@ventanamicro.com> wrote:
> > >
> > > On Wed, Feb 15, 2023 at 03:57:18PM -0300, Daniel Henrique Barboza wrote:
> > > > At this moment, and apparently since ever, we have no way of enabling
> > > > RISCV_FEATURE_MISA. This means that all the code from write_misa(), all
> > > > the nuts and bolts that handles how to properly write this CSR, has
> > > > always been a no-op as well because write_misa() will always exit
> > > > earlier.
> > > >
> > > > This seems to be benign in the majority of cases. Booting an Ubuntu
> > > > 'virt' guest and logging all the calls to 'write_misa' shows that no
> > > > writes to MISA CSR was attempted. Writing MISA, i.e. enabling/disabling
> > > > RISC-V extensions after the machine is powered on, seems to be a niche
> > > > use.
> > > >
> > > > Regardless, the spec says that MISA is a WARL read-write CSR, and gating
> > > > the writes in the register doesn't make sense. OS and applications
> > > > should be wary of the consequences when writing it, but the write itself
> > > > must always be allowed.
> > >
> > > The write is already allowed, i.e. no exception is raised when writing it.
> > > The spec only says that the fields may/can be writable. So we can
> > > correctly implement the spec with just
> > >
> > >  write_misa()
> > >  {
> > >    return RISCV_EXCP_NONE;
> > >  }
> >
> > Agree. Such change is still spec compliant without worrying about the bugs.
> >
> > >
> > > as it has effectively been implemented to this point.
> > >
> > > Based on Weiwei Li's pointing out of known bugs, and the fact that
> > > this function has likely never been tested, then maybe we should just
> > > implement it as above for now. Once a better solution to extension
> > > sanity checking exists and a use (or at least test) case arises, then
> > > the function could be expanded with some actually writable bits. (Also,
> > > I think that when/if we do the expansion, then something like the misa_w
> > > config proposed in the previous version of this series may still be
> > > needed in order to allow opting-in/out of the behavior change.)
> >
> > In QEMU RISC-V we have some examples of implementing optional spec
> > features without exposing a config parameter. Do we need to add config
> > parameters for those cases too? If yes, I am afraid the parameters
> > will grow a lot.
> >
>
> I agree, particularly for RISC-V, the options grow quickly. How about this
> for a policy?
>
> 1) When adding an optional, on-by-default CPU feature, which applies to
>    all currently existing CPU types, then just add the feature without a
>    config.
>
> 2) When, later, a CPU type or use case needs to disable an optional
>    CPU feature, which doesn't have a config, then the config is added
>    at that time.

This policy sounds good to me.

> While that policy seems reasonable (to me), I have a feeling the "applies
> to all currently existing CPU types" requirement won't be easily
> satisfied, so we'll end up mostly always adding configs anyway.

Probably this does not apply to machines that have fixed configuration
RISC-V processor. But let's see what happens.

> We can always change RISCVCPUConfig.ext_* to a bitmap if we feel like the
> CPU is getting too bloated.

Regards,
Bin


  reply	other threads:[~2023-02-16 13:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 18:57 [PATCH v3 00/10] enable write_misa() and RISCV_FEATURE_* cleanups Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 01/10] target/riscv: do not mask unsupported QEMU extensions in write_misa() Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 02/10] target/riscv: always allow write_misa() to write MISA Daniel Henrique Barboza
2023-02-16  0:31   ` Bin Meng
2023-02-16  1:37   ` weiwei
2023-02-16  9:29   ` Andrew Jones
2023-02-16  9:33     ` Bin Meng
2023-02-16 10:07       ` Andrew Jones
2023-02-16 13:30         ` Bin Meng [this message]
2023-02-16 12:16     ` Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 03/10] target/riscv: introduce riscv_cpu_cfg() Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 04/10] target/riscv: remove RISCV_FEATURE_DEBUG Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 05/10] target/riscv/cpu.c: error out if EPMP is enabled without PMP Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 06/10] target/riscv: remove RISCV_FEATURE_EPMP Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 07/10] target/riscv: remove RISCV_FEATURE_PMP Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 08/10] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus() Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 09/10] target/riscv: remove RISCV_FEATURE_MMU Daniel Henrique Barboza
2023-02-15 18:57 ` [PATCH v3 10/10] target/riscv/cpu: remove CPUArchState::features and friends Daniel Henrique Barboza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEUhbmVGO+ERoBxwVPK4cm4-wrrDc0nyuUoEhHGk6eeMMizedg@mail.gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=ajones@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=bmeng@tinylab.org \
    --cc=dbarboza@ventanamicro.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).