All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Linux IOMMU <iommu@lists.linux-foundation.org>,
	Michal Simek <monstr@monstr.eu>,
	ashutosh.dixit@intel.com, alpha <linux-alpha@vger.kernel.org>,
	arcml <linux-snps-arc@lists.infradead.org>,
	linux-c6x-dev@linux-c6x.org,
	linux-m68k <linux-m68k@lists.linux-m68k.org>,
	Openrisc <openrisc@lists.librecores.org>,
	Parisc List <linux-parisc@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	sparclinux <sparclinux@vger.kernel.org>,
	linux-xtensa@linux-xtensa.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_*
Date: Fri, 14 Dec 2018 10:54:32 +0100	[thread overview]
Message-ID: <CAMuHMdWOr0EsgFQF8tjJYLxKVXx+Jwn73N8SVKt8AQGLKQ8V-A@mail.gmail.com> (raw)
In-Reply-To: <20181214082515.14835-2-hch@lst.de>

Hi Christoph,

On Fri, Dec 14, 2018 at 9:26 AM Christoph Hellwig <hch@lst.de> wrote:
> If we want to map memory from the DMA allocator to userspace it must be
> zeroed at allocation time to prevent stale data leaks.   We already do
> this on most common architectures, but some architectures don't do this
> yet, fix them up, either by passing GFP_ZERO when we use the normal page
> allocator or doing a manual memset otherwise.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Thanks for your patch!

> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -32,7 +32,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
>         size = PAGE_ALIGN(size);
>         order = get_order(size);
>
> -       page = alloc_pages(flag, order);
> +       page = alloc_pages(flag | GFP_ZERO, order);
>         if (!page)
>                 return NULL;

There's second implementation below, which calls __get_free_pages() and
does an explicit memset().  As __get_free_pages() calls alloc_pages(), perhaps
it makes sense to replace the memset() by GFP_ZERO, to increase consistency?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: linux-s390 <linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>,
	linux-c6x-dev-jPsnJVOj+W6hPH1hqNUYSQ@public.gmane.org,
	Parisc List
	<linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-xtensa-PjhNF2WwrV/0Sa2dR60CXw@public.gmane.org,
	linux-m68k
	<linux-m68k-cunTk1MwBs8S/qaLPR03pWD2FQJk+8+b@public.gmane.org>,
	Linux Kernel Mailing List
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	ashutosh.dixit-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	Linux IOMMU
	<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	Openrisc
	<openrisc-cunTk1MwBs9a3B2Vnqf2dGD2FQJk+8+b@public.gmane.org>,
	alpha <linux-alpha-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	sparclinux <sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	arcml
	<linux-snps-arc-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_*
Date: Fri, 14 Dec 2018 09:54:32 +0000	[thread overview]
Message-ID: <CAMuHMdWOr0EsgFQF8tjJYLxKVXx+Jwn73N8SVKt8AQGLKQ8V-A@mail.gmail.com> (raw)
In-Reply-To: <20181214082515.14835-2-hch-jcswGhMUV9g@public.gmane.org>

Hi Christoph,

On Fri, Dec 14, 2018 at 9:26 AM Christoph Hellwig <hch@lst.de> wrote:
> If we want to map memory from the DMA allocator to userspace it must be
> zeroed at allocation time to prevent stale data leaks.   We already do
> this on most common architectures, but some architectures don't do this
> yet, fix them up, either by passing GFP_ZERO when we use the normal page
> allocator or doing a manual memset otherwise.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Thanks for your patch!

> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -32,7 +32,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
>         size = PAGE_ALIGN(size);
>         order = get_order(size);
>
> -       page = alloc_pages(flag, order);
> +       page = alloc_pages(flag | GFP_ZERO, order);
>         if (!page)
>                 return NULL;

There's second implementation below, which calls __get_free_pages() and
does an explicit memset().  As __get_free_pages() calls alloc_pages(), perhaps
it makes sense to replace the memset() by GFP_ZERO, to increase consistency?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: geert@linux-m68k.org (Geert Uytterhoeven)
To: linux-snps-arc@lists.infradead.org
Subject: [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_*
Date: Fri, 14 Dec 2018 10:54:32 +0100	[thread overview]
Message-ID: <CAMuHMdWOr0EsgFQF8tjJYLxKVXx+Jwn73N8SVKt8AQGLKQ8V-A@mail.gmail.com> (raw)
In-Reply-To: <20181214082515.14835-2-hch@lst.de>

Hi Christoph,

On Fri, Dec 14, 2018@9:26 AM Christoph Hellwig <hch@lst.de> wrote:
> If we want to map memory from the DMA allocator to userspace it must be
> zeroed at allocation time to prevent stale data leaks.   We already do
> this on most common architectures, but some architectures don't do this
> yet, fix them up, either by passing GFP_ZERO when we use the normal page
> allocator or doing a manual memset otherwise.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>

Thanks for your patch!

> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -32,7 +32,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
>         size = PAGE_ALIGN(size);
>         order = get_order(size);
>
> -       page = alloc_pages(flag, order);
> +       page = alloc_pages(flag | GFP_ZERO, order);
>         if (!page)
>                 return NULL;

There's second implementation below, which calls __get_free_pages() and
does an explicit memset().  As __get_free_pages() calls alloc_pages(), perhaps
it makes sense to replace the memset() by GFP_ZERO, to increase consistency?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: linux-s390 <linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>,
	linux-c6x-dev-jPsnJVOj+W6hPH1hqNUYSQ@public.gmane.org,
	Parisc List
	<linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-xtensa-PjhNF2WwrV/0Sa2dR60CXw@public.gmane.org,
	linux-m68k
	<linux-m68k-cunTk1MwBs8S/qaLPR03pWD2FQJk+8+b@public.gmane.org>,
	Linux Kernel Mailing List
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	ashutosh.dixit-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	Linux IOMMU
	<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	Openrisc
	<openrisc-cunTk1MwBs9a3B2Vnqf2dGD2FQJk+8+b@public.gmane.org>,
	alpha <linux-alpha-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	sparclinux <sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	arcml
	<linux-snps-arc-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_*
Date: Fri, 14 Dec 2018 10:54:32 +0100	[thread overview]
Message-ID: <CAMuHMdWOr0EsgFQF8tjJYLxKVXx+Jwn73N8SVKt8AQGLKQ8V-A@mail.gmail.com> (raw)
In-Reply-To: <20181214082515.14835-2-hch-jcswGhMUV9g@public.gmane.org>

Hi Christoph,

On Fri, Dec 14, 2018 at 9:26 AM Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org> wrote:
> If we want to map memory from the DMA allocator to userspace it must be
> zeroed at allocation time to prevent stale data leaks.   We already do
> this on most common architectures, but some architectures don't do this
> yet, fix them up, either by passing GFP_ZERO when we use the normal page
> allocator or doing a manual memset otherwise.
>
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Thanks for your patch!

> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -32,7 +32,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
>         size = PAGE_ALIGN(size);
>         order = get_order(size);
>
> -       page = alloc_pages(flag, order);
> +       page = alloc_pages(flag | GFP_ZERO, order);
>         if (!page)
>                 return NULL;

There's second implementation below, which calls __get_free_pages() and
does an explicit memset().  As __get_free_pages() calls alloc_pages(), perhaps
it makes sense to replace the memset() by GFP_ZERO, to increase consistency?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: openrisc@lists.librecores.org
Subject: [OpenRISC] [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_*
Date: Fri, 14 Dec 2018 10:54:32 +0100	[thread overview]
Message-ID: <CAMuHMdWOr0EsgFQF8tjJYLxKVXx+Jwn73N8SVKt8AQGLKQ8V-A@mail.gmail.com> (raw)
In-Reply-To: <20181214082515.14835-2-hch@lst.de>

Hi Christoph,

On Fri, Dec 14, 2018 at 9:26 AM Christoph Hellwig <hch@lst.de> wrote:
> If we want to map memory from the DMA allocator to userspace it must be
> zeroed at allocation time to prevent stale data leaks.   We already do
> this on most common architectures, but some architectures don't do this
> yet, fix them up, either by passing GFP_ZERO when we use the normal page
> allocator or doing a manual memset otherwise.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Thanks for your patch!

> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -32,7 +32,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
>         size = PAGE_ALIGN(size);
>         order = get_order(size);
>
> -       page = alloc_pages(flag, order);
> +       page = alloc_pages(flag | GFP_ZERO, order);
>         if (!page)
>                 return NULL;

There's second implementation below, which calls __get_free_pages() and
does an explicit memset().  As __get_free_pages() calls alloc_pages(), perhaps
it makes sense to replace the memset() by GFP_ZERO, to increase consistency?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2018-12-14  9:54 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14  8:25 ensure dma_alloc_coherent always returns zeroed memory Christoph Hellwig
2018-12-14  8:25 ` [OpenRISC] " Christoph Hellwig
2018-12-14  8:25 ` Christoph Hellwig
2018-12-14  8:25 ` Christoph Hellwig
2018-12-14  8:25 ` Christoph Hellwig
2018-12-14  8:25 ` [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_* Christoph Hellwig
2018-12-14  8:25   ` [OpenRISC] " Christoph Hellwig
2018-12-14  8:25   ` Christoph Hellwig
2018-12-14  8:25   ` Christoph Hellwig
2018-12-14  8:25   ` Christoph Hellwig
2018-12-14  9:54   ` Geert Uytterhoeven [this message]
2018-12-14  9:54     ` [OpenRISC] " Geert Uytterhoeven
2018-12-14  9:54     ` Geert Uytterhoeven
2018-12-14  9:54     ` Geert Uytterhoeven
2018-12-14  9:54     ` Geert Uytterhoeven
2018-12-14  9:55     ` Geert Uytterhoeven
2018-12-14  9:55       ` [OpenRISC] " Geert Uytterhoeven
2018-12-14  9:55       ` Geert Uytterhoeven
2018-12-14  9:55       ` Geert Uytterhoeven
2018-12-14  9:55       ` Geert Uytterhoeven
2018-12-14 11:47     ` Christoph Hellwig
2018-12-14 11:47       ` [OpenRISC] " Christoph Hellwig
2018-12-14 11:47       ` Christoph Hellwig
2018-12-14 11:47       ` Christoph Hellwig
2018-12-14 11:47       ` Christoph Hellwig
2018-12-14 12:36       ` Geert Uytterhoeven
2018-12-14 12:36         ` [OpenRISC] " Geert Uytterhoeven
2018-12-14 12:36         ` Geert Uytterhoeven
2018-12-14 12:36         ` Geert Uytterhoeven
2018-12-14 14:14       ` Greg Ungerer
2018-12-14 14:14         ` [OpenRISC] " Greg Ungerer
2018-12-14 14:14         ` Greg Ungerer
2018-12-14 14:14         ` Greg Ungerer
2018-12-14 14:14         ` Greg Ungerer
2018-12-14 14:14         ` Greg Ungerer
2018-12-17 11:59         ` Christoph Hellwig
2018-12-17 11:59           ` [OpenRISC] " Christoph Hellwig
2018-12-17 11:59           ` Christoph Hellwig
2018-12-17 11:59           ` Christoph Hellwig
2019-01-11  6:09           ` Greg Ungerer
2018-12-14 12:12   ` Eugeniy Paltsev
2018-12-14 12:12     ` [OpenRISC] " Eugeniy Paltsev
2018-12-14 12:12     ` Eugeniy Paltsev
2018-12-14 12:12     ` Eugeniy Paltsev
2018-12-14 12:12     ` Eugeniy Paltsev
2018-12-14 12:21     ` hch
2018-12-14 12:21       ` [OpenRISC] " hch
2018-12-14 12:21       ` hch-jcswGhMUV9g
2018-12-14 12:21       ` hch
2018-12-14 12:21       ` hch
2018-12-14 18:10   ` Sam Ravnborg
2018-12-14 18:10     ` [OpenRISC] " Sam Ravnborg
2018-12-14 18:10     ` Sam Ravnborg
2018-12-14 18:10     ` Sam Ravnborg
2018-12-14 18:35     ` Christoph Hellwig
2018-12-14 18:35       ` [OpenRISC] " Christoph Hellwig
2018-12-14 18:35       ` Christoph Hellwig
2018-12-14 18:35       ` Christoph Hellwig
2018-12-14  8:25 ` [PATCH 2/2] dma-mapping: deprecate dma_zalloc_coherent Christoph Hellwig
2018-12-14  8:25   ` [OpenRISC] " Christoph Hellwig
2018-12-14  8:25   ` Christoph Hellwig
2018-12-14  8:25   ` Christoph Hellwig
2018-12-14  8:25   ` Christoph Hellwig
2018-12-14 13:33 ` ensure dma_alloc_coherent always returns zeroed memory Christoph Hellwig
2018-12-14 13:33   ` [OpenRISC] " Christoph Hellwig
2018-12-14 13:33   ` Christoph Hellwig
2018-12-14 13:33   ` Christoph Hellwig
2018-12-19 16:59 ` Christoph Hellwig
2018-12-19 16:59   ` [OpenRISC] " Christoph Hellwig
2018-12-19 16:59   ` Christoph Hellwig
2018-12-19 16:59   ` Christoph Hellwig
2018-12-20 14:32   ` Eugeniy Paltsev
2018-12-20 14:32     ` Eugeniy Paltsev
2018-12-20 14:32     ` Eugeniy Paltsev
2018-12-20 14:32     ` Eugeniy Paltsev
2018-12-20 14:34     ` hch
2018-12-20 14:34       ` [OpenRISC] " hch
2018-12-20 14:34       ` hch
2018-12-20 14:34       ` hch
2018-12-20 14:34       ` hch
2018-12-20 14:39       ` Eugeniy Paltsev
2018-12-20 14:39         ` Eugeniy Paltsev
2018-12-20 14:39         ` Eugeniy Paltsev
2018-12-20 14:39         ` Eugeniy Paltsev
2018-12-20 14:46         ` hch
2018-12-20 14:46           ` [OpenRISC] " hch
2018-12-20 14:46           ` hch
2018-12-20 14:46           ` hch
2018-12-20 14:46           ` hch
2018-12-20 17:37           ` hch
2018-12-20 17:37             ` [OpenRISC] " hch
2018-12-20 17:37             ` hch
2018-12-20 17:37             ` hch
2018-12-20 17:37             ` hch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMuHMdWOr0EsgFQF8tjJYLxKVXx+Jwn73N8SVKt8AQGLKQ8V-A@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=ashutosh.dixit@intel.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-c6x-dev@linux-c6x.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=linux-xtensa@linux-xtensa.org \
    --cc=monstr@monstr.eu \
    --cc=openrisc@lists.librecores.org \
    --cc=sparclinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.