From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751116AbdAQTeW (ORCPT ); Tue, 17 Jan 2017 14:34:22 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:40974 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750893AbdAQTeT (ORCPT ); Tue, 17 Jan 2017 14:34:19 -0500 Subject: Re: [PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity) To: David Miller References: <0c08eb00e5a9735d7d0bcbeaadeacaa761011aab.1483999591.git.khalid.aziz@oracle.com> <20170116.233924.374841184595409216.davem@davemloft.net> Cc: corbet@lwn.net, viro@zeniv.linux.org.uk, nitin.m.gupta@oracle.com, mike.kravetz@oracle.com, akpm@linux-foundation.org, mingo@kernel.org, kirill.shutemov@linux.intel.com, adam.buchbinder@gmail.com, hughd@google.com, minchan@kernel.org, keescook@chromium.org, chris.hyser@oracle.com, atish.patra@oracle.com, cmetcalf@mellanox.com, atomlin@redhat.com, jslaby@suse.cz, joe@perches.com, paul.gortmaker@windriver.com, mhocko@suse.com, lstoakes@gmail.com, jack@suse.cz, dave.hansen@linux.intel.com, vbabka@suse.cz, dan.j.williams@intel.com, iamjoonsoo.kim@lge.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, khalid@gonehiking.org From: Khalid Aziz Organization: Oracle Corp Message-ID: <767310a9-d3bd-9721-2d20-ce2c60cddd06@oracle.com> Date: Tue, 17 Jan 2017 12:32:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170116.233924.374841184595409216.davem@davemloft.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/16/2017 09:39 PM, David Miller wrote: > From: Khalid Aziz > Date: Wed, 11 Jan 2017 09:12:54 -0700 > >> + __asm__ __volatile__( >> + ".word 0xa1438000\n\t" /* rd %mcdper, %l0 */ > > Just use "rd %%asr14, %0" this way you don't have to play all of these > fixed register games which kill the code generated by gcc. If you > forcefully clobber a windowed register like %l0 it means the function > being emitted can never be a leaf function, tail calls are no longer > allowed, etc. Hi David, "rd %%asr14, %0" should work but does not due to bugs in assembler - , and . These bugs were fixed in binutils 2.27 but older assemblers will cause kernel build to fail. Using byte coded equivalent is the safest option. > >> + ".word 0x9d800011\n\t" /* wr %g0, %l1, %mcdper */ > > Likewise use "wr %%g0, %0, %%asr14" > >> + ".word 0xaf900001\n\t" /* wrpr %g0, %g1, %pmcdper */ > > Hmmm, which %asr encodes %pmcdper? %pmcdper is not an asr, rather a privileged register (pr23). Thanks, Khalid > >> diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c >> index 8a6982d..68b03bf 100644 >> --- a/arch/sparc/kernel/mdesc.c >> +++ b/arch/sparc/kernel/mdesc.c >> @@ -20,6 +20,7 @@ >> #include >> #include >> #include >> +#include >> >> /* Unlike the OBP device tree, the machine description is a full-on >> * DAG. An arbitrary number of ARCs are possible from one >> @@ -1104,5 +1105,8 @@ void __init sun4v_mdesc_init(void) >> >> cur_mdesc = hp; >> >> +#ifdef CONFIG_SPARC64 > > mdesc.c is only built on sparc64, this ifdef is superfluous. > >> +/* Update the state of MCDPER register in current task's mm context before >> + * dup so the dup'd task will inherit flags in this register correctly. >> + * Current task may have updated flags since it started running. >> + */ >> +int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) >> +{ >> + if (adi_capable() && src->mm) { >> + register unsigned long tmp_mcdper; >> + >> + __asm__ __volatile__( >> + ".word 0x83438000\n\t" /* rd %mcdper, %g1 */ >> + "mov %%g1, %0\n\t" >> + : "=r" (tmp_mcdper) >> + : >> + : "g1"); >> + src->mm->context.mcdper = tmp_mcdper; > > I don't like the idea of duplicating 'mm' state using the task struct > copy. Why do not the MM handling interfaces handle this properly? > > Maybe it means you've abstracted the ADI register handling in the > wrong place. Maybe it's a thread property which is "pushed" from > the MM context. > -- > To unsubscribe from this list: send the line "unsubscribe sparclinux" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >