Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: rostedt@goodmis.org (Steven Rostedt)
To: linux-arm-kernel@lists.infradead.org
Subject: Dynamic ftrace self test broken on ARM
Date: Wed, 20 Jun 2018 21:29:06 -0400
Message-ID: <20180620212906.24b7b66e@vmware.local.home> (raw)
In-Reply-To: <20180620230734.GO17671@n2100.armlinux.org.uk>

On Thu, 21 Jun 2018 00:07:34 +0100
Russell King - ARM Linux <linux@armlinux.org.uk> wrote:


> > Any input from ARM folks?  
> 
> The same issues must exist on other architectures as ARM is not the only
> architecture to implement read-only kernel text and dynamic ftrace, so
> surely this problem isn't unique to ARM.

Probably because of the way set_kernel_text_ro() is implemented in
other archs. For example, in x86, we have:

void set_kernel_text_ro(void)
{
	unsigned long start = PFN_ALIGN(_text);
	unsigned long end = PFN_ALIGN(__stop___ex_table);

	if (!kernel_set_to_readonly)
		return;

	/*
	 * Set the kernel identity mapping for text RO.
	 */
	set_memory_ro(start, (end - start) >> PAGE_SHIFT);
}

and arm has:

void set_kernel_text_ro(void)
{
	set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), true,
				current->active_mm);
}

Where x86's set_kernel_text_ro() is a nop until the
kernel_set_to_readonly is set.

Perhaps this may fix things?

[ Not even compiled tested ]

-- Steve

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index c186474422f3..0cc8e04295a4 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -736,20 +736,29 @@ static int __mark_rodata_ro(void *unused)
 	return 0;
 }
 
+static int kernel_set_to_readonly __read_mostly;
+
 void mark_rodata_ro(void)
 {
+	kernel_set_to_readonly = 1;
 	stop_machine(__mark_rodata_ro, NULL, NULL);
 	debug_checkwx();
 }
 
 void set_kernel_text_rw(void)
 {
+	if (!kernel_set_to_readonly)
+		return;
+
 	set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), false,
 				current->active_mm);
 }
 
 void set_kernel_text_ro(void)
 {
+	if (!kernel_set_to_readonly)
+		return;
+
 	set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), true,
 				current->active_mm);
 }

  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 21:09 Stefan Agner
2018-06-18 21:54 ` Steven Rostedt
2018-06-19  8:16   ` Stefan Agner
2018-06-19 13:17     ` Steven Rostedt
2018-06-20 13:51       ` Stefan Agner
2018-06-20 14:13         ` Steven Rostedt
2018-06-20 19:06           ` Stefan Agner
2018-06-20 21:32             ` Stefan Agner
2018-06-20 22:45               ` Stefan Agner
2018-06-20 23:07                 ` Russell King - ARM Linux
2018-06-21  1:29                   ` Steven Rostedt [this message]
2018-06-21  7:25                     ` Stefan Agner
2018-06-21 13:51                       ` Steven Rostedt

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=20180620212906.24b7b66e@vmware.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-arm-kernel@lists.infradead.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

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git