qemu-patch-raspberry4/target-i386
Eduardo Habkost 57f26ae729 target-i386: CPUID: return highest basic leaf if eax > cpuid_xlevel
This fixes a subtle bug. A bug that probably won't cause trouble for any
existing OS, but a bug anyway:

Intel SDM Volume 2, CPUID Instruction states:

> Two types of information are returned: basic and extended function
> information. If a value entered for CPUID.EAX is higher than the maximum
> input value for basic or extended function for that processor then the
> data for the highest basic information leaf is returned. For example,
> using the Intel Core i7 processor, the following is true:
>
>   CPUID.EAX = 05H (* Returns MONITOR/MWAIT leaf. *)
>   CPUID.EAX = 0AH (* Returns Architectural Performance Monitoring leaf. *)
>   CPUID.EAX = 0BH (* Returns Extended Topology Enumeration leaf. *)
>   CPUID.EAX = 0CH (* INVALID: Returns the same information as CPUID.EAX = 0BH. *)
>   CPUID.EAX = 80000008H (* Returns linear/physical address size data. *)
>   CPUID.EAX = 8000000AH (* INVALID: Returns same information as CPUID.EAX = 0BH. *)

AMD's CPUID Specification, on the other hand, is less specific:

> The CPUID instruction supports two sets or ranges of functions,
> standard and extended.
>
> • The smallest function number of the standard function range is
>   Fn0000_0000. The largest function num- ber of the standard function
>   range, for a particular implementation, is returned in CPUID
>   Fn0000_0000_EAX.
>
> • The smallest function number of the extended function range is
>   Fn8000_0000. The largest function num- ber of the extended function
>   range, for a particular implementation, is returned in CPUID
>   Fn8000_0000_EAX.
>
> Functions that are neither standard nor extended are undefined and
> should not be relied upon.

QEMU's behavior matched Intel's specification before, but this was
changed by commit b3baa152aa. This patch
restores the behavior documented by Intel when cpuid_xlevel2 is 0.

The existing behavior when cpuid_xlevel2 is set (falling back to
level=cpuid_xlevel) is being kept, as I couldn't find any public
documentation on the CPUID 0xC0000000 function range on Centaur CPUs.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-23 09:11:24 -06:00
..
arch_dump.c exec: change RAM list to a TAILQ 2012-12-20 23:08:47 +01:00
arch_memory_mapping.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
cc_helper.c x86: Implement SMEP and SMAP 2012-10-01 08:04:22 -05:00
cc_helper_template.h x86: avoid AREG0 for condition code helpers 2012-08-14 19:01:25 +00:00
cpu-qom.h qom: move include files to include/qom/ 2012-12-19 08:31:32 +01:00
cpu.c target-i386: CPUID: return highest basic leaf if eax > cpuid_xlevel 2012-12-23 09:11:24 -06:00
cpu.h fpu: move public header file to include/fpu 2012-12-19 08:32:46 +01:00
excp_helper.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
fpu_helper.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
helper.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
helper.h exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
hyperv.c hyper-v: introduce Hyper-V support infrastructure. 2012-01-19 08:32:12 -02:00
hyperv.h hyperv: fix build on non-KVM hosts 2012-01-23 20:04:51 +00:00
int_helper.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
ioport-user.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
kvm-stub.c kvm: Move kvm_allows_irq0_override() to target-i386, fix return type 2012-08-09 16:16:55 +03:00
kvm.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
kvm_i386.h softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
machine.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
Makefile.objs x86: switch to AREG0 free mode 2012-08-14 19:01:26 +00:00
mem_helper.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
misc_helper.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
ops_sse.h x86: avoid AREG0 for FPU helpers 2012-08-14 19:01:25 +00:00
ops_sse_header.h x86: avoid AREG0 for FPU helpers 2012-08-14 19:01:25 +00:00
seg_helper.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
shift_helper_template.h x86: avoid AREG0 for integer helpers 2012-08-14 19:01:25 +00:00
smm_helper.c cpu_dump_state: move DUMP_FPU and DUMP_CCOP flags from x86-only to generic 2012-10-05 15:04:43 +01:00
svm.h Use new macro QEMU_PACKED for packed structures 2011-09-03 10:45:59 +00:00
svm_helper.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
TODO target-i386: fix {min,max}{pd,ps,sd,ss} SSE2 instructions 2012-01-11 09:55:28 +01:00
translate.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00