Skip to content

cpuid: cleanup, fixes and some enhancements

Andre Przywara qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest21 patches 1 replyIn review
  2. v112 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- fix build for non-i386 targets (thanks Anthony for spotting this)
- replace strtok() with QEMU's get_opt_name() (inspired by Amit Shah) (please see the notes below)
- fix multicore setup on Intel (thanks Dietmar Maurer for spotting this)
- removed unnecessary header file inclusions from cpuid.c
- fix and add various CPU models
- add kvm32 CPU model (for 32bit only migration)
- always expose all CPU models (regardless of the bitness)
----------------

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21cpuid: move CPUID functions into separate fileMakefile.target target-i386/cpu.h target-i386/cpuid.c +1 more+775 -7440 replies
2/21cpuid: fix over-long linestarget-i386/cpuid.c+18 -80 replies
3/21cpuid: replace magic number with named constanttarget-i386/cpuid.c+5 -40 replies
4/21cpuid: fix commentstarget-i386/cpuid.c+7 -50 replies
5/21cpuid: moved host_cpuid function and remove prototypetarget-i386/cpuid.c+34 -370 replies
6/21cpuid: Replace strtok with get_opt_nametarget-i386/cpuid.c+24 -100 replies
7/21cpuid: add missing CPUID feature flag namestarget-i386/cpuid.c+18 -100 replies
8/21cpuid: list all known x86 CPUID feature flagstarget-i386/cpuid.c+18 -10 replies
9/21cpuid: remove unnecessary kvm_trim functiontarget-i386/kvm.c+6 -210 replies
10/21cpuid: simplify CPUID flag search functiontarget-i386/cpuid.c+13 -200 replies
11/21cpuid: propagate further CPUID leafs when -cpu hosttarget-i386/cpu.h target-i386/cpuid.c+26 -70 replies
12/21cpuid: Fix multicore setup on Inteltarget-i386/cpuid.c+31 -180 replies
13/21cpuid: add TCG feature bit trimmingtarget-i386/cpuid.c+24 -30 replies
14/21cpuid: decrease L2 cache for Intel and add commentstarget-i386/cpuid.c+6 -60 replies
15/21cpuid: Adjust feature bit constantstarget-i386/cpuid.c+13 -130 replies
16/21cpuid: Update qemu64/32 CPU modelstarget-i386/cpuid.c+13 -120 replies
17/21cpuid: Fix CPU models to use new feature set namestarget-i386/cpuid.c+34 -600 replies
18/21cpuid: Fix 486 CPU modeltarget-i386/cpuid.c+2 -20 replies
19/21cpuid: Add athlon64 CPU modeltarget-i386/cpuid.c+19 -00 replies
20/21cpuid: Add kvm32 CPU modeltarget-i386/cpuid.c+13 -00 replies
21/21cpuid: Always expose 32 and 64-bit CPUstarget-i386/cpuid.c+0 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 00/21] cpuid: cleanup, fixes and some enhancements

Hi,

an updated version of my last week's series.
Changes from v1 -> v2:
- fix build for non-i386 targets (thanks Anthony for spotting this)
- replace strtok() with QEMU's get_opt_name() (inspired by Amit Shah) (please see the notes below)
- fix multicore setup on Intel (thanks Dietmar Maurer for spotting this)
- removed unnecessary header file inclusions from cpuid.c
- fix and add various CPU models
- add kvm32 CPU model (for 32bit only migration)
- always expose all CPU models (regardless of the bitness)
----------------

The following patchset cleans up CPUID bit handling and adds some smaller features.
The most prominent change is to move all CPUID related functions to a separate file. About 40% of helper.c was actually CPUID related, so say hello to cpuid.c. While at it, I fixed some formatting issues. (Patch 1-5) Patch 6 replaces the awkward strtok() with the better get_opt_name().
Please note: This renders the gotos useless. Shall they be removed? Second note: I pulled get_opt_name() from qemu-option.h into the file, because it did not work with linux-user due to a name clash:
linux-user/mmap.c:qemu_malloc() and qemu-malloc.c:qemu_malloc() If anyone has a better solution, I am all ears.
Patch 7 & 8 add the CPUID feature flag names to the output of -cpu ?. Patch 9 & 10 simplifies some code.
Patch 11 allows more CPUID leafs to be propagated to guests when -cpu host is used, this should now reflect the host CPU's cache size. Patch 12 fixes a bug with the multicore injection to the guest, where the Linux kernel on Intel hosts would not recognize multiple cores. Patch 13 adds a trimming feature (similar to KVM) to QEMU/TCG. The goal is to describe CPU models more precisely by reflecting the feature bits of the real hardware. Features that QEMU does not support are then masked. If we add features to QEMU, we only need to adjust it in one location. Patch 14 adjusts the size of the L2 cache described by leaf 4 to a more conservative value of one megabyte. This prevents guests assuming too large caches if they use optimized algorithms.
Patch 15-19 changes the CPU models to describe the actual CPUID bits of the real silicon (checked with actual machines, x86info examples and datasheets). Unsupported features will be masked.
Patch 20 adds a kvm32 CPU model, which is useful for migration. Patch 21 finally exposes both the 32- and 64-bit CPU model also to QEMU32, since the LM bit will be masked out.

Please review, comment and apply!
Thanks and Regards,
Andre.

--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 448 3567 12
----to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Andrew Bowd; Thomas M. McCoy; Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632