Re: [RFC PATCH v6 07/32] KVM: x86: apic_test_vector() to common code
From: Sean Christopherson
Date: Fri Jun 06 2025 - 14:56:35 EST
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.
> 3. Move all of the helpers out of KVM.