From patchwork Fri Oct 24 11:45:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jungseung Lee X-Patchwork-Id: 5146521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5A4F1C11AC for ; Fri, 24 Oct 2014 11:48:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8072B20256 for ; Fri, 24 Oct 2014 11:48:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9436201F5 for ; Fri, 24 Oct 2014 11:48:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhdKG-0002YT-Af; Fri, 24 Oct 2014 11:46:36 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhdKB-0002R2-OG for linux-arm-kernel@lists.infradead.org; Fri, 24 Oct 2014 11:46:32 +0000 Received: by mail-pa0-f42.google.com with SMTP id bj1so1005499pad.29 for ; Fri, 24 Oct 2014 04:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gJFKBcvEpw21XuuA/CIivPU6Yc6TzBaDyf6XEKmsKu4=; b=dYZXPE9xxraqMQVDHs7vS5JRT8dav+RS5SPoxZVl24pl58R9w8YGKaoWZk4Al76Kko CoY9XgEbfW1w+6QUQaQzkLIOzUN+IeMJgH4DxEo0MWioT7LwUl1YzKzuUGyxtI7tSQV8 kluarCvt9fx7aImKhyUQmOIpf6x+63Xzhxs8h43a6bj4hLXEUWVlitD5XIhVVqjIBuii 1ftLFMnSMFReRAJbn3WNvyMXkJJvXLDv/nzqxT2lDLCE/M7vQ07nrX3HQr04obNONX4x LIHLYqBBq8xLX7AsEv+xvwI1CBu1MS+tHAqyJB6ThF5JahXiUkn5JDznYz6NHoo/253B TtSg== X-Received: by 10.68.164.65 with SMTP id yo1mr4090783pbb.126.1414151170814; Fri, 24 Oct 2014 04:46:10 -0700 (PDT) Received: from localhost.localdomain ([165.132.120.48]) by mx.google.com with ESMTPSA id qx4sm3751851pbc.14.2014.10.24.04.46.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Oct 2014 04:46:09 -0700 (PDT) From: Jungseung Lee To: Russell King , Catalin Marinas , Ard Biesheuvel , Santosh Shilimkar , Magnus Damm , Laura Abbott , linux-arm-kernel@lists.infradead.org, Will Deacon Subject: [PATCH RESEND 1/2] arm: hwcap: add new hwcap for identifying PXN bits Date: Fri, 24 Oct 2014 20:45:54 +0900 Message-Id: <1414151155-26890-1-git-send-email-js07.lee@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141024_044631_815181_74E63E19 X-CRM114-Status: GOOD ( 14.98 ) X-Spam-Score: -0.8 (/) Cc: Jungseung Lee X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 };