Page 1 of 1

Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 4:05 am
by windows8

Code: Select all

movabs $_start64,%rcx
jmp *%rcx
This code cannot work,but this code can work:

Code: Select all

movq 1f,%rcx
jmp *%rcx
1: .quad _start64
Although | don't have to use "movabs",I cannot prevent the gcc/g++........
I have not encountered this situation before,I searched google but it didn't help me......

This is output of "objdump -S kernel"

Code: Select all

  8000100224:	48 b8 00 02 10 00 80 	movabs $0x8000100200,%rax
  800010022b:	00 00 00 
Thanks for your help!

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 4:44 am
by alexfru
The intent is clear, the instruction itself should work. I suspect something's wrong with the address, e.g. how you obtain it (linker issue?).

OTOH, it could be that you're missing or having an extra indirection. Do you really need a star in there?

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 4:53 am
by windows8
alexfru wrote:The intent is clear, the instruction itself should work. I suspect something's wrong with the address, e.g. how you obtain it (linker issue?).

OTOH, it could be that you're missing or having an extra indirection. Do you really need a star in there?
But wherever I put this code,it doesn't work at all.

I test this code just now:

Code: Select all

movabs $~0,%rax
cli
hlt
It doesn't work.

Code: Select all

cli
hlt
Of course,this code can work.

It seems impossible,I don't know where the wrong was.

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 5:03 am
by bluemoon
What you meant by "not work"? Is there any hint from bochs?

by the way, movabs (or simply mov r64, imm64) is only available in long mode, are you in long mode when executing such instruction?

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 5:13 am
by windows8
bluemoon wrote:What you meant by "not work"? Is there any hint from bochs?

by the way, movabs (or simply mov r64, imm64) is only available in long mode, are you in long mode when executing such instruction?
The Virtual Machine reboot at once.

Yes,I am in long mode.

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 5:23 am
by bluemoon
windows8 wrote:The Virtual Machine reboot at once.
Yes,I am in long mode.
This is contradicting.
To enter long mode properly you need exception handlers. This should give a trace instead of "reboot at once".
Also, bochs should have said something when it reboot (due to triple fault I believe).

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 6:32 am
by windows8
bluemoon wrote:
windows8 wrote:The Virtual Machine reboot at once.
Yes,I am in long mode.
This is contradicting.
To enter long mode properly you need exception handlers. This should give a trace instead of "reboot at once".
Also, bochs should have said something when it reboot (due to triple fault I believe).
It happens when I just entered long mode (in /arch/boot/boot.s),"callq kmain" (to /kernel/init/main.cpp) is not executed.
Is it really necessary to set exception handlers here?

It seems I found the reason,I set GDT to a wrong value....

Thanks.

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 6:51 am
by iansjack
It is, strictly speaking, not essential to have exception handlers. But, if you don't, it causes so many problems that it is foolish not to do so.

I don't know about others, but I would really appreciate it if people who can't be bothered to write simple exception handlers didn't waste forum space by asking why their code isn't working. You've got to help yourself just a little bit before relying upon others to do your debugging for you.

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 7:38 am
by Combuster
See Posting Checklist. The biggest problem here is the total lack of logs, even after several screens worth of debate going nowhere because of just this. Having interrupt handlers are nice, but you need to be able to get them running in the first place.

My crystal ball can't seem to decide on his addressing scheme being screwed up, or not being in long mode at all.

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 9:49 am
by no92
Combuster wrote:My crystal ball can't seem to decide on his addressing scheme being screwed up, or not being in long mode at all.
I finally start to adore your crystal ball. :D

Re: Both of bochs and qemu cann't executable "movabs"?

Posted: Mon Aug 25, 2014 11:08 am
by iansjack
no92 wrote:
Combuster wrote:My crystal ball can't seem to decide on his addressing scheme being screwed up, or not being in long mode at all.
I finally start to adore your crystal ball. :D
I don't know. It never seems to work very well. ;)