Received: by 10.223.164.200 with SMTP id h8csp922097wrb; Mon, 6 Nov 2017 01:01:25 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q5OLCRMhCVQM/CPxEIVE9q9J0DF789vE/okm+U5O6M6cTWnTRR5/GD2FEUAnK7MkI8GTUY X-Received: by 10.99.52.196 with SMTP id b187mr15222291pga.222.1509958885076; Mon, 06 Nov 2017 01:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509958885; cv=none; d=google.com; s=arc-20160816; b=R7upBnmSLFnNxnbtNpSFXUnUI/OhNjAFzSMfxpkXSiVbEPstTTD3l4GHDmDUrvsmp3 Xe9rMvkkTzzDvpEIdgcheXAkrBZDBbCAJQZFP15l3i1GatjEjUDOXKLAhMK+dR7KEGa2 BxKh2yjygSc2XhVzvMWzesCQR2qaPKvCyx1X1gzg8siAX0cZqWMBwqyO73szcCRK4CWs NnMwug/eK1NDnt3vDeEjDCY4dcGiVyE2gnLgM/nzTvXb8KMlL+5mI4+bt66Q/jWA1a09 LuOJB7zBzOq9DZRUzrtUmYM9PwhPmltHLoSP4CvOES8S4KQDeYFa9JZkt+30lIsuMPyz N4yg== 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=e9228ZZx/b9wKjcski93PcKfzUb1SmGShAgbyvj9+GU=; b=C1UN8FCFBZ3TP0XdhUi1vEbEQnRoeDurSan4jJwEDkgCMfpE7n1BM2zVsxfTHbvkGp MAitAyZLyJbkpgxG1JuTZyJg2gBm3RKRDqhC6K97TNN1Su1VKvBt2I5/o8G5dCv5ObH7 RA2pPxatiNRyOz4s4zYkphOHU/pCdQohfAR416SRPBZ3PunpufmDB/i6xjsvshkN3ZLD xN2DEuwxU1lHZaLx/keeWk//HGrBe/ZIiiT7lN5dh8ZquUWCGHEDAoVZYAK45WFeH7RK vddV65wwPHMTqKmeRuAOkMzVHV9vUKGJXefuR3aOKYr7QazujrC5jXeuTwI4wgF8SP8e ZWiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uq03Lcrq; 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 k70si10882736pge.427.2017.11.06.01.01.11; Mon, 06 Nov 2017 01:01:25 -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=uq03Lcrq; 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 S1752366AbdKFI7V (ORCPT + 98 others); Mon, 6 Nov 2017 03:59:21 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:50916 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338AbdKFI7R (ORCPT ); Mon, 6 Nov 2017 03:59:17 -0500 Received: by mail-qk0-f196.google.com with SMTP id o187so10007884qke.7; Mon, 06 Nov 2017 00:59:17 -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=e9228ZZx/b9wKjcski93PcKfzUb1SmGShAgbyvj9+GU=; b=uq03Lcrq1Z9iWby0PGtylrG1LJKPznUucFv/+VKopqJSwZNafMu/MJwPkwFmwGIHKk 1bbe9/P5qsg3PfGG5nylhCjyFyZwa7Hxx4v5CckBJoVZmZlteak+8QOEQLDe77aF79WZ 5vNLD8zSMu2eYh+iYTooc4HoTkmr6siJdSzghTrlLeZ/l8Q6mmIGiyvOP3jGX269x+oo Hek9vCB0i5BEG0HrqaCIWpVJchhfEZ0XUxcA/YGf6NZwdZyhm0BhvEMInjUZtQPK9cnR DVU2nRM6x+qghIYt5+aXXYklZb1YRzp5KubiyBDtHEZYvp4K+EA3GjwTp5GCgQfW/XAO Cp+w== 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=e9228ZZx/b9wKjcski93PcKfzUb1SmGShAgbyvj9+GU=; b=UC5qIT/JzvhJ6z4/B5T65nNZVtGxZ3i2o/MqP1QfM7vA4c5LlBJhj0jhRGGOAKxaMr e7xEumH18UO/z0enC+lQmGihTuC6d7i3QyUQRiGv39IIXNF1UuRlcTCBNkSon7PLGhgN 0lD3Of56zHRvu5mK+Ujv/43zyuGhUoxO3WFHrOfhWOiGygNjuz0DYUupSGI3CCs+zBDy ngcy4qXk8BY2ULJsfgtMpLc0PUvE7gjeii5Yh0xXWJmbmFpe7gikw2AlF/inovefN5jd tlyokh1dZqJdRWyuURZdt3MDeKeR3g8H+FaTcnp9ShkKQN+LBhKDbA5sjriRmR3iU1U6 sVhg== X-Gm-Message-State: AJaThX4dQx4xTtMx47ScG6MZokJj1gGrwuLn+TdQcBrzU+b1M55xkk/0 rdVtUUBfis5KMgD64e09naM= X-Received: by 10.55.21.135 with SMTP id 7mr8951193qkv.216.1509958756670; Mon, 06 Nov 2017 00:59:16 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.00.59.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 00:59:14 -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 v9 20/51] powerpc: introduce get_mm_addr_key() helper Date: Mon, 6 Nov 2017 00:57:12 -0800 Message-Id: <1509958663-18737-21-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-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 get_mm_addr_key() helper returns the pkey associated with an address corresponding to a given mm_struct. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/mmu.h | 9 +++++++++ arch/powerpc/mm/hash_utils_64.c | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 6364f5c..bb38312 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -260,6 +260,15 @@ static inline bool early_radix_enabled(void) } #endif +#ifdef CONFIG_PPC_MEM_KEYS +extern u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address); +#else +static inline u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address) +{ + return 0; +} +#endif /* CONFIG_PPC_MEM_KEYS */ + #endif /* !__ASSEMBLY__ */ /* The kernel use the constants below to index in the page sizes array. diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index ddfc673..0108d12 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -1575,6 +1575,30 @@ void hash_preload(struct mm_struct *mm, unsigned long ea, local_irq_restore(flags); } +#ifdef CONFIG_PPC_MEM_KEYS +/* + * Return the protection key associated with the given address and the + * mm_struct. + */ +u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address) +{ + pte_t *ptep; + u16 pkey = 0; + unsigned long flags; + + if (!mm || !mm->pgd) + return 0; + + local_irq_save(flags); + ptep = find_linux_pte(mm->pgd, address, NULL, NULL); + if (ptep) + pkey = pte_to_pkey_bits(pte_val(READ_ONCE(*ptep))); + local_irq_restore(flags); + + return pkey; +} +#endif /* CONFIG_PPC_MEM_KEYS */ + #ifdef CONFIG_PPC_TRANSACTIONAL_MEM static inline void tm_flush_hash_page(int local) { -- 1.7.1 From 1583309536161015528@xxx Mon Nov 06 09:47:19 +0000 2017 X-GM-THRID: 1583309536161015528 X-Gmail-Labels: Inbox,Category Promotions,HistoricalUnread