linux-stable/arch/x86/include/asm
Adam Dunlap 052d73ca94 x86/apic: Force native_apic_mem_read() to use the MOV instruction
commit 5ce344beac upstream.

When done from a virtual machine, instructions that touch APIC memory
must be emulated. By convention, MMIO accesses are typically performed
via io.h helpers such as readl() or writeq() to simplify instruction
emulation/decoding (ex: in KVM hosts and SEV guests) [0].

Currently, native_apic_mem_read() does not follow this convention,
allowing the compiler to emit instructions other than the MOV
instruction generated by readl(). In particular, when the kernel is
compiled with clang and run as a SEV-ES or SEV-SNP guest, the compiler
would emit a TESTL instruction which is not supported by the SEV-ES
emulator, causing a boot failure in that environment. It is likely the
same problem would happen in a TDX guest as that uses the same
instruction emulator as SEV-ES.

To make sure all emulators can emulate APIC memory reads via MOV, use
the readl() function in native_apic_mem_read(). It is expected that any
emulator would support MOV in any addressing mode as it is the most
generic and is what is usually emitted currently.

The TESTL instruction is emitted when native_apic_mem_read() is inlined
into apic_mem_wait_icr_idle(). The emulator comes from
insn_decode_mmio() in arch/x86/lib/insn-eval.c. It's not worth it to
extend insn_decode_mmio() to support more instructions since, in theory,
the compiler could choose to output nearly any instruction for such
reads which would bloat the emulator beyond reason.

  [0] https://lore.kernel.org/all/20220405232939.73860-12-kirill.shutemov@linux.intel.com/

  [ bp: Massage commit message, fix typos. ]

Signed-off-by: Adam Dunlap <acdunlap@google.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Kevin Loughlin <kevinloughlin@google.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20240318230927.2191933-1-acdunlap@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-17 11:19:36 +02:00
..
e820
fpu x86/fpu: Allow caller to constrain xfeatures when copying to uabi buffer 2023-10-12 11:08:58 -04:00
numachip
shared - Fix a race window where load_unaligned_zeropad() could cause 2023-06-26 16:32:47 -07:00
trace
uv efi/runtime-wrappers: Remove duplicated macro for service returning void 2023-08-22 10:39:26 +02:00
vdso clocksource: hyper-v: Adjust hv_read_tsc_page_tsc() to avoid special casing U64_MAX 2023-06-05 21:11:07 +02:00
xen x86/xen: attempt to inflate the memory balloon on PVH 2024-04-13 13:07:39 +02:00
GEN-for-each-reg.h
Kbuild x86/unwind/orc: Add ELF section with ORC version identifier 2023-06-16 17:17:42 +02:00
acenv.h
acpi.h acpi/processor: sanitize _OSC/_PDC capabilities for Xen dom0 2023-11-28 17:19:57 +00:00
acrn.h
agp.h
alternative.h x86/speculation, objtool: Use absolute relocations for annotations 2023-12-20 17:02:06 +01:00
amd-ibs.h
amd_hsmp.h
amd_nb.h
apic.h x86/apic: Force native_apic_mem_read() to use the MOV instruction 2024-04-17 11:19:36 +02:00
apicdef.h x86/apic: Fix use of X{,2}APIC_ENABLE in asm with older binutils 2023-05-22 14:06:33 +02:00
apm.h
arch_hweight.h
archrandom.h
asm-offsets.h
asm-prototypes.h x86/bugs: Fix the SRSO mitigation on Zen3/4 2024-04-10 16:35:50 +02:00
asm.h x86/sev: Fix position dependent variable references in startup code 2024-04-03 15:28:50 +02:00
atomic.h locking/atomic: treewide: delete arch_atomic_*() kerneldoc 2023-06-05 09:57:24 +02:00
atomic64_32.h locking/atomic: treewide: delete arch_atomic_*() kerneldoc 2023-06-05 09:57:24 +02:00
atomic64_64.h locking/atomic: treewide: delete arch_atomic_*() kerneldoc 2023-06-05 09:57:24 +02:00
audit.h x86/audit: Fix -Wmissing-variable-declarations warning for ia32_xyz_class 2023-08-30 10:11:16 +02:00
barrier.h x86/barrier: Do not serialize MSR accesses on AMD 2024-02-23 09:25:27 +01:00
bios_ebda.h
bitops.h
boot.h x86/efistub: Remap kernel text read-only before dropping NX attribute 2024-04-10 16:36:07 +02:00
bootparam_utils.h docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
bug.h
bugs.h x86/cpu: Switch to arch_cpu_finalize_init() 2023-06-16 10:15:59 +02:00
cache.h
cacheflush.h
cacheinfo.h
ce4100.h
cfi.h
checksum.h
checksum_32.h
checksum_64.h
clocksource.h
cmdline.h
cmpxchg.h arch: Remove cmpxchg_double 2023-06-05 09:36:39 +02:00
cmpxchg_32.h arch: Remove cmpxchg_double 2023-06-05 09:36:39 +02:00
cmpxchg_64.h locking/atomic: x86: add preprocessor symbols 2023-06-05 09:57:17 +02:00
coco.h x86/coco: Require seeding RNG with RDRAND on CoCo systems 2024-04-10 16:36:03 +02:00
compat.h
cpu.h cpu-hotplug: Provide prototypes for arch CPU registration 2023-10-11 14:27:37 +02:00
cpu_device_id.h
cpu_entry_area.h
cpufeature.h x86/cpufeatures: Add CPUID_LNX_5 to track recently added Linux-defined word 2024-04-10 16:35:48 +02:00
cpufeatures.h x86/bhi: Mitigate KVM by default 2024-04-10 16:36:08 +02:00
cpuid.h
cpuidle_haltpoll.h
cpumask.h x86/smpboot: Move synchronization masks to SMP boot code 2023-05-15 13:44:52 +02:00
crash.h
current.h
debugreg.h
delay.h
desc.h
desc_defs.h
device.h
disabled-features.h x86/cpufeatures: Add new word for scattered features 2024-04-10 16:35:47 +02:00
div64.h x86/asm: Avoid unneeded __div64_32 function definition 2023-08-03 12:08:35 +02:00
dma-mapping.h
dma.h
dmi.h
doublefault.h x86: Avoid missing-prototype warnings for doublefault code 2023-05-18 11:56:18 -07:00
dwarf2.h
edac.h
efi.h efi/x86: Move EFI runtime call setup/teardown helpers out of line 2023-09-11 06:37:50 +00:00
elf.h
elfcore-compat.h
emergency-restart.h
emulate_prefix.h
enclu.h
entry-common.h x86/bugs: Use ALTERNATIVE() instead of mds_user_clear static key 2024-03-06 14:48:44 +00:00
espfix.h
exec.h
extable.h
extable_fixup_types.h
fb.h arch/x86: Include <asm/fb.h> in fbdev source file 2023-04-26 15:07:57 +02:00
fixmap.h
floppy.h
frame.h
fsgsbase.h
ftrace.h Tracing updates for 6.5: 2023-06-30 10:33:17 -07:00
futex.h
gart.h
genapic.h
geode.h
gsseg.h
hardirq.h
highmem.h
hpet.h
hugetlb.h
hw_breakpoint.h
hw_irq.h x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup() 2023-08-06 14:15:09 +02:00
hyperv-tlfs.h x86/hyperv: Add hv_isolation_type_tdx() to detect TDX guests 2023-08-25 00:04:56 +00:00
hyperv_timer.h
hypervisor.h
i8259.h x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility 2023-10-27 20:36:49 +02:00
ia32.h x86/coco: Disable 32-bit emulation by default on TDX and SEV 2023-12-13 18:45:02 +01:00
ia32_unistd.h
ibt.h x86/alternative: Rename apply_ibt_endbr() 2023-07-10 09:52:23 +02:00
idtentry.h x86/entry: Convert INT 0x80 emulation to IDTENTRY 2023-12-13 18:45:02 +01:00
imr.h
inat.h
inat_types.h
init.h x86/head/64: Move the __head definition to <asm/init.h> 2024-04-10 16:36:07 +02:00
insn-eval.h
insn.h
inst.h
intel-family.h x86/cpu: Add model number for Intel Arrow Lake mobile processor 2023-10-27 10:19:26 -07:00
intel-mid.h x86/platform/intel-mid: Remove unused definitions from intel-mid.h 2023-03-22 11:08:40 -07:00
intel_ds.h
intel_pconfig.h
intel_pt.h
intel_punit_ipc.h
intel_scu_ipc.h
intel_telemetry.h
invpcid.h
io.h asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros 2023-08-18 10:12:32 -07:00
io_apic.h x86/apic/ioapic: Rename skip_ioapic_setup 2023-08-09 11:58:16 -07:00
io_bitmap.h
iomap.h
iommu.h
iosf_mbi.h
irq.h nmi_backtrace: allow excluding an arbitrary CPU 2023-08-18 10:19:00 -07:00
irq_remapping.h
irq_stack.h
irq_vectors.h x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback 2023-08-06 14:15:10 +02:00
irq_work.h arch: consolidate arch_irq_work_raise prototypes 2024-02-05 20:14:17 +00:00
irqdomain.h
irqflags.h
ist.h
jailhouse_para.h
jump_label.h work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:24:47 +01:00
kasan.h
kaslr.h
kbdleds.h
kdebug.h
kexec-bzimage64.h
kexec.h ARM: 2023-09-07 13:52:20 -07:00
kfence.h
kgdb.h
kmsan.h mm, kmsan: fix infinite recursion due to RCU critical section 2024-02-05 20:14:38 +00:00
kprobes.h
kvm-x86-ops.h KVM: x86: Fix lapic timer interrupt lost after loading a snapshot. 2023-11-28 17:19:56 +00:00
kvm-x86-pmu-ops.h KVM: x86/pmu: Move PMU reset logic to common x86 code 2024-01-25 15:35:48 -08:00
kvm_host.h KVM: x86: Fix lapic timer interrupt lost after loading a snapshot. 2023-11-28 17:19:56 +00:00
kvm_page_track.h KVM: x86/mmu: Handle KVM bookkeeping in page-track APIs, not callers 2023-08-31 14:08:19 -04:00
kvm_para.h
kvm_types.h
kvm_vcpu_regs.h
kvmclock.h
linkage.h x86/asm: Fix build of UML with KASAN 2023-09-18 19:30:08 +02:00
local.h locking/arch: Avoid variable shadowing in local_try_cmpxchg() 2023-07-10 09:52:36 +02:00
mach_timer.h
mach_traps.h
math_emu.h
mc146818rtc.h
mce.h x86/mce: Add copy_mc_fragile_handle_tail() prototype 2023-05-18 11:56:18 -07:00
mem_encrypt.h x86/sme: Move early SME kernel encryption handling into .head.text 2024-04-10 16:36:07 +02:00
memtype.h
microcode.h Misc x86 cleanups. 2023-08-28 17:05:58 -07:00
misc.h
mman.h x86: Remove the arch_calc_vm_prot_bits() macro from the UAPI 2023-09-06 23:50:46 +02:00
mmconfig.h
mmu.h x86/mm/iommu/sva: Make LAM and SVA mutually exclusive 2023-03-16 13:08:40 -07:00
mmu_context.h x86/shstk: Handle vfork clone failure correctly 2023-09-19 09:18:34 -07:00
mmzone.h
mmzone_32.h
mmzone_64.h
module.h
mpspec.h x86/apic/32: Decrapify the def_bigsmp mechanism 2023-08-09 11:58:25 -07:00
mpspec_def.h
mshyperv.h x86/hyperv: Remove hv_vtl_early_init initcall 2023-09-22 18:41:29 +00:00
msi.h
msr-index.h x86/bhi: Enumerate Branch History Injection (BHI) bug 2024-04-10 16:36:08 +02:00
msr-trace.h
msr.h
mtrr.h x86/mtrr: Remove unused code 2023-06-01 15:04:33 +02:00
mwait.h x86: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram 2024-01-25 15:35:12 -08:00
nmi.h
nops.h x86/alternatives: Add longer 64-bit NOPs 2023-05-31 10:21:21 +02:00
nospec-branch.h x86/bhi: Mitigate KVM by default 2024-04-10 16:36:08 +02:00
numa.h x86/mm: Drop the 4 MB restriction on minimal NUMA node memory size 2023-11-28 17:19:36 +00:00
numa_32.h
olpc.h
olpc_ofw.h
orc_header.h x86/unwind/orc: Add ELF section with ORC version identifier 2023-06-16 17:17:42 +02:00
orc_lookup.h
orc_types.h x86,objtool: Split UNWIND_HINT_EMPTY in two 2023-03-23 23:18:58 +01:00
page.h x86/mm: Ensure input to pfn_to_kaddr() is treated as a 64-bit type 2024-03-26 18:19:19 -04:00
page_32.h
page_32_types.h
page_64.h
page_64_types.h docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
page_types.h
paravirt.h x86/paravirt: Silence unused native_pv_lock_init() function warning 2023-08-03 16:50:19 +02:00
paravirt_api_clock.h
paravirt_types.h x86/xen: move paravirt lazy code 2023-09-19 07:04:49 +02:00
parport.h
pc-conf-reg.h
pci-direct.h
pci-functions.h
pci.h
pci_x86.h
percpu.h arch: Remove cmpxchg_double 2023-06-05 09:36:39 +02:00
perf_event.h Perf events changes for v6.5: 2023-06-27 14:43:02 -07:00
perf_event_p4.h
pgalloc.h
pgtable-2level.h
pgtable-2level_types.h
pgtable-3level.h
pgtable-3level_types.h
pgtable-invert.h
pgtable.h mm: abstract moving to the next PFN 2023-09-29 17:20:46 -07:00
pgtable_32.h
pgtable_32_areas.h
pgtable_32_types.h
pgtable_64.h x86/mm: Fix __swp_entry_to_pte() for Xen PV guests 2023-05-08 15:25:24 +02:00
pgtable_64_types.h docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
pgtable_areas.h
pgtable_types.h Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
pkeys.h
pkru.h
platform_sst_audio.h
pm-trace.h
posix_types.h
preempt.h
probe_roms.h
processor-cyrix.h
processor-flags.h x86: CPUID and CR3/CR4 flags for Linear Address Masking 2023-03-16 13:08:39 -07:00
processor.h x86/barrier: Do not serialize MSR accesses on AMD 2024-02-23 09:25:27 +01:00
prom.h
proto.h x86/entry: Convert INT 0x80 emulation to IDTENTRY 2023-12-13 18:45:02 +01:00
pti.h
ptrace.h
purgatory.h
pvclock-abi.h
pvclock.h
qrwlock.h
qspinlock.h x86/paravirt: Silence unused native_pv_lock_init() function warning 2023-08-03 16:50:19 +02:00
qspinlock_paravirt.h x86/qspinlock-paravirt: Fix missing-prototype warning 2023-08-03 17:15:05 +02:00
realmode.h x86/smpboot: Implement a bit spinlock to protect the realmode stack 2023-05-15 13:45:03 +02:00
reboot.h x86/reboot: Expose VMCS crash hooks if and only if KVM_{INTEL,AMD} is enabled 2023-08-03 15:37:14 -07:00
reboot_fixups.h
required-features.h x86/cpufeatures: Add new word for scattered features 2024-04-10 16:35:47 +02:00
resctrl.h x86/resctl: fix scheduler confusion with 'current' 2023-03-08 11:48:11 -08:00
rmwcc.h work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:24:47 +01:00
seccomp.h
sections.h lockdep: fix static memory detection even more 2023-08-21 13:46:24 -07:00
segment.h x86/vdso: Choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel 2023-08-08 09:31:43 +02:00
serial.h
set_memory.h
setup.h x86/head: Mark *_start_kernel() __noreturn 2023-04-14 17:31:24 +02:00
setup_arch.h
sev-common.h x86/sev: Put PSC struct on the stack in prep for unaccepted memory support 2023-06-06 18:28:25 +02:00
sev.h x86/sev: Move early startup code into .head.text section 2024-04-10 16:36:07 +02:00
sgx.h
shmparam.h
shstk.h x86/shstk: Add ARCH_SHSTK_STATUS 2023-08-02 15:01:51 -07:00
sigcontext.h
sigframe.h x86/init: Initialize signal frame size late 2023-06-16 10:16:00 +02:00
sighandling.h
signal.h
simd.h
smap.h
smp.h Revert "x86/smp: Put CPUs into INIT on shutdown if possible" 2023-10-15 12:02:02 -07:00
softirq_stack.h
sparsemem.h x86/numa: Introduce numa_fill_memblks() 2023-11-20 11:58:53 +01:00
spec-ctrl.h
special_insns.h work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:24:47 +01:00
spinlock.h
spinlock_types.h
sta2x11.h
stackprotector.h
stacktrace.h
static_call.h
string.h
string_32.h
string_64.h x86: kmsan: use C versions of memset16/memset32/memset64 2023-03-28 16:20:11 -07:00
suspend.h
suspend_32.h x86/pm: Work around false positive kmemleak report in msr_build_context() 2024-04-03 15:28:37 +02:00
suspend_64.h
svm.h x86: KVM: SVM: add support for Invalid IPI Vector interception 2023-10-12 11:08:59 -04:00
switch_to.h x86: Rewrite ret_from_fork() in C 2023-07-10 09:52:25 +02:00
sync_bitops.h
sync_core.h
syscall.h x86/bhi: Add support for clearing branch history at syscall entry 2024-04-10 16:36:07 +02:00
syscall_wrapper.h x86/entry/ia32: Ensure s32 is sign extended to s64 2024-01-31 16:19:14 -08:00
syscalls.h
tdx.h x86/tdx: Add unaccepted memory support 2023-06-06 18:25:57 +02:00
text-patching.h
thermal.h
thread_info.h thread_info: move function declarations to linux/thread_info.h 2023-06-09 17:44:16 -07:00
time.h init: consolidate prototypes in linux/init.h 2023-06-09 17:44:16 -07:00
timer.h
timex.h
tlb.h
tlbbatch.h
tlbflush.h Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
topology.h cpu/SMT: Remove topology_smt_supported() 2023-07-28 09:53:37 +02:00
trace_clock.h
trap_pf.h x86/mm: Check shadow stack page fault errors 2023-07-11 14:12:19 -07:00
trapnr.h
traps.h x86/ibt: Convert IBT selftest to asm 2023-08-17 17:07:09 +02:00
tsc.h - Arnd Bergmann has fixed a bunch of -Wmissing-prototypes in 2023-06-28 10:59:38 -07:00
uaccess.h work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:24:47 +01:00
uaccess_32.h x86: uaccess: move 32-bit and 64-bit parts into proper <asm/uaccess_N.h> header 2023-05-03 10:37:22 -07:00
uaccess_64.h x86: bring back rep movsq for user access on CPUs without ERMS 2023-08-30 09:45:12 -07:00
umip.h
unaccepted_memory.h x86/sev: Add SNP-specific unaccepted memory support 2023-06-06 18:31:37 +02:00
unistd.h
unwind.h
unwind_hints.h drm/vmwgfx: Add unwind hints around RBP clobber 2023-06-07 10:03:12 -07:00
uprobes.h
user.h
user32.h
user_32.h
user_64.h
vdso.h
vermagic.h
vga.h
vgtod.h
vm86.h
vmalloc.h
vmware.h
vmx.h KVM: VMX: Rename XSAVES control to follow KVM's preferred "ENABLE_XYZ" 2023-08-17 11:38:28 -07:00
vmxfeatures.h
vsyscall.h x86/mm: Move is_vsyscall_vaddr() into asm/vsyscall.h 2024-03-26 18:19:11 -04:00
vvar.h
word-at-a-time.h
x86_init.h x86/sev: Skip ROM range scans and validation for SEV-SNP guests 2024-04-03 15:29:03 +02:00
xor.h
xor_32.h
xor_64.h
xor_avx.h