From patchwork Fri Jan 19 01:50:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 863282 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zN5B20S5rz9s81 for ; Fri, 19 Jan 2018 13:58:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ilUt9cKW"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zN5B163y8zDqvm for ; Fri, 19 Jan 2018 13:58:33 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ilUt9cKW"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::244; helo=mail-qt0-x244.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ilUt9cKW"; dkim-atps=neutral Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com [IPv6:2607:f8b0:400d:c0d::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zN3kM5mdszF0xg for ; Fri, 19 Jan 2018 12:52:59 +1100 (AEDT) Received: by mail-qt0-x244.google.com with SMTP id m59so422576qte.11 for ; Thu, 18 Jan 2018 17:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=sztvT33L+/fpBb7qUGs28sh0AsYayfdECEyKDyCkE5k=; b=ilUt9cKWdwKr71ZXFmpP8o3i7DOuse2OwHF/ThEZoD6/uNhRMnG7qz7tpV13j7IIiD iqtXWzWs00v+LDNxajf6TI9OOh3b6AiiYloJlXlfOVOo6IfVCVDGvLq0tHRKEEmjNRdg 7QHUxpwkBtL/fe9si5i+VhQeq7xSic3uehr0ATd+CSuH1USO/wqNSEJX4XUbfrJwEb+g GFA4pqgdMrAVBcA7XHDga63ydwWhrQNcANmSvw3wEazY59tZK1MU+9wMG5TlxUGF0vpO LL+c/cNPyvVYmmngjgQvavXQ/PtiOcYKlsY/2LLeXIf8EqzvizSnJVO1TGoGlQU9BUCr UWmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=sztvT33L+/fpBb7qUGs28sh0AsYayfdECEyKDyCkE5k=; b=XDpmIUlLpBJGCZttLtnx+G5lpGt585cU6Dd4fMQrlEAB0YgNg45Gr/lt6mm29qGRYt 09l1fY5apDX2BR8dx+7pqqipngU415bIp2fzABlofZh1lqACkHGCmtzcgOdixNVH2NaE adTfFwOfHB6zJyT/PI4DwnQPlUf+uY0vbfQDYHr2FXj+EhKPdvJyXejcbyxqDnNB6IrI 7a+Wme1Cp/cNsHmMOX+hhszL3q4ZcqAkftM3iaqIhXNaucBFeftlYrnIFJ/AN12C9DVM NjkPK9TfFolsD4uW5TYwOG6cNGNv9LFB76an8rsg83ZemJbafEzTp6JlQVjMEDsH8Ara ZJOw== X-Gm-Message-State: AKwxyteJVSqz0YknIjNxzAHzRIYeF8KblGYEHrOP/sZSmiMK9gbjzcgH Ytd6u5bPRgRnV8Nr0iHz+yY= X-Google-Smtp-Source: ACJfBosqr7ULYWEvFSYASExzDCglMlmTp50Qosn/2eYbpYUSFH5WGFSaRR40Uwfpty5OsgRNGgHhTQ== X-Received: by 10.200.41.143 with SMTP id 15mr9354256qts.247.1516326777901; Thu, 18 Jan 2018 17:52:57 -0800 (PST) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id c127sm5483161qke.78.2018.01.18.17.52.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 17:52:56 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Subject: [PATCH v10 26/27] mm, x86 : introduce arch_pkeys_enabled() Date: Thu, 18 Jan 2018 17:50:47 -0800 Message-Id: <1516326648-22775-27-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1516326648-22775-1-git-send-email-linuxram@us.ibm.com> References: <1516326648-22775-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, ebiederm@xmission.com, linux-doc@vger.kernel.org, x86@kernel.org, dave.hansen@intel.com, linux-kernel@vger.kernel.org, linuxram@us.ibm.com, mhocko@kernel.org, linux-mm@kvack.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, linux-kselftest@vger.kernel.org, bauerman@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, khandual@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Arch neutral code needs to know if the architecture supports protection keys to display protection key in smaps. Hence introducing arch_pkeys_enabled(). This patch also provides x86 implementation for arch_pkeys_enabled(). Signed-off-by: Ram Pai --- arch/x86/include/asm/pkeys.h | 1 + arch/x86/kernel/fpu/xstate.c | 5 +++++ include/linux/pkeys.h | 5 +++++ 3 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h index a0ba1ff..f6c287b 100644 --- a/arch/x86/include/asm/pkeys.h +++ b/arch/x86/include/asm/pkeys.h @@ -6,6 +6,7 @@ extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val); +extern bool arch_pkeys_enabled(void); /* * Try to dedicate one of the protection keys to be used as an diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 87a57b7..4f566e9 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -945,6 +945,11 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, return 0; } + +bool arch_pkeys_enabled(void) +{ + return boot_cpu_has(X86_FEATURE_OSPKE); +} #endif /* ! CONFIG_ARCH_HAS_PKEYS */ /* diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h index 0794ca7..3ca2e44 100644 --- a/include/linux/pkeys.h +++ b/include/linux/pkeys.h @@ -35,6 +35,11 @@ static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, return 0; } +static inline bool arch_pkeys_enabled(void) +{ + return false; +} + static inline void copy_init_pkru_to_fpregs(void) { }