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]
Date:   Mon, 11 Jul 2022 15:36:12 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Li Chen <me@...ux.beauty>
Cc:     Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Li Chen <lchen@...arella.com>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        DTML <devicetree@...r.kernel.org>, Linux-MM <linux-mm@...ck.org>
Subject: Re: [PATCH 1/4] of: add struct page support to rmem

On Mon, Jul 11, 2022 at 2:24 PM Li Chen <me@...ux.beauty> wrote:

> +config OF_RESERVED_MEM_DIO_SUPPORT
> +       bool "add Direct I/O support to reserved_mem"
> +       depends on ZONE_DEVICE && ARCH_KEEP_MEMBLOCK
> +       help
> +          By default, reserved memory don't get struct page support, which
> +                means you cannot do Direct I/O from this region. This config takes
> +                uses of ZONE_DEVICE and treats rmem as hotplug mem to get struct
> +                page and DIO support.

This probably does not need to be user visible, it's enough to select it from
the drivers that need it.

> @@ -72,7 +72,6 @@ void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname,
>         rmem->size = size;
>
>         reserved_mem_count++;
> -       return;
>  }

This change is not wrong, but it does not belong into the same patch
as the rest, just drop it.

> +/**
> + * get_reserved_mem_from_dev() - get reserved_mem from a device node
> + * @dev: device pointer
> + *
> + * This function look for reserved_mem from given device.
> + *
> + * Returns a reserved_mem pointer, or NULL on error.
> + */
> +struct reserved_mem *get_reserved_mem_from_dev(struct device *dev)
> +{
> +       struct device_node *np = dev_of_node(dev);
> +       struct device_node *rmem_np;
> +       struct reserved_mem *rmem = NULL;
> +
> +       rmem_np = of_parse_phandle(np, "memory-region", 0);
> +       if (!rmem_np) {
> +               dev_err(dev, "failed to get memory region node\n");
> +               return ERR_PTR(-ENODEV);
> +       }
> +
> +       rmem = of_reserved_mem_lookup(rmem_np);
> +       if (!rmem) {
> +               dev_err(dev, "Failed to lookup reserved memory\n");
> +               return ERR_PTR(EINVAL);

This needs to be a negative error code rather than the positive EINVAL.
No need to initialize rmem=NULL first if you override it here.

> +       if (likely(reserved_mem_dio_in_region(pfn << PAGE_SHIFT, PAGE_SIZE, rmem) <
> +                  0))
> +               goto out;

It's not performance critical, so just drop the 'likely()' and put the
rest into one line.


> +       if (page) {
> +               *page = pfn_to_page(pfn);
> +               get_page(*page);
> +       }
> +
> +       ret = 0;
> +
> +out:
> +       pte_unmap(pte);
> +       return ret;
> +}

Should you perhaps return an error when 'page' is NULL?

> +#ifdef CONFIG_OF_RESERVED_MEM_DIO_SUPPORT
> +int reserved_mem_dio_mmap(struct file *file, struct vm_area_struct *vma, struct reserved_mem *rmem);
> +void *reserved_mem_memremap_pages(struct device *dev, struct reserved_mem *rmem);
> +#endif

The '#ifdef' check can be dropped here, declarations are normally
not hidden like this.

         Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ