[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH] arm/kvm: Enable support for KVM_CAP_ARM_EAGER_SPLIT_CHUN
From: |
Peter Maydell |
Subject: |
Re: [RFC PATCH] arm/kvm: Enable support for KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE |
Date: |
Thu, 27 Jul 2023 17:05:34 +0100 |
On Thu, 27 Jul 2023 at 16:43, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 25 Jul 2023 at 16:01, Shameer Kolothum
> <shameerali.kolothum.thodi@huawei.com> wrote:
> > +static bool kvm_arm_eager_split_size_valid(uint64_t req_size, uint32_t
> > sizes)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < sizeof(uint32_t) * BITS_PER_BYTE; i++) {
> > + if (!(sizes & (1 << i))) {
> > + continue;
> > + }
> > +
> > + if (req_size == (1 << i)) {
> > + return true;
> > + }
> > + }
>
> We know req_size is a power of 2 here, so if you also explicitly
> rule out 0 then you can do
> return sizes & (1 << ctz64(req_size));
Er, that's also over-complicated. Just
return sizes & req_size;
should do (and catches the 0 case correctly again).
-- PMM