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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZTvGaNZmGWpsM-yw@black.fi.intel.com>
Date:   Fri, 27 Oct 2023 17:17:12 +0300
From:   Raag Jadav <raag.jadav@...el.com>
To:     Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc:     rafael@...nel.org, len.brown@...el.com,
        andriy.shevchenko@...ux.intel.com, linux-acpi@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        mallikarjunappa.sangannavar@...el.com, bala.senthil@...el.com
Subject: Re: [PATCH v2] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID

On Fri, Oct 27, 2023 at 01:12:02PM +0300, Raag Jadav wrote:
> On Fri, Oct 27, 2023 at 11:18:55AM +0300, Mika Westerberg wrote:
> > On Thu, Oct 26, 2023 at 02:03:35PM +0530, Raag Jadav wrote:
> > > Now that we have a standard ACPI helper, we can use acpi_dev_uid_match()
> > > for matching _UID as per the original logic before commit 2a036e489eb1
> > > ("ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer()"),
> > > instead of treating it as an integer.
> > > 
> > > Signed-off-by: Raag Jadav <raag.jadav@...el.com>
> > > Acked-by: Mika Westerberg <mika.westerberg@...ux.intel.com>
> > 
> > The change still looks good to me, however I wonder if we could maybe
> > improve acpi_dev_uid_match() to support both data types possible for
> > _UID? This of course is separate patch (unless there are objections).
> > 
> > There is the _Generic() thing and I think that can be used to make
> > 
> >   acpi_dev_uid_match()
> > 
> > which takes either u64 (or maybe even unsigned int) or const char * and
> > based on that picks the correct implementation. Not sure if that's
> > possible, did not check but it would allow us to use one function
> > everywhere instead of acpi_dev_uid_to_integer() and
> > acpi_dev_uid_match().
> 
> The way I see it, acpi_dev_uid_to_integer() is useful when drivers want to
> parse _UID and store it in their private data, so that it is available for
> making various decisions throughout the lifetime of the driver, as opposed
> to acpi_dev_uid_match() which is more useful for oneshot comparisons in my
> opinion.
> 
> So I'm a bit conflicted about merging them into a single helper, unless
> ofcourse there is a way to serve both purposes.

Or perhaps something like,

bool acpi_dev_uid_match(struct acpi_device *adev, const void *uid2, enum uid_type type)
{
        u64 uid1_d, uid2_d;

        if (type == UID_TYPE_STR) {
                char *uid2_s = (char *)uid2;
                if (!(uid2_s && !kstrtou64(uid2_s, 0, &uid2_d)))
                        return false;
        } else if (type == UID_TYPE_INT) {
                u64 *uid2_p;
                uid2_p = (u64 *)uid2;
                uid2_d = *uid2_p;
        } else {
                return false;
        }

        if (!acpi_dev_uid_to_integer(adev, &uid1_d) && uid1_d == uid2_d)
                return true;
        else
                return false;
}

Although this looks unnecessarily hideous.

Raag

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ