linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: khalid.aziz@oracle.com
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
Subject: Re: [PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity)
Date: Mon, 16 Jan 2017 23:39:24 -0500 (EST)	[thread overview]
Message-ID: <20170116.233924.374841184595409216.davem@davemloft.net> (raw)
In-Reply-To: <0c08eb00e5a9735d7d0bcbeaadeacaa761011aab.1483999591.git.khalid.aziz@oracle.com>

From: Khalid Aziz <khalid.aziz@oracle.com>
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.

> +			".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?

> 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 <asm/uaccess.h>
>  #include <asm/oplib.h>
>  #include <asm/smp.h>
> +#include <asm/adi.h>
>  
>  /* 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.

  reply	other threads:[~2017-01-17  4:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 16:12 [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7 Khalid Aziz
2017-01-11 16:12 ` [PATCH v4 1/4] signals, sparc: Add signal codes for ADI violations Khalid Aziz
2017-01-11 16:12 ` [PATCH v4 2/4] mm: Add function to support extra actions on swap in/out Khalid Aziz
2017-01-11 16:56   ` Dave Hansen
2017-01-11 17:15     ` Khalid Aziz
2017-01-11 16:12 ` [PATCH v4 3/4] sparc64: Add support for ADI register fields, ASIs and traps Khalid Aziz
2017-01-17  4:23   ` David Miller
2017-01-17 15:55     ` Khalid Aziz
2017-01-11 16:12 ` [PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity) Khalid Aziz
2017-01-17  4:39   ` David Miller [this message]
2017-01-17 19:32     ` Khalid Aziz
2017-01-17 19:42       ` David Miller
2017-01-17 20:12         ` Khalid Aziz
2017-01-18  0:14     ` Khalid Aziz
2017-01-11 16:33 ` [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7 Dave Hansen
2017-01-11 16:56   ` Khalid Aziz
2017-01-11 18:13     ` Dave Hansen
2017-01-11 18:50       ` Khalid Aziz
2017-01-11 19:11         ` Dave Hansen
2017-01-12  0:22           ` Khalid Aziz
2017-01-12  0:49             ` Dave Hansen
2017-01-12 16:50               ` Khalid Aziz
2017-01-12 17:53                 ` Dave Hansen
2017-01-13  0:22                   ` Khalid Aziz
2017-01-13  1:31                     ` Rob Gardner
2017-01-13 14:48                       ` Khalid Aziz
2017-01-13 15:29                         ` Rob Gardner
2017-01-13 15:59                           ` Khalid Aziz
2017-01-13 16:08                           ` Dave Hansen
2017-01-13 17:36                             ` Rob Gardner
2017-01-17  4:47       ` David Miller
2017-01-17 21:43         ` Khalid Aziz
2017-01-17  4:42   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170116.233924.374841184595409216.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=adam.buchbinder@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=atish.patra@oracle.com \
    --cc=atomlin@redhat.com \
    --cc=chris.hyser@oracle.com \
    --cc=cmetcalf@mellanox.com \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hughd@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jack@suse.cz \
    --cc=joe@perches.com \
    --cc=jslaby@suse.cz \
    --cc=keescook@chromium.org \
    --cc=khalid.aziz@oracle.com \
    --cc=khalid@gonehiking.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=minchan@kernel.org \
    --cc=mingo@kernel.org \
    --cc=nitin.m.gupta@oracle.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=vbabka@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).