diff mbox series

[2/3] target/riscv/cpu.c: create flag for ziccrse

Message ID 20250218163854.425607-3-dbarboza@ventanamicro.com (mailing list archive)
State New
Headers show
Series target/riscv/kvm: update to Linux 6.14-rc3 | expand

Commit Message

Daniel Henrique Barboza Feb. 18, 2025, 4:38 p.m. UTC
At this moment ziccrse is a TCG always enable ext that has no flag. KVM
will expose ziccrse to users, allowing them to turn it on/off.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 target/riscv/cpu.c     | 5 +++++
 target/riscv/cpu_cfg.h | 3 +++
 2 files changed, 8 insertions(+)

Comments

Andrew Jones Feb. 21, 2025, 12:38 p.m. UTC | #1
On Tue, Feb 18, 2025 at 01:38:53PM -0300, Daniel Henrique Barboza wrote:
> At this moment ziccrse is a TCG always enable ext that has no flag. KVM
> will expose ziccrse to users, allowing them to turn it on/off.

KVM won't allow this to be disabled, since it can't be (there's no way
to turn off the behavior or fake that it's not there for the guest.)

The reason KVM has added it to its ISA extension list is to inform a
VMM that the extension is present on the current host, which may be
of interest when determining migration targets (especially since it
can't be disabled.)

> 
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> ---
>  target/riscv/cpu.c     | 5 +++++
>  target/riscv/cpu_cfg.h | 3 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> index 522d6584e4..0b8d2c0c25 100644
> --- a/target/riscv/cpu.c
> +++ b/target/riscv/cpu.c
> @@ -1711,6 +1711,11 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {
>      MULTI_EXT_CFG_BOOL("zvksc", ext_zvksc, false),
>      MULTI_EXT_CFG_BOOL("zvksg", ext_zvksg, false),
>  
> +    /*
> +     * KVM can turn it on/off. For TCG this is always
> +     * enabled if priv_ver >= 1.11.
> +     */
> +    MULTI_EXT_CFG_BOOL("ziccrse", ext_ziccrse, true),
>      { },
>  };
>  
> diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
> index 3f3c1118c0..88565e29fd 100644
> --- a/target/riscv/cpu_cfg.h
> +++ b/target/riscv/cpu_cfg.h
> @@ -157,6 +157,9 @@ struct RISCVCPUConfig {
>      bool ext_ssstateen;
>      bool ext_sha;
>  
> +    /* Always enabled for TCG, KVM wants to switch it on/off */
> +    bool ext_ziccrse;
> +
>      /*
>       * Always 'true' booleans for named features
>       * TCG always implement/can't be user disabled,
> -- 
> 2.48.1
> 
>

I would just drop all the comments from this patch and reword the commit
message to state something along the lines of what I did.

Thanks,
drew
diff mbox series

Patch

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 522d6584e4..0b8d2c0c25 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1711,6 +1711,11 @@  const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {
     MULTI_EXT_CFG_BOOL("zvksc", ext_zvksc, false),
     MULTI_EXT_CFG_BOOL("zvksg", ext_zvksg, false),
 
+    /*
+     * KVM can turn it on/off. For TCG this is always
+     * enabled if priv_ver >= 1.11.
+     */
+    MULTI_EXT_CFG_BOOL("ziccrse", ext_ziccrse, true),
     { },
 };
 
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
index 3f3c1118c0..88565e29fd 100644
--- a/target/riscv/cpu_cfg.h
+++ b/target/riscv/cpu_cfg.h
@@ -157,6 +157,9 @@  struct RISCVCPUConfig {
     bool ext_ssstateen;
     bool ext_sha;
 
+    /* Always enabled for TCG, KVM wants to switch it on/off */
+    bool ext_ziccrse;
+
     /*
      * Always 'true' booleans for named features
      * TCG always implement/can't be user disabled,