Re: [PATCH v2 06/14] target/riscv: Add cfg properties for Zvkn[c|g] extensions
On Fri, Oct 27, 2023 at 2:21 AM Max Chou wrote: > > Vector crypto spec defines the NIST algorithm suite related extensions > (Zvkn, Zvknc, Zvkng) combined by several vector crypto extensions. > > Signed-off-by: Max Chou Acked-by: Alistair Francis Alistair > --- > target/riscv/cpu_cfg.h | 3 +++ > target/riscv/tcg/tcg-cpu.c | 20 > 2 files changed, 23 insertions(+) > > diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h > index 935335e5721..fd07aa96a27 100644 > --- a/target/riscv/cpu_cfg.h > +++ b/target/riscv/cpu_cfg.h > @@ -96,6 +96,9 @@ struct RISCVCPUConfig { > bool ext_zvksed; > bool ext_zvksh; > bool ext_zvkt; > +bool ext_zvkn; > +bool ext_zvknc; > +bool ext_zvkng; > bool ext_zmmul; > bool ext_zvfbfmin; > bool ext_zvfbfwma; > diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c > index 1b08f27eee4..e460701a13c 100644 > --- a/target/riscv/tcg/tcg-cpu.c > +++ b/target/riscv/tcg/tcg-cpu.c > @@ -499,6 +499,26 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, > Error **errp) > return; > } > > +/* > + * Shorthand vector crypto extensions > + */ > +if (cpu->cfg.ext_zvknc) { > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkn), true); > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); > +} > + > +if (cpu->cfg.ext_zvkng) { > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkn), true); > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkg), true); > +} > + > +if (cpu->cfg.ext_zvkn) { > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkned), true); > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvknhb), true); > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkb), true); > +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkt), true); > +} > + > if (cpu->cfg.ext_zvkt) { > cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbb), true); > cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); > -- > 2.34.1 > >
Re: [PATCH v2 06/14] target/riscv: Add cfg properties for Zvkn[c|g] extensions
On 10/26/23 12:18, Max Chou wrote: Vector crypto spec defines the NIST algorithm suite related extensions (Zvkn, Zvknc, Zvkng) combined by several vector crypto extensions. Signed-off-by: Max Chou --- target/riscv/cpu_cfg.h | 3 +++ target/riscv/tcg/tcg-cpu.c | 20 2 files changed, 23 insertions(+) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 935335e5721..fd07aa96a27 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -96,6 +96,9 @@ struct RISCVCPUConfig { bool ext_zvksed; bool ext_zvksh; bool ext_zvkt; +bool ext_zvkn; +bool ext_zvknc; +bool ext_zvkng; bool ext_zmmul; bool ext_zvfbfmin; bool ext_zvfbfwma; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 1b08f27eee4..e460701a13c 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -499,6 +499,26 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) return; } +/* + * Shorthand vector crypto extensions + */ +if (cpu->cfg.ext_zvknc) { +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkn), true); +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); +} + +if (cpu->cfg.ext_zvkng) { +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkn), true); +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkg), true); +} + +if (cpu->cfg.ext_zvkn) { +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkned), true); +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvknhb), true); +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkb), true); +cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkt), true); +} + As a follow-up, we should move these vector validations to its own helper. We already have riscv_cpu_validate_v(), making it a good place to center all RVV related validations. For now: Reviewed-by: Daniel Henrique Barboza if (cpu->cfg.ext_zvkt) { cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbb), true); cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true);