qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 3/6] target/riscv: add remaining named features


From: Alistair Francis
Subject: Re: [PATCH v3 3/6] target/riscv: add remaining named features
Date: Fri, 16 Feb 2024 10:12:46 +1000

On Fri, Feb 16, 2024 at 6:00 AM Conor Dooley <conor@kernel.org> wrote:
>
> On Thu, Feb 15, 2024 at 08:11:45PM +0100, Andrew Jones wrote:
> > On Thu, Feb 15, 2024 at 04:34:32PM +0000, Conor Dooley wrote:
> > > On Thu, Feb 15, 2024 at 03:26:18PM +0100, Andrew Jones wrote:
> > > > On Thu, Feb 15, 2024 at 01:33:47PM +0000, Conor Dooley wrote:
> > > > > On Fri, Feb 02, 2024 at 12:21:51PM -0300, Daniel Henrique Barboza 
> > > > > wrote:
> > > > > > The RVA22U64 and RVA22S64 profiles mandates certain extensions that,
> > > > > > until now, we were implying that they were available.
> > > > > >
> > > > > > We can't do this anymore since named features also has a riscv,isa
> > > > > > entry. Let's add them to riscv_cpu_named_features[].
> > > > > >
> > > > > > Instead of adding one bool for each named feature that we'll always
> > > > > > implement, i.e. can't be turned off, add a 'ext_always_enabled' 
> > > > > > bool in
> > > > > > cpu->cfg. This bool will be set to 'true' in TCG accel init, and all
> > > > > > named features will point to it. This also means that KVM won't see
> > > > > > these features as always enable, which is our intention.
> > > > > >
> > > > > > If any accelerator adds support to disable one of these features, 
> > > > > > we'll
> > > > > > have to promote them to regular extensions and allow users to 
> > > > > > disable it
> > > > > > via command line.
> > > > > >
> > > > > > After this patch, here's the riscv,isa from a buildroot using the
> > > > > > 'rva22s64' CPU:
> > > > >
> > > > > Why does an "rva22s64" cpu have "zicclsm" in it? Isn't zicclsm only
> > > > > present in "u" profiles?
> > > >
> > > > "s" profiles mandate all the "u" profile mandatory extensions. For 
> > > > example
> > > > 6.2.2 says
> > > >
> > > > """
> > > > The RVA22S64 mandatory unprivileged extensions include all the 
> > > > mandatory unprivileged
> > > > extensions in RVA22U64.
> > > > """
> > >
> > > Doesn't that rule out emulating misaligned access in s-mode if you want
> > > to be profile compliant?
> >
> > That's how I interpret it, but I'll defer to a profile spec author, or
> > at least to somebody more confident of their spec interpretation skills.
>
> Hmm, actually it doesn't. Your firmware just needs to _also_ implement
> it. So your OS kernel could test whether or not the misaligned access
> performance is beans and then choose to emulate misaligned access
> itself. Not ideal, but better than I thought.
>
> > > > > >  # cat /proc/device-tree/cpus/cpu@0/riscv,isa
> > > > > > rv64imafdc_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_
> > > > > > zicntr_zicsr_zifencei_zihintpause_zihpm_za64rs_zfhmin_zca_zcd_zba_zbb_
> > > > > > zbs_zkt_ssccptr_sscounterenw_sstvala_sstvecd_svade_svinval_svpbmt#
> > > > >
> > > > > I want to raise my frustration with the crock we've been given here by
> > > > > RVI. Any "named feature" that just creates a name for something that
> > > > > already is assumed is completely useless, and DT property that is used
> > > > > to communicate it's presence cannot be used - instead the property 
> > > > > needs
> > > > > to be inverted - indicating the absence of that named feature.
> > > > >
> > > > > Without the inversion, software that parses "riscv,isa" cannot make 
> > > > > any
> > > > > determination based on the absence of the property - it could be 
> > > > > parsing
> > > > > an old DT that does not have the property or it could be parsing the 
> > > > > DT
> > > > > of a system that does not support the extension.
> > > >
> > > > I'm guessing any platform which wants to advertise that it's compliant
> > > > with a profile will update its hardware descriptions to ensure all the
> > > > profile's mandatory extensions are presented. But, I think I understand
> > > > your concern. If somebody is parsing the ISA string as way to determine
> > > > if the platform is compliant with a profile, then they may get a false
> > > > negative due to the ISA string missing a newly named feature.
> > >
> > > Nah, you misunderstand me. I don't care at all about profiles or
> > > checking for compliance with one. I'm only interested in how my software
> > > can check that some feature is (or is not) supported. This creating a name
> > > for something implicit business is not a problem in and of itself, but
> > > putting then into "riscv,isa" is a pointless activity as it communicates
> > > nothing.
> > >
> > > > I'm not
> > > > sure how much of a problem that will be in practice, though, since 
> > > > testing
> > > > for profile compliance, just for the sake of it, doesn't seem very 
> > > > useful.
> > > > Software really only needs to know which extensions are available and if
> > > > it's an old feature that got newly named, then software likely already
> > > > has another way of detecting it.
> > >
> > > Right. That part is fine, but creating extensions for these things we
> > > previously assumed present gives me the impression that creating systems
> > > that do not support these features is valid. IFF that does happen,
> > > removing the string from "riscv,isa" isn't going to be able to
> > > communicate that the feature is unsupported.
> >
> > Ah, now I think I understand the concern. The new names might as well be
> > ignored because the absence of the names in the hardware descriptions is
> > ambiguous.
>
> Correct.
>
> > I guess I'd encourage software that has a role in advertising
> > features to use the new names when it has detected the feature or assumes
> > the feature is present (and presumably wouldn't be running if its
> > assumption was wrong). If, for example, Linux puts a new name in
> > /proc/cpuinfo after detecting or assuming the feature's presence, then it
> > no longer matters that the hardware description had it or not from the
> > perspective of the /proc/cpuinfo consumer (assuming they're aware of which
> > kernel version they need). With these types of fixups and enough time,
> > then hopefully most of the software ecosystem will able to live in
> > ignorant bliss.
>
> Yeah, that's effectively what we have to do. I started doing that for
> zifencei/zicsr in Linux and it should be done for anything else like
> this going forwards.
>
> > > The commit message here
> > > says:
> > > > > > If any accelerator adds support to disable one of these features, 
> > > > > > we'll
> > > > > > have to promote them to regular extensions and allow users to 
> > > > > > disable it
> > > > > > via command line.
> > >
> > > Which is part of what prompted me here, since they cannot be handled in
> > > the same way that "regular extensions" are.
> > >
> >
> > From QEMU's perspective, they can.
>
> No they can't. For a "regular extension" you populate the DT with the
> extension. For these extensions it has to put negated properties in the
> DT, otherwise it is incorrectly describing the hardware it is emulating.
> That is handling them differently in my book! If QEMU generates an
> incorrect DT representation of the hardware it is emulating, that's a
> QEMU bug.

QEMU listing the extensions that it supports seems to me to be the
correct approach.

It's clunky that the list of "extensions" are constantly changing.
There isn't much we can do about that from a QEMU perspective though.

Listing the hardware and what it supports is the job of the DT.

I see your concern about what happens if the "extensions" are disabled
though. Realislity they probably never will be.

>
> > Linux or whatever software consuming
> > the hardware descriptions may want to distrust the absence of newly
> > named feature extensions and do their own checks, but that's not QEMU's
> > concern.
>
> Software should be able to trust that the DT describes the system
> correctly. I can only speak for Linux here, but validating the DT is not
> the job of the running kernel - it should be a correct description.

AFAIK the DT is correct. We are describing the hardware within the
scope of the DT spec.

If a new node exists that describes what the hardware does not support
we can update to support that as well.

>
> > Actually, being able to disable these newly named features allows
> > Linux and other software to test how they behave when the feature goes
> > away.
>
> That's helpful sure, but it doesn't absolve QEMU of having to correctly
> generate a DT.

I'm pretty sure there isn't anything for us to do differently here
right? It's just a bad situation that we are trying to support.

Alistair

>
> Thanks,
> Conor.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]