On Thu, Sep 19 2024, Ganapatrao Kulkarni <gankulka...@os.amperecomputing.com> 
wrote:

> I have modified as below diff to keep TCG if loop as it is and adding if 
> for KVM case to clear/mask the MTE bits if MTE in KVM mode is not 
> enabled by user command(if no mte=on).
>
> Is below diff makes sense?
>
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index a59417aac8..523996576d 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -2390,15 +2390,20 @@ static void arm_cpu_realizefn(DeviceState *dev, 
> Error **errp)
>
>   #ifndef CONFIG_USER_ONLY
>           /*
> -         * If we do not have tag-memory provided by the TCG
> -         * nor MTE at KVM enabled, reduce MTE support to
> -         * instructions enabled at EL0.
> +         * If we do not have tag-memory provided by the TCG,
> +         * reduce MTE support to instructions enabled at EL0.
>            * This matches Cortex-A710 BROADCASTMTE input being LOW.
>            */
> -        if (cpu->tag_memory == NULL && !cpu->kvm_mte) {
> +        if (tcg_enabled() && cpu->tag_memory == NULL) {
>               cpu->isar.id_aa64pfr1 =
>                   FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1);
>           }
> +
> +        /* Disable MTE, if it is not enabled by the user for KVM mode.
> +         */
> +        if (kvm_enabled() && !cpu->kvm_mte) {
> +                FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0);
> +        }
>   #endif
>       }

Wouldn't that be a possibly guest-visible change?


Reply via email to