From patchwork Fri Oct 24 09:57:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jungseung Lee X-Patchwork-Id: 5145301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 925509F374 for ; Fri, 24 Oct 2014 10:00:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 885532025A for ; Fri, 24 Oct 2014 10:00:27 +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 8F4FB20251 for ; Fri, 24 Oct 2014 10:00:26 +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 1XhbdQ-0006CB-SW; Fri, 24 Oct 2014 09:58:16 +0000 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhbdN-00062D-59 for linux-arm-kernel@lists.infradead.org; Fri, 24 Oct 2014 09:58:13 +0000 Received: by mail-pd0-f174.google.com with SMTP id p10so1184539pdj.33 for ; Fri, 24 Oct 2014 02:57:51 -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=BoatezBabi0DRwXHctz+kasVK+xncQVGrjTQq56dKmY=; b=gMuf7GZdcs4RBqJM7ZJzvpCMBNotzGnuGVPB+pLc+shajm+6ZD7JVx64ST8gxl6xxh wVoutJYTc/OMlt+ywEZE58r8XbVpX8jfNPCV1wDD9hsSw6wE3AN7CuC3ucSlztbZjTm+ 7Cm7NH9Ih9z8X8HcUNc13nynTU4GbkFbvmQPTl1v4YYPrG1GW11FO2L1B+kX0uAz8O// XQVR9h2fEZPMnqDqFL6ds22d30/FvSeZvGxNsVxKE44L843eS5dTNLMRQNoQcSU8EkIs d5dw95H9oJANZN5PTjyIUujTf6RzW1EKLi9D6/N7DK0NpvvoQ/fu2wHYt8VA0EPrYK/Y VeLw== X-Received: by 10.70.3.196 with SMTP id e4mr3481178pde.35.1414144671429; Fri, 24 Oct 2014 02:57:51 -0700 (PDT) Received: from localhost.localdomain ([165.132.120.48]) by mx.google.com with ESMTPSA id jy14sm3489661pbb.71.2014.10.24.02.57.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Oct 2014 02:57:50 -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 1/2] arm: hwcap: add new hwcap for identifying PXN bits Date: Fri, 24 Oct 2014 18:57:34 +0900 Message-Id: <1414144655-25204-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_025813_381859_1ABBFB5E X-CRM114-Status: GOOD ( 13.64 ) 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. This patch adds new HWCAP defines to describe new feature. On an implementation that does not include the LPAE, PXN is optionally supported. 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..a06faba 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) /* Privileged execute-never */ /* * 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..48828fe 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", + "pxn", NULL };