From: Chuck Ebbert <76306.1226@compuserve.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>
Subject: [patch 2.6.13-rc3] i386: add alternative_output() for altinstructions
Date: Sat, 23 Jul 2005 18:09:37 -0400 [thread overview]
Message-ID: <200507231813_MC3-1-A560-460E@compuserve.com> (raw)
This patch adds alternative_output() for altinstructions that
have output. Only one output is allowed.
It also cleans up the comments for alternative_input().
With this patch in place, I cleaned up the i387 save/restore in
my local copy so it now looks like this:
===================================================================
static inline void restore_fpu( struct task_struct *tsk )
{
alternative_input(
"frstor %1 ; nop",
"fxrstor %1",
X86_FEATURE_FXSR,
"m" (tsk->thread.i387.fxsave));
}
static inline void __save_init_fpu( struct task_struct *tsk )
{
alternative_output(
"fnsave %0 ; nop ; fwait ; nop",
"fxsave %0 ; fnclex",
X86_FEATURE_FXSR,
"=m" (tsk->thread.i387.fxsave));
tsk->thread_info->status &= ~TS_USEDFPU;
}
===================================================================
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Index: 2.6.13-rc3a/include/asm-i386/system.h
===================================================================
--- 2.6.13-rc3a.orig/include/asm-i386/system.h 2005-06-24 00:50:33.000000000 -0400
+++ 2.6.13-rc3a/include/asm-i386/system.h 2005-07-23 15:36:02.000000000 -0400
@@ -313,13 +313,13 @@
/*
* Alternative inline assembly with input.
- *
- * Pecularities:
- * No memory clobber here.
+ *
+ * Peculiarities:
+ * No memory clobber here.
* Argument numbers start with 1.
* Best is to use constraints that are fixed size (like (%1) ... "r")
- * If you use variable sized constraints like "m" or "g" in the
- * replacement maake sure to pad to the worst case length.
+ * If you use variable sized constraints like "m" or "g" in the
+ * replacement make sure to pad to the worst case length.
*/
#define alternative_input(oldinstr, newinstr, feature, input...) \
asm volatile ("661:\n\t" oldinstr "\n662:\n" \
@@ -336,6 +336,27 @@
".previous" :: "i" (feature), ##input)
/*
+ * Alternative inline assembly with output.
+ *
+ * Same as alternative_input, except:
+ * No inputs.
+ * Only one output: 0.
+ */
+#define alternative_output(oldinstr, newinstr, feature, output...) \
+ asm volatile ("661:\n\t" oldinstr "\n662:\n" \
+ ".section .altinstructions,\"a\"\n" \
+ " .align 4\n" \
+ " .long 661b\n" /* label */ \
+ " .long 663f\n" /* new instruction */ \
+ " .byte %c1\n" /* feature bit */ \
+ " .byte 662b-661b\n" /* sourcelen */ \
+ " .byte 664f-663f\n" /* replacementlen */ \
+ ".previous\n" \
+ ".section .altinstr_replacement,\"ax\"\n" \
+ "663:\n\t" newinstr "\n664:\n" /* replacement */ \
+ ".previous" : output : "i" (feature))
+
+/*
* Force strict CPU ordering.
* And yes, this is required on UP too when we're talking
* to devices.
__
Chuck
reply other threads:[~2005-07-23 22:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200507231813_MC3-1-A560-460E@compuserve.com \
--to=76306.1226@compuserve.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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).