All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/asm: Drop __GET_CURRENT()
@ 2018-01-29 18:12 Andrew Cooper
  2018-01-30  7:21 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2018-01-29 18:12 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich

__GET_CURRENT() is very dangerous to use, as is easy to confuse with
GET_CURRENT(), but strictly depends on the regster parameter already having
the STACK_END value in it.  Also, there is no reason to special case accesses
of current_vcpu differently to other cpuinfo fields.

Expand __GET_CURRENT() in its current users, and remove the macro.

Take the opportunity to replace the GET_CURRENT() in the cstar path which
doesn't need to recalculate STACK_END.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/x86_64/compat/entry.S | 2 +-
 xen/arch/x86/x86_64/entry.S        | 8 ++++----
 xen/include/asm-x86/asm_defns.h    | 4 +---
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 4190c73..8fc594f 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -224,7 +224,7 @@ ENTRY(cstar_enter)
         movq  $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx)
 .Lcstar_cr3_okay:
 
-        GET_CURRENT(bx)
+        movq STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
         movq  VCPU_domain(%rbx),%rcx
         cmpb  $0,DOMAIN_is_32bit_pv(%rcx)
         je    switch_to_kernel
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index a5a6702..308bbf3 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -171,7 +171,7 @@ ENTRY(lstar_enter)
         movq  $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx)
 .Llstar_cr3_okay:
 
-        __GET_CURRENT(bx)
+        movq STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
         testb $TF_kernel_mode,VCPU_thread_flags(%rbx)
         jz    switch_to_kernel
 
@@ -277,7 +277,7 @@ GLOBAL(sysenter_eflags_saved)
         movq  $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx)
 .Lsyse_cr3_okay:
 
-        __GET_CURRENT(bx)
+        movq STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
         cmpb  $0,VCPU_sysenter_disables_events(%rbx)
         movq  VCPU_sysenter_addr(%rbx),%rax
         setne %cl
@@ -332,7 +332,7 @@ UNLIKELY_START(ne, msi_check)
         call  check_for_unexpected_msi
 UNLIKELY_END(msi_check)
 
-        __GET_CURRENT(bx)
+        movq STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
 
         /* Check that the callback is non-null. */
         leaq  VCPU_int80_bounce(%rbx),%rdx
@@ -477,7 +477,7 @@ ENTRY(dom_crash_sync_extable)
         GET_STACK_END(ax)
         leaq  STACK_CPUINFO_FIELD(guest_cpu_user_regs)(%rax),%rsp
         # create_bounce_frame() temporarily clobbers CS.RPL. Fix up.
-        __GET_CURRENT(ax)
+        movq STACK_CPUINFO_FIELD(current_vcpu)(%rax), %rax
         movq  VCPU_domain(%rax),%rax
         testb $1,DOMAIN_is_32bit_pv(%rax)
         setz  %al
diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index 88b775b..aee14ba 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -132,11 +132,9 @@ void ret_from_intr(void);
         GET_STACK_END(reg);                       \
         addq $STACK_CPUINFO_FIELD(field), %r##reg
 
-#define __GET_CURRENT(reg)                        \
-        movq STACK_CPUINFO_FIELD(current_vcpu)(%r##reg), %r##reg
 #define GET_CURRENT(reg)                          \
         GET_STACK_END(reg);                       \
-        __GET_CURRENT(reg)
+        movq STACK_CPUINFO_FIELD(current_vcpu)(%r##reg), %r##reg
 
 #ifndef NDEBUG
 #define ASSERT_NOT_IN_ATOMIC                                             \
-- 
2.1.4


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

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

* Re: [PATCH] x86/asm: Drop __GET_CURRENT()
  2018-01-29 18:12 [PATCH] x86/asm: Drop __GET_CURRENT() Andrew Cooper
@ 2018-01-30  7:21 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2018-01-30  7:21 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel

>>> On 29.01.18 at 19:12, <andrew.cooper3@citrix.com> wrote:
> __GET_CURRENT() is very dangerous to use, as is easy to confuse with

I wouldn't say "very", but for the change as a whole - well, yes, why
not.

> GET_CURRENT(), but strictly depends on the regster parameter already having
> the STACK_END value in it.  Also, there is no reason to special case accesses
> of current_vcpu differently to other cpuinfo fields.
> 
> Expand __GET_CURRENT() in its current users, and remove the macro.
> 
> Take the opportunity to replace the GET_CURRENT() in the cstar path which
> doesn't need to recalculate STACK_END.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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



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

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

end of thread, other threads:[~2018-01-30  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29 18:12 [PATCH] x86/asm: Drop __GET_CURRENT() Andrew Cooper
2018-01-30  7:21 ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.