linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: kernel test robot <rong.a.chen@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	x86@kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Bin Yang <bin.yang@intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Mark Gross <mark.gross@intel.com>,
	lkp@01.org
Subject: Re: [LKP] [x86/mm/cpa] c77d419f92: WARNING:at_arch/x86/mm/pageattr.c:#__change_page_attr_set_clr
Date: Mon, 17 Sep 2018 13:05:22 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1809171258560.16580@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20180917003127.GJ7632@shao2-debian>

On Mon, 17 Sep 2018, kernel test robot wrote:
>
> [    5.168861] WARNING: CPU: 0 PID: 1 at arch/x86/mm/pageattr.c:829 __change_page_attr_set_clr+0x324/0x7b8

> [    5.172255] EIP: __change_page_attr_set_clr+0x324/0x7b8
> [    5.178966]  change_page_attr_set_clr+0x101/0x29c
> [    5.179497]  ? preempt_count_add+0x5b/0x8c
> [    5.179953]  set_memory_ro+0x19/0x1b
> [    5.180356]  set_pages_ro+0x14/0x16
> [    5.180757]  mark_rodata_ro+0x73/0xa5

That's caused by 32bit mark_rodata_ro() doing:

       set_ro(kernel_text)
       kernel_set_to_readonly = 1;
       set_ro(rodata);

kernel_set_to_readonly enables the protection mechanism in CPA and
consequently triggers the WARN_ON() telling that the existing PTE/PMD is
incorrect vs. static protections.

64bit does not trigger this because it makes kernel text and rodata
readonly in one go. There is no real reasons not to do so on 32bit, so the
fix is obvious.

Thanks,

	tglx

8<------------------
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -923,34 +923,19 @@ static void mark_nxdata_nx(void)
 void mark_rodata_ro(void)
 {
 	unsigned long start = PFN_ALIGN(_text);
-	unsigned long size = PFN_ALIGN(_etext) - start;
+	unsigned long size = (unsigned long)__end_rodata - start;
 
 	set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
-	printk(KERN_INFO "Write protecting the kernel text: %luk\n",
+	pr_info("Write protecting kernel text and read-only data: %luk\n",
 		size >> 10);
 
 	kernel_set_to_readonly = 1;
 
 #ifdef CONFIG_CPA_DEBUG
-	printk(KERN_INFO "Testing CPA: Reverting %lx-%lx\n",
-		start, start+size);
-	set_pages_rw(virt_to_page(start), size>>PAGE_SHIFT);
-
-	printk(KERN_INFO "Testing CPA: write protecting again\n");
-	set_pages_ro(virt_to_page(start), size>>PAGE_SHIFT);
-#endif
-
-	start += size;
-	size = (unsigned long)__end_rodata - start;
-	set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
-	printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
-		size >> 10);
-
-#ifdef CONFIG_CPA_DEBUG
-	printk(KERN_INFO "Testing CPA: undo %lx-%lx\n", start, start + size);
+	pr_info("Testing CPA: Reverting %lx-%lx\n", start, start + size);
 	set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT);
 
-	printk(KERN_INFO "Testing CPA: write protecting again\n");
+	pr_info("Testing CPA: write protecting again\n");
 	set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
 #endif
 	mark_nxdata_nx();



  reply	other threads:[~2018-09-17 11:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 13:09 [patch V2 00/10] x86/mm/cpa: Improve large page preservation handling Thomas Gleixner
2018-09-14 13:09 ` [patch V2 01/10] x86/mm/cpa: Split, rename and clean up try_preserve_large_page() Thomas Gleixner
2018-09-14 13:09 ` [patch V2 02/10] x86/mm/cpa: Rework static_protections() Thomas Gleixner
2018-09-14 13:09 ` [patch V2 03/10] x86/mm/cpa: Allow range check for static protections Thomas Gleixner
2018-09-14 13:09 ` [patch V2 04/10] x86/mm/cpa: Add debug mechanism Thomas Gleixner
2018-09-14 23:22   ` kbuild test robot
2018-09-15  6:58   ` kbuild test robot
2018-09-15 13:06   ` [patch V3 " Thomas Gleixner
2018-09-14 13:09 ` [patch V2 05/10] x86/mm/cpa: Add large page preservation statistics Thomas Gleixner
2018-09-14 13:09 ` [patch V2 06/10] x86/mm/cpa: Avoid static protection checks on unmap Thomas Gleixner
2018-09-14 13:09 ` [patch V2 07/10] x86/mm/cpa: Add sanity check for existing mappings Thomas Gleixner
2018-09-17  0:31   ` [LKP] [x86/mm/cpa] c77d419f92: WARNING:at_arch/x86/mm/pageattr.c:#__change_page_attr_set_clr kernel test robot
2018-09-17 11:05     ` Thomas Gleixner [this message]
2018-09-14 13:09 ` [patch V2 08/10] x86/mm/cpa: Optimize same protection check Thomas Gleixner
2018-09-14 13:09 ` [patch V2 09/10] x86/mm/cpa: Do the range check early Thomas Gleixner
2018-09-14 13:09 ` [patch V2 10/10] x86/mm/cpa: Avoid the 4k pages check completely Thomas Gleixner

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=alpine.DEB.2.21.1809171258560.16580@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=bin.yang@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=mark.gross@intel.com \
    --cc=peterz@infradead.org \
    --cc=rong.a.chen@intel.com \
    --cc=x86@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).