Received: by 10.223.176.46 with SMTP id f43csp307956wra; Thu, 18 Jan 2018 17:55:51 -0800 (PST) X-Google-Smtp-Source: ACJfBotgCmgEE5L7a+ZT6hAuFOmmCktD1OeUOdgnLnoZ8Eoh7G4uNBOkOi3abbbI8mE2bdZuPrA/ X-Received: by 10.99.160.88 with SMTP id u24mr30299094pgn.122.1516326951324; Thu, 18 Jan 2018 17:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516326951; cv=none; d=google.com; s=arc-20160816; b=Yjg0HcorZRz7KoMnZ5UhI4psw6Oh7gv+NBGXcRQsduFKc1/Tq76pnu5vjWfWbWer5b I626pToPpsm2V/6zz2jqwb3ASBobVMQ34a1mimT7Lc8wy137gfr71pfncuDki+aDjbgq rMR6BNuWFO5dTl08xMpc8UppZiKtNSf8EQuXQv8p0DRs1MJzUOxqameIvGanyrU3chAg YToejgsMtftSxIl/a9PvHDT9SHz584mldSPYU512sq2Ot+Sy3oSx90s1iCwzC+itl+wX 7oV+n30GC+Bneg+UUe4y4MSytn2jTdhU6z7bBRH2leWBXQSWDVZrZYkhVjklc/wj35DQ EEvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=sztvT33L+/fpBb7qUGs28sh0AsYayfdECEyKDyCkE5k=; b=ilMZGB+WfZeuJM4i5y056MPJIXfbCsLhhVEkgHfc+tKhbW7FwjsR0CxrdNZUklUkPp THa5hMq9ZwoJk2OP+W0uPnQjShaxmO7BV1qCpajr1dkt7d8ycQ5ZI9lyeV5zM+Y6lX7F tQKGIqad1sZQzZg1qdN+W90QhKdBvfkHHI7ouBN0nTH0T3c8tTg9TTAFyhv8TQ1D7W0k QUP3Jax67wPpsDa0gSj+2LSp+2XyY7y+2wydISMLOq2TkjHTGdsh+1899qAptO38n6Qf p/T2hxXiMBz6P3JpPmyEf9xuRWVhXPe8Gy1VR/D3BPNaVlOaceA/ad6jiEA8hhssVZPd XsaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ilUt9cKW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u74si7157552pgc.445.2018.01.18.17.55.37; Thu, 18 Jan 2018 17:55:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ilUt9cKW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932972AbeASByl (ORCPT + 99 others); Thu, 18 Jan 2018 20:54:41 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:34937 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755856AbeASBw7 (ORCPT ); Thu, 18 Jan 2018 20:52:59 -0500 Received: by mail-qt0-f196.google.com with SMTP id u10so459686qtg.2; Thu, 18 Jan 2018 17:52:58 -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=eLhEw5XQVTxQXr5IhZSneViVf6hX4dvB7WTVgY4fUQPBErSDhTzTYzv9Pzvpy19OU8 U9RRJBx0/hSCVtRBqvrCtZLQLyzHDrxOLT/lEko8I8+++EE3/6ZS6Lifbp5MYJTmUW6x PQOUpemn+gFC2MZCNzgPOo9u0I3WW0ZOHrAY+dl6hBOMcx9UMGiY7HiU4rjDtqQhULaw znLK3AR79mcysb20ih4o2KSdhhYij95bxOB/QKTiPxt4DWJtH1xkVRcp6qeQ2OYeoxKe NdUdi0fgcIlDWhT+P9pIsCeMi8dbThuJW2JfxxwQUY1IfCiTvjSZoDqqrgTpWUt3x+Wh +tNQ== X-Gm-Message-State: AKwxyteKVxlQ+LSaaHPUX7+/l7BEGFbm6+rsCGvR9PjBaG/BqaH5PRm/ Ui4zux3ZGTThsjR7yOfX5tw= 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 Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, linuxram@us.ibm.com 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { } -- 1.7.1