* kvm_arch_para_features() call triggers invalid opcode on i486
@ 2021-01-03 16:23 tedheadster
2021-01-04 0:55 ` Wanpeng Li
0 siblings, 1 reply; 2+ messages in thread
From: tedheadster @ 2021-01-03 16:23 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: rkrcmar, kvm
Paolo,
I am doing regression testing on a first generation i486 and came up
with a kernel crash because it incorrectly thinks the processor
supports KVM features. Yes, we do still support the ancient i486.
This processor does NOT have the cpuid instruction, and I believe
testing for it returns -1 (not supported) in two's-compliment form.
I think the -1 is not checked for, and this is causing
kvm_arch_para_features() to think it _does_ support
KVM_CPUID_FEATURES, causing it to later execute an invalid opcode
(cpuid).
Here is the dmesg output:
[ 0.580000] clocksource: pit: mask: 0xffffffff max_cycles:
0xffffffff, max_idle_ns: 1601818034827 ns
[ 0.584000] invalid opcode: 0000 [#1] PREEMPT
[ 0.584000] CPU: 0 PID: 1 Comm: swapper Not tainted
5.4.86.i486-i486-m486-i486 #7707
[ 0.584000] EIP: kvm_arch_para_features+0x15/0x1a
[ 0.584000] Code: 74 12 55 89 e5 31 c9 31 d2 b8 03 4d 56 4b e8 8b
fb ff ff 5d c3 3e 8d 74 26 00 55 89 e5 53 e8 67 fc ff ff 0d 01 00 00
40 31 c9 <0f> a2 5b 5d c3 55 89 e5 53 89 c3 e8 db ff ff ff 88 d9 d3 e8
83 e0
[ 0.584000] EAX: 40000001 EBX: 00000009 ECX: 00000000 EDX: c15e7080
[ 0.584000] ESI: c167282f EDI: ffffffff EBP: cf06ff20 ESP: cf06ff1c
[ 0.584000] DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 EFLAGS: 00010246
[ 0.584000] CR0: 80050033 CR2: 00000000 CR3: 016e3000 CR4: 00000000
[ 0.584000] Call Trace:
[ 0.584000] kvm_para_has_feature+0xb/0x15
[ 0.584000] kvm_setup_pv_tlb_flush+0x12/0x46
[ 0.584000] do_one_initcall+0x4c/0x163
[ 0.584000] ? kernel_init_freeable+0xcf/0x18f
[ 0.584000] kernel_init_freeable+0xfe/0x18f
[ 0.584000] ? rest_init+0x93/0x93
[ 0.584000] kernel_init+0xd/0xda
[ 0.584000] ret_from_fork+0x19/0x30
[ 0.584000] Modules linked in:
[ 0.588000] ---[ end trace d6d5e35d5ec118f1 ]---
The call is coming from arch/x86/kernel/kvm.c:
unsigned int kvm_arch_para_features(void)
{
return cpuid_eax(kvm_cpuid_base() | KVM_CPUID_FEATURES);
}
# grep cpuid /proc/cpuinfo
cpuid level : -1
# /usr/bin/cpuid
CPU 0:
[ 1035.325926] traps: cpuid[140] trap invalid opcode ip:49bf31
sp:bfe36280 error:0[ 1035.331956] in cpuid[480000+3f000]
Illegal instruction
- Matthew
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: kvm_arch_para_features() call triggers invalid opcode on i486
2021-01-03 16:23 kvm_arch_para_features() call triggers invalid opcode on i486 tedheadster
@ 2021-01-04 0:55 ` Wanpeng Li
0 siblings, 0 replies; 2+ messages in thread
From: Wanpeng Li @ 2021-01-04 0:55 UTC (permalink / raw)
To: whiteheadm; +Cc: Paolo Bonzini, Radim Krcmar, kvm
On Mon, 4 Jan 2021 at 00:42, tedheadster <tedheadster@gmail.com> wrote:
>
> Paolo,
> I am doing regression testing on a first generation i486 and came up
> with a kernel crash because it incorrectly thinks the processor
> supports KVM features. Yes, we do still support the ancient i486.
>
> This processor does NOT have the cpuid instruction, and I believe
> testing for it returns -1 (not supported) in two's-compliment form.
>
> I think the -1 is not checked for, and this is causing
> kvm_arch_para_features() to think it _does_ support
> KVM_CPUID_FEATURES, causing it to later execute an invalid opcode
> (cpuid).
Please try the latest Linus tree or kvm/queue, it will not have this
issue since commit 64b38bd1906bb ("x86/kvm: do not setup pv tlb flush
when not paravirtualized").
Wanpeng
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-04 0:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-03 16:23 kvm_arch_para_features() call triggers invalid opcode on i486 tedheadster
2021-01-04 0:55 ` Wanpeng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).