Re: [RFC v2 05/17] x86/apic: Add update_vector callback for Secure AVIC

Thomas Gleixner
2025-03-27T12:18:14Z

On Thu, Mar 27 2025 at 16:47, Neeraj Upadhyay wrote:
> On 3/27/2025 3:57 PM, Thomas Gleixner wrote:
>> The relevant registers are starting at regs[SAVIC_ALLOWED_IRR]. Due to
>> the 16-byte alignment the vector number obviously cannot be used for
>> linear bitmap addressing.
>>
>> But the resulting bit number can be trivially calculated with:
>>
>> bit = vector + 32 * (vector / 32);
>>
>
> Somehow, this math is not working for me. I will think more on how this
> works. From what I understand, bit number is:
>
> bit = vector % 32 + (vector / 32) * 16 * 8
>
> So, for example, vector number 32, bit number need to be 128.
> With you formula, it comes as 64.

Duh. I did the math for 8 byte alignment. But for 16 byte it's obviously
exactly the same formula just with a different multiplicator:

bit = vector + 96 * (vector / 32);

No?