Skip to contentSkip to conversation

pstore: Use memcpy_toio instead of memcpy

PATCH In review Furquan Shaikh 2 participants 2 messages Nov 13, 2014 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pstore: Use memcpy_toio instead of memcpy

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.

---
 fs/pstore/ram_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/ram_core.c +1 -1
index 9d7b9a8..cfbc5e4 100644
@@ -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);
 }
 
Signature · 1 line
2.1.0.rc2.206.gedb03e5
Acked-by on v1 1/1
#1 lore raw
Quoted 24 lines · Furquan Shaikh

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.

---
 fs/pstore/ram_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/ram_core.c +1 -2
index 9d7b9a8..cfbc5e4 100644
@@ -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);
 }
 
--
Quoted 2 lines

2.1.0.rc2.206.gedb03e5

Thanks!

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security