[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z92dqEhfj1GG6Fxb@google.com>
Date: Fri, 21 Mar 2025 10:11:04 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Neeraj Upadhyay <Neeraj.Upadhyay@....com>, linux-kernel@...r.kernel.org, bp@...en8.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
Subject: Re: [RFC v2 13/17] x86/apic: Handle EOI writes for SAVIC guests
On Fri, Mar 21, 2025, Thomas Gleixner wrote:
> On Wed, Feb 26 2025 at 14:35, Neeraj Upadhyay wrote:
> > +static int find_highest_isr(void *backing_page)
> > +{
> > + int vec_per_reg = 32;
> > + int max_vec = 256;
> > + u32 reg;
> > + int vec;
> > +
> > + for (vec = max_vec - 32; vec >= 0; vec -= vec_per_reg) {
> > + reg = get_reg(backing_page, APIC_ISR + REG_POS(vec));
> > + if (reg)
> > + return __fls(reg) + vec;
> > + }
> > +
> > + return -1;
>
> Congrats. You managed to re-implement find_last_bit() in the most
> incomprehesible way.
Heh, having burned myself quite badly by trying to use find_last_bit() to get
pending/in-service IRQs in KVM code...
Using find_last_bit() doesn't work because the ISR chunks aren't contiguous,
they're 4-byte registers at 16-byte strides.
That said, copy+pasting the aforementioned KVM code is absurd. Please extract
KVM's find_highest_vector() to common code, along with any other APIC utilities
in KVM that would be useful. I haven't looked at this series, but I suspect
there's a _lot_ of code in KVM's local APIC emulation that can be shared.
Powered by blists - more mailing lists