[PATCH] Module argument to control whether intel-spi-pci attempts to turn the SPI flash chip writeable
Daniel Gutson
daniel at eclypsium.com
Thu Jul 30 10:18:20 EDT 2020
On Thu, Jul 30, 2020 at 11:09 AM Arnd Bergmann <arnd at arndb.de> wrote:
>
> On Thu, Jul 30, 2020 at 2:21 PM Daniel Gutson <daniel at eclypsium.com> wrote:
> > El jue., 30 jul. 2020 2:31 a. m., Greg Kroah-Hartman <gregkh at linuxfoundation.org> escribió:
> >>
> >> Again, module parameters are working on a per-chunk-of-code basis, while
> >> you want to work on a per-device basis,
> >
> >
> > I think there is a misunderstanding. What I want is to control (turn on or off) is a very specific code snippet that provides the "functionality" of trying to turn the chip writable. The rest of the device driver is fine.
> > I assume that the one that doesn't understand is me.
> >
>
> I looked at the source code again and found that the existing module
> parameter applies to both the platform and pci device front-ends, both
> of which go through
>
> /* Prevent writes if not explicitly enabled */
> if (!ispi->writeable || !writeable)
> ispi->nor.mtd.flags &= ~MTD_WRITEABLE;
>
I think you missed
https://elixir.bootlin.com/linux/latest/source/drivers/mtd/spi-nor/controllers/intel-spi-pci.c#L44
/* Try to make the chip read/write */
pci_read_config_dword(pdev, BCR, &bcr);
if (!(bcr & BCR_WPD)) {
bcr |= BCR_WPD;
pci_write_config_dword(pdev, BCR, bcr);
pci_read_config_dword(pdev, BCR, &bcr);
}
in the probe function, and is executed always and unconditionally.
/* Try to make the chip read/write */
pci_read_config_dword(pdev, BCR, &bcr);
if (!(bcr & BCR_WPD)) {
bcr |= BCR_WPD;
pci_write_config_dword(pdev, BCR, bcr);
pci_read_config_dword(pdev, BCR, &bcr);
}
> Setting the PCI device writable in hardware makes it possible to
> actually write to it *only* if the module parameter is also set to '1'.
> One might disagree with that design, but I don't think your patch
> would make it any better, it just means one would have to set
> two module parameters instead of one.
>
> Arnd
--
Daniel Gutson
Argentina Site Director
Enginieering Director
Eclypsium
Below The Surface: Get the latest threat research and insights on
firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport
More information about the linux-mtd
mailing list