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: <afaf66ea-2eee-cd16-ede8-095b8b6a6de6@nvidia.com>
Date:   Wed, 28 Jul 2021 13:17:26 -0500
From:   Shanker R Donthineni <sdonthineni@...dia.com>
To:     Bjorn Helgaas <helgaas@...nel.org>,
        Amey Narkhede <ameynarkhede03@...il.com>
CC:     <alex.williamson@...hat.com>,
        Raphael Norwitz <raphael.norwitz@...anix.com>,
        <linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <kw@...ux.com>, Sinan Kaya <okaya@...nel.org>,
        Len Brown <lenb@...nel.org>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>
Subject: Re: [PATCH v10 2/8] PCI: Add new array for keeping track of ordering
 of reset methods

Hi Bjorn,

On 7/28/21 12:59 PM, Bjorn Helgaas wrote:
> External email: Use caution opening links or attachments
>
>
> On Wed, Jul 28, 2021 at 11:15:19PM +0530, Amey Narkhede wrote:
>> On 21/07/27 05:59PM, Bjorn Helgaas wrote:
>>> On Fri, Jul 09, 2021 at 06:08:07PM +0530, Amey Narkhede wrote:
>>>> Introduce a new array reset_methods in struct pci_dev to keep track of
>>>> reset mechanisms supported by the device and their ordering.
>>>>
>>>> Also refactor probing and reset functions to take advantage of calling
>>>> convention of reset functions.
>>>>
>>>> Co-developed-by: Alex Williamson <alex.williamson@...hat.com>
>>>> Signed-off-by: Alex Williamson <alex.williamson@...hat.com>
>>>> Signed-off-by: Amey Narkhede <ameynarkhede03@...il.com>
>>>> ---
>>>>  drivers/pci/pci.c   | 92 ++++++++++++++++++++++++++-------------------
>>>>  drivers/pci/pci.h   |  9 ++++-
>>>>  drivers/pci/probe.c |  5 +--
>>>>  include/linux/pci.h |  7 ++++
>>>>  4 files changed, 70 insertions(+), 43 deletions(-)
>>>>
>> [...]
>>>> + BUILD_BUG_ON(ARRAY_SIZE(pci_reset_fn_methods) != PCI_NUM_RESET_METHODS);
>>>>
>>>>   might_sleep();
>>>>
>>>> - rc = pci_dev_specific_reset(dev, 1);
>>>> - if (rc != -ENOTTY)
>>>> -         return rc;
>>>> - rc = pcie_reset_flr(dev, 1);
>>>> - if (rc != -ENOTTY)
>>>> -         return rc;
>>>> - rc = pci_af_flr(dev, 1);
>>>> - if (rc != -ENOTTY)
>>>> -         return rc;
>>>> - rc = pci_pm_reset(dev, 1);
>>>> - if (rc != -ENOTTY)
>>>> -         return rc;
>>>> + for (i = 1; i < PCI_NUM_RESET_METHODS; i++) {
>>>> +         rc = pci_reset_fn_methods[i].reset_fn(dev, 1);
>>>> +         if (!rc)
>>>> +                 reset_methods[n++] = i;
>>> Why do we need this local reset_methods[] array?  Can we just fill
>>> in dev->reset_methods[] directly and skip the memcpy() below?
>>>
>> This is for avoiding caching of previously supported reset methods.
>> Is it okay if I use memset(dev->reset_methods, 0,
>> sizeof(dev->reset_methods)) instead to clear the values in
>> dev->reset_methods?
> I don't think there's ever a case where you look at a
> dev->reset_methods[] element past a zero value, so we shouldn't care
> about any previously-supported methods left in the array.
>
> If we *do* look at something past a zero value, why do we do that?  It
> sounds like it would be a bug.
>

I think either we need memset or clear 0th/last element. Can we set the last
index explicitly to zero?

void pci_init_reset_methods(struct pci_dev *dev)
{
        int i, n, rc;

        BUILD_BUG_ON(ARRAY_SIZE(pci_reset_fn_methods) != PCI_NUM_RESET_METHODS);

        might_sleep();

        n = 0;
        for (i = 1; i < PCI_NUM_RESET_METHODS; i++) {
                rc = pci_reset_fn_methods[i].reset_fn(dev, 1);
                if (!rc)
                        dev->reset_methods[n++] = i;
                else if (rc != -ENOTTY)
                        break;
        }
        dev->reset_methods[n] = 0;
}





Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ