[PATCH for-8.2 0/2] target/riscv: add zicntr and zihpm flags

Daniel Henrique Barboza posted 2 patches 9 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230717215419.124258-1-dbarboza@ventanamicro.com
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Weiwei Li <liweiwei@iscas.ac.cn>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
target/riscv/cpu.c     | 29 +++++++++++++++++++++++------
target/riscv/cpu_cfg.h |  2 ++
2 files changed, 25 insertions(+), 6 deletions(-)
[PATCH for-8.2 0/2] target/riscv: add zicntr and zihpm flags
Posted by Daniel Henrique Barboza 9 months, 2 weeks ago
Hi,

I decided to include flags for both timer/counter extensions to make it
easier for us later on when dealing with the RVA22 profile (which
includes both). 

The features were already implemented by Atish Patra some time ago, but
back then these 2 extensions weren't introduced yet. This means that,
aside from extra stuff in riscv,isa FDT no other functional changes were
made.

Both are defaulted to 'true' since QEMU already implements both
features, but the flag can be disabled if Zicsr isn't present or, in
the case of zihpm, if pmu_num = 0.

Daniel Henrique Barboza (2):
  target/riscv/cpu.c: add zicntr extension flag
  target/riscv/cpu.c: add zihpm extension flag

 target/riscv/cpu.c     | 29 +++++++++++++++++++++++------
 target/riscv/cpu_cfg.h |  2 ++
 2 files changed, 25 insertions(+), 6 deletions(-)

-- 
2.41.0
Re: [PATCH for-8.2 0/2] target/riscv: add zicntr and zihpm flags
Posted by Conor Dooley 9 months, 2 weeks ago
Hey,

On Mon, Jul 17, 2023 at 06:54:17PM -0300, Daniel Henrique Barboza wrote:
> Hi,
> 
> I decided to include flags for both timer/counter extensions to make it
> easier for us later on when dealing with the RVA22 profile (which
> includes both). 
> 
> The features were already implemented by Atish Patra some time ago, but
> back then these 2 extensions weren't introduced yet. This means that,
> aside from extra stuff in riscv,isa FDT no other functional changes were
> made.
> 
> Both are defaulted to 'true' since QEMU already implements both
> features, but the flag can be disabled if Zicsr isn't present or, in
> the case of zihpm, if pmu_num = 0.

Out of curiosity, since you are allowing them to be disabled, how do you
intend to communicate to a guest that zicsr or zihpm are not present?

> This means that,
> aside from extra stuff in riscv,isa FDT no other functional changes were
> made.

This is barely a "functional" change either, as the presence of these
extensions has to be assumed, whether they appear in riscv,isa or not :/
Re: [PATCH for-8.2 0/2] target/riscv: add zicntr and zihpm flags
Posted by Daniel Henrique Barboza 9 months, 2 weeks ago

On 7/17/23 19:33, Conor Dooley wrote:
> Hey,
> 
> On Mon, Jul 17, 2023 at 06:54:17PM -0300, Daniel Henrique Barboza wrote:
>> Hi,
>>
>> I decided to include flags for both timer/counter extensions to make it
>> easier for us later on when dealing with the RVA22 profile (which
>> includes both).
>>
>> The features were already implemented by Atish Patra some time ago, but
>> back then these 2 extensions weren't introduced yet. This means that,
>> aside from extra stuff in riscv,isa FDT no other functional changes were
>> made.
>>
>> Both are defaulted to 'true' since QEMU already implements both
>> features, but the flag can be disabled if Zicsr isn't present or, in
>> the case of zihpm, if pmu_num = 0.
> 
> Out of curiosity, since you are allowing them to be disabled, how do you
> intend to communicate to a guest that zicsr or zihpm are not present?

At this point I'd say that existing guests are using other ways of checking
if these timers and counters are available. After this patches OSes can confirm
if these timers are available via riscv,isa, but they can't assume that
they are not available if riscv,isa doesn't display them.

There's a chance that guests will continue ignoring these 2 extensions regardless
of whether the platform exposes them or not.

> 
>> This means that,
>> aside from extra stuff in riscv,isa FDT no other functional changes were
>> made.
> 
> This is barely a "functional" change either, as the presence of these
> extensions has to be assumed, whether they appear in riscv,isa or not :/

It's more of an organizational change for the sake of QEMU internals because the
RVA22 profile happens to include zicntr and zihpm as mandatory extensions. It's
easier to add the flags than to document why we're claiming RVA22 support but
aren't displaying these 2 in riscv,isa.



Thanks,


Daniel
Re: [PATCH for-8.2 0/2] target/riscv: add zicntr and zihpm flags
Posted by Conor Dooley 9 months, 2 weeks ago
On Mon, Jul 17, 2023 at 08:11:09PM -0300, Daniel Henrique Barboza wrote:
> On 7/17/23 19:33, Conor Dooley wrote:

> > On Mon, Jul 17, 2023 at 06:54:17PM -0300, Daniel Henrique Barboza wrote:
> > > Hi,
> > > 
> > > I decided to include flags for both timer/counter extensions to make it
> > > easier for us later on when dealing with the RVA22 profile (which
> > > includes both).
> > > 
> > > The features were already implemented by Atish Patra some time ago, but
> > > back then these 2 extensions weren't introduced yet. This means that,
> > > aside from extra stuff in riscv,isa FDT no other functional changes were
> > > made.
> > > 
> > > Both are defaulted to 'true' since QEMU already implements both
> > > features, but the flag can be disabled if Zicsr isn't present or, in
> > > the case of zihpm, if pmu_num = 0.
> > 
> > Out of curiosity, since you are allowing them to be disabled, how do you
> > intend to communicate to a guest that zicsr or zihpm are not present?
> 
> At this point I'd say that existing guests are using other ways of checking
> if these timers and counters are available.

Or they just assume they're there as part of their baseline requirements
;)

> After this patches OSes can confirm
> if these timers are available via riscv,isa, but they can't assume that
> they are not available if riscv,isa doesn't display them.
> 
> There's a chance that guests will continue ignoring these 2 extensions regardless
> of whether the platform exposes them or not.
> 
> > 
> > > This means that,
> > > aside from extra stuff in riscv,isa FDT no other functional changes were
> > > made.
> > 
> > This is barely a "functional" change either, as the presence of these
> > extensions has to be assumed, whether they appear in riscv,isa or not :/
> 
> It's more of an organizational change for the sake of QEMU internals because the
> RVA22 profile happens to include zicntr and zihpm as mandatory extensions. It's
> easier to add the flags than to document why we're claiming RVA22 support but
> aren't displaying these 2 in riscv,isa.

Possibly you should call out ACPI here too, since that does not suffer
from the same issues as riscv,isa in DT, and putting zicntr/zihpm et al
in the ISA string there is needed.