xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH] x86/boot: Various bits of trampoline cleanup
@ 2019-08-19 13:42 Andrew Cooper
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections Andrew Cooper
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andrew Cooper @ 2019-08-19 13:42 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné

Andrew Cooper (3):
  x86/boot: Further minor GDT corrections
  x86/boot: Reposition trampoline data
  x86/boot: Drop all use of lmsw

 xen/arch/x86/boot/head.S          |  2 +-
 xen/arch/x86/boot/trampoline.S    | 78 +++++++++++++++++----------------------
 xen/arch/x86/boot/wakeup.S        |  5 ++-
 xen/arch/x86/x86_64/kexec_reloc.S |  4 +-
 4 files changed, 40 insertions(+), 49 deletions(-)

-- 
2.11.0


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

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

* [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections
  2019-08-19 13:42 [Xen-devel] [PATCH] x86/boot: Various bits of trampoline cleanup Andrew Cooper
@ 2019-08-19 13:42 ` Andrew Cooper
  2019-08-27 14:49   ` Jan Beulich
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Reposition trampoline data Andrew Cooper
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Drop all use of lmsw Andrew Cooper
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew Cooper @ 2019-08-19 13:42 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné

gdt_boot_descr and gdt_48 disagree on how long trampoline_gdt is.

Introduce an end label and have the linker calculate the size, rather than
hard coding it.

Also, just as with c/s af292b41e9, there is no point forcing the CPU to set
Access bits.  Fix all remaining GDTs in Xen.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>

The trampoline GDT access bits were actually noticed when trying to clean up
our boot time pagetables and map the trampoline read-only.
---
 xen/arch/x86/boot/head.S          |  2 +-
 xen/arch/x86/boot/trampoline.S    | 15 ++++++++-------
 xen/arch/x86/x86_64/kexec_reloc.S |  4 ++--
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 26b680521d..9fdb9b3954 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -129,7 +129,7 @@ multiboot2_header:
 
         .word   0
 gdt_boot_descr:
-        .word   7*8-1
+        .word   .Ltramopline_gdt_end - trampoline_gdt - 1
 gdt_boot_base:
         .long   sym_offs(trampoline_gdt)
         .long   0 /* Needed for 64-bit lgdt */
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 7c6a2328d2..1761fc1213 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -63,22 +63,23 @@ trampoline_gdt:
         /* 0x0000: unused */
         .quad   0x0000000000000000
         /* 0x0008: ring 0 code, 32-bit mode */
-        .quad   0x00cf9a000000ffff
+        .quad   0x00cf9b000000ffff
         /* 0x0010: ring 0 code, 64-bit mode */
-        .quad   0x00af9a000000ffff
+        .quad   0x00af9b000000ffff
         /* 0x0018: ring 0 data */
-        .quad   0x00cf92000000ffff
+        .quad   0x00cf93000000ffff
         /* 0x0020: real-mode code @ BOOT_TRAMPOLINE */
         .long   0x0000ffff
-        .long   0x00009a00
+        .long   0x00009b00
         /* 0x0028: real-mode data @ BOOT_TRAMPOLINE */
         .long   0x0000ffff
-        .long   0x00009200
+        .long   0x00009300
         /*
          * 0x0030: ring 0 Xen data, 16 MiB size, base
          * address is computed at runtime.
          */
-        .quad   0x00c0920000000fff
+        .quad   0x00c0930000000fff
+.Ltramopline_gdt_end:
 
         .pushsection .trampoline_rel, "a"
         .long   trampoline_gdt + BOOT_PSEUDORM_CS + 2 - .
@@ -182,7 +183,7 @@ start64:
         .word   0
 idt_48: .word   0, 0, 0 # base = limit = 0
         .word   0
-gdt_48: .word   6*8-1
+gdt_48: .word   .Ltramopline_gdt_end - trampoline_gdt - 1
         .long   bootsym_rel(trampoline_gdt,4)
 
 /* The first page of trampoline is permanent, the rest boot-time only. */
diff --git a/xen/arch/x86/x86_64/kexec_reloc.S b/xen/arch/x86/x86_64/kexec_reloc.S
index 5bf61d5c2d..9e5b7a6ba1 100644
--- a/xen/arch/x86/x86_64/kexec_reloc.S
+++ b/xen/arch/x86/x86_64/kexec_reloc.S
@@ -182,8 +182,8 @@ compat_mode_gdt_desc:
         .align 8
 compat_mode_gdt:
         .quad 0x0000000000000000     /* null                              */
-        .quad 0x00cf92000000ffff     /* 0x0008 ring 0 data                */
-        .quad 0x00cf9a000000ffff     /* 0x0010 ring 0 code, compatibility */
+        .quad 0x00cf93000000ffff     /* 0x0008 ring 0 data                */
+        .quad 0x00cf9b000000ffff     /* 0x0010 ring 0 code, compatibility */
 
 compat_mode_idt:
         .word 0                      /* limit */
-- 
2.11.0


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

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

* [Xen-devel] [PATCH] x86/boot: Reposition trampoline data
  2019-08-19 13:42 [Xen-devel] [PATCH] x86/boot: Various bits of trampoline cleanup Andrew Cooper
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections Andrew Cooper
@ 2019-08-19 13:42 ` Andrew Cooper
  2019-08-19 16:02   ` David Woodhouse
  2019-08-27 14:50   ` Jan Beulich
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Drop all use of lmsw Andrew Cooper
  2 siblings, 2 replies; 8+ messages in thread
From: Andrew Cooper @ 2019-08-19 13:42 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné

... to separate code from data.  In particular, trampoline_realmode_entry's
write to trampoline_cpu_started clobbers the I-cache line containing
trampoline_protmode_entry, which won't be great for AP startup.

Reformat the comments for trampoline_gdt to reduce their volume.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/boot/trampoline.S | 67 ++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 39 deletions(-)

diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 1761fc1213..1b11b4757a 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -59,45 +59,6 @@ GLOBAL(trampoline_realmode_entry)
         lmsw    %ax                       # CR0.PE = 1 (enter protected mode)
         ljmpl   $BOOT_CS32,$bootsym_rel(trampoline_protmode_entry,6)
 
-trampoline_gdt:
-        /* 0x0000: unused */
-        .quad   0x0000000000000000
-        /* 0x0008: ring 0 code, 32-bit mode */
-        .quad   0x00cf9b000000ffff
-        /* 0x0010: ring 0 code, 64-bit mode */
-        .quad   0x00af9b000000ffff
-        /* 0x0018: ring 0 data */
-        .quad   0x00cf93000000ffff
-        /* 0x0020: real-mode code @ BOOT_TRAMPOLINE */
-        .long   0x0000ffff
-        .long   0x00009b00
-        /* 0x0028: real-mode data @ BOOT_TRAMPOLINE */
-        .long   0x0000ffff
-        .long   0x00009300
-        /*
-         * 0x0030: ring 0 Xen data, 16 MiB size, base
-         * address is computed at runtime.
-         */
-        .quad   0x00c0930000000fff
-.Ltramopline_gdt_end:
-
-        .pushsection .trampoline_rel, "a"
-        .long   trampoline_gdt + BOOT_PSEUDORM_CS + 2 - .
-        .long   trampoline_gdt + BOOT_PSEUDORM_DS + 2 - .
-        .popsection
-
-GLOBAL(trampoline_misc_enable_off)
-        .quad   0
-
-GLOBAL(cpuid_ext_features)
-        .long   0
-
-GLOBAL(trampoline_xen_phys_start)
-        .long   0
-
-GLOBAL(trampoline_cpu_started)
-        .byte   0
-
         .code32
 trampoline_protmode_entry:
         /* Set up a few descriptors: on entry only CS is guaranteed good. */
@@ -186,6 +147,34 @@ idt_48: .word   0, 0, 0 # base = limit = 0
 gdt_48: .word   .Ltramopline_gdt_end - trampoline_gdt - 1
         .long   bootsym_rel(trampoline_gdt,4)
 
+trampoline_gdt:
+        .quad   0x0000000000000000 /* 0x0000: unused */
+        .quad   0x00cf9b000000ffff /* 0x0008: ring 0 code, 32-bit mode */
+        .quad   0x00af9b000000ffff /* 0x0010: ring 0 code, 64-bit mode */
+        .quad   0x00cf93000000ffff /* 0x0018: ring 0 data */
+        .quad   0x00009b000000ffff /* 0x0020: real-mode code @ BOOT_TRAMPOLINE */
+        .quad   0x000093000000ffff /* 0x0028: real-mode data @ BOOT_TRAMPOLINE */
+        .quad   0x00c0930000000fff /* 0x0030: ring 0 Xen data, 16M @ XEN */
+.Ltramopline_gdt_end:
+
+        /* Relocations for trampoline Real Mode segments. */
+        .pushsection .trampoline_rel, "a"
+        .long   trampoline_gdt + BOOT_PSEUDORM_CS + 2 - .
+        .long   trampoline_gdt + BOOT_PSEUDORM_DS + 2 - .
+        .popsection
+
+GLOBAL(trampoline_misc_enable_off)
+        .quad   0
+
+GLOBAL(cpuid_ext_features)
+        .long   0
+
+GLOBAL(trampoline_xen_phys_start)
+        .long   0
+
+GLOBAL(trampoline_cpu_started)
+        .byte   0
+
 /* The first page of trampoline is permanent, the rest boot-time only. */
 /* Reuse the boot trampoline on the 1st trampoline page as stack for wakeup. */
         .equ    wakeup_stack, trampoline_start + PAGE_SIZE
-- 
2.11.0


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

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

* [Xen-devel] [PATCH] x86/boot: Drop all use of lmsw
  2019-08-19 13:42 [Xen-devel] [PATCH] x86/boot: Various bits of trampoline cleanup Andrew Cooper
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections Andrew Cooper
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Reposition trampoline data Andrew Cooper
@ 2019-08-19 13:42 ` Andrew Cooper
  2019-08-27 14:52   ` Jan Beulich
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew Cooper @ 2019-08-19 13:42 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné

lmsw is an obsolete relic of the 286 processor - so much so that it even lacks
intercept assistance on AMD processors.

Use a plain mov to %cr0 which is easier to follow, certainly faster to
virtualise on AMD hardware, and almost certainly a faster microcode path in
real hardware.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/boot/trampoline.S | 12 ++++++------
 xen/arch/x86/boot/wakeup.S     |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 1b11b4757a..89f841331d 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -54,9 +54,10 @@ GLOBAL(trampoline_realmode_entry)
         lidt    bootsym(idt_48)
         lgdt    bootsym(gdt_48)
         mov     $1,%bl                    # EBX != 0 indicates we are an AP
-        xor     %ax, %ax
-        inc     %ax
-        lmsw    %ax                       # CR0.PE = 1 (enter protected mode)
+
+        mov     $X86_CR0_PE, %eax
+        mov     %eax, %cr0
+
         ljmpl   $BOOT_CS32,$bootsym_rel(trampoline_protmode_entry,6)
 
         .code32
@@ -252,9 +253,8 @@ trampoline_boot_cpu_entry:
         lgdt    bootsym(gdt_48)
 
         /* Enter protected mode, and flush insn queue. */
-        xor     %ax,%ax
-        inc     %ax
-        lmsw    %ax                       # CR0.PE = 1 (enter protected mode)
+        mov     $X86_CR0_PE, %eax
+        mov     %eax, %cr0
 
         /* Load proper protected-mode values into all segment registers. */
         ljmpl   $BOOT_CS32,$bootsym_rel(1f,6)
diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
index e3cb9e033a..2af6c6017c 100644
--- a/xen/arch/x86/boot/wakeup.S
+++ b/xen/arch/x86/boot/wakeup.S
@@ -51,8 +51,9 @@ ENTRY(wakeup_start)
         lidt    wakesym(idt_48)
         lgdt    wakesym(gdt_48)
 
-        movw    $1, %ax
-        lmsw    %ax             # Turn on CR0.PE 
+        mov     $X86_CR0_PE, %eax
+        mov     %eax, %cr0
+
         ljmpl   $BOOT_CS32, $bootsym_rel(wakeup_32, 6)
 
 /* This code uses an extended set of video mode numbers. These include:
-- 
2.11.0


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

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

* Re: [Xen-devel] [PATCH] x86/boot: Reposition trampoline data
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Reposition trampoline data Andrew Cooper
@ 2019-08-19 16:02   ` David Woodhouse
  2019-08-27 14:50   ` Jan Beulich
  1 sibling, 0 replies; 8+ messages in thread
From: David Woodhouse @ 2019-08-19 16:02 UTC (permalink / raw)
  To: Andrew Cooper, Xen-devel; +Cc: Jan Beulich, Wei Liu, Roger Pau Monné


[-- Attachment #1.1: Type: text/plain, Size: 4295 bytes --]

On Mon, 2019-08-19 at 14:42 +0100, Andrew Cooper wrote:
> ... to separate code from data.  In particular,
> trampoline_realmode_entry's
> write to trampoline_cpu_started clobbers the I-cache line containing
> trampoline_protmode_entry, which won't be great for AP startup.
> 
> Reformat the comments for trampoline_gdt to reduce their volume.
> 
> No functional change.

Please, let's not do this one until my other boot cleanups have landed.
It just hurts. I have also reordered some of these for functional
reasons, because they are used in different contexts (and end up in
completely different trampolines).

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wl@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> ---
>  xen/arch/x86/boot/trampoline.S | 67 ++++++++++++++++++------------
> ------------
>  1 file changed, 28 insertions(+), 39 deletions(-)
> 
> diff --git a/xen/arch/x86/boot/trampoline.S
> b/xen/arch/x86/boot/trampoline.S
> index 1761fc1213..1b11b4757a 100644
> --- a/xen/arch/x86/boot/trampoline.S
> +++ b/xen/arch/x86/boot/trampoline.S
> @@ -59,45 +59,6 @@ GLOBAL(trampoline_realmode_entry)
>          lmsw    %ax                       # CR0.PE = 1 (enter
> protected mode)
>          ljmpl   $BOOT_CS32,$bootsym_rel(trampoline_protmode_entry,6)
>  
> -trampoline_gdt:
> -        /* 0x0000: unused */
> -        .quad   0x0000000000000000
> -        /* 0x0008: ring 0 code, 32-bit mode */
> -        .quad   0x00cf9b000000ffff
> -        /* 0x0010: ring 0 code, 64-bit mode */
> -        .quad   0x00af9b000000ffff
> -        /* 0x0018: ring 0 data */
> -        .quad   0x00cf93000000ffff
> -        /* 0x0020: real-mode code @ BOOT_TRAMPOLINE */
> -        .long   0x0000ffff
> -        .long   0x00009b00
> -        /* 0x0028: real-mode data @ BOOT_TRAMPOLINE */
> -        .long   0x0000ffff
> -        .long   0x00009300
> -        /*
> -         * 0x0030: ring 0 Xen data, 16 MiB size, base
> -         * address is computed at runtime.
> -         */
> -        .quad   0x00c0930000000fff
> -.Ltramopline_gdt_end:
> -
> -        .pushsection .trampoline_rel, "a"
> -        .long   trampoline_gdt + BOOT_PSEUDORM_CS + 2 - .
> -        .long   trampoline_gdt + BOOT_PSEUDORM_DS + 2 - .
> -        .popsection
> -
> -GLOBAL(trampoline_misc_enable_off)
> -        .quad   0
> -
> -GLOBAL(cpuid_ext_features)
> -        .long   0
> -
> -GLOBAL(trampoline_xen_phys_start)
> -        .long   0
> -
> -GLOBAL(trampoline_cpu_started)
> -        .byte   0
> -
>          .code32
>  trampoline_protmode_entry:
>          /* Set up a few descriptors: on entry only CS is guaranteed
> good. */
> @@ -186,6 +147,34 @@ idt_48: .word   0, 0, 0 # base = limit = 0
>  gdt_48: .word   .Ltramopline_gdt_end - trampoline_gdt - 1
>          .long   bootsym_rel(trampoline_gdt,4)
>  
> +trampoline_gdt:
> +        .quad   0x0000000000000000 /* 0x0000: unused */
> +        .quad   0x00cf9b000000ffff /* 0x0008: ring 0 code, 32-bit
> mode */
> +        .quad   0x00af9b000000ffff /* 0x0010: ring 0 code, 64-bit
> mode */
> +        .quad   0x00cf93000000ffff /* 0x0018: ring 0 data */
> +        .quad   0x00009b000000ffff /* 0x0020: real-mode code @
> BOOT_TRAMPOLINE */
> +        .quad   0x000093000000ffff /* 0x0028: real-mode data @
> BOOT_TRAMPOLINE */
> +        .quad   0x00c0930000000fff /* 0x0030: ring 0 Xen data, 16M @
> XEN */
> +.Ltramopline_gdt_end:
> +
> +        /* Relocations for trampoline Real Mode segments. */
> +        .pushsection .trampoline_rel, "a"
> +        .long   trampoline_gdt + BOOT_PSEUDORM_CS + 2 - .
> +        .long   trampoline_gdt + BOOT_PSEUDORM_DS + 2 - .
> +        .popsection
> +
> +GLOBAL(trampoline_misc_enable_off)
> +        .quad   0
> +
> +GLOBAL(cpuid_ext_features)
> +        .long   0
> +
> +GLOBAL(trampoline_xen_phys_start)
> +        .long   0
> +
> +GLOBAL(trampoline_cpu_started)
> +        .byte   0
> +
>  /* The first page of trampoline is permanent, the rest boot-time
> only. */
>  /* Reuse the boot trampoline on the 1st trampoline page as stack for
> wakeup. */
>          .equ    wakeup_stack, trampoline_start + PAGE_SIZE


[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5174 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

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

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

* Re: [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections Andrew Cooper
@ 2019-08-27 14:49   ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2019-08-27 14:49 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Roger Pau Monné

On 19.08.2019 15:42, Andrew Cooper wrote:
> gdt_boot_descr and gdt_48 disagree on how long trampoline_gdt is.
> 
> Introduce an end label and have the linker calculate the size, rather than
> hard coding it.
> 
> Also, just as with c/s af292b41e9, there is no point forcing the CPU to set
> Access bits.  Fix all remaining GDTs in Xen.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wl@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> 
> The trampoline GDT access bits were actually noticed when trying to clean up
> our boot time pagetables and map the trampoline read-only.
> ---
>   xen/arch/x86/boot/head.S          |  2 +-
>   xen/arch/x86/boot/trampoline.S    | 15 ++++++++-------
>   xen/arch/x86/x86_64/kexec_reloc.S |  4 ++--
>   3 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index 26b680521d..9fdb9b3954 100644
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -129,7 +129,7 @@ multiboot2_header:
>   
>           .word   0
>   gdt_boot_descr:
> -        .word   7*8-1
> +        .word   .Ltramopline_gdt_end - trampoline_gdt - 1
>   gdt_boot_base:
>           .long   sym_offs(trampoline_gdt)
>           .long   0 /* Needed for 64-bit lgdt */
> diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
> index 7c6a2328d2..1761fc1213 100644
> --- a/xen/arch/x86/boot/trampoline.S
> +++ b/xen/arch/x86/boot/trampoline.S
> @@ -63,22 +63,23 @@ trampoline_gdt:
>           /* 0x0000: unused */
>           .quad   0x0000000000000000
>           /* 0x0008: ring 0 code, 32-bit mode */
> -        .quad   0x00cf9a000000ffff
> +        .quad   0x00cf9b000000ffff
>           /* 0x0010: ring 0 code, 64-bit mode */
> -        .quad   0x00af9a000000ffff
> +        .quad   0x00af9b000000ffff
>           /* 0x0018: ring 0 data */
> -        .quad   0x00cf92000000ffff
> +        .quad   0x00cf93000000ffff
>           /* 0x0020: real-mode code @ BOOT_TRAMPOLINE */
>           .long   0x0000ffff
> -        .long   0x00009a00
> +        .long   0x00009b00
>           /* 0x0028: real-mode data @ BOOT_TRAMPOLINE */
>           .long   0x0000ffff
> -        .long   0x00009200
> +        .long   0x00009300
>           /*
>            * 0x0030: ring 0 Xen data, 16 MiB size, base
>            * address is computed at runtime.
>            */
> -        .quad   0x00c0920000000fff
> +        .quad   0x00c0930000000fff
> +.Ltramopline_gdt_end:

With the typo here fixed

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

But may I talk you into ...

> --- a/xen/arch/x86/x86_64/kexec_reloc.S
> +++ b/xen/arch/x86/x86_64/kexec_reloc.S
> @@ -182,8 +182,8 @@ compat_mode_gdt_desc:
>           .align 8
>   compat_mode_gdt:
>           .quad 0x0000000000000000     /* null                              */
> -        .quad 0x00cf92000000ffff     /* 0x0008 ring 0 data                */
> -        .quad 0x00cf9a000000ffff     /* 0x0010 ring 0 code, compatibility */
> +        .quad 0x00cf93000000ffff     /* 0x0008 ring 0 data                */
> +        .quad 0x00cf9b000000ffff     /* 0x0010 ring 0 code, compatibility */

... introducing a similar "end" label here and using it at
compat_mode_gdt_desc (the R-b above stands with that change)?

Jan

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

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

* Re: [Xen-devel] [PATCH] x86/boot: Reposition trampoline data
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Reposition trampoline data Andrew Cooper
  2019-08-19 16:02   ` David Woodhouse
@ 2019-08-27 14:50   ` Jan Beulich
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2019-08-27 14:50 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Roger Pau Monné

On 19.08.2019 15:42, Andrew Cooper wrote:
> ... to separate code from data.  In particular, trampoline_realmode_entry's
> write to trampoline_cpu_started clobbers the I-cache line containing
> trampoline_protmode_entry, which won't be great for AP startup.
> 
> Reformat the comments for trampoline_gdt to reduce their volume.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

, ... subject to David's concern wrt his series.

Jan

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

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

* Re: [Xen-devel] [PATCH] x86/boot: Drop all use of lmsw
  2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Drop all use of lmsw Andrew Cooper
@ 2019-08-27 14:52   ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2019-08-27 14:52 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Roger Pau Monné

On 19.08.2019 15:42, Andrew Cooper wrote:
> lmsw is an obsolete relic of the 286 processor - so much so that it even lacks
> intercept assistance on AMD processors.
> 
> Use a plain mov to %cr0 which is easier to follow, certainly faster to
> virtualise on AMD hardware, and almost certainly a faster microcode path in
> real hardware.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

with one further suggestion:

> --- a/xen/arch/x86/boot/trampoline.S
> +++ b/xen/arch/x86/boot/trampoline.S
> @@ -54,9 +54,10 @@ GLOBAL(trampoline_realmode_entry)
>          lidt    bootsym(idt_48)
>          lgdt    bootsym(gdt_48)
>          mov     $1,%bl                    # EBX != 0 indicates we are an AP
> -        xor     %ax, %ax
> -        inc     %ax
> -        lmsw    %ax                       # CR0.PE = 1 (enter protected mode)
> +
> +        mov     $X86_CR0_PE, %eax
> +        mov     %eax, %cr0

Why don't you use %ebx here, allowing the move to %bl to be
dropped at the same time?

Jan

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

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

end of thread, other threads:[~2019-08-27 14:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 13:42 [Xen-devel] [PATCH] x86/boot: Various bits of trampoline cleanup Andrew Cooper
2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Further minor GDT corrections Andrew Cooper
2019-08-27 14:49   ` Jan Beulich
2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Reposition trampoline data Andrew Cooper
2019-08-19 16:02   ` David Woodhouse
2019-08-27 14:50   ` Jan Beulich
2019-08-19 13:42 ` [Xen-devel] [PATCH] x86/boot: Drop all use of lmsw Andrew Cooper
2019-08-27 14:52   ` 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).