linux-stable/arch/x86
Kai Huang 4bb7cb4990 x86/asm: Remove the __iomem annotation of movdir64b()'s dst argument
[ Upstream commit 5bdd181821 ]

Commit e56d28df2f ("x86/virt/tdx: Configure global KeyID on all
packages") causes a sparse warning:

  arch/x86/virt/vmx/tdx/tdx.c:683:27: warning: incorrect type in argument 1 (different address spaces)
  arch/x86/virt/vmx/tdx/tdx.c:683:27:    expected void [noderef] __iomem *dst
  arch/x86/virt/vmx/tdx/tdx.c:683:27:    got void *

The reason is TDX must use the MOVDIR64B instruction to convert TDX
private memory (which is normal RAM but not MMIO) back to normal.  The
TDX code uses existing movdir64b() helper to do that, but the first
argument @dst of movdir64b() is annotated with __iomem.

When movdir64b() was firstly introduced in commit 0888e1030d
("x86/asm: Carve out a generic movdir64b() helper for general usage"),
it didn't have the __iomem annotation.  But this commit also introduced
the same "incorrect type" sparse warning because the iosubmit_cmds512(),
which was the solo caller of movdir64b(), has the __iomem annotation.

This was later fixed by commit 6ae58d8713 ("x86/asm: Annotate
movdir64b()'s dst argument with __iomem").  That fix was reasonable
because until TDX code the movdir64b() was only used to move data to
MMIO location, as described by the commit message:

  ... The current usages send a 64-bytes command descriptor to an MMIO
  location (portal) on a device for consumption. When future usages for
  the MOVDIR64B instruction warrant a separate variant of a memory to
  memory operation, the argument annotation can be revisited.

Now TDX code uses MOVDIR64B to move data to normal memory so it's time
to revisit.

The SDM says the destination of MOVDIR64B is "memory location specified
in a general register", thus it's more reasonable that movdir64b() does
not have the __iomem annotation on the @dst.

Remove the __iomem annotation from the @dst argument of movdir64b() to
fix the sparse warning in TDX code.  Similar to memset_io(), introduce a
new movdir64b_io() to cover the case where the destination is an MMIO
location, and change the solo caller iosubmit_cmds512() to use the new
movdir64b_io().

In movdir64b_io() explicitly use __force in the type casting otherwise
there will be below sparse warning:

  warning: cast removes address space '__iomem' of expression

[ dhansen: normal changelog tweaks ]

Closes: https://lore.kernel.org/oe-kbuild-all/202312311924.tGjsBIQD-lkp@intel.com/
Fixes: e56d28df2f ("x86/virt/tdx: Configure global KeyID on all packages")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Kai Huang <kai.huang@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Yuan Yao <yuan.yao@intel.com>
Link: https://lore.kernel.org/all/20240126023852.11065-1-kai.huang%40intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:16:30 -04:00
..
boot x86/efistub: Use 1:1 file:memory mapping for PE/COFF .compat section 2024-02-05 10:24:51 +00:00
coco - Add support managing TDX host hardware 2024-01-18 13:41:48 -08:00
configs hardening updates for v6.7-rc1 2023-10-30 19:09:55 -10:00
crypto This update includes the following changes: 2024-01-10 12:23:43 -08:00
entry x86/entry_32: Add VERW just before userspace transition 2024-02-19 16:31:46 -08:00
events Performance events changes for v6.8 are: 2024-01-08 19:37:20 -08:00
hyperv x86/hyperv: Allow 15-bit APIC IDs for VTL platforms 2024-03-01 08:36:22 +00:00
ia32
include x86/asm: Remove the __iomem annotation of movdir64b()'s dst argument 2024-03-26 18:16:30 -04:00
kernel x86/resctrl: Implement new mba_MBps throttling heuristic 2024-03-26 18:16:29 -04:00
kvm KVM/x86: Export RFDS_NO and RFDS_CLEAR to guests 2024-03-15 10:48:13 -04:00
lib x86/lib: Revert to _ASM_EXTABLE_UA() for {get,put}_user() fixups 2024-01-29 11:40:41 +01:00
math-emu
mm x86/sme: Fix memory encryption setting if enabled by default and not overridden 2024-03-26 18:16:29 -04:00
net Networking changes for 6.8. 2024-01-11 10:07:29 -08:00
pci pci-v6.8-changes 2024-01-17 16:23:17 -08:00
platform x86/cleanups changes for v6.8: 2024-01-08 17:23:32 -08:00
power
purgatory x86/purgatory: Remove LTO flags 2023-09-17 09:49:03 +02:00
ras
realmode x86/cleanups changes for v6.8: 2024-01-08 17:23:32 -08:00
tools x86/build changes for v6.8: 2024-01-08 17:22:02 -08:00
um This pull request contains the following changes for UML: 2024-01-17 10:44:34 -08:00
video fbdev: Replace fb_pgprotect() with pgprot_framebuffer() 2023-10-12 09:20:46 +02:00
virt x86/mce: Differentiate real hardware #MCs from TDX erratum ones 2023-12-12 08:46:46 -08:00
xen x86/xen: Add some null pointer checking to smp.c 2024-02-12 20:14:52 +01:00
.gitignore
Kbuild
Kconfig x86/rfds: Mitigate Register File Data Sampling (RFDS) 2024-03-15 10:48:13 -04:00
Kconfig.assembler
Kconfig.cpu x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 2024-02-09 16:28:19 +01:00
Kconfig.debug
Makefile kbuild: use 4-space indentation when followed by conditionals 2024-02-15 06:05:44 +09:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00
Makefile.um
Makefile_32.cpu