[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3e638993-9541-1ed7-743b-5c2ddba4104e@huawei.com>
Date: Mon, 25 Mar 2019 09:59:18 +0000
From: John Garry <john.garry@...wei.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
CC: Bjorn Helgaas <bhelgaas@...gle.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Arnd Bergmann <arnd@...db.de>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Borislav Petkov <bp@...e.de>,
Guenter Roeck <linux@...ck-us.net>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
<linux-pci@...r.kernel.org>,
Kefeng Wang <wangkefeng.wang@...wei.com>,
Linuxarm <linuxarm@...wei.com>, Alexander Graf <agraf@...e.de>
Subject: Re: [PATCH v2 2/3] lib: logic_pio: Reject access to unregistered CPU
MMIO regions
On 23/03/2019 19:15, Andy Shevchenko wrote:
> On Wed, Mar 20, 2019 at 8:14 PM John Garry <john.garry@...wei.com> wrote:
>>
>> Currently when accessing logical indirect PIO addresses in
>> logic_{in, out}{,s}, we first ensure that the region is registered.
>>
>> However, no such check exists for CPU MMIO regions. The CPU MMIO regions
>> would be registered by the PCI host (when PCI_IOBASE is defined) in
>> pci_register_io_range().
>>
>> We have seen scenarios when systems which don't have a PCI host or, they
>> do, and the PCI host probe fails, that certain devices attempts to still
>> attempt to access PCI IO ports; examples are in [1] and [2].
>>
>> And even though we would protect against this by ensuring the driver call
>> request_{muxed_}region(), some don't do this:
>>
>
Hi Andy,
>
>> #if defined(CONFIG_INDIRECT_PIO) && defined(PCI_IOBASE)
>> +#define INVALID_RANGE(range) (!range || \
>> + (range->flags == LOGIC_PIO_CPU_MMIO && !range->ops))
>
> It would be better to read in a form
> #define foo(x) \
Sure, I can change that if you think it reads better.
> (...)
>
>> + ret = range->ops->in(range->hostdata, \
>> + addr, sizeof(type)); \
>
> Can it fit one line?
It should be ok. I can shorten some variable names.
>
Thanks for checking,
John
Powered by blists - more mailing lists