qemu/hw
Babu Moger b776569a53 target/i386: Fix CPUID encoding of Fn8000001E_ECX
Observed the following failure while booting the SEV-SNP guest and the
guest fails to boot with the smp parameters:
"-smp 192,sockets=1,dies=12,cores=8,threads=2".

qemu-system-x86_64: sev_snp_launch_update: SNP_LAUNCH_UPDATE ret=-5 fw_error=22 'Invalid parameter'
qemu-system-x86_64: SEV-SNP: CPUID validation failed for function 0x8000001e, index: 0x0.
provided: eax:0x00000000, ebx: 0x00000100, ecx: 0x00000b00, edx: 0x00000000
expected: eax:0x00000000, ebx: 0x00000100, ecx: 0x00000300, edx: 0x00000000
qemu-system-x86_64: SEV-SNP: failed update CPUID page

Reason for the failure is due to overflowing of bits used for "Node per
processor" in CPUID Fn8000001E_ECX. This field's width is 3 bits wide and
can hold maximum value 0x7. With dies=12 (0xB), it overflows and spills
over into the reserved bits. In the case of SEV-SNP, this causes CPUID
enforcement failure and guest fails to boot.

The PPR documentation for CPUID_Fn8000001E_ECX [Node Identifiers]
=================================================================
Bits    Description
31:11   Reserved.

10:8    NodesPerProcessor: Node per processor. Read-only.
        ValidValues:
        Value   Description
        0h      1 node per processor.
        7h-1h   Reserved.

7:0     NodeId: Node ID. Read-only. Reset: Fixed,XXh.
=================================================================

As in the spec, the valid value for "node per processor" is 0 and rest
are reserved.

Looking back at the history of decoding of CPUID_Fn8000001E_ECX, noticed
that there were cases where "node per processor" can be more than 1. It
is valid only for pre-F17h (pre-EPYC) architectures. For EPYC or later
CPUs, the linux kernel does not use this information to build the L3
topology.

Also noted that the CPUID Function 0x8000001E_ECX is available only when
TOPOEXT feature is enabled. This feature is enabled only for EPYC(F17h)
or later processors. So, previous generation of processors do not not
enumerate 0x8000001E_ECX leaf.

There could be some corner cases where the older guests could enable the
TOPOEXT feature by running with -cpu host, in which case legacy guests
might notice the topology change. To address those cases introduced a
new CPU property "legacy-multi-node". It will be true for older machine
types to maintain compatibility. By default, it will be false, so new
decoding will be used going forward.

The documentation is taken from Preliminary Processor Programming
Reference (PPR) for AMD Family 19h Model 11h, Revision B1 Processors 55901
Rev 0.25 - Oct 6, 2022.

Cc: qemu-stable@nongnu.org
Fixes: 31ada106d8 ("Simplify CPUID_8000_001E for AMD")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Babu Moger <babu.moger@amd.com>
Message-ID: <0ee4b0a8293188a53970a2b0e4f4ef713425055e.1714757834.git.babu.moger@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-05-07 08:50:38 +02:00
..
9pfs
acpi hmat acpi: Fix out of bounds access due to missing use of indirection 2024-03-12 17:59:46 -04:00
adc hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
alpha alpha: switch boards to "default y" 2024-05-03 15:47:47 +02:00
arm arm: switch boards to "default y" 2024-05-03 15:47:47 +02:00
audio exec: Declare target_words_bigendian() in 'exec/tswap.h' 2024-04-26 17:03:05 +02:00
avr avr: switch boards to "default y" 2024-05-03 15:47:47 +02:00
block hw/block/nand: Fix out-of-bound access in NAND block buffer 2024-04-10 09:09:34 +02:00
char hw/char/stm32l4x5_usart: Fix memory corruption by adding correct class_size 2024-04-30 15:45:37 +01:00
core accel/tcg: Restrict qemu_plugin_vcpu_exit_hook() to TCG plugins 2024-05-06 11:24:14 +02:00
cpu hw: Add a Kconfig switch for the TYPE_CPU_CLUSTER device 2024-04-25 12:48:12 +02:00
cris cris: switch boards to "default y" 2024-05-03 15:47:47 +02:00
cxl hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean 2024-04-25 12:48:12 +02:00
display display: remove GraphicHwOps from typedefs.h 2024-05-03 15:47:48 +02:00
dma hw/dmax/xlnx_dpdma: fix handling of address_extension descriptor fields 2024-04-30 15:39:54 +01:00
fsi
gpio hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
hppa hppa: switch boards to "default y" 2024-05-03 15:47:47 +02:00
hyperv kvm: move target-dependent interrupt routing out of kvm-all.c 2024-05-03 15:47:48 +02:00
i2c hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
i386 target/i386: Fix CPUID encoding of Fn8000001E_ECX 2024-05-07 08:50:38 +02:00
ide hw/ide/core.c (cmd_read_native_max): Avoid limited device parameters 2024-04-30 06:21:47 +02:00
input hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
intc kvm: move target-dependent interrupt routing out of kvm-all.c 2024-05-03 15:47:48 +02:00
ipack
ipmi
isa hw/isa/vt82c686: Keep track of PIRQ/PINT pins separately 2024-04-15 13:07:11 +02:00
loongarch loongarch: switch boards to "default y" 2024-05-03 15:47:47 +02:00
m68k m68k: switch boards to "default y" 2024-05-03 15:47:47 +02:00
mem hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean 2024-04-25 12:48:12 +02:00
microblaze microblaze: switch boards to "default y" 2024-05-03 15:47:47 +02:00
mips mips: switch boards to "default y" 2024-05-03 15:47:47 +02:00
misc hw: misc: edu: use qemu_log_mask instead of hw_error 2024-04-30 06:21:47 +02:00
net Misc HW patch queue 2024-04-25 09:43:29 -07:00
nubus hw/nubus: add nubus-virtio-mmio device 2024-02-27 09:36:39 +01:00
nvme hw/nvme: fix -Werror=maybe-uninitialized 2024-04-02 16:15:07 +02:00
nvram hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
openrisc openrisc: switch boards to "default y" 2024-05-03 15:47:47 +02:00
pci hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
pci-bridge Misc HW patch queue 2024-04-25 09:43:29 -07:00
pci-host hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
pcmcia
ppc Accelerator patches 2024-05-06 10:19:10 -07:00
remote hw/remote/remote-obj: hw/misc/ivshmem: Fix missing ERRP_GUARD() for error_prepend() 2024-03-09 18:51:45 +01:00
riscv riscv: switch boards to "default y" 2024-05-03 15:47:48 +02:00
rtc hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
rx rx: switch boards to "default y" 2024-05-03 15:47:48 +02:00
s390x s390x: switch boards to "default y" 2024-05-03 15:47:48 +02:00
scsi esp.c: remove explicit setting of DRQ within ESP state machine 2024-04-04 15:17:53 +01:00
sd hw/sd/sdhci: Do not update TRNMOD when Command Inhibit (DAT) is set 2024-04-10 09:09:34 +02:00
sensor hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
sh4 sh4: switch boards to "default y" 2024-05-03 15:47:48 +02:00
smbios hw/smbios: add stub for smbios_get_table_legacy() 2024-03-26 14:32:54 +01:00
sparc sparc: switch boards to "default y" 2024-05-03 15:47:48 +02:00
sparc64 qemu-sparc queue 2024-05-06 10:19:56 -07:00
ssi Misc HW patch queue 2024-04-25 09:43:29 -07:00
timer hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
tpm hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init 2024-02-29 11:35:36 -10:00
tricore tricore: switch boards to "default y" 2024-05-03 15:47:48 +02:00
ufs hw/ufs: Fix buffer overflow bug 2024-04-29 12:13:35 +09:00
usb hw, target: Add ResetType argument to hold and exit phase methods 2024-04-25 10:21:06 +01:00
vfio memory: Add Error** argument to .log_global_start() handler 2024-04-23 18:36:01 -04:00
virtio exec: Declare target_words_bigendian() in 'exec/tswap.h' 2024-04-26 17:03:05 +02:00
watchdog hw/watchdog/sbsa_gwdt: Make watchdog timer frequency a QOM property 2024-04-30 15:14:15 +01:00
xen system: Pass RAM MemoryRegion and is_write in xen_map_cache() 2024-05-06 14:41:39 +02:00
xenpv
xtensa xtensa: switch boards to "default y" 2024-05-03 15:47:48 +02:00
Kconfig hw: Fix problem with the A*MPCORE switches in the Kconfig files 2024-04-25 12:48:12 +02:00
meson.build hw/rdma: Remove deprecated pvrdma device and rdmacm-mux helper 2024-04-24 16:03:38 +02:00