Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode
* Use heap for linker script calculated constant to fix relocation symbols in mixed assembly code. * Work around a strange bug that causes the CPU to halt when accessing MMX registers in long mode
Tested on HPZ220: * Still boots in x86_32.
Change-Id: I3e72a0bebf728fb678308006ea3a3aeb92910a84 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/cpu/intel/car/non-evict/cache_as_ram.S 1 file changed, 40 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/44673/1
diff --git a/src/cpu/intel/car/non-evict/cache_as_ram.S b/src/cpu/intel/car/non-evict/cache_as_ram.S index b24f101..481cbee 100644 --- a/src/cpu/intel/car/non-evict/cache_as_ram.S +++ b/src/cpu/intel/car/non-evict/cache_as_ram.S @@ -9,6 +9,27 @@
.global bootblock_pre_c_entry
+/* Trick the linker into supporting x86_64 relocations in 32bit code */ +#ifdef __x86_64__ +rom_mtrr_mask: +.quad _rom_mtrr_mask + +rom_mtrr_base: +.quad _rom_mtrr_base + +car_mtrr_mask: +.quad _car_mtrr_mask +#else +rom_mtrr_mask: +.long _rom_mtrr_mask + +rom_mtrr_base: +.long _rom_mtrr_base + +car_mtrr_mask: +.long _car_mtrr_mask +#endif + .code32 _cache_as_ram_setup:
@@ -83,7 +104,6 @@ movl $MTRR_PHYS_MASK(1), %ecx wrmsr
- post_code(0x23) /* Set Cache-as-RAM base address. */ movl $(MTRR_PHYS_BASE(0)), %ecx @@ -96,20 +116,20 @@ /* Set Cache-as-RAM mask. */ movl $(MTRR_PHYS_MASK(0)), %ecx rdmsr - movl $_car_mtrr_mask, %eax + mov car_mtrr_mask, %eax orl $MTRR_PHYS_MASK_VALID, %eax wrmsr
/* Enable cache for our code in Flash because we do XIP here */ movl $MTRR_PHYS_BASE(1), %ecx xorl %edx, %edx - movl $_rom_mtrr_base, %eax + mov rom_mtrr_base, %eax orl $MTRR_TYPE_WRPROT, %eax wrmsr
movl $MTRR_PHYS_MASK(1), %ecx rdmsr - movl $_rom_mtrr_mask, %eax + mov rom_mtrr_mask, %eax orl $MTRR_PHYS_MASK_VALID, %eax wrmsr
@@ -208,17 +228,24 @@ the pushes below. */ andl $0xfffffff0, %esp
- /* entry64.inc preserves ebx. */ +#ifdef __x86_64__ + /* + * BUG: On some x86 platforms acessing MMX register in long mode + * causes a crash. Retrieve them here and then switch to long mode. + */ + movd %mm2, %eax + push %eax + movd %mm1, %eax /* tsc */ + push %eax + movd %mm0, %eax + push %eax + xorl %eax, %eax + push %eax /* BIST */ + #include <cpu/x86/64bit/entry64.inc>
-#ifdef __x86_64__ - - movd %mm2, %rdi - shld %rdi, 32 - movd %mm1, %rsi - or %rsi, %rdi /* tsc */ - - movd %mm0, %rsi /* BIST */ + pop %rsi /* BIST */ + pop %rdi /* tsc */ #else subl $4, %esp /* push TSC and BIST to stack */
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/1/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/1/src/cpu/intel/car/non-evict... PS1, Line 233: * BUG: On some x86 platforms acessing MMX register in long mode 'acessing' may be misspelled - perhaps 'accessing'?
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/2/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/2/src/cpu/intel/car/non-evict... PS2, Line 233: * BUG: On some x86 platforms acessing MMX register in long mode 'acessing' may be misspelled - perhaps 'accessing'?
Hello build bot (Jenkins), Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/44673
to look at the new patch set (#3).
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode
* Use heap for linker script calculated constant to fix relocation symbols in mixed assembly code. * Work around a strange bug that causes the CPU to halt when accessing MMX registers in long mode
Tested on HPZ220: * Still boots in x86_32.
Tested on Lenovo T410: * Doesn't need the MMX register fix in long mode.
Change-Id: I3e72a0bebf728fb678308006ea3a3aeb92910a84 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/cpu/intel/car/non-evict/cache_as_ram.S 1 file changed, 42 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/44673/3
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 233: * BUG: On some x86 platforms acessing MMX register in long mode 'acessing' may be misspelled - perhaps 'accessing'?
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 3: Code-Review+1
(2 comments)
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 233: * BUG: On some x86 platforms acessing MMX register in long mode
'acessing' may be misspelled - perhaps 'accessing'?
Would be good to fix
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 236: A single space should be enough
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 3: Code-Review+1
(3 comments)
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 12: /* Trick the linker into supporting x86_64 relocations in 32bit code */ : #ifdef __x86_64__ : rom_mtrr_mask: : .quad _rom_mtrr_mask : : rom_mtrr_base: : .quad _rom_mtrr_base : : car_mtrr_mask: : .quad _car_mtrr_mask : #else : rom_mtrr_mask: : .long _rom_mtrr_mask : : rom_mtrr_base: : .long _rom_mtrr_base : : car_mtrr_mask: : .long _car_mtrr_mask : #endif I think it would be a good idea to put these in a separatly linked file (with .global), to reduce boilerplate in other CAR setup files.
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 110: _car_mtrr_start Maybe be consistent about this one?
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 236:
A single space should be enough
This is the string cpuid reports in 0x80000002-0x80000004.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 236:
A single space should be enough […]
Ack
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 12: /* Trick the linker into supporting x86_64 relocations in 32bit code */ : #ifdef __x86_64__ : rom_mtrr_mask: : .quad _rom_mtrr_mask : : rom_mtrr_base: : .quad _rom_mtrr_base : : car_mtrr_mask: : .quad _car_mtrr_mask : #else : rom_mtrr_mask: : .long _rom_mtrr_mask : : rom_mtrr_base: : .long _rom_mtrr_base : : car_mtrr_mask: : .long _car_mtrr_mask : #endif
I think it would be a good idea to put these in a separatly linked file (with . […]
Done
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 110: _car_mtrr_start
Maybe be consistent about this one?
Done
Hello build bot (Jenkins), Angel Pons, Arthur Heymans, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/44673
to look at the new patch set (#4).
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode
* Use heap for linker script calculated constant to fix relocation symbols in mixed assembly code. * Work around a strange bug that causes the CPU to halt when accessing MMX registers in long mode
Tested on HPZ220: * Still boots in x86_32.
Tested on Lenovo T410: * Doesn't need the MMX register fix in long mode.
Change-Id: I3e72a0bebf728fb678308006ea3a3aeb92910a84 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- A src/cpu/intel/car/cache_as_ram_symbols.inc M src/cpu/intel/car/non-evict/cache_as_ram.S 2 files changed, 50 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/44673/4
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/4/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/4/src/cpu/intel/car/non-evict... PS4, Line 214: * BUG: On some x86 platforms acessing MMX register in long mode 'acessing' may be misspelled - perhaps 'accessing'?
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Angel Pons, Arthur Heymans, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/44673
to look at the new patch set (#5).
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode
* Use heap for linker script calculated constant to fix relocation symbols in mixed assembly code. * Work around a strange bug that causes the CPU to halt when accessing MMX registers in long mode
Tested on HPZ220: * Still boots in x86_32.
Tested on Lenovo T410: * Doesn't need the MMX register fix in long mode.
Change-Id: I3e72a0bebf728fb678308006ea3a3aeb92910a84 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- A src/cpu/intel/car/cache_as_ram_symbols.inc M src/cpu/intel/car/non-evict/cache_as_ram.S 2 files changed, 50 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/44673/5
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/3/src/cpu/intel/car/non-evict... PS3, Line 233: * BUG: On some x86 platforms acessing MMX register in long mode
Would be good to fix
Done
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Angel Pons, Arthur Heymans, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/44673
to look at the new patch set (#6).
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode
* Use heap for linker script calculated constant to fix relocation symbols in mixed assembly code.
Tested on HPZ220: * Still boots in x86_32.
Tested on Lenovo T410: * Doesn't need the MMX register fix in long mode.
Change-Id: I3e72a0bebf728fb678308006ea3a3aeb92910a84 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- A src/cpu/intel/car/cache_as_ram_symbols.inc M src/cpu/intel/car/non-evict/cache_as_ram.S 2 files changed, 39 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/44673/6
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 6: Code-Review+2
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 6: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/6/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/6/src/cpu/intel/car/non-evict... PS6, Line 11: : #include <cpu/intel/car/cache_as_ram_symbols.inc> Is having this as an *.S file linked by included via the Makefile.inc a better idea?
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 6:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/6/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/6/src/cpu/intel/car/non-evict... PS6, Line 11: : #include <cpu/intel/car/cache_as_ram_symbols.inc>
Is having this as an *.S file linked by included via the Makefile. […]
it's quite common to include assmbly files. That way there's no need for additional globals.
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
Patch Set 6:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44673/6/src/cpu/intel/car/non-evict... File src/cpu/intel/car/non-evict/cache_as_ram.S:
https://review.coreboot.org/c/coreboot/+/44673/6/src/cpu/intel/car/non-evict... PS6, Line 11: : #include <cpu/intel/car/cache_as_ram_symbols.inc>
it's quite common to include assmbly files. That way there's no need for additional globals.
Ack
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/44673 )
Change subject: cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode ......................................................................
cpu/intel/car/non-evict/cache_as_ram.S: Add support for longmode
* Use heap for linker script calculated constant to fix relocation symbols in mixed assembly code.
Tested on HPZ220: * Still boots in x86_32.
Tested on Lenovo T410: * Doesn't need the MMX register fix in long mode.
Change-Id: I3e72a0bebf728fb678308006ea3a3aeb92910a84 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/44673 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Arthur Heymans arthur@aheymans.xyz --- A src/cpu/intel/car/cache_as_ram_symbols.inc M src/cpu/intel/car/non-evict/cache_as_ram.S 2 files changed, 39 insertions(+), 6 deletions(-)
Approvals: build bot (Jenkins): Verified Arthur Heymans: Looks good to me, approved Angel Pons: Looks good to me, approved
diff --git a/src/cpu/intel/car/cache_as_ram_symbols.inc b/src/cpu/intel/car/cache_as_ram_symbols.inc new file mode 100644 index 0000000..857e039 --- /dev/null +++ b/src/cpu/intel/car/cache_as_ram_symbols.inc @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* Trick the linker into supporting x86_64 relocations in 32bit code */ +#if ENV_X86_64 +#define uintptr_t quad +#else +#define uintptr_t long +#endif + +rom_mtrr_mask: +.uintptr_t _rom_mtrr_mask + +rom_mtrr_base: +.uintptr_t _rom_mtrr_base + +car_mtrr_mask: +.uintptr_t _car_mtrr_mask + +car_mtrr_start: +.uintptr_t _car_mtrr_start diff --git a/src/cpu/intel/car/non-evict/cache_as_ram.S b/src/cpu/intel/car/non-evict/cache_as_ram.S index d087365..cde1ca3 100644 --- a/src/cpu/intel/car/non-evict/cache_as_ram.S +++ b/src/cpu/intel/car/non-evict/cache_as_ram.S @@ -9,6 +9,8 @@
.global bootblock_pre_c_entry
+#include <cpu/intel/car/cache_as_ram_symbols.inc> + .code32 _cache_as_ram_setup:
@@ -83,11 +85,10 @@ movl $MTRR_PHYS_MASK(1), %ecx wrmsr
- post_code(0x23) /* Set Cache-as-RAM base address. */ movl $(MTRR_PHYS_BASE(0)), %ecx - movl $_car_mtrr_start, %eax + movl car_mtrr_start, %eax orl $MTRR_TYPE_WRBACK, %eax xorl %edx, %edx wrmsr @@ -96,20 +97,20 @@ /* Set Cache-as-RAM mask. */ movl $(MTRR_PHYS_MASK(0)), %ecx rdmsr - movl $_car_mtrr_mask, %eax + mov car_mtrr_mask, %eax orl $MTRR_PHYS_MASK_VALID, %eax wrmsr
/* Enable cache for our code in Flash because we do XIP here */ movl $MTRR_PHYS_BASE(1), %ecx xorl %edx, %edx - movl $_rom_mtrr_base, %eax + mov rom_mtrr_base, %eax orl $MTRR_TYPE_WRPROT, %eax wrmsr
movl $MTRR_PHYS_MASK(1), %ecx rdmsr - movl $_rom_mtrr_mask, %eax + mov rom_mtrr_mask, %eax orl $MTRR_PHYS_MASK_VALID, %eax wrmsr
@@ -207,8 +208,19 @@ /* Need to align stack to 16 bytes at call instruction. Account for the pushes below. */ andl $0xfffffff0, %esp - subl $4, %esp
+#if ENV_X86_64 + + #include <cpu/x86/64bit/entry64.inc> + + movd %mm2, %rdi + shlq $32, %rdi + movd %mm1, %rsi + or %rsi, %rdi + movd %mm0, %rsi + +#else + subl $4, %esp /* push TSC and BIST to stack */ movd %mm0, %eax pushl %eax /* BIST */ @@ -216,6 +228,7 @@ pushl %eax /* tsc[63:32] */ movd %mm1, %eax pushl %eax /* tsc[31:0] */ +#endif
before_c_entry: post_code(0x29)