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: <c902e7e690dcdf57c2e8402e083d27ce84aee21b.camel@redhat.com>
Date:   Fri, 01 Dec 2023 22:56:05 +0100
From:   Philipp Stanner <pstanner@...hat.com>
To:     Arnd Bergmann <arnd@...db.de>, Bjorn Helgaas <bhelgaas@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Dave Jiang <dave.jiang@...el.com>,
        Uladzislau Koshchanka <koshchanka@...il.com>,
        Neil Brown <neilb@...e.de>,
        Niklas Schnelle <schnelle@...ux.ibm.com>,
        John Sanpe <sanpeqf@...il.com>,
        Kent Overstreet <kent.overstreet@...il.com>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        David Gow <davidgow@...gle.com>,
        Yury Norov <yury.norov@...il.com>,
        "wuqiang.matt" <wuqiang.matt@...edance.com>,
        Jason Baron <jbaron@...mai.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        Ben Dooks <ben.dooks@...ethink.co.uk>,
        Danilo Krummrich <dakr@...hat.com>
Cc:     linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org,
        Linux-Arch <linux-arch@...r.kernel.org>,
        Arnd Bergmann <arnd@...nel.org>, pstanner@...hat.com
Subject: Re: [PATCH v2 4/4] lib, pci: unify generic pci_iounmap()

On Fri, 2023-12-01 at 22:32 +0100, Arnd Bergmann wrote:
> On Fri, Dec 1, 2023, at 20:37, Philipp Stanner wrote:
> > On Fri, 2023-12-01 at 16:26 +0100, Arnd Bergmann wrote:
> > > 
> > > static inline bool struct iomem_is_ioport(void __iomem *p)
> > > {
> > > #ifdef CONFIG_HAS_IOPORT
> > >         uintptr_t start = (uintptr_t) PCI_IOBASE;
> > >         uintptr_t addr = (uintptr_t) p;
> > > 
> > >         if (addr >= start && addr < start + IO_SPACE_LIMIT)
> > >                 return true;
> > > #endif
> > >         return false;
> > > }
> > > 
> > > > +#else /* CONFIG_GENERIC_IOMAP. Version from lib/iomap.c will
> > > > be
> > > > used. 
> > > > */
> > > > +bool iomem_is_ioport(void __iomem *addr);
> > > > +#define ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT
> > > 
> > > I'm not sure what this macro is for, since it appears to
> > > do the opposite of what its name suggests: rather than
> > > provide the generic version of iomem_is_ioport(), it
> > > skips that and provides a custom one to go with lib/iomap.c
> > 
> > Hmmm well now it's getting tricky.
> > 
> > This else-branch is the one where CONFIG_GENERIC_IOMAP is actually
> > set.
> > 
> > I think we're running into the "generic not being generic now that
> > IA64
> > has died" problem you were hinting at.
> > 
> > If we build for x86 and have CONFIG_GENERIC set, only then do we
> > want
> > iomem_is_ioport() from lib/iomap.c. So the macro serves avoiding a
> > collision between symbols. Because lib/iomap.c might be compiled
> > even
> > if someone else already has defined iomem_is_ioport().
> > I also don't like it, but it was the least bad solution I could
> > come up
> > with
> > Suggestions?
> 
> The best I can think of is to move the lib/iomap.c version
> of iomem_is_ioport() to include/asm-generic/iomap.h with
> an #ifndef iomem_is_ioport / #define iomem_is_ioport
> check around it. This file is only included on parisc, alpha,
> sh and when CONFIG_GENERIC_IOMAP is set.

My implementation from lib/iomap.c basically just throws away the
IO_COND macro and does the checks manually:

#if defined(ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT)
bool iomem_is_ioport(void __iomem *addr)
{
	unsigned long port = (unsigned long __force)addr;

	if (port > PIO_OFFSET && port < PIO_RESERVED)
		return true;

	return false;
}
#endif /* ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT */

So we'd also need PIO_OFFSET and PIO_RESERVED, which are not present in
asm-generic/iomap.h.

Sure, we could move them there or into a common header. But I'm not
sure if that is wise, meaning: is it really better than the ugly
WANTS_GENERIC_IOMEM... macro?

Our entire goal in this series is, after all, to simplify the
implementation.


P.

> 
> The default version in asm-generic/io.h then just needs
> one more #ifdef iomem_is_ioport check around it.
> 
>       Arnd
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ