Received: by 10.192.165.148 with SMTP id m20csp4407280imm; Tue, 8 May 2018 08:01:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpsOjR85YWnjMfdYDroLHaB3ChSc1+lEsrG6nj96QmYq3gXuCaNICLaEE9M0CVBmoeU4l3y X-Received: by 2002:a63:7c0b:: with SMTP id x11-v6mr30667601pgc.384.1525791672885; Tue, 08 May 2018 08:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525791672; cv=none; d=google.com; s=arc-20160816; b=zwwByhdKjCLzkUuZKeIdkiahIvmP9Pz7QM5kSAkZnhZZ4G45LyiTTOgmnz295g+++Z +T345mPpbYj7eCwP+6hyJC+E/Q5k60pbSQfeKCVriE2x+f18oHDSO848+uXyUp/BlQ+3 7npBGystQqNdqIc8vR3kADSLEXrsC65cjoleWVm6EpoQh5FRGgX+xHz9yhrxQNt1Wmmh UJc12zT//+OUifjnA5ezzVfo4yCb1DY6Qc6GT/980DaBKOdDIl7tLg15zQn55Ijga8Cl jJk0OZsdCPcIEnZ/v+7o6vbncmSL5UnduLF73ntqikPZGe0wm4RHzwRzRsJLnBqcd21X 6rWA== 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:arc-authentication-results; bh=s0rvmMzERKbmGULHFR3ygLwYtoXakGB2m7js4Rc+j+k=; b=u9OSzPePHSJl0IvYsIlBdJMiq3FDktpotSvuV6VUniJA171N1QYhrl9k+M5gKQlKru u6/8cDBtS6HyMEsyfoVhweZ9EmrJnVW/75vOdks8fYYoaQv6hUFIPO3yLSddxEq1PyOQ n0vZRcLDFMX++1gMkLx5t1jImTvAUJyPe7SWac2nZ05sg0Akef2UsXZ5xlGjpkxaYFsv K+HtlHpDAfcGFcyy8X76tOWbgOzzS88FlJMd0UDmh+YXcyawmfVMVO/6Eu2xfTdxt/lX 1eRrk5hwpFOKO67o6uEV6jtYiWYR7vz1NdUoWqXBhyVEfVhOCqmreepjL4rxw/V7itsM UVMg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1-v6si23353618plt.276.2018.05.08.08.00.58; Tue, 08 May 2018 08:01:12 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932952AbeEHPA2 (ORCPT + 99 others); Tue, 8 May 2018 11:00:28 -0400 Received: from ozlabs.org ([203.11.71.1]:35025 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932897AbeEHPAD (ORCPT ); Tue, 8 May 2018 11:00:03 -0400 Received: by ozlabs.org (Postfix, from userid 1034) id 40gN2B3tBJz9s7G; Wed, 9 May 2018 01:00:02 +1000 (AEST) From: Michael Ellerman To: linuxram@us.ibm.com Cc: mingo@redhat.com, linuxppc-dev@ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com Subject: [PATCH 8/8] mm/pkeys, x86, powerpc: Display pkey in smaps if arch supports pkeys Date: Wed, 9 May 2018 00:59:48 +1000 Message-Id: <20180508145948.9492-9-mpe@ellerman.id.au> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180508145948.9492-1-mpe@ellerman.id.au> References: <20180508145948.9492-1-mpe@ellerman.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ram Pai 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, i.e arch_pkeys_enabled() returns true. x86 arch_show_smap() function is not needed anymore, delete it. Signed-off-by: Thiago Jung Bauermann Signed-off-by: Ram Pai [mpe: Split out from larger patch, rebased on header changes] Signed-off-by: Michael Ellerman --- arch/x86/kernel/setup.c | 8 -------- fs/proc/task_mmu.c | 8 +++----- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 5c623dfe39d1..2f86d883dd95 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1312,11 +1312,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 c2163606e6fb..93cea7b07a80 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -730,10 +731,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) -{ -} - #define SEQ_PUT_DEC(str, val) \ seq_put_decimal_ull_width(m, str, (val) >> 10, 8) static int show_smap(struct seq_file *m, void *v, int is_pid) @@ -838,7 +835,8 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) seq_puts(m, " kB\n"); } if (!rollup_mode) { - arch_show_smap(m, vma); + if (arch_pkeys_enabled()) + seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); show_smap_vma_flags(m, vma); } m_cache_vma(m, vma); -- 2.14.1