On Thu, Mar 3, 2016 at 4:28 AM, Borislav Petkov wrote:
> From: Borislav Petkov
> Date: Sun, 28 Feb 2016 21:35:44 +0100
> Subject: [PATCH -v2] x86/asm: Make sure verify_cpu() has a good stack
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode
On Thu, Mar 3, 2016 at 4:28 AM, Borislav Petkov wrote:
> From: Borislav Petkov
> Date: Sun, 28 Feb 2016 21:35:44 +0100
> Subject: [PATCH -v2] x86/asm: Make sure verify_cpu() has a good stack
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to
On Thu, Mar 3, 2016 at 4:28 AM, Borislav Petkov wrote:
>
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to verify_cpu() for sanitizing CPU configuration.
>
> The latter uses the stack minimally and it can happen that we land in
>
On Thu, Mar 3, 2016 at 4:28 AM, Borislav Petkov wrote:
>
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to verify_cpu() for sanitizing CPU configuration.
>
> The latter uses the stack minimally and it can happen that we land in
> startup_64()
On Thu, Mar 03, 2016 at 01:22:59PM -0800, H. Peter Anvin wrote:
> reason I can see for -8 though.
... and keeping the -8 won't hurt us or anything. I'll add a small
comment about it.
Thanks.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
On Thu, Mar 03, 2016 at 01:22:59PM -0800, H. Peter Anvin wrote:
> reason I can see for -8 though.
... and keeping the -8 won't hurt us or anything. I'll add a small
comment about it.
Thanks.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
On 03/03/16 12:54, Borislav Petkov wrote:
> On Thu, Mar 03, 2016 at 12:22:06PM -0800, H. Peter Anvin wrote:
>> The only thing I can think of is that the -8 creates a null pointer that
>> terminates a stack trace.
>
> Probably not needed anymore as print_context_stack()->valid_stack_ptr()
> in
On 03/03/16 12:54, Borislav Petkov wrote:
> On Thu, Mar 03, 2016 at 12:22:06PM -0800, H. Peter Anvin wrote:
>> The only thing I can think of is that the -8 creates a null pointer that
>> terminates a stack trace.
>
> Probably not needed anymore as print_context_stack()->valid_stack_ptr()
> in
On Thu, Mar 03, 2016 at 12:22:06PM -0800, H. Peter Anvin wrote:
> The only thing I can think of is that the -8 creates a null pointer that
> terminates a stack trace.
Probably not needed anymore as print_context_stack()->valid_stack_ptr()
in dumpstack.c look at the stack boundaries instead of
On Thu, Mar 03, 2016 at 12:22:06PM -0800, H. Peter Anvin wrote:
> The only thing I can think of is that the -8 creates a null pointer that
> terminates a stack trace.
Probably not needed anymore as print_context_stack()->valid_stack_ptr()
in dumpstack.c look at the stack boundaries instead of
On 03/03/16 08:29, Borislav Petkov wrote:
> On Thu, Mar 03, 2016 at 07:26:06AM -0800, H. Peter Anvin wrote:
>> Why -8?
>
> GLOBAL(stack_start)
> .quad init_thread_union+THREAD_SIZE-8
> ^^^
>
> But I don't see why it needed the -8 then.
On 03/03/16 08:29, Borislav Petkov wrote:
> On Thu, Mar 03, 2016 at 07:26:06AM -0800, H. Peter Anvin wrote:
>> Why -8?
>
> GLOBAL(stack_start)
> .quad init_thread_union+THREAD_SIZE-8
> ^^^
>
> But I don't see why it needed the -8 then.
On Thu, Mar 03, 2016 at 07:26:06AM -0800, H. Peter Anvin wrote:
> Why -8?
GLOBAL(stack_start)
.quad init_thread_union+THREAD_SIZE-8
^^^
But I don't see why it needed the -8 then. It came with a conglomerate
dump in 2002:
commit
On Thu, Mar 03, 2016 at 07:26:06AM -0800, H. Peter Anvin wrote:
> Why -8?
GLOBAL(stack_start)
.quad init_thread_union+THREAD_SIZE-8
^^^
But I don't see why it needed the -8 then. It came with a conglomerate
dump in 2002:
commit
On March 3, 2016 4:28:36 AM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 02:32:54PM -0800, H. Peter Anvin wrote:
>> I'm trying to think of any reason why we couldn't simply have a
>symbol
>> at the top of the initial stack? Then a simple leaq would suffice;
>> this is for
On March 3, 2016 4:28:36 AM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 02:32:54PM -0800, H. Peter Anvin wrote:
>> I'm trying to think of any reason why we couldn't simply have a
>symbol
>> at the top of the initial stack? Then a simple leaq would suffice;
>> this is for the BSP after
On Wed, Mar 02, 2016 at 02:32:54PM -0800, H. Peter Anvin wrote:
> I'm trying to think of any reason why we couldn't simply have a symbol
> at the top of the initial stack? Then a simple leaq would suffice;
> this is for the BSP after all.
How about something like this:
---
From: Borislav Petkov
On Wed, Mar 02, 2016 at 02:32:54PM -0800, H. Peter Anvin wrote:
> I'm trying to think of any reason why we couldn't simply have a symbol
> at the top of the initial stack? Then a simple leaq would suffice;
> this is for the BSP after all.
How about something like this:
---
From: Borislav Petkov
On Wed, Mar 2, 2016 at 5:00 PM, Yinghai Lu wrote:
> On Wed, Mar 2, 2016 at 4:13 PM, Yinghai Lu wrote:
>> On Wed, Mar 2, 2016 at 2:32 PM, H. Peter Anvin wrote:
>>>
>>> I'm trying to think of any reason why we couldn't simply have a symbol
On Wed, Mar 2, 2016 at 5:00 PM, Yinghai Lu wrote:
> On Wed, Mar 2, 2016 at 4:13 PM, Yinghai Lu wrote:
>> On Wed, Mar 2, 2016 at 2:32 PM, H. Peter Anvin wrote:
>>>
>>> I'm trying to think of any reason why we couldn't simply have a symbol at
>>> the top of the initial stack? Then a simple leaq
On Wed, Mar 2, 2016 at 4:13 PM, Yinghai Lu wrote:
> On Wed, Mar 2, 2016 at 2:32 PM, H. Peter Anvin wrote:
>>
>> I'm trying to think of any reason why we couldn't simply have a symbol at
>> the top of the initial stack? Then a simple leaq would suffice; this
On Wed, Mar 2, 2016 at 4:13 PM, Yinghai Lu wrote:
> On Wed, Mar 2, 2016 at 2:32 PM, H. Peter Anvin wrote:
>>
>> I'm trying to think of any reason why we couldn't simply have a symbol at
>> the top of the initial stack? Then a simple leaq would suffice; this is for
>> the BSP after all.
>
>
On Wed, Mar 2, 2016 at 2:32 PM, H. Peter Anvin wrote:
>
> I'm trying to think of any reason why we couldn't simply have a symbol at the
> top of the initial stack? Then a simple leaq would suffice; this is for the
> BSP after all.
Why do we need to call verify_cpu in
On Wed, Mar 2, 2016 at 2:32 PM, H. Peter Anvin wrote:
>
> I'm trying to think of any reason why we couldn't simply have a symbol at the
> top of the initial stack? Then a simple leaq would suffice; this is for the
> BSP after all.
Why do we need to call verify_cpu in arch/x86/kernel/head_64.S
On Wed, Mar 02, 2016 at 02:32:54PM -0800, H. Peter Anvin wrote:
> I'm trying to think of any reason why we couldn't simply have a symbol
> at the top of the initial stack? Then a simple leaq would suffice;
> this is for the BSP after all.
That should be simpler. And we do games like that already
On Wed, Mar 02, 2016 at 02:32:54PM -0800, H. Peter Anvin wrote:
> I'm trying to think of any reason why we couldn't simply have a symbol
> at the top of the initial stack? Then a simple leaq would suffice;
> this is for the BSP after all.
That should be simpler. And we do games like that already
On March 2, 2016 2:28:42 PM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 02:11:51PM -0800, H. Peter Anvin wrote:
>> Not sure if we need a reference to _text here.
>
>Ah, so stack_start is in .ref.data, I guess we can add a __ref_data
>marker in vmlinux.lds.S to denote the
On March 2, 2016 2:28:42 PM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 02:11:51PM -0800, H. Peter Anvin wrote:
>> Not sure if we need a reference to _text here.
>
>Ah, so stack_start is in .ref.data, I guess we can add a __ref_data
>marker in vmlinux.lds.S to denote the start of the
On Wed, Mar 02, 2016 at 02:11:51PM -0800, H. Peter Anvin wrote:
> Not sure if we need a reference to _text here.
Ah, so stack_start is in .ref.data, I guess we can add a __ref_data
marker in vmlinux.lds.S to denote the start of the .ref.data section and
use that for calculating the delta...
--
On Wed, Mar 02, 2016 at 02:11:51PM -0800, H. Peter Anvin wrote:
> Not sure if we need a reference to _text here.
Ah, so stack_start is in .ref.data, I guess we can add a __ref_data
marker in vmlinux.lds.S to denote the start of the .ref.data section and
use that for calculating the delta...
--
On 03/02/16 14:09, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 01:54:50PM -0800, H. Peter Anvin wrote:
>> A relocating bootloader is one that doesn't load the kernel at
>> CONFIG_PHYSICAL_ADDRESS. The EFI stub is one example.
>>
>> __START_KERNEL_map is not relocated. On x86-64 we do
On 03/02/16 14:09, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 01:54:50PM -0800, H. Peter Anvin wrote:
>> A relocating bootloader is one that doesn't load the kernel at
>> CONFIG_PHYSICAL_ADDRESS. The EFI stub is one example.
>>
>> __START_KERNEL_map is not relocated. On x86-64 we do
On Wed, Mar 02, 2016 at 01:54:50PM -0800, H. Peter Anvin wrote:
> A relocating bootloader is one that doesn't load the kernel at
> CONFIG_PHYSICAL_ADDRESS. The EFI stub is one example.
>
> __START_KERNEL_map is not relocated. On x86-64 we do relocation by
> pointing the page tables at a
On Wed, Mar 02, 2016 at 01:54:50PM -0800, H. Peter Anvin wrote:
> A relocating bootloader is one that doesn't load the kernel at
> CONFIG_PHYSICAL_ADDRESS. The EFI stub is one example.
>
> __START_KERNEL_map is not relocated. On x86-64 we do relocation by
> pointing the page tables at a
On 03/02/16 13:46, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 01:35:09PM -0800, H. Peter Anvin wrote:
>> You're not actually testing anything as the real issue is what happens
>> with a relocating bootloader.
>
> Hmm, how would that relocation happen so that va - __START_KERNEL_map
>
On 03/02/16 13:46, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 01:35:09PM -0800, H. Peter Anvin wrote:
>> You're not actually testing anything as the real issue is what happens
>> with a relocating bootloader.
>
> Hmm, how would that relocation happen so that va - __START_KERNEL_map
>
On Wed, Mar 02, 2016 at 01:35:09PM -0800, H. Peter Anvin wrote:
> You're not actually testing anything as the real issue is what happens
> with a relocating bootloader.
Hmm, how would that relocation happen so that va - __START_KERNEL_map
doesn't give pa?
Or do you mean something else with
On Wed, Mar 02, 2016 at 01:35:09PM -0800, H. Peter Anvin wrote:
> You're not actually testing anything as the real issue is what happens
> with a relocating bootloader.
Hmm, how would that relocation happen so that va - __START_KERNEL_map
doesn't give pa?
Or do you mean something else with
On 03/02/16 11:50, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 10:39:05AM -0800, H. Peter Anvin wrote:
>> Well, we definitely should use %rip-relative addressing if we can.
>
> Right you are.
>
>> However, even so I believe this breaks if the kernel is loaded anywhere
>> but its default
On 03/02/16 11:50, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 10:39:05AM -0800, H. Peter Anvin wrote:
>> Well, we definitely should use %rip-relative addressing if we can.
>
> Right you are.
>
>> However, even so I believe this breaks if the kernel is loaded anywhere
>> but its default
On Wed, Mar 02, 2016 at 08:50:53PM +0100, Borislav Petkov wrote:
> But better safe than sorry.
I got this, it looks good when I'm single-stepping through it with gdb
and it boots fine in kvm. I'll run it on baremetal tomorrow:
/*
* Setup stack for verify_cpu(): make sure we
On Wed, Mar 02, 2016 at 08:50:53PM +0100, Borislav Petkov wrote:
> But better safe than sorry.
I got this, it looks good when I'm single-stepping through it with gdb
and it boots fine in kvm. I'll run it on baremetal tomorrow:
/*
* Setup stack for verify_cpu(): make sure we
On Wed, Mar 02, 2016 at 10:39:05AM -0800, H. Peter Anvin wrote:
> Well, we definitely should use %rip-relative addressing if we can.
Right you are.
> However, even so I believe this breaks if the kernel is loaded anywhere
> but its default load address. I think we need to do something like:
>
On Wed, Mar 02, 2016 at 10:39:05AM -0800, H. Peter Anvin wrote:
> Well, we definitely should use %rip-relative addressing if we can.
Right you are.
> However, even so I believe this breaks if the kernel is loaded anywhere
> but its default load address. I think we need to do something like:
>
On 03/02/16 10:15, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 09:53:28AM -0800, H. Peter Anvin wrote:
>> Please explain why we can't use rip-relative addressing in some form...
>
> We *can* do almost what Brian suggested:
>
> movqstack_start(%rip), %rsp
> subq
On 03/02/16 10:15, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 09:53:28AM -0800, H. Peter Anvin wrote:
>> Please explain why we can't use rip-relative addressing in some form...
>
> We *can* do almost what Brian suggested:
>
> movqstack_start(%rip), %rsp
> subq
On March 2, 2016 10:15:56 AM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 09:53:28AM -0800, H. Peter Anvin wrote:
>> Please explain why we can't use rip-relative addressing in some
>form...
>
>We *can* do almost what Brian suggested:
>
>movqstack_start(%rip),
On March 2, 2016 10:15:56 AM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 09:53:28AM -0800, H. Peter Anvin wrote:
>> Please explain why we can't use rip-relative addressing in some
>form...
>
>We *can* do almost what Brian suggested:
>
>movqstack_start(%rip), %rsp
>
On Wed, Mar 02, 2016 at 09:53:28AM -0800, H. Peter Anvin wrote:
> Please explain why we can't use rip-relative addressing in some form...
We *can* do almost what Brian suggested:
movqstack_start(%rip), %rsp
subq$__START_KERNEL_map, %rsp
But we still have to subtract
On Wed, Mar 02, 2016 at 09:53:28AM -0800, H. Peter Anvin wrote:
> Please explain why we can't use rip-relative addressing in some form...
We *can* do almost what Brian suggested:
movqstack_start(%rip), %rsp
subq$__START_KERNEL_map, %rsp
But we still have to subtract
On March 2, 2016 8:25:30 AM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 11:22:30AM -0500, Brian Gerst wrote:
>> This should be: movq stack_start(%rip), %rsp
>
>No it wouldn't. That doesn't work.
>
>> > + subq$__START_KERNEL_map, %rsp
>>
>> It would be better to
On March 2, 2016 8:25:30 AM PST, Borislav Petkov wrote:
>On Wed, Mar 02, 2016 at 11:22:30AM -0500, Brian Gerst wrote:
>> This should be: movq stack_start(%rip), %rsp
>
>No it wouldn't. That doesn't work.
>
>> > + subq$__START_KERNEL_map, %rsp
>>
>> It would be better to add the offset
On 02.03.2016 18:55, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 06:38:15PM +0200, Mika Penttilä wrote:
>> I actually looked at it a while too...
>>
>> The
>> movq stack_start - __START_KERNEL_map, %rsp
>>
>> turns into (objdump disassembly)
>>
>> mov0x0,%rsp
>>
>> with relocation
On 02.03.2016 18:55, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 06:38:15PM +0200, Mika Penttilä wrote:
>> I actually looked at it a while too...
>>
>> The
>> movq stack_start - __START_KERNEL_map, %rsp
>>
>> turns into (objdump disassembly)
>>
>> mov0x0,%rsp
>>
>> with relocation
On Wed, Mar 02, 2016 at 06:38:15PM +0200, Mika Penttilä wrote:
> I actually looked at it a while too...
>
> The
> movq stack_start - __START_KERNEL_map, %rsp
>
> turns into (objdump disassembly)
>
> mov0x0,%rsp
>
> with relocation
> 0004 R_X86_64_32S
On Wed, Mar 02, 2016 at 06:38:15PM +0200, Mika Penttilä wrote:
> I actually looked at it a while too...
>
> The
> movq stack_start - __START_KERNEL_map, %rsp
>
> turns into (objdump disassembly)
>
> mov0x0,%rsp
>
> with relocation
> 0004 R_X86_64_32S
On 02.03.2016 18:15, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 05:55:14PM +0200, Mika Penttilä wrote:
>>> + /* Setup a stack for verify_cpu */
>>> + movqstack_start - __START_KERNEL_map, %rsp
>>> + subq$__START_KERNEL_map, %rsp
>>> +
>> You subtract __START_KERNEL_map twice ?
On 02.03.2016 18:15, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 05:55:14PM +0200, Mika Penttilä wrote:
>>> + /* Setup a stack for verify_cpu */
>>> + movqstack_start - __START_KERNEL_map, %rsp
>>> + subq$__START_KERNEL_map, %rsp
>>> +
>> You subtract __START_KERNEL_map twice ?
On Wed, Mar 02, 2016 at 11:22:30AM -0500, Brian Gerst wrote:
> This should be: movq stack_start(%rip), %rsp
No it wouldn't. That doesn't work.
> > + subq$__START_KERNEL_map, %rsp
>
> It would be better to add the offset to the initializer for
> stack_start instead of adjusting it at
On Wed, Mar 02, 2016 at 11:22:30AM -0500, Brian Gerst wrote:
> This should be: movq stack_start(%rip), %rsp
No it wouldn't. That doesn't work.
> > + subq$__START_KERNEL_map, %rsp
>
> It would be better to add the offset to the initializer for
> stack_start instead of adjusting it at
On Wed, Mar 2, 2016 at 6:20 AM, Borislav Petkov wrote:
> From: Borislav Petkov
>
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to verify_cpu() for sanitizing CPU configuration.
>
> The latter uses the stack
On Wed, Mar 2, 2016 at 6:20 AM, Borislav Petkov wrote:
> From: Borislav Petkov
>
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to verify_cpu() for sanitizing CPU configuration.
>
> The latter uses the stack minimally and it can happen that we
On 02.03.2016 13:20, Borislav Petkov wrote:
> From: Borislav Petkov
>
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to verify_cpu() for sanitizing CPU configuration.
>
> The latter uses the stack minimally and it can happen that we
On 02.03.2016 13:20, Borislav Petkov wrote:
> From: Borislav Petkov
>
> 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
> added the call to verify_cpu() for sanitizing CPU configuration.
>
> The latter uses the stack minimally and it can happen that we land in
>
On Wed, Mar 02, 2016 at 05:55:14PM +0200, Mika Penttilä wrote:
> > + /* Setup a stack for verify_cpu */
> > + movqstack_start - __START_KERNEL_map, %rsp
> > + subq$__START_KERNEL_map, %rsp
> > +
>
> You subtract __START_KERNEL_map twice ?
Yes. That's not very obvious and it took me
On Wed, Mar 02, 2016 at 05:55:14PM +0200, Mika Penttilä wrote:
> > + /* Setup a stack for verify_cpu */
> > + movqstack_start - __START_KERNEL_map, %rsp
> > + subq$__START_KERNEL_map, %rsp
> > +
>
> You subtract __START_KERNEL_map twice ?
Yes. That's not very obvious and it took me
From: Borislav Petkov
04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
added the call to verify_cpu() for sanitizing CPU configuration.
The latter uses the stack minimally and it can happen that we land in
startup_64() directly from a 64-bit
From: Borislav Petkov
04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too")
added the call to verify_cpu() for sanitizing CPU configuration.
The latter uses the stack minimally and it can happen that we land in
startup_64() directly from a 64-bit bootloader. Then we
68 matches
Mail list logo