Skip to content

KVM: arm64: Return -EINVAL for an empty SMCCC filter range at base 0

Karl Mehltretter kvm kvmarm linux-arm-kernel linux-kselftest lkml 1 version Applied

Status from this message: Applied to fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: Return -EINVAL for an empty SMCCC filter range at base 0arch/arm64/kvm/hypercalls.c+2 -14 replies
2/2KVM: arm64: selftests: Test empty SMCCC filter range at base 0tools/testing/selftests/kvm/arm64/smccc_filter.c+4 -02 replies

Reviews trailers per patch

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

PatchFuad TabbaSteffen Eiden
1/2R-b T-b R-b
2/2R-b T-b R-b

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

Read the v1 thread

Cover letter [PATCH 0/2] KVM: arm64: Return -EINVAL for an empty SMCCC filter range at base 0

KVM_ARM_VM_SMCCC_FILTER rejects an empty range (nr_functions == 0) with -EINVAL for every base except 0. kvm_smccc_set_filter() only rejects a range if its inclusive end, base + nr_functions - 1, is below base; for base 0 that end wraps to U32_MAX, and KVM then tries to insert [0, U32_MAX], which overlaps the reserved Arm Architecture Calls ranges, so the attribute returns -EEXIST instead of -EINVAL.

The request is rejected either way; only the errno is wrong, so this is a minor UAPI validation fix.

Patch 1 rejects a zero function count explicitly. Patch 2 adds the base 0 case to test_invalid_nr_functions(), which only covered a nonzero base and therefore never caught this.

Tested on an arm64 KVM host in VHE mode running under QEMU TCG: a small userspace reproducer gets EEXIST before patch 1 and EINVAL after it, and the smccc_filter selftest including the new assertion passes with patch 1 applied and fails at the new assertion with EEXIST without it.

Karl Mehltretter (2):
KVM: arm64: Return -EINVAL for an empty SMCCC filter range at base 0
KVM: arm64: selftests: Test empty SMCCC filter range at base 0

 arch/arm64/kvm/hypercalls.c                      | 3 ++-
 tools/testing/selftests/kvm/arm64/smccc_filter.c | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

base-commit: 548e7bcd0c5460ddcbca9600cea603ebeebf4da7

Signature · 1 line
2.39.5 (Apple Git-154)