History log of /openbmc/linux/arch/x86/kernel/cpu/microcode/ (Results 1 – 25 of 333)
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
e686349c10-Mar-2025 Florent Revest <revest@chromium.org>

x86/microcode/AMD: Fix out-of-bounds on systems with CPU-less NUMA nodes

commit e3e89178a9f4a80092578af3ff3c8478f9187d59 upstream.

Currently, load_microcode_amd() iterates over all NUMA nodes, retr

x86/microcode/AMD: Fix out-of-bounds on systems with CPU-less NUMA nodes

commit e3e89178a9f4a80092578af3ff3c8478f9187d59 upstream.

Currently, load_microcode_amd() iterates over all NUMA nodes, retrieves their
CPU masks and unconditionally accesses per-CPU data for the first CPU of each
mask.

According to Documentation/admin-guide/mm/numaperf.rst:

"Some memory may share the same node as a CPU, and others are provided as
memory only nodes."

Therefore, some node CPU masks may be empty and wouldn't have a "first CPU".

On a machine with far memory (and therefore CPU-less NUMA nodes):
- cpumask_of_node(nid) is 0
- cpumask_first(0) is CONFIG_NR_CPUS
- cpu_data(CONFIG_NR_CPUS) accesses the cpu_info per-CPU array at an
index that is 1 out of bounds

This does not have any security implications since flashing microcode is
a privileged operation but I believe this has reliability implications by
potentially corrupting memory while flashing a microcode update.

When booting with CONFIG_UBSAN_BOUNDS=y on an AMD machine that flashes
a microcode update. I get the following splat:

UBSAN: array-index-out-of-bounds in arch/x86/kernel/cpu/microcode/amd.c:X:Y
index 512 is out of range for type 'unsigned long[512]'
[...]
Call Trace:
dump_stack
__ubsan_handle_out_of_bounds
load_microcode_amd
request_microcode_amd
reload_store
kernfs_fop_write_iter
vfs_write
ksys_write
do_syscall_64
entry_SYSCALL_64_after_hwframe

Change the loop to go over only NUMA nodes which have CPUs before determining
whether the first CPU on the respective node needs microcode update.

[ bp: Massage commit message, fix typo. ]

Fixes: 7ff6edf4fef3 ("x86/microcode/AMD: Fix mixed steppings support")
Signed-off-by: Florent Revest <revest@chromium.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250310144243.861978-1-revest@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...


/openbmc/linux/Documentation/timers/no_hz.rst
/openbmc/linux/Makefile
/openbmc/linux/arch/alpha/include/asm/elf.h
/openbmc/linux/arch/alpha/include/asm/pgtable.h
/openbmc/linux/arch/alpha/include/asm/processor.h
/openbmc/linux/arch/alpha/kernel/osf_sys.c
/openbmc/linux/arch/arm64/include/asm/hugetlb.h
/openbmc/linux/arch/arm64/mm/hugetlbpage.c
/openbmc/linux/arch/loongarch/include/asm/hugetlb.h
/openbmc/linux/arch/loongarch/kernel/machine_kexec.c
/openbmc/linux/arch/loongarch/kernel/setup.c
/openbmc/linux/arch/loongarch/kernel/smp.c
/openbmc/linux/arch/mips/include/asm/hugetlb.h
/openbmc/linux/arch/parisc/include/asm/hugetlb.h
/openbmc/linux/arch/parisc/mm/hugetlbpage.c
/openbmc/linux/arch/powerpc/include/asm/hugetlb.h
/openbmc/linux/arch/powerpc/kvm/e500_mmu_host.c
/openbmc/linux/arch/riscv/include/asm/csr.h
/openbmc/linux/arch/riscv/include/asm/hugetlb.h
/openbmc/linux/arch/riscv/kernel/cpufeature.c
/openbmc/linux/arch/riscv/mm/hugetlbpage.c
/openbmc/linux/arch/s390/include/asm/hugetlb.h
/openbmc/linux/arch/s390/kernel/traps.c
/openbmc/linux/arch/s390/mm/hugetlbpage.c
/openbmc/linux/arch/sparc/include/asm/hugetlb.h
/openbmc/linux/arch/sparc/mm/hugetlbpage.c
/openbmc/linux/arch/x86/boot/compressed/acpi.c
/openbmc/linux/arch/x86/boot/compressed/cmdline.c
/openbmc/linux/arch/x86/boot/compressed/ident_map_64.c
/openbmc/linux/arch/x86/boot/compressed/kaslr.c
/openbmc/linux/arch/x86/boot/compressed/mem.c
/openbmc/linux/arch/x86/boot/compressed/misc.c
/openbmc/linux/arch/x86/boot/compressed/misc.h
/openbmc/linux/arch/x86/boot/compressed/pgtable_64.c
/openbmc/linux/arch/x86/boot/compressed/sev.c
/openbmc/linux/arch/x86/events/intel/core.c
/openbmc/linux/arch/x86/include/asm/boot.h
/openbmc/linux/arch/x86/kernel/cpu/cacheinfo.c
/openbmc/linux/arch/x86/kernel/cpu/intel.c
amd.c
/openbmc/linux/arch/x86/kernel/cpu/mshyperv.c
/openbmc/linux/arch/x86/kernel/cpu/sgx/ioctl.c
/openbmc/linux/arch/x86/kernel/irq.c
/openbmc/linux/arch/x86/kvm/cpuid.c
/openbmc/linux/arch/x86/kvm/svm/svm.c
/openbmc/linux/arch/x86/kvm/svm/svm.h
/openbmc/linux/arch/x86/mm/init.c
/openbmc/linux/block/bio.c
/openbmc/linux/block/partitions/efi.c
/openbmc/linux/drivers/acpi/resource.c
/openbmc/linux/drivers/base/core.c
/openbmc/linux/drivers/block/ublk_drv.c
/openbmc/linux/drivers/block/zram/zram_drv.c
/openbmc/linux/drivers/bluetooth/btusb.c
/openbmc/linux/drivers/bus/mhi/host/pci_generic.c
/openbmc/linux/drivers/cdx/cdx.c
/openbmc/linux/drivers/char/misc.c
/openbmc/linux/drivers/clocksource/i8253.c
/openbmc/linux/drivers/firmware/efi/libstub/x86-stub.c
/openbmc/linux/drivers/firmware/efi/libstub/x86-stub.h
/openbmc/linux/drivers/firmware/iscsi_ibft.c
/openbmc/linux/drivers/gpio/gpio-aggregator.c
/openbmc/linux/drivers/gpio/gpio-rcar.c
/openbmc/linux/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
/openbmc/linux/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
/openbmc/linux/drivers/gpu/drm/i915/display/icl_dsi.c
/openbmc/linux/drivers/gpu/drm/nouveau/nouveau_connector.c
/openbmc/linux/drivers/gpu/drm/radeon/r300.c
/openbmc/linux/drivers/gpu/drm/radeon/radeon_asic.h
/openbmc/linux/drivers/gpu/drm/radeon/rs400.c
/openbmc/linux/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
/openbmc/linux/drivers/gpu/drm/vkms/vkms_composer.c
/openbmc/linux/drivers/hid/Kconfig
/openbmc/linux/drivers/hid/hid-apple.c
/openbmc/linux/drivers/hid/hid-appleir.c
/openbmc/linux/drivers/hid/hid-google-hammer.c
/openbmc/linux/drivers/hid/hid-ids.h
/openbmc/linux/drivers/hid/hid-quirks.c
/openbmc/linux/drivers/hid/hid-steam.c
/openbmc/linux/drivers/hid/hid-topre.c
/openbmc/linux/drivers/hid/intel-ish-hid/ipc/ipc.c
/openbmc/linux/drivers/hid/intel-ish-hid/ishtp-hid.c
/openbmc/linux/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
/openbmc/linux/drivers/hv/vmbus_drv.c
/openbmc/linux/drivers/hwmon/ad7314.c
/openbmc/linux/drivers/hwmon/ntc_thermistor.c
/openbmc/linux/drivers/hwmon/peci/dimmtemp.c
/openbmc/linux/drivers/hwmon/pmbus/pmbus.c
/openbmc/linux/drivers/hwmon/xgene-hwmon.c
/openbmc/linux/drivers/hwtracing/intel_th/pci.c
/openbmc/linux/drivers/iio/adc/at91-sama5d2_adc.c
/openbmc/linux/drivers/iio/dac/ad3552r.c
/openbmc/linux/drivers/iio/filter/admv8818.c
/openbmc/linux/drivers/input/joystick/xpad.c
/openbmc/linux/drivers/input/misc/iqs7222.c
/openbmc/linux/drivers/input/serio/i8042-acpipnpio.h
/openbmc/linux/drivers/input/touchscreen/ads7846.c
/openbmc/linux/drivers/misc/cardreader/rtsx_usb.c
/openbmc/linux/drivers/misc/eeprom/digsy_mtc_eeprom.c
/openbmc/linux/drivers/misc/mei/hw-me-regs.h
/openbmc/linux/drivers/misc/mei/pci-me.c
/openbmc/linux/drivers/net/bonding/bond_options.c
/openbmc/linux/drivers/net/caif/caif_virtio.c
/openbmc/linux/drivers/net/dsa/mt7530.c
/openbmc/linux/drivers/net/dsa/mv88e6xxx/chip.c
/openbmc/linux/drivers/net/ethernet/broadcom/bnxt/bnxt.c
/openbmc/linux/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
/openbmc/linux/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h
/openbmc/linux/drivers/net/ethernet/emulex/benet/be.h
/openbmc/linux/drivers/net/ethernet/emulex/benet/be_cmds.c
/openbmc/linux/drivers/net/ethernet/emulex/benet/be_main.c
/openbmc/linux/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
/openbmc/linux/drivers/net/ethernet/intel/ice/ice_arfs.c
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
/openbmc/linux/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
/openbmc/linux/drivers/net/ipa/data/ipa_data-v4.7.c
/openbmc/linux/drivers/net/mctp/mctp-i2c.c
/openbmc/linux/drivers/net/ppp/ppp_generic.c
/openbmc/linux/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
/openbmc/linux/drivers/net/wwan/mhi_wwan_mbim.c
/openbmc/linux/drivers/nvme/host/apple.c
/openbmc/linux/drivers/nvme/host/core.c
/openbmc/linux/drivers/nvme/host/fc.c
/openbmc/linux/drivers/nvme/host/pci.c
/openbmc/linux/drivers/nvme/host/tcp.c
/openbmc/linux/drivers/nvme/target/rdma.c
/openbmc/linux/drivers/nvme/target/tcp.c
/openbmc/linux/drivers/of/of_reserved_mem.c
/openbmc/linux/drivers/pinctrl/bcm/pinctrl-bcm281xx.c
/openbmc/linux/drivers/platform/x86/intel/pmc/core.c
/openbmc/linux/drivers/platform/x86/thinkpad_acpi.c
/openbmc/linux/drivers/powercap/powercap_sys.c
/openbmc/linux/drivers/rapidio/devices/rio_mport_cdev.c
/openbmc/linux/drivers/rapidio/rio-scan.c
/openbmc/linux/drivers/s390/cio/chp.c
/openbmc/linux/drivers/scsi/qla1280.c
/openbmc/linux/drivers/scsi/scsi_scan.c
/openbmc/linux/drivers/slimbus/messaging.c
/openbmc/linux/drivers/spi/spi-mxs.c
/openbmc/linux/drivers/thermal/cpufreq_cooling.c
/openbmc/linux/drivers/ufs/core/ufshcd.c
/openbmc/linux/drivers/usb/atm/cxacru.c
/openbmc/linux/drivers/usb/core/hub.c
/openbmc/linux/drivers/usb/core/quirks.c
/openbmc/linux/drivers/usb/dwc3/core.c
/openbmc/linux/drivers/usb/dwc3/core.h
/openbmc/linux/drivers/usb/dwc3/drd.c
/openbmc/linux/drivers/usb/dwc3/gadget.c
/openbmc/linux/drivers/usb/gadget/composite.c
/openbmc/linux/drivers/usb/gadget/function/u_ether.c
/openbmc/linux/drivers/usb/host/xhci-mem.c
/openbmc/linux/drivers/usb/host/xhci-pci.c
/openbmc/linux/drivers/usb/host/xhci.h
/openbmc/linux/drivers/usb/phy/phy-generic.c
/openbmc/linux/drivers/usb/renesas_usbhs/common.c
/openbmc/linux/drivers/usb/renesas_usbhs/mod_gadget.c
/openbmc/linux/drivers/usb/serial/ftdi_sio.c
/openbmc/linux/drivers/usb/serial/ftdi_sio_ids.h
/openbmc/linux/drivers/usb/serial/option.c
/openbmc/linux/drivers/usb/typec/tcpm/tcpci_rt1711h.c
/openbmc/linux/drivers/usb/typec/ucsi/ucsi.c
/openbmc/linux/drivers/video/fbdev/hyperv_fb.c
/openbmc/linux/drivers/virt/acrn/hsm.c
/openbmc/linux/drivers/xen/swiotlb-xen.c
/openbmc/linux/fs/exfat/balloc.c
/openbmc/linux/fs/exfat/exfat_fs.h
/openbmc/linux/fs/exfat/fatent.c
/openbmc/linux/fs/fuse/dir.c
/openbmc/linux/fs/namei.c
/openbmc/linux/fs/nfs/file.c
/openbmc/linux/fs/proc/base.c
/openbmc/linux/fs/select.c
/openbmc/linux/fs/smb/client/inode.c
/openbmc/linux/fs/smb/client/smb2pdu.c
/openbmc/linux/fs/smb/common/smbfsctl.h
/openbmc/linux/fs/smb/server/smb2pdu.c
/openbmc/linux/fs/smb/server/smbacl.c
/openbmc/linux/fs/smb/server/transport_ipc.c
/openbmc/linux/fs/vboxsf/super.c
/openbmc/linux/include/asm-generic/hugetlb.h
/openbmc/linux/include/linux/compaction.h
/openbmc/linux/include/linux/fs.h
/openbmc/linux/include/linux/hugetlb.h
/openbmc/linux/include/linux/i8253.h
/openbmc/linux/include/linux/io_uring_types.h
/openbmc/linux/include/linux/nvme-tcp.h
/openbmc/linux/include/linux/sched.h
/openbmc/linux/include/net/bluetooth/hci_core.h
/openbmc/linux/io_uring/io-wq.c
/openbmc/linux/io_uring/io_uring.c
/openbmc/linux/io_uring/io_uring.h
/openbmc/linux/io_uring/kbuf.c
/openbmc/linux/io_uring/kbuf.h
/openbmc/linux/io_uring/rsrc.c
/openbmc/linux/kernel/bpf/ringbuf.c
/openbmc/linux/kernel/events/core.c
/openbmc/linux/kernel/events/uprobes.c
/openbmc/linux/kernel/sched/core.c
/openbmc/linux/kernel/sched/debug.c
/openbmc/linux/kernel/sched/fair.c
/openbmc/linux/kernel/sys.c
/openbmc/linux/kernel/time/hrtimer.c
/openbmc/linux/kernel/trace/trace_fprobe.c
/openbmc/linux/kernel/trace/trace_probe.h
/openbmc/linux/mm/compaction.c
/openbmc/linux/mm/hugetlb.c
/openbmc/linux/mm/kmsan/hooks.c
/openbmc/linux/mm/memory.c
/openbmc/linux/mm/nommu.c
/openbmc/linux/mm/page_alloc.c
/openbmc/linux/mm/vmalloc.c
/openbmc/linux/net/8021q/vlan.c
/openbmc/linux/net/bluetooth/hci_core.c
/openbmc/linux/net/bluetooth/hci_event.c
/openbmc/linux/net/bluetooth/iso.c
/openbmc/linux/net/bluetooth/l2cap_core.c
/openbmc/linux/net/bluetooth/mgmt.c
/openbmc/linux/net/bluetooth/rfcomm/core.c
/openbmc/linux/net/bluetooth/sco.c
/openbmc/linux/net/core/dev.c
/openbmc/linux/net/core/netpoll.c
/openbmc/linux/net/ipv4/tcp.c
/openbmc/linux/net/ipv4/tcp_offload.c
/openbmc/linux/net/ipv4/udp_offload.c
/openbmc/linux/net/ipv6/addrconf.c
/openbmc/linux/net/ipv6/ila/ila_lwt.c
/openbmc/linux/net/llc/llc_s_ac.c
/openbmc/linux/net/mptcp/pm_netlink.c
/openbmc/linux/net/mptcp/protocol.h
/openbmc/linux/net/netfilter/ipvs/ip_vs_ctl.c
/openbmc/linux/net/netfilter/nf_conncount.c
/openbmc/linux/net/netfilter/nft_ct.c
/openbmc/linux/net/netfilter/nft_exthdr.c
/openbmc/linux/net/openvswitch/flow_netlink.c
/openbmc/linux/net/sched/sch_api.c
/openbmc/linux/net/sched/sch_fifo.c
/openbmc/linux/net/sched/sch_gred.c
/openbmc/linux/net/sctp/stream.c
/openbmc/linux/net/switchdev/switchdev.c
/openbmc/linux/net/wireless/core.c
/openbmc/linux/net/wireless/nl80211.c
/openbmc/linux/net/wireless/reg.c
/openbmc/linux/security/integrity/ima/ima_main.c
/openbmc/linux/security/integrity/integrity.h
/openbmc/linux/sound/core/seq/seq_clientmgr.c
/openbmc/linux/sound/pci/hda/Kconfig
/openbmc/linux/sound/pci/hda/hda_intel.c
/openbmc/linux/sound/pci/hda/patch_realtek.c
/openbmc/linux/sound/soc/codecs/arizona.c
/openbmc/linux/sound/soc/codecs/madera.c
/openbmc/linux/sound/soc/codecs/tas2764.c
/openbmc/linux/sound/soc/codecs/tas2764.h
/openbmc/linux/sound/soc/codecs/tas2770.c
/openbmc/linux/sound/soc/codecs/wm5110.c
/openbmc/linux/sound/soc/generic/simple-card-utils.c
/openbmc/linux/sound/soc/sh/rcar/core.c
/openbmc/linux/sound/soc/sh/rcar/rsnd.h
/openbmc/linux/sound/soc/sh/rcar/src.c
/openbmc/linux/sound/soc/sh/rcar/ssi.c
/openbmc/linux/sound/soc/sof/amd/acp-ipc.c
/openbmc/linux/sound/soc/sof/intel/hda-codec.c
/openbmc/linux/sound/usb/usx2y/usbusx2y.c
/openbmc/linux/sound/usb/usx2y/usbusx2y.h
/openbmc/linux/sound/usb/usx2y/usbusx2yaudio.c
/openbmc/linux/tools/objtool/check.c
/openbmc/linux/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
/openbmc/linux/usr/include/Makefile
2d62d8f307-Mar-2025 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Add some forgotten models to the SHA check

commit 058a6bec37c6c3b826158f6d26b75de43816a880 upstream.

Add some more forgotten models to the SHA check.

Fixes: 50cef76d5cb0 ("x86/m

x86/microcode/AMD: Add some forgotten models to the SHA check

commit 058a6bec37c6c3b826158f6d26b75de43816a880 upstream.

Add some more forgotten models to the SHA check.

Fixes: 50cef76d5cb0 ("x86/microcode/AMD: Load only SHA256-checksummed patches")
Reported-by: Toralf Förster <toralf.foerster@gmx.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Toralf Förster <toralf.foerster@gmx.de>
Link: https://lore.kernel.org/r/20250307220256.11816-1-bp@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

98a4462230-Jul-2024 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Fix a -Wsometimes-uninitialized clang false positive

commit 5343558a868e7e635b40baa2e46bf53df1a2d131 upstream.

Initialize equiv_id in order to shut up:

arch/x86/kernel/cpu/mic

x86/microcode/AMD: Fix a -Wsometimes-uninitialized clang false positive

commit 5343558a868e7e635b40baa2e46bf53df1a2d131 upstream.

Initialize equiv_id in order to shut up:

arch/x86/kernel/cpu/microcode/amd.c:714:6: warning: variable 'equiv_id' is \
used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (x86_family(bsp_cpuid_1_eax) < 0x17) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

because clang doesn't do interprocedural analysis for warnings to see
that this variable won't be used uninitialized.

Fixes: 94838d230a6c ("x86/microcode/AMD: Use the family,model,stepping encoded in the patch ID")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202407291815.gJBST0P3-lkp@intel.com/
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

bef8301423-Jan-2025 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Load only SHA256-checksummed patches

commit 50cef76d5cb0e199cda19f026842560f6eedc4f7 upstream

Load patches for which the driver carries a SHA256 checksum of the patch
blob.

This

x86/microcode/AMD: Load only SHA256-checksummed patches

commit 50cef76d5cb0e199cda19f026842560f6eedc4f7 upstream

Load patches for which the driver carries a SHA256 checksum of the patch
blob.

This can be disabled by adding "microcode.amd_sha_check=off" on the
kernel cmdline. But it is highly NOT recommended.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

1241283523-Jan-2025 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Add get_patch_level()

commit 037e81fb9d2dfe7b31fd97e5f578854e38f09887 upstream

Put the MSR_AMD64_PATCH_LEVEL reading of the current microcode revision
the hw has, into a separate

x86/microcode/AMD: Add get_patch_level()

commit 037e81fb9d2dfe7b31fd97e5f578854e38f09887 upstream

Put the MSR_AMD64_PATCH_LEVEL reading of the current microcode revision
the hw has, into a separate function.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20250211163648.30531-6-bp@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

5e253de223-Jan-2025 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Get rid of the _load_microcode_amd() forward declaration

commit b39c387164879eef71886fc93cee5ca7dd7bf500 upstream

Simply move save_microcode_in_initrd() down.

No functional chan

x86/microcode/AMD: Get rid of the _load_microcode_amd() forward declaration

commit b39c387164879eef71886fc93cee5ca7dd7bf500 upstream

Simply move save_microcode_in_initrd() down.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20250211163648.30531-5-bp@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

8a76fed323-Jan-2025 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Merge early_apply_microcode() into its single callsite

commit dc15675074dcfd79a2f10a6e39f96b0244961a01 upstream

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@a

x86/microcode/AMD: Merge early_apply_microcode() into its single callsite

commit dc15675074dcfd79a2f10a6e39f96b0244961a01 upstream

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20250211163648.30531-4-bp@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

be5a41a918-Nov-2024 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Have __apply_microcode_amd() return bool

commit 78e0aadbd4c6807a06a9d25bc190fe515d3f3c42 upstream

This is the natural thing to do anyway.

No functional changes.

Signed-off-by:

x86/microcode/AMD: Have __apply_microcode_amd() return bool

commit 78e0aadbd4c6807a06a9d25bc190fe515d3f3c42 upstream

This is the natural thing to do anyway.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

1f4caaf018-Oct-2024 Nikolay Borisov <nik.borisov@suse.com>

x86/microcode/AMD: Make __verify_patch_size() return bool

commit d8317f3d8e6b412ff51ea66f1de2b2f89835f811 upstream

The result of that function is in essence boolean, so simplify to return the
resul

x86/microcode/AMD: Make __verify_patch_size() return bool

commit d8317f3d8e6b412ff51ea66f1de2b2f89835f811 upstream

The result of that function is in essence boolean, so simplify to return the
result of the relevant expression. It also makes it follow the convention used
by __verify_patch_section().

No functional changes.

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20241018155151.702350-3-nik.borisov@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

5b330c1818-Oct-2024 Nikolay Borisov <nik.borisov@suse.com>

x86/microcode/AMD: Return bool from find_blobs_in_containers()

commit a85c08aaa665b5436d325f6d7138732a0e1315ce upstream

Instead of open-coding the check for size/data move it inside the
function an

x86/microcode/AMD: Return bool from find_blobs_in_containers()

commit a85c08aaa665b5436d325f6d7138732a0e1315ce upstream

Instead of open-coding the check for size/data move it inside the
function and make it return a boolean indicating whether data was found
or not.

No functional changes.

[ bp: Write @ret in find_blobs_in_containers() only on success. ]

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20241018155151.702350-2-nik.borisov@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

60675acf19-Nov-2024 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Flush patch buffer mapping after application

commit c809b0d0e52d01c30066367b2952c4c4186b1047 upstream

Due to specific requirements while applying microcode patches on Zen1
and 2,

x86/microcode/AMD: Flush patch buffer mapping after application

commit c809b0d0e52d01c30066367b2952c4c4186b1047 upstream

Due to specific requirements while applying microcode patches on Zen1
and 2, the patch buffer mapping needs to be flushed from the TLB after
application. Do so.

If not, unnecessary and unnatural delays happen in the boot process.

Reported-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Cc: <stable@kernel.org> # f1d84b59cbb9 ("x86/mm: Carve out INVLPG inline asm for use by others")
Link: https://lore.kernel.org/r/ZyulbYuvrkshfsd2@antipodes
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

d31d50b301-Oct-2024 Chang S. Bae <chang.seok.bae@intel.com>

x86/microcode/intel: Remove unnecessary cache writeback and invalidation

commit 9a819753b0209c6edebdea447a1aa53e8c697653 upstream

Currently, an unconditional cache flush is performed during every
m

x86/microcode/intel: Remove unnecessary cache writeback and invalidation

commit 9a819753b0209c6edebdea447a1aa53e8c697653 upstream

Currently, an unconditional cache flush is performed during every
microcode update. Although the original changelog did not mention
a specific erratum, this measure was primarily intended to address
a specific microcode bug, the load of which has already been blocked by
is_blacklisted(). Therefore, this cache flush is no longer necessary.

Additionally, the side effects of doing this have been overlooked. It
increases CPU rendezvous time during late loading, where the cache flush
takes between 1x to 3.5x longer than the actual microcode update.

Remove native_wbinvd() and update the erratum name to align with the
latest errata documentation, document ID 334163 Version 022US.

[ bp: Zap the flaky documentation URL. ]

Fixes: 91df9fdf5149 ("x86/microcode/intel: Writeback and invalidate caches before updating microcode")
Reported-by: Yan Hua Wu <yanhua1.wu@intel.com>
Reported-by: William Xie <william.xie@intel.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Ashok Raj <ashok.raj@intel.com>
Tested-by: Yan Hua Wu <yanhua1.wu@intel.com>
Link: https://lore.kernel.org/r/20241001161042.465584-2-chang.seok.bae@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

9b86a44e21-Oct-2024 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Split load_microcode_amd()

commit 1d81d85d1a19e50d5237dc67d6b825c34ae13de8 upstream

This function should've been split a long time ago because it is used in
two paths:

1) On the

x86/microcode/AMD: Split load_microcode_amd()

commit 1d81d85d1a19e50d5237dc67d6b825c34ae13de8 upstream

This function should've been split a long time ago because it is used in
two paths:

1) On the late loading path, when the microcode is loaded through the
request_firmware interface

2) In the save_microcode_in_initrd() path which collects all the
microcode patches which are relevant for the current system before
the initrd with the microcode container has been jettisoned.

In that path, it is not really necessary to iterate over the nodes on
a system and match a patch however it didn't cause any trouble so it
was left for a later cleanup

However, that later cleanup was expedited by the fact that Jens was
enabling "Use L3 as a NUMA node" in the BIOS setting in his machine and
so this causes the NUMA CPU masks used in cpumask_of_node() to be
generated *after* 2) above happened on the first node. Which means, all
those masks were funky, wrong, uninitialized and whatnot, leading to
explosions when dereffing c->microcode in load_microcode_amd().

So split that function and do only the necessary work needed at each
stage.

Fixes: 94838d230a6c ("x86/microcode/AMD: Use the family,model,stepping encoded in the patch ID")
Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/91194406-3fdf-4e38-9838-d334af538f74@kernel.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

e7b2ccfe21-Oct-2024 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/AMD: Pay attention to the stepping dynamically

commit d1744a4c975b1acbe8b498356d28afbc46c88428 upstream

Commit in Fixes changed how a microcode patch is loaded on Zen and newer but
th

x86/microcode/AMD: Pay attention to the stepping dynamically

commit d1744a4c975b1acbe8b498356d28afbc46c88428 upstream

Commit in Fixes changed how a microcode patch is loaded on Zen and newer but
the patch matching needs to happen with different rigidity, depending on what
is being done:

1) When the patch is added to the patches cache, the stepping must be ignored
because the driver still supports different steppings per system

2) When the patch is matched for loading, then the stepping must be taken into
account because each CPU needs the patch matching its exact stepping

Take care of that by making the matching smarter.

Fixes: 94838d230a6c ("x86/microcode/AMD: Use the family,model,stepping encoded in the patch ID")
Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/91194406-3fdf-4e38-9838-d334af538f74@kernel.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

0433b8e925-Jul-2024 Borislav Petkov <bp@alien8.de>

x86/microcode/AMD: Use the family,model,stepping encoded in the patch ID

commit 94838d230a6c835ced1bad06b8759e0a5f19c1d3 upstream

On Zen and newer, the family, model and stepping is part of the
mic

x86/microcode/AMD: Use the family,model,stepping encoded in the patch ID

commit 94838d230a6c835ced1bad06b8759e0a5f19c1d3 upstream

On Zen and newer, the family, model and stepping is part of the
microcode patch ID so that the equivalence table the driver has been
using, is not needed anymore.

So switch the driver to use that from now on.

The equivalence table in the microcode blob should still remain in case
there's need to pass some additional information to the kernel loader.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20240725112037.GBZqI1BbUk1KMlOJ_D@fat_crate.local
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

dbdf088f01-Dec-2023 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode/intel: Set new revision only after a successful update

commit 9c21ea53e6bd1104c637b80a0688040f184cc761 upstream

This was meant to be done only when early microcode got updated
success

x86/microcode/intel: Set new revision only after a successful update

commit 9c21ea53e6bd1104c637b80a0688040f184cc761 upstream

This was meant to be done only when early microcode got updated
successfully. Move it into the if-branch.

Also, make sure the current revision is read unconditionally and only
once.

Fixes: 080990aa3344 ("x86/microcode: Rework early revisions reporting")
Reported-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Ashok Raj <ashok.raj@intel.com>
Link: https://lore.kernel.org/r/ZWjVt5dNRjbcvlzR@a4bf019067fa.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

73aba0a015-Nov-2023 Borislav Petkov (AMD) <bp@alien8.de>

x86/microcode: Rework early revisions reporting

commit 080990aa3344123673f686cda2df0d1b0deee046 upstream

The AMD side of the loader issues the microcode revision for each
logical thread on the syst

x86/microcode: Rework early revisions reporting

commit 080990aa3344123673f686cda2df0d1b0deee046 upstream

The AMD side of the loader issues the microcode revision for each
logical thread on the system, which can become really noisy on huge
machines. And doing that doesn't make a whole lot of sense - the
microcode revision is already in /proc/cpuinfo.

So in case one is interested in the theoretical support of mixed silicon
steppings on AMD, one can check there.

What is also missing on the AMD side - something which people have
requested before - is showing the microcode revision the CPU had
*before* the early update.

So abstract that up in the main code and have the BSP on each vendor
provide those revision numbers.

Then, dump them only once on driver init.

On Intel, do not dump the patch date - it is not needed.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/CAHk-=wg=%2B8rceshMkB4VnKxmRccVLtBLPBawnewZuuqyx5U=3A@mail.gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

fba6e6fc17-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Prepare for minimal revision check

commit 9407bda845dd19756e276d4f3abc15a20777ba45 upstream

Applying microcode late can be fatal for the running kernel when the
update changes functi

x86/microcode: Prepare for minimal revision check

commit 9407bda845dd19756e276d4f3abc15a20777ba45 upstream

Applying microcode late can be fatal for the running kernel when the
update changes functionality which is in use already in a non-compatible
way, e.g. by removing a CPUID bit.

There is no way for admins which do not have access to the vendors deep
technical support to decide whether late loading of such a microcode is
safe or not.

Intel has added a new field to the microcode header which tells the
minimal microcode revision which is required to be active in the CPU in
order to be safe.

Provide infrastructure for handling this in the core code and a command
line switch which allows to enforce it.

If the update is considered safe the kernel is not tainted and the annoying
warning message not emitted. If it's enforced and the currently loaded
microcode revision is not safe for late loading then the load is aborted.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231017211724.079611170@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

287a86b402-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Handle "offline" CPUs correctly

commit 8f849ff63bcbc77670da03cb8f2b78b06257f455 upstream

Offline CPUs need to be parked in a safe loop when microcode update is
in progress on the pri

x86/microcode: Handle "offline" CPUs correctly

commit 8f849ff63bcbc77670da03cb8f2b78b06257f455 upstream

Offline CPUs need to be parked in a safe loop when microcode update is
in progress on the primary CPU. Currently, offline CPUs are parked in
mwait_play_dead(), and for Intel CPUs, its not a safe instruction,
because the MWAIT instruction can be patched in the new microcode update
that can cause instability.

- Add a new microcode state 'UCODE_OFFLINE' to report status on per-CPU
basis.
- Force NMI on the offline CPUs.

Wake up offline CPUs while the update is in progress and then return
them back to mwait_play_dead() after microcode update is complete.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.660850472@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

f2be909902-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Protect against instrumentation

commit 1582c0f4a21303792f523fe2839dd8433ee630c0 upstream

The wait for control loop in which the siblings are waiting for the
microcode update on the p

x86/microcode: Protect against instrumentation

commit 1582c0f4a21303792f523fe2839dd8433ee630c0 upstream

The wait for control loop in which the siblings are waiting for the
microcode update on the primary thread must be protected against
instrumentation as instrumentation can end up in #INT3, #DB or #PF,
which then returns with IRET. That IRET reenables NMI which is the
opposite of what the NMI rendezvous is trying to achieve.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.545969323@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

52b5dd8402-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Rendezvous and load in NMI

commit 7eb314a22800457396f541c655697dabd71e44a7 upstream

stop_machine() does not prevent the spin-waiting sibling from handling
an NMI, which is obviously

x86/microcode: Rendezvous and load in NMI

commit 7eb314a22800457396f541c655697dabd71e44a7 upstream

stop_machine() does not prevent the spin-waiting sibling from handling
an NMI, which is obviously violating the whole concept of rendezvous.

Implement a static branch right in the beginning of the NMI handler
which is nopped out except when enabled by the late loading mechanism.

The late loader enables the static branch before stop_machine() is
invoked. Each CPU has an nmi_enable in its control structure which
indicates whether the CPU should go into the update routine.

This is required to bridge the gap between enabling the branch and
actually being at the point where it is required to enter the loader
wait loop.

Each CPU which arrives in the stopper thread function sets that flag and
issues a self NMI right after that. If the NMI function sees the flag
clear, it returns. If it's set it clears the flag and enters the
rendezvous.

This is safe against a real NMI which hits in between setting the flag
and sending the NMI to itself. The real NMI will be swallowed by the
microcode update and the self NMI will then let stuff continue.
Otherwise this would end up with a spurious NMI.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.489900814@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

9c31ea5b02-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Replace the all-in-one rendevous handler

commit 0bf871651211b58c7b19f40b746b646d5311e2ec upstream

with a new handler which just separates the control flow of primary and
secondary CP

x86/microcode: Replace the all-in-one rendevous handler

commit 0bf871651211b58c7b19f40b746b646d5311e2ec upstream

with a new handler which just separates the control flow of primary and
secondary CPUs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.433704135@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

058370ff02-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Provide new control functions

commit 6067788f04b1020b316344fe34746f96d594a042 upstream

The current all in one code is unreadable and really not suited for
adding future features like

x86/microcode: Provide new control functions

commit 6067788f04b1020b316344fe34746f96d594a042 upstream

The current all in one code is unreadable and really not suited for
adding future features like uniform loading with package or system
scope.

Provide a set of new control functions which split the handling of the
primary and secondary CPUs. These will replace the current rendezvous
all in one function in the next step. This is intentionally a separate
change because diff makes an complete unreadable mess otherwise.

So the flow separates the primary and the secondary CPUs into their own
functions which use the control field in the per CPU ucode_ctrl struct.

primary() secondary()
wait_for_all() wait_for_all()
apply_ucode() wait_for_release()
release() apply_ucode()

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.377922731@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

08631b0202-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Add per CPU control field

commit ba3aeb97cb2c53025356f31c5a0a294385194115 upstream

Add a per CPU control field to ucode_ctrl and define constants for it
which are going to be used to

x86/microcode: Add per CPU control field

commit ba3aeb97cb2c53025356f31c5a0a294385194115 upstream

Add a per CPU control field to ucode_ctrl and define constants for it
which are going to be used to control the loading state machine.

In theory this could be a global control field, but a global control does
not cover the following case:

15 primary CPUs load microcode successfully
1 primary CPU fails and returns with an error code

With global control the sibling of the failed CPU would either try again or
the whole operation would be aborted with the consequence that the 15
siblings do not invoke the apply path and end up with inconsistent software
state. The result in dmesg would be inconsistent too.

There are two additional fields added and initialized:

ctrl_cpu and secondaries. ctrl_cpu is the CPU number of the primary thread
for now, but with the upcoming uniform loading at package or system scope
this will be one CPU per package or just one CPU. Secondaries hands the
control CPU a CPU mask which will be required to release the secondary CPUs
out of the wait loop.

Preparatory change for implementing a properly split control flow for
primary and secondary CPUs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.319959519@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

05baf15d17-Oct-2023 Thomas Gleixner <tglx@linutronix.de>

x86/microcode: Add per CPU result state

commit 4b753955e9151ad2f722137a7bcbafda756186b3 upstream

The microcode rendezvous is purely acting on global state, which does
not allow to analyze fails in

x86/microcode: Add per CPU result state

commit 4b753955e9151ad2f722137a7bcbafda756186b3 upstream

The microcode rendezvous is purely acting on global state, which does
not allow to analyze fails in a coherent way.

Introduce per CPU state where the results are written into, which allows to
analyze the return codes of the individual CPUs.

Initialize the state when walking the cpu_present_mask in the online
check to avoid another for_each_cpu() loop.

Enhance the result print out with that.

The structure is intentionally named ucode_ctrl as it will gain control
fields in subsequent changes.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231017211723.632681010@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

show more ...

12345678910>>...14