Re: [RFC PATCH v6 07/32] KVM: x86: apic_test_vector() to common code

From: Neeraj Upadhyay
Date: Tue Jun 10 2025 - 00:26:35 EST




On 6/7/2025 12:26 AM, Sean Christopherson wrote:
> On Fri, Jun 06, 2025, Sean Christopherson wrote:
>> Actually, looking at the end usage, just drop VEC_POS/REG_POS entirely. IIRC, I
>> suggested keeping the shorthand versions for KVM, but I didn't realize there would
>> literally be two helpers left. At that point, keeping VEC_POS and REG_POS is
>> pure stubborness :-)
>>
>> 1. Rename VEC_POS/REG_POS => APIC_VECTOR_TO_BIT_NUMBER/APIC_VECTOR_TO_REG_OFFSET
>> 2. Rename all of the KVM helpers you intend to move out of KVM.
>
> Looking at the earlier patches again, I vote to add a 4th:
>
> 2a. Replace all "char *" with "void *" in all affected helpers.
>
> Pointer arithmetic for "void *" and "char *" operate identically, and AFAICT that's
> the only reason why e.g. __kvm_lapic_set_reg64() takes a "char *". That way there
> is even less of a chance of doing the wrong thing, e.g. neglecting to cast and
> reading a byte instead of the desired size.
>

Sounds good. Will include this in the next version.


- Neeraj

>> 3. Move all of the helpers out of KVM.