Received: by 10.223.176.46 with SMTP id f43csp307982wra; Thu, 18 Jan 2018 17:55:53 -0800 (PST) X-Google-Smtp-Source: ACJfBos9IaiBD7Q4kMJSTN98DuxKpwLOjtKTnD2k81wk+cSFCcVlQSz6q+3ojbknqvAdpWi9nOYR X-Received: by 10.101.97.204 with SMTP id j12mr38386990pgv.266.1516326953496; Thu, 18 Jan 2018 17:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516326953; cv=none; d=google.com; s=arc-20160816; b=PQE35rgZwZEVqiaznwmGBWeutY3NAYnOFygOKTU717sE/7djbuGeYuKId/C7m4mxBD KIUs4P75QjOAPlxPMGpp8jPbRMQ5+k+QL279yq6+2fze+wRdsvKTPRdLl/yJwCA4zdPu PbkS6lGl7LElHLc1XUwzUI1tMkejGRn1mtLFRoD2SIMc1xV1SzQVsQH0n6KmzVKN7tQX P9iS8harjP66cHxsmfr0X3Hd8fbBRwUdQEBqsaw71bInGtmumBz02ptqVo1raFlIbED+ ZaBnkA1mEIcqDWZS+Z+tAF+2si0Eq4dWPpCqm9I8MPtCyHSGDqR9irOaiETzFxLj4ufy Bd2g== 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=SmWIPNL9MTaxuVElIxS6c34H+Mh3PU5KbBtsaVSuT6I=; b=KQhMAtjwQ7N8iYkXzz3dCuun4VhIbZ4UmIZ6LqRMVfLrp216aZeZlS2vNaL0yBT3pP YGShu1qykc3d99qzTNIVbOHuoReMmHc5KGXGjnhMByJb56GdSK3r05jCqG1U+pckV/SG 17ir41+tN+poT+pLQYV7r2ekHt1iC5Qdvp/eHD9W9uvcO9hNjIz7jvfYZtUK3CIYmIff /Iax5gDElv9L6f2cXsRisOpNGlvGN4BhTDznU8sEAiTkMAId1U+y2yCKa2CQhJQaYChc 3Rb/4MwMJG9GjmhQH0DQAi632RXGWmTDsnLrJeQiDj1TBFX3d6K4Qgw8OESH2XWRQgiC 5eDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=T4aqMCYh; 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 k71si7477359pge.131.2018.01.18.17.55.40; Thu, 18 Jan 2018 17:55:53 -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=T4aqMCYh; 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 S932956AbeASByF (ORCPT + 99 others); Thu, 18 Jan 2018 20:54:05 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:37987 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755870AbeASBxC (ORCPT ); Thu, 18 Jan 2018 20:53:02 -0500 Received: by mail-qt0-f196.google.com with SMTP id z10so445600qti.5; Thu, 18 Jan 2018 17:53:02 -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=SmWIPNL9MTaxuVElIxS6c34H+Mh3PU5KbBtsaVSuT6I=; b=T4aqMCYhjrbqTuUGW+Q0i7bsOCbXT42v/0SALAVAfFqSJBlmaIuIlRV/oiqpZkSG9U AssxlsyaMdRMNT7lRHD1QOv9kM/Io6Hfb3AGFdYnlE2LitY2NnZ0D0DQ6TtOlzJgf2/b YKwBcV46vHF426NnawuwjrDkLhykKt31bQ4VvrHeltOwucuhDC9WLLX335WyLiv7VFco eqsL4xdPeV+ip/P11cIG1F0v2Lsn3FxUdUETPGazlPQ3XxGhGs7A0uwtrWcjRya6hrWC nkvtYuXvYvabDHu+/VTvk96a+nIIckcAFKTBaBvwAI4wPQdYmHoa8kSBuG9QilU0yTbs XlUg== 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=SmWIPNL9MTaxuVElIxS6c34H+Mh3PU5KbBtsaVSuT6I=; b=LxbYOkbZw+c9VK4Mp/ZhlRv+sSCkbMq7k5fHuW/LyVY8dTdVRz3HsKxWuzyeZVzlSE TwKQ2jlCvP7MchM1Vkk4Ls1Zxxb5V0W1WjD1pm/woJ+/gewJ0Tx4h2Uw+DD3zszCcoKy smRysfFAv908Ei1s8NNcIsGhXROzfnO/VwcmJskHyAFzCdjm0Cx18oOG7WeGyf0V0vuY P5SKZvTYMbEsZNq28trODIY+kwslOaoLukqxiRpm9tAKAwM57WpCx3U9ZN7JXCaq5ZgK SKqdRY9DCAmMFu+FRxBTscvEG+qKItX2dA1yucLHDIQycWNQstvwdKKX8CXBb5n50M70 fd6A== X-Gm-Message-State: AKwxyteIRPYGuo5qOwUCzwMMFeNEVVsK8UnV4tsz6+s487emLP3IiWLJ 8FkzYRjzvU0csS56uFjRG8k= X-Received: by 10.55.22.29 with SMTP id g29mr65417541qkh.26.1516326781305; Thu, 18 Jan 2018 17:53:01 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 17:53:00 -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 27/27] mm: display pkey in smaps if arch_pkeys_enabled() is true Date: Thu, 18 Jan 2018 17:50:48 -0800 Message-Id: <1516326648-22775-28-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 Currently the architecture specific code is expected to display the protection keys in smap for a given vma. This can lead to redundant code and possibly to divergent formats in which the key gets displayed. This patch changes the implementation. It displays the pkey only if the architecture support pkeys. x86 arch_show_smap() function is not needed anymore. Delete it. Signed-off-by: Ram Pai --- arch/x86/kernel/setup.c | 8 -------- fs/proc/task_mmu.c | 11 ++++++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 8af2e8d..ddf945a 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1326,11 +1326,3 @@ static int __init register_kernel_offset_dumper(void) return 0; } __initcall(register_kernel_offset_dumper); - -void arch_show_smap(struct seq_file *m, struct vm_area_struct *vma) -{ - if (!boot_cpu_has(X86_FEATURE_OSPKE)) - return; - - seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); -} diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 0edd4da..4b39a94 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -728,10 +729,6 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask, } #endif /* HUGETLB_PAGE */ -void __weak arch_show_smap(struct seq_file *m, struct vm_area_struct *vma) -{ -} - static int show_smap(struct seq_file *m, void *v, int is_pid) { struct proc_maps_private *priv = m->private; @@ -851,9 +848,13 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) (unsigned long)(mss->pss >> (10 + PSS_SHIFT))); if (!rollup_mode) { - arch_show_smap(m, vma); +#ifdef CONFIG_ARCH_HAS_PKEYS + if (arch_pkeys_enabled()) + seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); +#endif show_smap_vma_flags(m, vma); } + m_cache_vma(m, vma); return ret; } -- 1.7.1