[{"id":1793236,"web_url":"http://patchwork.ozlabs.org/comment/1793236/","msgid":"<8760b44kgg.fsf@concordia.ellerman.id.au>","date":"2017-10-24T15:46:55","subject":"Re: [PATCH 22/25] powerpc: capture the violated protection key on\n\tfault","submitter":{"id":46580,"url":"http://patchwork.ozlabs.org/api/people/46580/","name":"Michael Ellerman","email":"mpe@ellerman.id.au"},"content":"Ram Pai <linuxram@us.ibm.com> writes:\n\n> diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h\n> index 04b60af..51c89c1 100644\n> --- a/arch/powerpc/include/asm/paca.h\n> +++ b/arch/powerpc/include/asm/paca.h\n> @@ -97,6 +97,9 @@ struct paca_struct {\n>  \tstruct dtl_entry *dispatch_log_end;\n>  #endif /* CONFIG_PPC_STD_MMU_64 */\n>  \tu64 dscr_default;\t\t/* per-CPU default DSCR */\n> +#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n> +\tu16 paca_pkey;                  /* exception causing pkey */\n> +#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */\n\nI can't see any reason why this should be in the paca.\n\n> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c\n> index a16bc43..ad31f6e 100644\n> --- a/arch/powerpc/mm/fault.c\n> +++ b/arch/powerpc/mm/fault.c\n> @@ -153,6 +153,7 @@ static int bad_page_fault_exception(struct pt_regs *regs, unsigned long address,\n>  \n>  #ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n>  \tif (si_code & DSISR_KEYFAULT) {\n> +\t\tget_paca()->paca_pkey = get_pte_pkey(current->mm, address);\n\nYou seem to be using the paca as a temporary stash so that you don't\nhave to pass it to _exception().\n\nBut that's not what the paca is for, the paca is for per-cpu data not\nper-thread data, and (preferably) only for things that need to be\naccessed in low-level code where proper per_cpu() variables don't work.\n\nUpdating _exception() to take the key would be a mess, because there are\nso many callers who don't care about the key. For now we can probably\njust do something ~=:\n\nvoid _exception_pkey(int signr, struct pt_regs *regs, int code, unsigned long addr, int key)\n{\n\t< current body of _exception >\n\n\t+ pkey bits\n}\n\nvoid _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)\n{\n\t_exception_pkey(..., 0);\n}\n\n\ncheers","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yLyPY0yRZz9s1h\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 25 Oct 2017 02:49:21 +1100 (AEDT)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3yLyPX6zkqzDrFG\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 25 Oct 2017 02:49:20 +1100 (AEDT)","from ozlabs.org (bilbo.ozlabs.org [103.22.144.67])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3yLyLv27HRzDqlH\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tWed, 25 Oct 2017 02:47:03 +1100 (AEDT)","from authenticated.ozlabs.org (localhost [127.0.0.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPSA id 3yLyLr5VjXz9sNc;\n\tWed, 25 Oct 2017 02:47:00 +1100 (AEDT)"],"From":"Michael Ellerman <mpe@ellerman.id.au>","To":"Ram Pai <linuxram@us.ibm.com>, linuxppc-dev@lists.ozlabs.org","Subject":"Re: [PATCH 22/25] powerpc: capture the violated protection key on\n\tfault","In-Reply-To":"<1504910713-7094-31-git-send-email-linuxram@us.ibm.com>","References":"<1504910713-7094-1-git-send-email-linuxram@us.ibm.com>\n\t<1504910713-7094-31-git-send-email-linuxram@us.ibm.com>","Date":"Tue, 24 Oct 2017 17:46:55 +0200","Message-ID":"<8760b44kgg.fsf@concordia.ellerman.id.au>","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"ebiederm@xmission.com, linuxram@us.ibm.com, mhocko@kernel.org,\n\tpaulus@samba.org, aneesh.kumar@linux.vnet.ibm.com,\n\tbauerman@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}}]