linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: oleg@redhat.com, linux-arch@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>
Subject: [PATCH 2/3] Mark the 'current' pointer register read-only when such a thing exists
Date: Tue, 18 May 2010 17:45:42 +0100	[thread overview]
Message-ID: <20100518164542.6194.451.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20100518164537.6194.73366.stgit@warthog.procyon.org.uk>

Where the value of current is kept in a register, that register can be marked
such that the pointer value is read only, e.g.:

	register struct task_struct *const current asm("e2");

This prevents inadvertent assignment outside of assembly code.

This has been available on the MN10300 arch for a while now, and I've also
tested it on the FRV arch.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 arch/frv/include/asm/current.h        |    2 +-
 arch/microblaze/include/asm/current.h |    2 +-
 arch/powerpc/include/asm/current.h    |    2 +-
 arch/sparc/include/asm/current.h      |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/frv/include/asm/current.h b/arch/frv/include/asm/current.h
index 86b0274..51bdaf2 100644
--- a/arch/frv/include/asm/current.h
+++ b/arch/frv/include/asm/current.h
@@ -17,7 +17,7 @@
 /*
  * dedicate GR29 to keeping the current task pointer
  */
-register struct task_struct *current asm("gr29");
+register struct task_struct *const current asm("gr29");
 
 #define get_current() current
 
diff --git a/arch/microblaze/include/asm/current.h b/arch/microblaze/include/asm/current.h
index 29303ed..b824847 100644
--- a/arch/microblaze/include/asm/current.h
+++ b/arch/microblaze/include/asm/current.h
@@ -21,7 +21,7 @@
 /*
  * Dedicate r31 to keeping the current task pointer
  */
-register struct task_struct *current asm("r31");
+register struct task_struct *const current asm("r31");
 
 # define get_current()	current
 # endif /* __ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/current.h b/arch/powerpc/include/asm/current.h
index e2c7f06..4ca5126 100644
--- a/arch/powerpc/include/asm/current.h
+++ b/arch/powerpc/include/asm/current.h
@@ -32,7 +32,7 @@ static inline struct task_struct *get_current(void)
 /*
  * We keep `current' in r2 for speed.
  */
-register struct task_struct *current asm ("r2");
+register struct task_struct *const current asm ("r2");
 
 #endif
 
diff --git a/arch/sparc/include/asm/current.h b/arch/sparc/include/asm/current.h
index f04fd6c..9ae8826 100644
--- a/arch/sparc/include/asm/current.h
+++ b/arch/sparc/include/asm/current.h
@@ -14,7 +14,7 @@
 #include <linux/thread_info.h>
 
 #ifdef CONFIG_SPARC64
-register struct task_struct *current asm("g4");
+register struct task_struct *const current asm("g4");
 #endif
 
 #ifdef CONFIG_SPARC32

  reply	other threads:[~2010-05-18 17:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-18 16:45 [PATCH 1/3] Reduce get_current() to the asm-generic implementation where possible David Howells
2010-05-18 16:45 ` David Howells [this message]
2010-05-18 21:05   ` [PATCH 2/3] Mark the 'current' pointer register read-only when such a thing exists David Miller
2010-05-18 16:45 ` [PATCH 3/3] Make get_current() __attribute__((const)) David Howells
2010-05-18 21:22   ` schedule() && prev/current (Was: [PATCH 3/3] Make get_current() __attribute__((const))) Oleg Nesterov
2010-05-19  6:21     ` Peter Zijlstra
2010-05-19 10:27       ` Oleg Nesterov
2010-05-19 10:37         ` Peter Zijlstra
2010-05-19 12:57           ` [PATCH] schedule: simplify the reacquire_kernel_lock() logic Oleg Nesterov
2010-05-19 12:57             ` Oleg Nesterov
2010-05-19 13:11             ` Yong Zhang
2010-05-19 13:07         ` schedule() && prev/current (Was: [PATCH 3/3] Make get_current() __attribute__((const))) Yong Zhang
2010-05-19 13:07           ` Yong Zhang
2010-05-18 17:39 ` [PATCH 1/3] Reduce get_current() to the asm-generic implementation where possible Kyle McMartin
2010-05-18 19:47 ` Jamie Lokier
2010-05-19  6:21   ` Nick Piggin
2010-05-19 11:02     ` Oleg Nesterov
2010-05-21 10:13 ` David Howells

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=20100518164542.6194.451.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=oleg@redhat.com \
    /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).