]> xenbits.xensource.com Git - xen.git/commitdiff
x86: replace reset_stack_and_jump_nolp()
authorJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 12:40:27 +0000 (13:40 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 12:40:27 +0000 (13:40 +0100)
Move the necessary check into check_for_livepatch_work(), rather than
mostly duplicating reset_stack_and_jump() for this purpose. This is to
prevent an inflation of reset_stack_and_jump() flavors.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/pv/domain.c
xen/arch/x86/setup.c
xen/common/livepatch.c
xen/include/asm-x86/current.h

index 1b894d0124d7c86ed94104b76f5bbac2917d6c64..6d3561ea77fd4f1e48977ca2d42c718d0d9f5221 100644 (file)
@@ -192,7 +192,7 @@ static void noreturn continue_idle_domain(struct vcpu *v)
 {
     /* Idle vcpus might be attached to non-idle units! */
     if ( !is_idle_domain(v->sched_unit->domain) )
-        reset_stack_and_jump_nolp(guest_idle_loop);
+        reset_stack_and_jump(guest_idle_loop);
 
     reset_stack_and_jump(idle_loop);
 }
index cfea5b5523e7db472a7f4faf2c98e7d5e91d2f2a..e41330ca550cfca2a5d6a79035e3f93429d428cf 100644 (file)
@@ -1036,7 +1036,7 @@ static void noreturn svm_do_resume(struct vcpu *v)
 
     hvm_do_resume(v);
 
-    reset_stack_and_jump_nolp(svm_asm_do_resume);
+    reset_stack_and_jump(svm_asm_do_resume);
 }
 
 void svm_vmenter_helper(const struct cpu_user_regs *regs)
index ca94c2bedc98b61b064ea5c23ca33768cad6ed35..a71b935c10b5b5c8ee2fb383a16e6b75e935e5ff 100644 (file)
@@ -1909,7 +1909,7 @@ void vmx_do_resume(struct vcpu *v)
     if ( host_cr4 != read_cr4() )
         __vmwrite(HOST_CR4, read_cr4());
 
-    reset_stack_and_jump_nolp(vmx_asm_do_vmentry);
+    reset_stack_and_jump(vmx_asm_do_vmentry);
 }
 
 static inline unsigned long vmr(unsigned long field)
index 663e76c773037bef38d92ecd6f8df9b278d60b3d..27dc0f8ed76b9cf42aeb62dd11e13d5748678daa 100644 (file)
@@ -113,7 +113,7 @@ static int parse_pcid(const char *s)
 static void noreturn continue_nonidle_domain(struct vcpu *v)
 {
     check_wakeup_from_wait();
-    reset_stack_and_jump_nolp(ret_from_intr);
+    reset_stack_and_jump(ret_from_intr);
 }
 
 static int setup_compat_l4(struct vcpu *v)
index 30d6f375a3af5e58768c7b7a2769e82b79f5742a..1a2e5e41ab32271c94dc47e5392acf5f8a11183b 100644 (file)
@@ -676,7 +676,7 @@ static void __init noreturn reinit_bsp_stack(void)
         asm volatile ("setssbsy" ::: "memory");
     }
 
-    reset_stack_and_jump_nolp(init_done);
+    reset_stack_and_jump(init_done);
 }
 
 /*
index 861a227dbd2de7ea5f165661dcbcf591016af321..81ceafce9805d99e771d92ea626585801d55ebfd 100644 (file)
@@ -1635,6 +1635,11 @@ void check_for_livepatch_work(void)
     s_time_t timeout;
     unsigned long flags;
 
+    /* Only do any work when invoked in truly idle state. */
+    if ( system_state != SYS_STATE_active ||
+         !is_idle_domain(current->sched_unit->domain) )
+        return;
+
     /* Fast path: no work to do. */
     if ( !per_cpu(work_to_do, cpu ) )
         return;
index 51a4cdbf7c5bc6246fa10a99ce09bb291cb8c9a6..b47addb3c80159a7f4d84a36ac9e7f5f8da2381b 100644 (file)
@@ -155,13 +155,13 @@ unsigned long get_stack_dump_bottom (unsigned long sp);
 # define SHADOW_STACK_WORK ""
 #endif
 
-#define switch_stack_and_jump(fn, instr)                                \
+#define reset_stack_and_jump(fn)                                        \
     ({                                                                  \
         unsigned int tmp;                                               \
         __asm__ __volatile__ (                                          \
             SHADOW_STACK_WORK                                           \
             "mov %[stk], %%rsp;"                                        \
-            instr                                                       \
+            CHECK_FOR_LIVEPATCH_WORK                                    \
             "jmp %c[fun];"                                              \
             : [val] "=&r" (tmp),                                        \
               [ssp] "=&r" (tmp)                                         \
@@ -176,12 +176,6 @@ unsigned long get_stack_dump_bottom (unsigned long sp);
         unreachable();                                                  \
     })
 
-#define reset_stack_and_jump(fn)                                        \
-    switch_stack_and_jump(fn, CHECK_FOR_LIVEPATCH_WORK)
-
-#define reset_stack_and_jump_nolp(fn)                                   \
-    switch_stack_and_jump(fn, "")
-
 /*
  * Which VCPU's state is currently running on each CPU?
  * This is not necesasrily the same as 'current' as a CPU may be