linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: js07.lee@gmail.com (Jungseung Lee)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RESEND 1/2] arm: hwcap: add new hwcap for identifying PXN bits
Date: Fri, 24 Oct 2014 20:45:54 +0900	[thread overview]
Message-ID: <1414151155-26890-1-git-send-email-js07.lee@gmail.com> (raw)

Modern ARMv7-A/R cores can optionally implement below new
hardware feature:

- PXN:
Privileged execute-never(PXN) is a security feature. PXN bit
determines whether the processor can execute software from
the region. This is effective solution against ret2usr attack.
On an implementation that does not include the LPAE, PXN is
optionally supported.

This patch adds new HWCAP defines to describe new feature.

In ARM world, elf_hwcap is used both internally in the kernel and
for user space to keep track of optional features.
HWCAP_PXN is exceptionally not exposed to user space since the user
doesn't need to know.

Signed-off-by: Jungseung Lee <js07.lee@gmail.com>
---
 arch/arm/include/uapi/asm/hwcap.h | 1 +
 arch/arm/kernel/setup.c           | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/arch/arm/include/uapi/asm/hwcap.h b/arch/arm/include/uapi/asm/hwcap.h
index 20d12f2..7075207 100644
--- a/arch/arm/include/uapi/asm/hwcap.h
+++ b/arch/arm/include/uapi/asm/hwcap.h
@@ -27,6 +27,7 @@
 #define HWCAP_IDIV	(HWCAP_IDIVA | HWCAP_IDIVT)
 #define HWCAP_LPAE	(1 << 20)
 #define HWCAP_EVTSTRM	(1 << 21)
+#define HWCAP_PXN   (1 << 22)       /* set if support the PXN attribute */
 
 /*
  * HWCAP2 flags - for elf_hwcap2 (in kernel) and AT_HWCAP2
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index c031063..22cd19a 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -390,6 +390,10 @@ static void __init cpuid_init_hwcaps(void)
 
 	/* LPAE implies atomic ldrd/strd instructions */
 	vmsa = (read_cpuid_ext(CPUID_EXT_MMFR0) & 0xf) >> 0;
+
+	if (vmsa >= 4)
+		elf_hwcap |= HWCAP_PXN;
+
 	if (vmsa >= 5)
 		elf_hwcap |= HWCAP_LPAE;
 }
@@ -1015,6 +1019,7 @@ static const char *hwcap_str[] = {
 	"vfpd32",
 	"lpae",
 	"evtstrm",
+	"",	/* HWCAP_PXN : not expose to user */
 	NULL
 };
 
-- 
1.9.1

             reply	other threads:[~2014-10-24 11:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24 11:45 Jungseung Lee [this message]
2014-10-24 11:45 ` [PATCH RESEND 2/2] arm: Support for the PXN CPU feature on ARMv7 Jungseung Lee
2014-10-24 11:53 ` [PATCH RESEND 1/2] arm: hwcap: add new hwcap for identifying PXN bits Russell King - ARM Linux

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=1414151155-26890-1-git-send-email-js07.lee@gmail.com \
    --to=js07.lee@gmail.com \
    --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
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).