Port-amd64 archive

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

Re: Weird assembly code behavior

Le 12/03/2020 à 18:17, Joerg Sonnenberger a écrit :
> On Thu, Mar 12, 2020 at 03:02:32AM +0100, Emmanuel Dreyfus wrote:
>> If I understand correctly, that means code built with x86_64 target
>> architecture if not generaly suitable to run before switching the CPU to
>> long mode. multiboot2_pre_reloc(), which is run before this operation,
>> must therefore be built with -m32, like it was in the patch I posted in
>> january:
>> http://mail-index.netbsd.org/port-amd64/2020/01/30/msg003139.html
> No, you can't run 64bit code in 32bit mode with few exceptions. But that
> doesn't answer the more important question on why it has to be run in
> 64bit mode.

I think that, in fact, there should be no mode dance in the locore. The C
function should be rewritten in assembly, consistently with the rest of
the locore. There is existing assembly code that copies bootloader data
into the kernel, the multiboot-specific stuff can be modeled after that.

Using C will produce unreliable code, which will entirely fall apart next
time the compiler decides to change the register use. As far as I can
tell from this thread, it is already falling apart.


Home | Main Index | Thread Index | Old Index