From patchwork Wed Feb 21 23:52:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 876428 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 3zmvcG0zgyz9sWH for ; Thu, 22 Feb 2018 10:59:58 +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="mjvpUOx9"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zmvcF6q8RzDrK3 for ; Thu, 22 Feb 2018 10:59:57 +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="mjvpUOx9"; 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::241; helo=mail-qt0-x241.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="mjvpUOx9"; dkim-atps=neutral Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) (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 3zmvSR0T5kzDrLC for ; Thu, 22 Feb 2018 10:53:08 +1100 (AEDT) Received: by mail-qt0-x241.google.com with SMTP id k13so4229245qtg.5 for ; Wed, 21 Feb 2018 15:53:07 -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=C9ObSsYZHPDk1HYTIPd2/+d1VbYagCwTCzsAVG9RlHk=; b=mjvpUOx9uQ0yYwIC7LhjMxa2yeVuuKRCnDe5QWRNUxTn5/QUwcG99H9uQ7+f++oy8U tkxHhbqdTh7lrlmD3+WtvVziBsd6KHFss8giFtWRQFgk5GruXZpTGysHiwRWSel/E3GO UPfGnXxsa/l2XGBm/mDJgQ6MT2lhg1g31PSGw4vVJv/WezwcQzwfRfTYNvSzto/Dxp+i xj9SX1pU5WgMuHc+ddomOkHH2qifxVfv9gxGQXC7vfcLOPxOy0ditjGoLM9QhzlINocf NIVXiNr3qPnE9zpbxdCrUCKmmWvl5o5Afd2DTUQAwq6LFYbMAkHz+C6mJcmsRTO1xyx7 Hryw== 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=C9ObSsYZHPDk1HYTIPd2/+d1VbYagCwTCzsAVG9RlHk=; b=RzaD/AEjcMueEFkHl0ok8TtUyRq9fGovwxFheBRxJu2HzIwMKU0a2AYcw19KvoCVim hT+mziLfZEawV5sggH7qBgQAjepTr/ljaJiikzdYqWUDjzb6/zGv60qZbVYEDhCgz9O5 9pH91XIhLqS3r5Mo929yt2O+LwojgNvCzWn0mq0WH0/MxQKIoIlNf1+Jc7l6TSx+ce2O hs2I4sGRvyRLPConDT1kJIK5RgbUjPCgaUUEIbhOaZ3tYFbmmdZnz/YgWuGfC0ToPGJn KqiEXcUkeSG3jEli8gZXvu5hQoHOGGpMJXGAtwSrmBnFwC75nxCdb87oZOlhepba/HVS 4aGA== X-Gm-Message-State: APf1xPCZnl3tcyWftubzur5geopaWHeJKN3AbtmgLKZt3tpQ5jAbE2W8 jkBYasjE7maHaj292vgGC2Y= X-Google-Smtp-Source: AH8x226//I4uGiKszE76+TqbG/ojkVi/9TlQeu4kATnWLRcan9MXULDxJ0ypQBMj9bmKgWzefjF7KQ== X-Received: by 10.237.56.34 with SMTP id j31mr8324297qte.208.1519257186180; Wed, 21 Feb 2018 15:53:06 -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 b25sm3804881qte.40.2018.02.21.15.53.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 15:53:05 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org Subject: [PATCH v12 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled Date: Wed, 21 Feb 2018 15:52:16 -0800 Message-Id: <1519257138-23797-2-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519257138-23797-1-git-send-email-linuxram@us.ibm.com> References: <1519257138-23797-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 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, corbet@lwn.net, ebiederm@xmission.com, msuchanek@suse.com, fweimer@redhat.com, arnd@arndb.de, dave.hansen@intel.com, x86@kernel.org, linuxram@us.ibm.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, 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" VM_PKEY_BITx are defined only if CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS is enabled. Powerpc also needs these bits. Hence lets define the VM_PKEY_BITx bits for any architecture that enables CONFIG_ARCH_HAS_PKEYS. cc: Dave Hansen cc: Michael Ellermen cc: Benjamin Herrenschmidt cc: Andrew Morton Signed-off-by: Ram Pai Reviewed-by: Ingo Molnar Reviewed-by: Aneesh Kumar K.V Reviewed-by: Dave Hansen --- fs/proc/task_mmu.c | 4 ++-- include/linux/mm.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index ec6d298..6b996d0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -679,13 +679,13 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_MERGEABLE)] = "mg", [ilog2(VM_UFFD_MISSING)]= "um", [ilog2(VM_UFFD_WP)] = "uw", -#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS +#ifdef CONFIG_ARCH_HAS_PKEYS /* These come out via ProtectionKey: */ [ilog2(VM_PKEY_BIT0)] = "", [ilog2(VM_PKEY_BIT1)] = "", [ilog2(VM_PKEY_BIT2)] = "", [ilog2(VM_PKEY_BIT3)] = "", -#endif +#endif /* CONFIG_ARCH_HAS_PKEYS */ }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index ad06d42..ad207ad 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -228,15 +228,16 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *, #define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4) #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ -#if defined(CONFIG_X86) -# define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */ -#if defined (CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) +#ifdef CONFIG_ARCH_HAS_PKEYS # define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 # define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */ # define VM_PKEY_BIT1 VM_HIGH_ARCH_1 # define VM_PKEY_BIT2 VM_HIGH_ARCH_2 # define VM_PKEY_BIT3 VM_HIGH_ARCH_3 -#endif +#endif /* CONFIG_ARCH_HAS_PKEYS */ + +#if defined(CONFIG_X86) +# define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */ #elif defined(CONFIG_PPC) # define VM_SAO VM_ARCH_1 /* Strong Access Ordering (powerpc) */ #elif defined(CONFIG_PARISC) From patchwork Wed Feb 21 23:52:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 876427 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zmvYh4Tp9z9sWJ for ; Thu, 22 Feb 2018 10:57:44 +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="u0/e+LQc"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zmvYh3CG2zDrf5 for ; Thu, 22 Feb 2018 10:57:44 +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="u0/e+LQc"; 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:c09::242; helo=mail-qk0-x242.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="u0/e+LQc"; dkim-atps=neutral Received: from mail-qk0-x242.google.com (mail-qk0-x242.google.com [IPv6:2607:f8b0:400d:c09::242]) (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 3zmvSR2ZJmzDrPf for ; Thu, 22 Feb 2018 10:53:11 +1100 (AEDT) Received: by mail-qk0-x242.google.com with SMTP id f25so4357736qkm.0 for ; Wed, 21 Feb 2018 15:53:11 -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=kerfeK2JoO7+oQrs2Rs90drlJqT4/y+dgPYmSKQcDZY=; b=u0/e+LQcHjwlE++qProYJNHFVAWSboHk+pTuapK+feHTcoNwsYRUgo1RDbU/FqVpXE alNuph1inarT+WH0kwVoba6R8nrK10N4A2nzbEFk7mQmKviDayT6gmoT/BEj2l7W+0xU OxKheFbIKciqASfv/FLCGYv5gVt3JJFJn6M3rVhkwTb70gcl/srSSbt+kiDooyVNLrMt oFxqqBN7u32ZsCOXyIsRYJp50GKrw2HLm7MQQfZuib+087hVf0/cJ8dkEWr/aa9tVP2M UdQbhKuB6VZ8dbPFxKi7RPq87jTtpNLl6eSWoWS87B1n0VguzBJs2dEkCeVLp41cw91r 2dsg== 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=kerfeK2JoO7+oQrs2Rs90drlJqT4/y+dgPYmSKQcDZY=; b=qtR0bpfTliNsJToKUIZ+etdYRzhru2Xx3uDPfS3O/bF9KAb+HIfqaN7qFrPizmi5HN URmUSS4TG6BvIcyZOX3op/DAFNJtjeWHUDUNU2RoI7xlWCZGOEDVSXnZR6Ze07iCMV7d o2eOT6YxjP9KLYl+69AP1VtxjwfWdkkZebEsba+8STaa9UwuJE/A7kbxBJOehXV5blfV Xs1KOT1iNHjUxrT6pJYYchgZ4PcsEektThdBXh5Xs3GVJTmDLFv+HyiagyiYzm4wPR0V baeQt1dAQpP6YQ42FV8DitRk+uCOEp87581MgDezxjMKWqZ9xVjnDu0FUWpfWClHYxJh TIog== X-Gm-Message-State: APf1xPBytORwZkrJAiPAAzeH/uoNXLnAbX+k3E3DRe5vl5yBTEgdAVft OtIb+Em8xJx2JVLloYtnDMk= X-Google-Smtp-Source: AH8x226UK/4cVXlAnZnaw+9wdND2RM1ZUu96VI4oymKjUWx4cqkfv2AlxE09bUdLefjuKnl9XWpSow== X-Received: by 10.55.3.66 with SMTP id 63mr7599323qkd.283.1519257189138; Wed, 21 Feb 2018 15:53:09 -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 b25sm3804881qte.40.2018.02.21.15.53.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 15:53:08 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org Subject: [PATCH v12 2/3] mm, powerpc, x86: introduce an additional vma bit for powerpc pkey Date: Wed, 21 Feb 2018 15:52:17 -0800 Message-Id: <1519257138-23797-3-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519257138-23797-1-git-send-email-linuxram@us.ibm.com> References: <1519257138-23797-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 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, corbet@lwn.net, ebiederm@xmission.com, msuchanek@suse.com, fweimer@redhat.com, arnd@arndb.de, dave.hansen@intel.com, x86@kernel.org, linuxram@us.ibm.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, 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" Currently only 4bits are allocated in the vma flags to hold 16 keys. This is sufficient for x86. PowerPC supports 32 keys, which needs 5bits. This patch allocates an additional bit. cc: Dave Hansen cc: Michael Ellermen cc: Benjamin Herrenschmidt cc: Andrew Morton Reviewed-by: Ingo Molnar Acked-by: Balbir Singh Signed-off-by: Ram Pai --- fs/proc/task_mmu.c | 1 + include/linux/mm.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6b996d0..6d83bb7 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -685,6 +685,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_PKEY_BIT1)] = "", [ilog2(VM_PKEY_BIT2)] = "", [ilog2(VM_PKEY_BIT3)] = "", + [ilog2(VM_PKEY_BIT4)] = "", #endif /* CONFIG_ARCH_HAS_PKEYS */ }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index ad207ad..d534f46 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -231,9 +231,10 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *, #ifdef CONFIG_ARCH_HAS_PKEYS # define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 # define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */ -# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 +# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 /* on x86 and 5-bit value on ppc64 */ # define VM_PKEY_BIT2 VM_HIGH_ARCH_2 # define VM_PKEY_BIT3 VM_HIGH_ARCH_3 +# define VM_PKEY_BIT4 VM_HIGH_ARCH_4 #endif /* CONFIG_ARCH_HAS_PKEYS */ #if defined(CONFIG_X86) From patchwork Wed Feb 21 23:52:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 876429 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zmvgF66F7z9sWJ for ; Thu, 22 Feb 2018 11:02:33 +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="I3KciERb"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zmvgF4bt5zDqF9 for ; Thu, 22 Feb 2018 11:02: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="I3KciERb"; 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:c09::243; helo=mail-qk0-x243.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="I3KciERb"; dkim-atps=neutral Received: from mail-qk0-x243.google.com (mail-qk0-x243.google.com [IPv6:2607:f8b0:400d:c09::243]) (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 3zmvST5m8FzDrTn for ; Thu, 22 Feb 2018 10:53:13 +1100 (AEDT) Received: by mail-qk0-x243.google.com with SMTP id h129so4337983qke.8 for ; Wed, 21 Feb 2018 15:53:13 -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=sra53Tt7ExbQjIXtI+GCBSRazE+x5zx5SXrD7qrQQ44=; b=I3KciERbOm9xyPijecwnyWZ1iM6C1cfzq7s2rBtSVlpLcYDIKoHizzV4vKWhkMW10J UeNCQ1JK7bu9eNNWfsNig+4ya/hRSkdzWZSXQQW5vU9d1UPtYc6tiTmdhJoq5fnWNuVL hI0yhGSZSoO/ZPKKEPoVAuqsBrycvo+rKDjuBploBxCdNNNe3GctuIaEZ0Dcr2qpliw/ Pxjn+JcYKtrEKO1l3GlOxGXRk4TjASyIf1HZ0AnQKe77OuinQl3beqk8B3Ybua5I6UI1 q+hGrR3uCo7D4nwDR6cQ6FuCxZvST3jJCbzGjM1Rs20oxvp2Npx28p0iSVuthfG+s2OB G0bA== 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=sra53Tt7ExbQjIXtI+GCBSRazE+x5zx5SXrD7qrQQ44=; b=kQZw/TMQQYoQznY1v3iIPQ+T75CX8znP6RQdHEp8dN6Ive7yV4BQ4a6+ikzP09BwMy Qak8YDDR38ozD9QMAqAVVbLVkHRiWZus8vO+bsM++oL+zcVyCyByCsr7COv2WKHVsZCW PM9toZbPMEIyt/nTpJG9SdBeZka3A5TuN/4Xx0aTL25AvWS6wbTC8SU46AVcYqurUJxC 1Str3nT38GBvEppbAJI0ZM5RljtqHw7rF6cNwHqW8wNYlCbJ4wMwOPhyx384mIR3SML1 2rxpP0x+HhEqLqJQlO1RQcHNTkIESwnw/huT5i2hvRMfpUscQr6lDfoq9W2BqhSESg08 Y+4A== X-Gm-Message-State: APf1xPD5tTlMj3O6dupnCPZFH9MFbxFze2vUzn+9X1UGUDDmoo4sixt+ 4dW5uwJBxSRrQKG/guGZfWM= X-Google-Smtp-Source: AH8x227K39il3lFBQMPK0q1b09Z2tjnO+ZSqyESsFC1I4BvRKo2Pw/JWaE3W2PGi8m/4vA6lHnTvmQ== X-Received: by 10.55.19.232 with SMTP id 101mr8005831qkt.198.1519257191860; Wed, 21 Feb 2018 15:53:11 -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 b25sm3804881qte.40.2018.02.21.15.53.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 15:53:11 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org Subject: [PATCH v12 3/3] mm, x86, powerpc: display pkey in smaps only if arch supports pkeys Date: Wed, 21 Feb 2018 15:52:18 -0800 Message-Id: <1519257138-23797-4-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519257138-23797-1-git-send-email-linuxram@us.ibm.com> References: <1519257138-23797-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 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, corbet@lwn.net, ebiederm@xmission.com, msuchanek@suse.com, fweimer@redhat.com, arnd@arndb.de, dave.hansen@intel.com, x86@kernel.org, linuxram@us.ibm.com, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, 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" 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. This patch provides x86 implementation for arch_pkeys_enabled(). x86 arch_show_smap() function is not needed anymore. Deleting it. cc: Dave Hansen cc: Michael Ellermen cc: Benjamin Herrenschmidt cc: Andrew Morton Signed-off-by: Thiago Jung Bauermann (fixed compilation errors for x86 configs) Acked-by: Michal Hocko Reviewed-by: Ingo Molnar Signed-off-by: Ram Pai Reviewed-by: Dave Hansen --- arch/powerpc/include/asm/mmu_context.h | 5 ----- arch/x86/include/asm/mmu_context.h | 5 ----- arch/x86/include/asm/pkeys.h | 1 + arch/x86/kernel/fpu/xstate.c | 5 +++++ arch/x86/kernel/setup.c | 8 -------- fs/proc/task_mmu.c | 10 +++++----- include/linux/pkeys.h | 7 ++++++- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h index 051b3d6..566b3c2 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h @@ -203,11 +203,6 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma, #define thread_pkey_regs_restore(new_thread, old_thread) #define thread_pkey_regs_init(thread) -static inline int vma_pkey(struct vm_area_struct *vma) -{ - return 0; -} - static inline u64 pte_to_hpte_pkey_bits(u64 pteflags) { return 0x0UL; diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index c931b88..134f3a0 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -294,11 +294,6 @@ static inline int vma_pkey(struct vm_area_struct *vma) return (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT; } -#else -static inline int vma_pkey(struct vm_area_struct *vma) -{ - return 0; -} #endif /* 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/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 1ae67e9..d0539e3 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1314,11 +1314,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 6d83bb7..70aa912 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -18,10 +18,12 @@ #include #include #include +#include #include #include #include +#include #include "internal.h" void task_mem(struct seq_file *m, struct mm_struct *mm) @@ -733,10 +735,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; @@ -856,9 +854,11 @@ 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); + if (arch_pkeys_enabled()) + seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); show_smap_vma_flags(m, vma); } + m_cache_vma(m, vma); return ret; } diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h index 0794ca7..49dff15 100644 --- a/include/linux/pkeys.h +++ b/include/linux/pkeys.h @@ -3,7 +3,6 @@ #define _LINUX_PKEYS_H #include -#include #ifdef CONFIG_ARCH_HAS_PKEYS #include @@ -13,6 +12,7 @@ #define arch_override_mprotect_pkey(vma, prot, pkey) (0) #define PKEY_DEDICATED_EXECUTE_ONLY 0 #define ARCH_VM_PKEY_FLAGS 0 +#define vma_pkey(vma) 0 static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey) { @@ -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) { }