]> xenbits.xensource.com Git - xen.git/commitdiff
x86/S3: Clarify and improve the behaviour of do_suspend_lowlevel()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 13 Dec 2019 17:36:09 +0000 (17:36 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Dec 2019 11:42:54 +0000 (11:42 +0000)
do_suspend_lowlevel() behaves as a function call, even when the trampoline
jumps back into the middle of it.  Discuss this property, while renaming the
far-too-generic __ret_point to s3_resume.

Optimise the calling logic for acpi_enter_sleep_state().  $3 doesn't require a
64bit write, and the function isn't variadic so doesn't need to specify zero
FPU registers in use.

In the case of an acpi_enter_sleep_state() error, we didn't actually lose
state so don't need to restore it.  Jump straight to the end.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/acpi/wakeup_prot.S
xen/arch/x86/boot/wakeup.S

index 74261cb4f10291e25274e797044c62bed7206d00..8c525a802b5ce19da3b222183bd64b49c7474894 100644 (file)
@@ -42,15 +42,23 @@ ENTRY(do_suspend_lowlevel)
 
         call    save_rest_processor_state
 
-        mov     $3, %rdi
-        xor     %eax, %eax
-
         /* enter sleep state physically */
+        mov     $3, %edi
         call    acpi_enter_sleep_state
-        jmp     __ret_point
-
 
-ENTRY(__ret_point)
+        /* It seems we didn't suspend.  Get out of here. */
+        jmp     .Lsuspend_err
+
+        /*
+         * do_suspend_lowlevel() is arranged to behave as a regular function
+         * call, even if hardware actually goes to sleep in the middle.
+         *
+         * The trampoline re-intercepts here.  State is:
+         *  - 64bit mode
+         *
+         * Everything else, including the stack, needs restoring.
+         */
+ENTRY(s3_resume)
         lgdt    boot_gdtr(%rip)
 
         /* mmu_cr4_features contains latest cr4 setting */
@@ -92,7 +100,8 @@ ENTRY(__ret_point)
         LOAD_GREG(13)
         LOAD_GREG(14)
         LOAD_GREG(15)
-        ret 
+.Lsuspend_err:
+        ret
 
 .data
         .align 16
index fc47721f4346f5aaf73d40fe7953c64fcc689f03..c17d613b61ff450519026b8a8f9722cf3b93617a 100644 (file)
@@ -151,7 +151,7 @@ wakeup_32:
         .code64
 wakeup_64:
         /* Jump to high mappings and the higher-level wakeup code. */
-        movabs  $__ret_point, %rbx
+        movabs  $s3_resume, %rbx
         jmp     *%rbx
 
 bogus_saved_magic: