lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <62ae9c91-b62e-4bf9-8cf2-e68ddd0a1487@amd.com>
Date: Tue, 29 Apr 2025 23:39:53 +0530
From: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: linux-kernel@...r.kernel.org, bp@...en8.de, tglx@...utronix.de,
 mingo@...hat.com, dave.hansen@...ux.intel.com, Thomas.Lendacky@....com,
 nikunj@....com, Santosh.Shukla@....com, Vasant.Hegde@....com,
 Suravee.Suthikulpanit@....com, David.Kaplan@....com, x86@...nel.org,
 hpa@...or.com, peterz@...radead.org, pbonzini@...hat.com,
 kvm@...r.kernel.org, kirill.shutemov@...ux.intel.com, huibo.wang@....com,
 naveen.rao@....com, francescolavra.fl@...il.com
Subject: Re: [PATCH v5 01/20] KVM: x86: Move find_highest_vector() to a common
 header



On 4/29/2025 8:12 PM, Sean Christopherson wrote:
...

>> +
>> +static inline int apic_find_highest_vector(void *bitmap)
>> +{
>> +	unsigned int regno;
>> +	unsigned int vec;
>> +	u32 *reg;
>> +
>> +	/*
>> +	 * The registers in the bitmap are 32-bit wide and 16-byte
>> +	 * aligned. State of a vector is stored in a single bit.
>> +	 */
>> +	for (regno = MAX_APIC_VECTOR / APIC_VECTORS_PER_REG - 1; regno >= 0; regno--) {
>> +		vec = regno * APIC_VECTORS_PER_REG;
>> +		reg = bitmap + regno * 16;
>> +		if (*reg)
>> +			return __fls(*reg) + vec;
>> +	}
> 
> NAK.  The changelog says nothing about rewriting the logic, and I have zero desire

My bad. I missed updating the changelog with the information about logic update.

> to review or test this for correctness.  If someone has requested that the logic be
> cleaned up, then do that as a separate patch (or patches) on top, with a changelog
> that justifies the change, because to my eyes this isn't an improvement.
>

Ok. I will keep the original logic in apic_find_highest_vector() in next version of
this patch.
 
> I suspect the rewrite is in part due to REG_POS() being a KVM helper that's poorly
> named for a global macro.  lapic_vector_set_in_irr() already has open coded
> versions of REG_POS() and VEC_POS(), just dedup those.
>  
> *sigh*
> 
> And you created your own versions of those in get_reg_bitmap() and get_vec_bit().
> 
> Please slot the below in.  And if there is any more code in this series that is
> duplicating existing functionality, try to figure out a clean way to share code
> instead of open coding yet another version.
> 

Ok sure. I will take your patch and reuse the APIC regs manipulation functions
between KVM and SAVIC in next version. Thanks for sharing the patch!


- Neeraj



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ