[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] vmx: Introduce vcpu single context VPID invalidation



Le 05/06/2025 à 16:51, Jan Beulich a écrit :
> On 30.05.2025 10:48, Teddy Astie wrote:
>> Introduce vpid_sync_vcpu_context to do a single-context invalidation
>> on the vpid attached to the vcpu as a alternative to per-gva and all-contexts
>> invlidations.
>>
>> Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
>> ---
>> Extracted from SEV series.
>> This will be used for instance in fixed-ASID patches (in SEV series).
>
> I think it should be in that series, which may still be some long way out.
> Until then we'd carry dead/unreachable code (disliked by Misra), and we'd
> risk that this bit-rots because of being unused.
>

Yes, that make sense, it should exist along with patches that make use
of it.

>> --- a/xen/arch/x86/include/asm/
hvm/vmx/vmx.h
>> +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
>> @@ -451,6 +451,23 @@ static inline void ept_sync_all(void)
>>
>>   void ept_sync_domain(struct p2m_domain *p2m);
>>
>> +static inline void vpid_sync_vcpu_context(struct vcpu *v)
>
> pointer-to-const?
>
>> +{
>> +    int type = INVVPID_SINGLE_CONTEXT;
>
> Please don't use plain int when all values possibly held in a variable are
> non-negative.
>

I mostly took the code from other vcpu_sync_* functions. I will take a
look as a separate patch on reworking the existing vpid_sync_vcpu_gva
with these proposed changes, as it has the same problem.

>> +    /*
>> +     * If single context invalidation is not supported, we escalate to
>> +     * use all context invalidation.
>> +     */
>> +    if ( likely(cpu_has_vmx_vpid_invvpid_single_context) )
>> +        goto execute_invvpid;
>> +
>> +    type = INVVPID_ALL_CONTEXT;
>> +
>> +execute_invvpid:
>
> There no reason at all to use "goto" here (and with that replaced there's
> then also no style issue with the label placement).
>

Should a similar treatment be made for vpid_sync_vcpu_gva ?

> Jan
>
>> +    __invvpid(type, v->arch.hvm.n1asid.asid, 0);
>> +}
>> +
>>   static inline void vpid_sync_vcpu_gva(struct vcpu *v, unsigned long gva)
>>   {
>>       int type = INVVPID_INDIVIDUAL_ADDR;
>
>

Teddy



Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.