Skip to contentSkip to conversation

: nVMX, gcc labels as values, FEATURE_CONTROL lock bit

kvm-unit-tests Marius Vlad 2 participants 2 messages Feb 23, 2014 – Feb 24, 2014 KVM

lore
Share & tools
lore
#0 lore raw

Hello,

        $ qemu --version
        QEMU emulator version 1.7.0 (Debian 1.7.0+dfsg-3), Copyright (c) 2003-2008 Fabrice Bellard
        $ gcc --version
        gcc (Debian 4.8.2-15) 4.8.2
        $ git rev-list HEAD | head -n1
        c0a4e715eb30944f984a92fbd4bb2cff6ee298a5
        $ git branch 
        master
        $ qemu-system-x86_64 -enable-kvm -device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4 \
                -display none -serial stdio -device pci-testdev -kernel x86/vmx.flat -cpu host,+vmx,+x2apic -smp 1
        enabling apic
        paging enabled
        cr0 = 80010011
        cr3 = 7fff000
        cr4 = 20
        PASS: test vmxon with FEATURE_CONTROL cleared
        PASS: test vmxon without FEATURE_CONTROL lock
        PASS: test enable VMX in FEATURE_CONTROL
        unhandled excecption 6
        + ret=15
        + echo Return value from qemu: 15
        Return value from qemu: 15
        + exit 15

I need to add a nop statement for GCC to generate the proper jump address.

w/o:

0000000000400493 <do_write_feature_control>:
400493: 48 c7 05 02 f4 00 00 b0 04 40 00 movq $0x4004b0,0xf402(%rip) # 40f8a0 <exception_return>
40049e: b9 3a 00 00 00 mov $0x3a,%ecx
4004a3: ba 00 00 00 00 mov $0x0,%edx
4004a8: b8 00 00 00 00 mov $0x0,%eax
4004ad: 0f 30 wrmsr
4004af: c3 retq

00000000004004b0 <init_vmcs>:
4004b0: 53 push %rbx # <- jumps here, in case of GP

with:

0000000000400493 <do_write_feature_control>:
400493: 48 c7 05 02 f4 00 00 af 04 40 00 movq $0x4004af,0xf402(%rip) # 40f8a0 <exception_return>
40049e: b9 3a 00 00 00 mov $0x3a,%ecx
4004a3: ba 00 00 00 00 mov $0x0,%edx
4004a8: b8 00 00 00 00 mov $0x0,%eax
4004ad: 0f 30 wrmsr
4004af: 90 nop # <- lands here
4004b0: c3 retq

$ qemu-system-x86_64 -enable-kvm -device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4 \
-display none -serial stdio -device pci-testdev -kernel x86/vmx.flat -cpu host,+vmx,+x2apic -smp 1
enabling apic
paging enabled
cr0 = 80010011
cr3 = 7fff000
cr4 = 20
PASS: test vmxon with FEATURE_CONTROL cleared
PASS: test vmxon without FEATURE_CONTROL lock
PASS: test enable VMX in FEATURE_CONTROL
PASS: test FEATURE_CONTROL lock bit
PASS: test vmxon
PASS: test vmptrld
PASS: test vmclear
PASS: test vmptrst
PASS: test vmxoff
....
SUMMARY: 57 tests, 0 failures
+ ret=1
+ echo Return value from qemu: 1
Return value from qemu: 1
+ exit 1

#1 lore raw
Quoted 52 lines · Marius Vlad

Hello,

$ qemu --version QEMU emulator version 1.7.0 (Debian 1.7.0+dfsg-3),
Copyright (c) 2003-2008 Fabrice Bellard
$ gcc --version gcc (Debian 4.8.2-15) 4.8.2
$ git rev-list HEAD | head -n1 
c0a4e715eb30944f984a92fbd4bb2cff6ee298a5
$ git branch master
$ qemu-system-x86_64 -enable-kvm -device pc-testdev -device
isa-debug-exit,iobase=0xf4,iosize=0x4 \ -display none -serial stdio
(quoted diff) +0 -2
-device pci-testdev -kernel x86/vmx.flat -cpu host,+vmx,+x2apic
-smp 1 enabling apic paging enabled cr0 = 80010011 cr3 = 7fff000 

cr4 = 20 PASS: test vmxon with FEATURE_CONTROL cleared PASS: test vmxon without FEATURE_CONTROL lock PASS: test enable VMX in FEATURE_CONTROL unhandled excecption 6 + ret=15 + echo Return value from qemu: 15 Return value from qemu: 15 + exit 15

I need to add a nop statement for GCC to generate the proper jump address.

w/o:

0000000000400493 <do_write_feature_control>: 400493: 48 c7 05
02 f4 00 00 b0 04 40 00 movq $0x4004b0,0xf402(%rip)
# 40f8a0 <exception_return> 40049e: b9 3a 00 00 00
mov $0x3a,%ecx 4004a3: ba 00 00 00 00 mov
$0x0,%edx 4004a8: b8 00 00 00 00 mov $0x0,%eax
4004ad: 0f 30 wrmsr 4004af: c3
retq

00000000004004b0 <init_vmcs>: 4004b0: 53
push %rbx # <- jumps here, in case of GP

with:

0000000000400493 <do_write_feature_control>: 400493: 48 c7 05
02 f4 00 00 af 04 40 00 movq $0x4004af,0xf402(%rip)
# 40f8a0 <exception_return> 40049e: b9 3a 00 00 00
mov $0x3a,%ecx 4004a3: ba 00 00 00 00 mov
$0x0,%edx 4004a8: b8 00 00 00 00 mov $0x0,%eax
4004ad: 0f 30 wrmsr 4004af: 90
nop # <- lands here 4004b0: c3
retq

$ qemu-system-x86_64 -enable-kvm -device pc-testdev -device
isa-debug-exit,iobase=0xf4,iosize=0x4 \ -display none -serial stdio
(quoted diff) +0 -2
-device pci-testdev -kernel x86/vmx.flat -cpu host,+vmx,+x2apic
-smp 1 enabling apic paging enabled cr0 = 80010011 cr3 = 7fff000 
Quoted 7 lines

cr4 = 20 PASS: test vmxon with FEATURE_CONTROL cleared PASS: test vmxon without FEATURE_CONTROL lock PASS: test enable VMX in FEATURE_CONTROL PASS: test FEATURE_CONTROL lock bit PASS: test vmxon PASS: test vmptrld PASS: test vmclear PASS: test vmptrst
PASS: test vmxoff .... SUMMARY: 57 tests, 0 failures + ret=1 + echo Return value from qemu: 1 Return value from qemu: 1 + exit 1

Paolo, did you report these effects to gcc?

Marius, could you provide a corresponding patch with a description of the affected gcc version (or a link to this thread)?

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux