Skip to content

KVM: arm64: Fix and test MMIO sign-extending loads

Fuad Tabba kvmarm linux-arm-kernel lkml sashiko-reviews 3 versions – Applied

Status from this message: Applied to fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesApplied
  2. v22 patches 1 replySuperseded
  3. v12 patches 5 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: Fix sign-extension of MMIO loadsarch/arm64/kvm/mmio.c+4 -30 replies
2/2KVM: arm64: selftests: Add MMIO sign-extending load testtools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/arm64/mmio_sign_ext.c+256 -01 reply

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchOliver Upton
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] KVM: arm64: Fix and test MMIO sign-extending loads

Hi folks,

Changes since v2 [1]:
- Patch 2: dropped the second make_el0_accessible() call and the el0_be_loads_end symbol; the EL0 code page does not need its user-access bit set because it is fetched, not loaded. (sashiko)

Oliver's Reviewed-by is on patch 1 only: the code there is unchanged since v1.

A sign-extending load (LDRSB/LDRSH/LDRSW) from emulated MMIO returns a zero-extended value rather than the sign-extended one the architecture requires; vcpu_data_host_to_guest() strips the sign bits when it masks the data to the access width.

If my git archeology is right, the masking dates to 2014 (b30070862edbd, big-endian support) and has been wrong ever since, but sign-extending loads from device memory are rare enough that nobody hit it. Patch 1 fixes it; patch 2 adds a selftest so it doesn't regress.

Both passes run under QEMU, which reports mixed-endian support.

Based on Linux 7.2-rc2 (8cdeaa50eae8d).

Cheers,
/fuad

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

Fuad Tabba (2):
KVM: arm64: Fix sign-extension of MMIO loads
KVM: arm64: selftests: Add MMIO sign-extending load test

 arch/arm64/kvm/mmio.c                         |   7 +-
 tools/testing/selftests/kvm/Makefile.kvm      |   1 +
 .../selftests/kvm/arm64/mmio_sign_ext.c       | 255 ++++++++++++++++++
 3 files changed, 260 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/arm64/mmio_sign_ext.c
Signature · 1 line
2.39.5