xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86emul: correct stub invocation constraints
@ 2017-04-25  9:04 Jan Beulich
  2017-04-25 15:00 ` Andrew Cooper
  2017-04-26 14:01 ` Boris Ostrovsky
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Beulich @ 2017-04-25  9:04 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Julien Grall

[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]

Stub invocations need to have the space the stub occupies as an input,
to prevent the compiler from re-ordering (or omitting) writes to it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -837,7 +837,8 @@ do{ asm volatile (
                    ".popsection\n\t"                                    \
                    _ASM_EXTABLE(.Lret%=, .Lfix%=)                       \
                    : [exn] "+g" (res_), constraints,                    \
-                     [stub] "rm" (stub.func) );                         \
+                     [stub] "rm" (stub.func),                           \
+                     "m" (*(uint8_t(*)[MAX_INST_LEN + 1])stub.ptr) );   \
     if ( unlikely(~res_.raw) )                                          \
     {                                                                   \
         gprintk(XENLOG_WARNING,                                         \
@@ -853,7 +854,8 @@ do{ asm volatile (
 #else
 # define invoke_stub(pre, post, constraints...)                         \
     asm volatile ( pre "\n\tcall *%[stub]\n\t" post                     \
-                   : constraints, [stub] "rm" (stub.func) )
+                   : constraints, [stub] "rm" (stub.func),              \
+                     "m" (*(uint8_t(*)[MAX_INST_LEN + 1])stub.buf) )
 #endif
 
 #define emulate_stub(dst, src...) do {                                  \




[-- Attachment #2: x86emul-stub-constraints.patch --]
[-- Type: text/plain, Size: 1555 bytes --]

x86emul: correct stub invocation constraints

Stub invocations need to have the space the stub occupies as an input,
to prevent the compiler from re-ordering (or omitting) writes to it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -837,7 +837,8 @@ do{ asm volatile (
                    ".popsection\n\t"                                    \
                    _ASM_EXTABLE(.Lret%=, .Lfix%=)                       \
                    : [exn] "+g" (res_), constraints,                    \
-                     [stub] "rm" (stub.func) );                         \
+                     [stub] "rm" (stub.func),                           \
+                     "m" (*(uint8_t(*)[MAX_INST_LEN + 1])stub.ptr) );   \
     if ( unlikely(~res_.raw) )                                          \
     {                                                                   \
         gprintk(XENLOG_WARNING,                                         \
@@ -853,7 +854,8 @@ do{ asm volatile (
 #else
 # define invoke_stub(pre, post, constraints...)                         \
     asm volatile ( pre "\n\tcall *%[stub]\n\t" post                     \
-                   : constraints, [stub] "rm" (stub.func) )
+                   : constraints, [stub] "rm" (stub.func),              \
+                     "m" (*(uint8_t(*)[MAX_INST_LEN + 1])stub.buf) )
 #endif
 
 #define emulate_stub(dst, src...) do {                                  \

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-04-27  8:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-25  9:04 [PATCH] x86emul: correct stub invocation constraints Jan Beulich
2017-04-25 15:00 ` Andrew Cooper
2017-04-25 16:48   ` Julien Grall
2017-04-26 14:01 ` Boris Ostrovsky
2017-04-26 14:19   ` Jan Beulich
2017-04-26 14:29     ` Boris Ostrovsky
2017-04-27  8:07   ` Jan Beulich
2017-04-27  8:30     ` Jan Beulich

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).