From: Xavi Drudis Ferran <xdrudis@tinet.cat>
To: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>,
NXP Linux Team <linux-imx@nxp.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] ARM: imx: W+X ocram page in imx6q
Date: Tue, 22 Sep 2020 14:02:07 +0200 [thread overview]
Message-ID: <20200922120207.GA3308@martinet.casa.ct> (raw)
In-Reply-To: <20200922071537.GI25109@dragon>
El Tue, Sep 22, 2020 at 03:15:38PM +0800, Shawn Guo deia:
> I tested it on my imx6q-sabresd board with v5.9-rc6 kernel, and
> suspend/resume still works with your patch applied.
>
Thank you very much.
> There is a build warning with your patch though.
>
Silly me. I'm sorry about that. This new version removes the warning.
I've tested on linux-libre-5.8.10 on a wandboard quad (imx6q) and it
works the same with or without the patch. Hibernate gives a runtine
warning less in 5.8.10 than 5.8.9 (both with or without patch), but
suspend still fails to resume the eth phy (both with or without the patch).
imx6q: Mark the SRAM page for resume code read-only,executable (once written)
The code used for resume after suspend in imx6 is copied to a SRAM
on chip, so that it stays in the CPU chip while the system is
partially powered down. The page mapping that SRAM was marked as
RW+X, which gave a warning when CONFIG_DEBUG_WX=y. Mark it
read-only and executable once the writting from kernel text is done
to get rid of the warning and prevent possible exploitation.
Signed-off-by: Xavier Drudis Ferran <xdrudis@tinet.cat>
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
index 40c74b4c4..8baa1307f 100644
--- a/arch/arm/mach-imx/pm-imx6.c
+++ b/arch/arm/mach-imx/pm-imx6.c
@@ -16,6 +16,7 @@
#include <linux/of_platform.h>
#include <linux/regmap.h>
#include <linux/suspend.h>
+#include <linux/set_memory.h>
#include <asm/cacheflush.h>
#include <asm/fncpy.h>
#include <asm/proc-fns.h>
@@ -570,6 +571,13 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
&imx6_suspend,
MX6Q_SUSPEND_OCRAM_SIZE - sizeof(*pm_info));
+ ret = set_memory_ro((unsigned long)suspend_ocram_base,
+ __KERNEL_DIV_ROUND_UP(MX6Q_SUSPEND_OCRAM_SIZE, PAGE_SIZE));
+ if (ret) {
+ pr_warn("%s: failed to mark executable on chip SRAM as read only after writing to it: %d!\n",
+ __func__, ret);
+ }
+
goto put_device;
pl310_cache_map_failed:
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2020-09-22 12:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 20:30 [PATCH] ARM: imx: W+X ocram page in imx6q. Might someone with working imx6 suspend please test ? Xavi Drudis Ferran
2020-09-22 7:15 ` Shawn Guo
2020-09-22 12:02 ` Xavi Drudis Ferran [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=20200922120207.GA3308@martinet.casa.ct \
--to=xdrudis@tinet.cat \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).