Skip to content

x86/tdx: Fix port I/O handling bugs

Kiryl Shutsemau (Meta) kvm linux-coco lkml stable 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 7 repliesIn review
  2. v32 patches 7 repliesSuperseded
  3. v22 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches5 repliesSuperseded

Changes in v4 from the cover letter

- Patch 1/2 carried over unchanged as 1/3.
- Helper extracted from KVM (new patch 2/3) and used from handle_in() (Dave, David Laight).
- Reviewed-by tags from v3 2/2 dropped on patch 3/3 because the implementation changed substantially. v3 1/2 -> v4 1/3 Rb tags preserved (patch unchanged).

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3x86/tdx: Fix off-by-one in port I/O handlingarch/x86/coco/tdx/tdx.c+2 -22 replies
2/3x86/insn-eval: Add insn_assign_reg() helperarch/x86/include/asm/insn-eval.h arch/x86/kvm/emulate.c+29 -223 replies
3/3x86/tdx: Fix zero-extension for 32-bit port I/Oarch/x86/coco/tdx/tdx.c+3 -52 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchKai HuangKuppuswamy SathyanarayananBinbin WuRick Edgecombe
1/3R-b R-b R-b R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v4 thread

Cover letter [PATCH v4 0/3] x86/tdx: Fix port I/O handling bugs

Two bugs in the TDX guest port I/O #VE emulation, plus a small helper extracted from KVM to avoid open-coding partial-register-write logic in the second fix.

Patch 1 is an off-by-one in the mask used to clip the I/O value:
GENMASK(BITS_PER_BYTE * size, 0) is one bit too wide. Unchanged from v3 1/2.

Patch 2 lifts KVM's instruction-emulator helper assign_register() out of arch/x86/kvm/emulate.c into <asm/insn-eval.h>, renamed to insn_assign_reg(). Dave suggested consolidating rather than adding a third copy of the same partial-register switch; the body is rewritten using plain arithmetic (suggested by David Laight) so the helper does not rely on -fno-strict-aliasing or little-endian byte order. KVM behaviour is unchanged.

Patch 3 fixes the architectural zero-extension of 32-bit IN: the old mask-based handle_in() preserves RAX[63:32] after inl, which is wrong. Now done by calling the helper.

Changes since v3:
- Patch 1/2 carried over unchanged as 1/3.
- Helper extracted from KVM (new patch 2/3) and used from handle_in() (Dave, David Laight).
- Reviewed-by tags from v3 2/2 dropped on patch 3/3 because the implementation changed substantially. v3 1/2 -> v4 1/3 Rb tags preserved (patch unchanged).

v3: https://lore.kernel.org/all/[email protected]/

Kiryl Shutsemau (Meta) (3):
x86/tdx: Fix off-by-one in port I/O handling
x86/insn-eval: Add insn_assign_reg() helper
x86/tdx: Fix zero-extension for 32-bit port I/O

 arch/x86/coco/tdx/tdx.c          | 10 ++++------
 arch/x86/include/asm/insn-eval.h | 25 +++++++++++++++++++++++++
 arch/x86/kvm/emulate.c           | 26 ++++----------------------
 3 files changed, 33 insertions(+), 28 deletions(-)
Signature · 1 line
2.54.0