Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1314343 > unrolled thread

[PATCH RESEND 0/2] fs/pstore: Use memcpy_from/toio() instead of memcpy.

Started byEnric Balletbo i Serra <enric.balletbo@collabora.com>
First post2016-01-21 17:50 +0100
Last post2016-01-21 20:20 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RESEND 0/2] fs/pstore: Use memcpy_from/toio() instead of memcpy. Enric Balletbo i Serra <enric.balletbo@collabora.com> - 2016-01-21 17:50 +0100
    [PATCH RESEND 2/2] fs/pstore: Use memcpy_fromio() to save old ramoops buffer Enric Balletbo i Serra <enric.balletbo@collabora.com> - 2016-01-21 17:50 +0100
    [PATCH RESEND 1/2] fs/pstore: Use memcpy_toio instead of memcpy Enric Balletbo i Serra <enric.balletbo@collabora.com> - 2016-01-21 17:50 +0100
    Re: [PATCH RESEND 0/2] fs/pstore: Use memcpy_from/toio() instead of memcpy. Kees Cook <keescook@chromium.org> - 2016-01-21 20:20 +0100

#1314343 — [PATCH RESEND 0/2] fs/pstore: Use memcpy_from/toio() instead of memcpy.

FromEnric Balletbo i Serra <enric.balletbo@collabora.com>
Date2016-01-21 17:50 +0100
Subject[PATCH RESEND 0/2] fs/pstore: Use memcpy_from/toio() instead of memcpy.
Message-ID<qTqAN-7W1-1@gated-at.bofh.it>
Dear all,

These patches were needed in order to make ramoops work in my armv8 board. They
originally come from chrome os kernel, so I kept the original authors. I found
that weren't in mainline so I thought that will be really interesting send them.

Best regards,
Enric

Andrew Bresticker (1):
  fs/pstore: Use memcpy_fromio() to save old ramoops buffer

Furquan Shaikh (1):
  fs/pstore: Use memcpy_toio instead of memcpy

 fs/pstore/ram_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.1.0

[toc] | [next] | [standalone]


#1314344 — [PATCH RESEND 2/2] fs/pstore: Use memcpy_fromio() to save old ramoops buffer

FromEnric Balletbo i Serra <enric.balletbo@collabora.com>
Date2016-01-21 17:50 +0100
Subject[PATCH RESEND 2/2] fs/pstore: Use memcpy_fromio() to save old ramoops buffer
Message-ID<qTqAO-7W1-3@gated-at.bofh.it>
In reply to#1314343
From: Andrew Bresticker <abrestic@chromium.org>

The ramoops buffer may be mapped as either I/O memory or uncached
memory.  On ARM64, this results in a device-type (strongly-ordered)
mapping.  Since unnaligned accesses to device-type memory will
generate an alignment fault (regardless of whether or not strict
alignment checking is enabled), it is not safe to use memcpy().
memcpy_fromio() is guaranteed to only use aligned accesses, so use
that instead.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com>
---
 fs/pstore/ram_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 351164d..5308277 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -322,8 +322,8 @@ void persistent_ram_save_old(struct persistent_ram_zone *prz)
 	}
 
 	prz->old_log_size = size;
-	memcpy(prz->old_log, &buffer->data[start], size - start);
-	memcpy(prz->old_log + size - start, &buffer->data[0], start);
+	memcpy_fromio(prz->old_log, &buffer->data[start], size - start);
+	memcpy_fromio(prz->old_log + size - start, &buffer->data[0], start);
 }
 
 int notrace persistent_ram_write(struct persistent_ram_zone *prz,
-- 
2.1.0

[toc] | [prev] | [next] | [standalone]


#1314345 — [PATCH RESEND 1/2] fs/pstore: Use memcpy_toio instead of memcpy

FromEnric Balletbo i Serra <enric.balletbo@collabora.com>
Date2016-01-21 17:50 +0100
Subject[PATCH RESEND 1/2] fs/pstore: Use memcpy_toio instead of memcpy
Message-ID<qTqAO-7W1-21@gated-at.bofh.it>
In reply to#1314343
From: Furquan Shaikh <furquan@google.com>

persistent_ram_update uses vmap / iomap based on whether the buffer is in
memory region or reserved region. However, both map it as non-cacheable
memory. For armv8 specifically, non-cacheable mapping requests use a
memory type that has to be accessed aligned to the request size. memcpy()
doesn't guarantee that.

Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com>
---
 fs/pstore/ram_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 76c3f80..351164d 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -299,7 +299,7 @@ static void notrace persistent_ram_update(struct persistent_ram_zone *prz,
 	const void *s, unsigned int start, unsigned int count)
 {
 	struct persistent_ram_buffer *buffer = prz->buffer;
-	memcpy(buffer->data + start, s, count);
+	memcpy_toio(buffer->data + start, s, count);
 	persistent_ram_update_ecc(prz, start, count);
 }
 
-- 
2.1.0

[toc] | [prev] | [next] | [standalone]


#1314437

FromKees Cook <keescook@chromium.org>
Date2016-01-21 20:20 +0100
Message-ID<qTsVY-1dK-9@gated-at.bofh.it>
In reply to#1314343
On Thu, Jan 21, 2016 at 8:44 AM, Enric Balletbo i Serra
<enric.balletbo@collabora.com> wrote:
> Dear all,
>
> These patches were needed in order to make ramoops work in my armv8 board. They
> originally come from chrome os kernel, so I kept the original authors. I found
> that weren't in mainline so I thought that will be really interesting send them.
>
> Best regards,
> Enric
>
> Andrew Bresticker (1):
>   fs/pstore: Use memcpy_fromio() to save old ramoops buffer
>
> Furquan Shaikh (1):
>   fs/pstore: Use memcpy_toio instead of memcpy
>
>  fs/pstore/ram_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Thanks! These look fine to me.

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web