From: Yujie Liu <yujie.liu@intel.com>
To: Dave Hansen <dave.hansen@intel.com>,
"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
<linux-kernel@vger.kernel.org>, <dave.hansen@linux.intel.com>
Cc: "peterz@infradead.org" <peterz@infradead.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"Lutomirski, Andy" <luto@kernel.org>,
"bp@alien8.de" <bp@alien8.de>, lkp <lkp@intel.com>
Subject: Re: [PATCH] x86/mm: Set NX bit when making pages present
Date: Tue, 20 Sep 2022 11:12:22 +0800 [thread overview]
Message-ID: <YykvlsPEHZRU65IM@yujie-X299> (raw)
In-Reply-To: <c83b4d34-8447-03dd-1068-99aaa159e04b@intel.com>
On Mon, Sep 19, 2022 at 11:30:09AM -0700, Dave Hansen wrote:
> On 9/19/22 11:14, Edgecombe, Rick P wrote:
> > Clearly somehow it is though. The original report has this in the log:
> > Notice: NX (Execute Disable) protection cannot be enabled: non-PAE
> > kernel!
>
> Ah, crud. Nice catch, btw.
>
> So, the CPU has NX, making cpu_feature_enabled(X86_FEATURE_NX)==1, but
> the page table mode does not have support.
>
> I guess we can either clear X86_FEATURE_NX around the "protection cannot
> be enabled" message, or do something like the attached patch and just do
> the check at runtime.
>
> I'm not sure we want to mess with X86_FEATURE_NX itself. It seems to
> get used for a few different things, including on the KVM side.
>
> 0day folks, can you see if _this_ one (totally untested) helps the
> situation? At least this is a real oddball case. It's not something
> that folks are very likely to hit at all.
This patch fixes the issues in below two reports. Thanks.
https://lore.kernel.org/all/fcf89147-440b-e478-40c9-228c9fe56691@intel.com/
https://lore.kernel.org/all/202209141701.e293ea84-yujie.liu@intel.com/
Comparison of test results:
=========================================================================================
compiler/kconfig/rootfs/runtime/scale_type/tbox_group/testcase:
gcc-11/i386-randconfig-a013-20211012/debian-i386-20191205.cgz/300s/srcu/vm-snb/rcuscale
commit:
652c5bf380ad01 ("x86/mm: Refuse W^X violations")
0718e6a68e2a7c ("nx.patch")
652c5bf380ad018e 0718e6a68e2a7cb20800b1b1372
---------------- ---------------------------
fail:runs %reproduction fail:runs
| | |
6:6 -100% :6 dmesg.BUG:unable_to_handle_page_fault_for_address
6:6 -100% :6 dmesg.EIP:__change_page_attr
6:6 -100% :6 dmesg.Kernel_panic-not_syncing:Fatal_exception
6:6 -100% :6 dmesg.Oops:#[##]
6:6 -100% :6 dmesg.WARNING:at_arch/x86/mm/pat/set_memory.c:#__change_page_attr
=========================================================================================
compiler/kconfig/rootfs/runtime/tbox_group/test/testcase/torture_type:
gcc-11/i386-randconfig-a004-20211104/debian-i386-20191205.cgz/300s/vm-snb/cpuhotplug/rcutorture/tasks-tracing
commit:
652c5bf380ad01 ("x86/mm: Refuse W^X violations")
0718e6a68e2a7c ("nx.patch")
652c5bf380ad018e 0718e6a68e2a7cb20800b1b1372
---------------- ---------------------------
fail:runs %reproduction fail:runs
| | |
6:6 -100% :6 dmesg.BUG:unable_to_handle_page_fault_for_address
6:6 -100% :6 dmesg.EIP:verify_rwx
6:6 -100% :6 dmesg.Kernel_panic-not_syncing:Fatal_exception
6:6 -100% :6 dmesg.Oops:#[##]
6:6 -100% :6 dmesg.WARNING:at_arch/x86/mm/pat/set_memory.c:#verify_rwx
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index 216fee7144ee..005492257abb 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -844,6 +844,7 @@ static void __init x86_report_nx(void)
> /* 32bit non-PAE kernel, NX cannot be used */
> printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
> "cannot be enabled: non-PAE kernel!\n");
> + __supported_pte_mask &= ~_PAGE_NX;
> #endif
> }
> }
> diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
> index 1a2d6376251c..f8162fe94bd0 100644
> --- a/arch/x86/mm/pat/set_memory.c
> +++ b/arch/x86/mm/pat/set_memory.c
> @@ -587,7 +587,7 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star
> {
> unsigned long end;
>
> - if (!cpu_feature_enabled(X86_FEATURE_NX))
> + if (!(__supported_pte_mask & _PAGE_NX))
> return new;
>
> if (!((pgprot_val(old) ^ pgprot_val(new)) & (_PAGE_RW | _PAGE_NX)))
prev parent reply other threads:[~2022-09-20 3:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 15:27 Dave Hansen
2022-09-16 3:59 ` Yujie Liu
2022-09-19 18:14 ` Edgecombe, Rick P
2022-09-19 18:30 ` Dave Hansen
2022-09-20 3:12 ` Yujie Liu [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=YykvlsPEHZRU65IM@yujie-X299 \
--to=yujie.liu@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®