From patchwork Tue May 8 14:59:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 10386301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCDDD60236 for ; Tue, 8 May 2018 15:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB06428E49 for ; Tue, 8 May 2018 15:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDF2C28DBD; Tue, 8 May 2018 15:00:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50C1628E42 for ; Tue, 8 May 2018 15:00:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD4D46B0297; Tue, 8 May 2018 11:00:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C7AC76B0298; Tue, 8 May 2018 11:00:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF9536B0299; Tue, 8 May 2018 11:00:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 674286B0297 for ; Tue, 8 May 2018 11:00:06 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id bd7-v6so1921391plb.20 for ; Tue, 08 May 2018 08:00:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=s0rvmMzERKbmGULHFR3ygLwYtoXakGB2m7js4Rc+j+k=; b=WVmPrUnNTpnjMgM9IPT6sCrlBistvza5i4y4pLzbx79tpe9sgZYRG0vPk/ZgzuNP92 YPjdsezwmG4QelXixpi+cqb09t2jRCZLxwIYnXH4O+05jA0DDsflQk1EMWLNunKciqBu ntEpi5WHxQIF+w1i21aR3DTDGBlh5kJbcH/JupyC7EHHGcnHaFk8PsJOiAnO3nyVSmf/ p/Y3PMngii+Y+wnTGm6vwpO4/ZJ3nSdaqE9PZ4WNeCVC1oMEt4SRMAAUhGZGoAVVnqdY gELtmp3oReEGacUAwH+MmVh8ZMG4JCBIkF7cAmcUGGIfMcEqeOASjkB5+jhV6d6lZjBf 79CQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of michael@ozlabs.org designates 203.11.71.1 as permitted sender) smtp.mailfrom=michael@ozlabs.org X-Gm-Message-State: ALQs6tDLjbfU6PiAx2IKKGmwFIK1p5EvH1zAWIc4MTtG8I1OzKS2KMN5 62GtMtohwSI7VF/qOJqwI66PzwhgbFFVfvkhFBX2uteTa8A7+p8/cT30k+Ra2v9DvnhTIvxSLba EjqzZSaO1c380rR8/QSsHDzdM3liNW2F4qgt2GrdtiA/fNnBI4obZch+H/8p4g/8= X-Received: by 2002:a65:5645:: with SMTP id m5-v6mr2435191pgs.175.1525791606083; Tue, 08 May 2018 08:00:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoRRnp+IFzowk8dlU9AY2xiJcK+gFs8qLhaXLgmhimojUnpNLTVp8Rdl4vn6wT542GpyPqj X-Received: by 2002:a65:5645:: with SMTP id m5-v6mr2435150pgs.175.1525791605298; Tue, 08 May 2018 08:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525791605; cv=none; d=google.com; s=arc-20160816; b=DBCanKjIA3yzABESFPB0K5o7rYVjUXMIIbsc2eAECOXw2kCosnBrRBdu3Ke4Tcu+UE JNEDqsYE6XvUbm1ywDGPRaL03OK9zcgtNLy9zfcuOUXKbpqQTmAZ88UJQVTFMW8oYssW j55nrZ3L0dqWNlv6Muk/Zjq01k/UF2Shtjlsyxe6e839B66wrzEpUTPDufXlV53Mifit Jr1H3PpS0jAubEB1biUsN5inATGo4Nfps5Sri7AFS6MRCgCfA3WqxOVKOZhhTPz11OwI ZeWqhdLMfG3hniABoOt/V/QADw++snD2JGTpVHKQi64q/O1WGkTDWe+inR9oLfIedrqs NFCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=s0rvmMzERKbmGULHFR3ygLwYtoXakGB2m7js4Rc+j+k=; b=eIy4ZgX0WkR+DyRtLO2XbZLC2GDA5RHRFZjlBPUkikFjOAeXB4aCnwCXGE3r87V/M5 Twgq7xsV0eZ7KM8b5Sr6OeP5StHFnEIgLOauhVpB/MeKxhD3Tuo8xl8jc+CdPJQu4df/ LsNeb2TGdqBE3piptoPk0Bm+gfzgxNtrxUAVYrZfx5WvVyi8vT36nCezD/8FM9IqK2zb +peJxJCwXWQEfGYBfIb2/j+wFdT2g7c21E3gb9C88f+vJ6+BP/EnOZQ9wAz4PkXQ8kmx HT4qTgtFUHkz3B5tbvU9aS+DzktY8o1XwOUVxlymcU8EwoHPCX6xT3wsklSdx2l4rE5j jE+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of michael@ozlabs.org designates 203.11.71.1 as permitted sender) smtp.mailfrom=michael@ozlabs.org Received: from ozlabs.org (ozlabs.org. [203.11.71.1]) by mx.google.com with ESMTPS id y14-v6si19511453pgo.286.2018.05.08.08.00.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:00:05 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@ozlabs.org designates 203.11.71.1 as permitted sender) client-ip=203.11.71.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of michael@ozlabs.org designates 203.11.71.1 as permitted sender) smtp.mailfrom=michael@ozlabs.org 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Dave Hansen --- 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);