changing the GDT fails when hardware virtualization is enabled

Discussions about using non Windows and Linux guests such as FreeBSD, DOS, OS/2, OpenBSD, etc.
Post Reply
andrej1991
Posts: 1
Joined: 9. Aug 2016, 23:02

changing the GDT fails when hardware virtualization is enabled

Post by andrej1991 »

Hello,
I'm writing an own os and when I try to change the GDT it fires IRQ 6 (invalid opcode). When the hardware virtualization is disabled everything is fine.
The code which supposed to change the GDT:

Code: Select all

    call    get_gdt_base
    lea     GDTdescriptor, %ebx
    movl    %eax, %ds:2(%ebx)
    lea     memory_descriptor, %eax
    sgdt    (oldGDTdescriptor)
    push    %eax
    call    create_base_gdt
    movw    $8, %dx
    mulw    %dx
    decw    %ax
    movw    %ax, %ds:(%ebx)
    lgdt    (GDTdescriptor)
    movl    $0x10,%eax
    mov     %ax,%ds
    mov     %ax,%es
    mov     %ax,%fs
    mov     %ax,%gs
    mov     %ax,%ss
    jmp     $8,$next
    next:
    movl    $0x3FFE0, %eax
    movl    %eax, %esp
    call    main
Function "get_gdt_base" just select a valid area in the memory where the GDT can fit.
Function "create_base_gdt" creates a GDT with the following entries:

Code: Select all

.quad 0x0
.quad 0x00C09B0000008000 /*code segment*/
.quad 0x00C0930000008000 /*data segment*/
I'm using VirtualBox 5.1.2 r108956 for ubuntu 14.04.

Thank you in advance,
Andrej
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: changing the GDT fails when hardware virtualization is enabled

Post by socratis »

I believe that your question is pretty specialized. You may have a better chance of getting it answered if you ask the developers either at the mailing list or on IRC. See https://www.virtualbox.org/wiki/Community for details.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply