mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pi-Hsun Shih <pihsun@chromium.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Pi-Hsun Shih <pihsun@chromium.org>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-remoteproc@vger.kernel.org (open list:REMOTE PROCESSOR
	(REMOTEPROC) SUBSYSTEM), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 2/2] remoteproc: elf_loader: Use memset_io instead of memset.
Date: Mon, 21 Jan 2019 15:34:08 +0800	[thread overview]
Message-ID: <20190121073408.56557-2-pihsun@chromium.org> (raw)
In-Reply-To: <20190121073408.56557-1-pihsun@chromium.org>

Use memset_io and memcpy_toio instead of memset and memcpy in
rproc_elf_load_segments, since the target ptr may be device memory.

Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
---
This fix issue while trying to load ELF firmware based on
https://lore.kernel.org/patchwork/patch/1033804/, that the memset(...,
0) would use "dc zva" instruction on aarch64, which cause kernel crash
since the target is device memory.
---
 drivers/remoteproc/remoteproc_elf_loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c
index b17d72ec8603bc..17f1815757dc54 100644
--- a/drivers/remoteproc/remoteproc_elf_loader.c
+++ b/drivers/remoteproc/remoteproc_elf_loader.c
@@ -159,7 +159,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
 		u32 memsz = phdr->p_memsz;
 		u32 filesz = phdr->p_filesz;
 		u32 offset = phdr->p_offset;
-		void *ptr;
+		void __iomem *ptr;
 
 		if (phdr->p_type != PT_LOAD)
 			continue;
@@ -191,7 +191,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
 
 		/* put the segment where the remote processor expects it */
 		if (phdr->p_filesz)
-			memcpy(ptr, elf_data + phdr->p_offset, filesz);
+			memcpy_toio(ptr, elf_data + phdr->p_offset, filesz);
 
 		/*
 		 * Zero out remaining memory for this segment.
@@ -201,7 +201,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
 		 * this.
 		 */
 		if (memsz > filesz)
-			memset(ptr + filesz, 0, memsz - filesz);
+			memset_io(ptr + filesz, 0, memsz - filesz);
 	}
 
 	return ret;
-- 
2.20.1.321.g9e740568ce-goog


      reply	other threads:[~2019-01-21  7:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21  7:34 [PATCH 1/2] remoteproc: Add __iomem to return of rproc_da_to_va Pi-Hsun Shih
2019-01-21  7:34 ` Pi-Hsun Shih [this message]

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=20190121073408.56557-2-pihsun@chromium.org \
    --to=pihsun@chromium.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®