[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/S3: put data segment registers into known state upon resume

  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 23 Jul 2020 15:40:47 +0100
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: "M. Vefa Bicakci" <m.v.b@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 23 Jul 2020 14:43:45 +0000
  • Ironport-sdr: SAiegcltMIL9ydSkPEo7wUhAqyySwFguryX74FJRFwvQqEhn+wu9sR207uvhGU6SiDdQdIWb0Y 8XyVNW3Fq7Iee4vXkP+3WNIAIOiWKX4emhDDLoREs4DgyIbRFTL45GCYNqFZHoUdgL9uZf32sD S81l6wCmyddCESFHLHEt4qgMLTq9hzzKervYWVN5ZTli0KXf9zzKnJw+8j7PlxHRzB38EqQhVS Ju9icWXj5mIDdOGMqDgCEp6m5F3ge67ZXBQJQPMgpigEjAYnVDnoa7FmHsiT9MDhFtMM5sZ9+e +w4=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20/07/2020 16:20, Jan Beulich wrote:
> wakeup_32 sets %ds and %es to BOOT_DS, while leaving %fs at what
> wakeup_start did set it to, and %gs at whatever BIOS did load into it.
> All of this may end up confusing the first load_segments() to run on
> the BSP after resume, in particular allowing a non-nul selector value
> to be left in %fs.
> Alongside %ss, also put all other data segment registers into the same
> state that the boot and CPU bringup paths put them in.
> Reported-by: M. Vefa Bicakci <m.v.b@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> --- a/xen/arch/x86/acpi/wakeup_prot.S
> +++ b/xen/arch/x86/acpi/wakeup_prot.S
> @@ -52,6 +52,16 @@ ENTRY(s3_resume)
>          mov     %eax, %ss
>          mov     saved_rsp(%rip), %rsp
> +        /*
> +         * Also put other segment registers into known state, like would
> +         * be done on the boot path. This is in particular necessary for
> +         * the first load_segments() to work as intended.
> +         */

I don't think the comment is helpful, not least because it refers to a
broken behaviour in load_segemnts() which is soon going to change anyway.

We've literally just loaded the GDT, at which point reloading all
segments *is* the expected thing to do.

I'd recommend that the diff be simply:

diff --git a/xen/arch/x86/acpi/wakeup_prot.S
index dcc7e2327d..a2c41c4f3f 100644
--- a/xen/arch/x86/acpi/wakeup_prot.S
+++ b/xen/arch/x86/acpi/wakeup_prot.S
@@ -49,6 +49,10 @@ ENTRY(s3_resume)
         mov     %rax, %cr0
         mov     $__HYPERVISOR_DS64, %eax
+        mov     %eax, %ds
+        mov     %eax, %es
+        mov     %eax, %fs
+        mov     %eax, %gs
         mov     %eax, %ss
         mov     saved_rsp(%rip), %rsp

It is a shame that the CR0 load breaks up the obvious connection with
lgdt, but IIRC, that was a consequence of how the code was laid out

Preferably with the above diff, Reviewed-by: Andrew Cooper



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.