On 12.11.2025 11:52, Teddy Astie wrote:
> Le 11/11/2025 à 21:11, Grygorii Strashko a écrit :
>> @@ -1451,6 +1452,66 @@ static int cf_check vmx_get_guest_pat(struct vcpu *v, 
>> u64 *gpat)
>>       return 1;
>>   }
>>   
>> +/* Exit UC mode only if all VCPUs agree on MTRR/PAT and are not in no_fill. 
>> */
>> +static bool domain_exit_uc_mode(struct vcpu *v)
>> +{
>> +    struct domain *d = v->domain;
>> +    struct vcpu *vs;
>> +
>> +    for_each_vcpu(d, vs)
>> +    {
>> +        if ( (vs == v) || !vs->is_initialised )
>> +            continue;
>> +        if ( (vs->arch.hvm.cache_mode == NO_FILL_CACHE_MODE) ||
>> +             mtrr_pat_not_equal(vs, v) )
>> +            return false;
>> +    }
>> +
>> +    return true;
>> +}
>> +
>> +static void hvm_set_uc_mode(struct domain *d, bool is_in_uc_mode)
>> +{
>> +    d->arch.hvm.is_in_uc_mode = is_in_uc_mode;
>> +    shadow_blow_tables_per_domain(d);
>> +}
>> +
>> +static void hvm_shadow_handle_cd(struct vcpu *v, unsigned long value)
>> +{
>> +    struct domain *d = v->domain;
>> +
>> +    if ( value & X86_CR0_CD )
>> +    {
>> +        /* Entering no fill cache mode. */
>> +        spin_lock(&d->arch.hvm.uc_lock);
>> +        v->arch.hvm.cache_mode = NO_FILL_CACHE_MODE;
>> +
>> +        if ( !d->arch.hvm.is_in_uc_mode )
>> +        {
>> +            domain_pause_nosync(d);
>> +
>> +            /* Flush physical caches. */
>> +            flush_all(FLUSH_CACHE_EVICT);
>> +            hvm_set_uc_mode(d, true);
>> +
>> +            domain_unpause(d);
>> +        }
>> +        spin_unlock(&d->arch.hvm.uc_lock);
>> +    }
>> +    else if ( !(value & X86_CR0_CD) &&
>> +              (v->arch.hvm.cache_mode == NO_FILL_CACHE_MODE) )
>> +    {
>> +        /* Exit from no fill cache mode. */
>> +        spin_lock(&d->arch.hvm.uc_lock);
>> +        v->arch.hvm.cache_mode = NORMAL_CACHE_MODE;
>> +
>> +        if ( domain_exit_uc_mode(v) )
>> +            hvm_set_uc_mode(d, false);
>> +
>> +        spin_unlock(&d->arch.hvm.uc_lock);
>> +    }
>> +}
>> +
> 
> Given that these functions are now static in vmx.c, I would give them 
> the vmx_* prefix instead of hvm_* (which could be confusing as it sounds 
> like something that is in general code).

There's no need for either prefix really, I would say.

Jan

Reply via email to