On Tue, Jun 27, 2023 at 11:29:54PM +0200, Philippe Mathieu-Daudé wrote: > On 27/6/23 18:31, Daniel Henrique Barboza wrote: > > Next patch will add KVM specific user properties for both MISA and > > multi-letter extensions. For MISA extensions we want to make use of what > > is already available in misa_ext_cfgs[] to avoid code repetition. > > > > misa_ext_info_arr[] array will hold name and description for each MISA > > extension that misa_ext_cfgs[] is declaring. We'll then use this new > > array in KVM code to avoid duplicating strings. > > > > There's nothing holding us back from doing the same with multi-letter > > extensions. For now doing just with MISA extensions is enough. > > > > Suggested-by: Andrew Jones <ajo...@ventanamicro.com> > > Signed-off-by: Daniel Henrique Barboza <dbarb...@ventanamicro.com> > > Reviewed-by: Andrew Jones <ajo...@ventanamicro.com> > > --- > > target/riscv/cpu.c | 60 ++++++++++++++++++++++++++-------------------- > > target/riscv/cpu.h | 11 ++++++++- > > 2 files changed, 44 insertions(+), 27 deletions(-) > > > > +const MISAExtInfo misa_ext_info_arr[] = { > > + [RVA] = {"a", "Atomic instructions"}, > > + [RVC] = {"c", "Compressed instructions"}, > > + [RVD] = {"d", "Double-precision float point"}, > > + [RVF] = {"f", "Single-precision float point"}, > > + [RVI] = {"i", "Base integer instruction set"}, > > + [RVE] = {"e", "Base integer instruction set (embedded)"}, > > + [RVM] = {"m", "Integer multiplication and division"}, > > + [RVS] = {"s", "Supervisor-level instructions"}, > > + [RVU] = {"u", "User-level instructions"}, > > + [RVH] = {"h", "Hypervisor"}, > > + [RVJ] = {"x-j", "Dynamic translated languages"}, > > + [RVV] = {"v", "Vector operations"}, > > + [RVG] = {"g", "General purpose (IMAFD_Zicsr_Zifencei)"}, > > +}; > > Personally I prefer using a getter() helper because we can check in > a single place for empty entries in the array. > > IIUC this 13-entries array takes 4MiB (RVV is '1<<21' = 2MiB).
Oh, ouch. I never looked close enough to see that these indices where the _shifted_ bitnums. I assumed they were _the_ bitnums, i.e. RVV == 21, not RVV == 2097152! Thanks, drew