diff options
author | Bingsong Si <owen.si@ucloud.cn> | 2019-08-22 12:29:01 +0800 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2019-10-15 18:34:44 -0300 |
commit | 76ecd7a514aa74b92dca807c60ca1e427e178fda (patch) | |
tree | f5aa52b8659cc283ab21dd04ce3b29ee76e9486a /target/i386 | |
parent | e7694a5eae34a31a5b240467b5201a7f31b7f96a (diff) | |
download | qemu-76ecd7a514aa74b92dca807c60ca1e427e178fda.zip qemu-76ecd7a514aa74b92dca807c60ca1e427e178fda.tar.gz qemu-76ecd7a514aa74b92dca807c60ca1e427e178fda.tar.bz2 |
i386: Fix legacy guest with xsave panic on host kvm without update cpuid.
without kvm commit 412a3c41, CPUID(EAX=0xd,ECX=0).EBX always equal to 0 even
through guest update xcr0, this will crash legacy guest(e.g., CentOS 6).
Below is the call trace on the guest.
[ 0.000000] kernel BUG at mm/bootmem.c:469!
[ 0.000000] invalid opcode: 0000 [#1] SMP
[ 0.000000] last sysfs file:
[ 0.000000] CPU 0
[ 0.000000] Modules linked in:
[ 0.000000]
[ 0.000000] Pid: 0, comm: swapper Tainted: G --------------- H 2.6.32-279#2 Red Hat KVM
[ 0.000000] RIP: 0010:[<ffffffff81c4edc4>] [<ffffffff81c4edc4>] alloc_bootmem_core+0x7b/0x29e
[ 0.000000] RSP: 0018:ffffffff81a01cd8 EFLAGS: 00010046
[ 0.000000] RAX: ffffffff81cb1748 RBX: ffffffff81cb1720 RCX: 0000000001000000
[ 0.000000] RDX: 0000000000000040 RSI: 0000000000000000 RDI: ffffffff81cb1720
[ 0.000000] RBP: ffffffff81a01d38 R08: 0000000000000000 R09: 0000000000001000
[ 0.000000] R10: 02008921da802087 R11: 00000000ffff8800 R12: 0000000000000000
[ 0.000000] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000001000000
[ 0.000000] FS: 0000000000000000(0000) GS:ffff880002200000(0000) knlGS:0000000000000000
[ 0.000000] CS: 0010 DS: 0018 ES: 0018 CR0: 0000000080050033
[ 0.000000] CR2: 0000000000000000 CR3: 0000000001a85000 CR4: 00000000001406b0
[ 0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 0.000000] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[ 0.000000] Process swapper (pid: 0, threadinfo ffffffff81a00000, task ffffffff81a8d020)
[ 0.000000] Stack:
[ 0.000000] 0000000000000002 81a01dd881eaf060 000000007e5fe227 0000000000001001
[ 0.000000] <d> 0000000000000040 0000000000000001 0000006cffffffff 0000000001000000
[ 0.000000] <d> ffffffff81cb1720 0000000000000000 0000000000000000 0000000000000000
[ 0.000000] Call Trace:
[ 0.000000] [<ffffffff81c4f074>] ___alloc_bootmem_nopanic+0x8d/0xca
[ 0.000000] [<ffffffff81c4f0cf>] ___alloc_bootmem+0x11/0x39
[ 0.000000] [<ffffffff81c4f172>] __alloc_bootmem+0xb/0xd
[ 0.000000] [<ffffffff814d42d9>] xsave_cntxt_init+0x249/0x2c0
[ 0.000000] [<ffffffff814e0689>] init_thread_xstate+0x17/0x25
[ 0.000000] [<ffffffff814e0710>] fpu_init+0x79/0xaa
[ 0.000000] [<ffffffff814e27e3>] cpu_init+0x301/0x344
[ 0.000000] [<ffffffff81276395>] ? sort+0x155/0x230
[ 0.000000] [<ffffffff81c30cf2>] trap_init+0x24e/0x25f
[ 0.000000] [<ffffffff81c2bd73>] start_kernel+0x21c/0x430
[ 0.000000] [<ffffffff81c2b33a>] x86_64_start_reservations+0x125/0x129
[ 0.000000] [<ffffffff81c2b438>] x86_64_start_kernel+0xfa/0x109
[ 0.000000] Code: 03 48 89 f1 49 c1 e8 0c 48 0f af d0 48 c7 c6 00 a6 61 81 48 c7 c7 00 e5 79 81 31 c0 4c 89 74 24 08 e8 f2 d7 89 ff 4d 85 e4 75 04 <0f> 0b eb fe 48 8b 45 c0 48 83 e8 01 48 85 45
c0 74 04 0f 0b eb
Signed-off-by: Bingsong Si <owen.si@ucloud.cn>
Message-Id: <20190822042901.16858-1-owen.si@ucloud.cn>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'target/i386')
-rw-r--r-- | target/i386/cpu.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/target/i386/cpu.c b/target/i386/cpu.c index daece62..b821132 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4693,7 +4693,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx = xsave_area_size(x86_cpu_xsave_components(cpu)); *eax = env->features[FEAT_XSAVE_COMP_LO]; *edx = env->features[FEAT_XSAVE_COMP_HI]; - *ebx = xsave_area_size(env->xcr0); + /* + * The initial value of xcr0 and ebx == 0, On host without kvm + * commit 412a3c41(e.g., CentOS 6), the ebx's value always == 0 + * even through guest update xcr0, this will crash some legacy guest + * (e.g., CentOS 6), So set ebx == ecx to workaroud it. + */ + *ebx = kvm_enabled() ? *ecx : xsave_area_size(env->xcr0); } else if (count == 1) { *eax = env->features[FEAT_XSAVE]; } else if (count < ARRAY_SIZE(x86_ext_save_areas)) { |