Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: PPC: Don't return -ENOTSUPP to userspace in ioctls

ENOTSUPP is a linux only thingy, the value of which is unknown to
userspace, not to be confused with ENOTSUP which linux maps to
EOPNOTSUPP, as permitted by POSIX [1]:

[EOPNOTSUPP]
Operation not supported on socket. The type of socket (address family
or protocol) does not support the requested operation. A conforming
implementation may assign the same values for [EOPNOTSUPP] and [ENOTSUP].

Return -EOPNOTSUPP instead of -ENOTSUPP for the following ioctls:
- KVM_GET_FPU for Book3s and BookE
- KVM_SET_FPU for Book3s and BookE
- KVM_GET_DIRTY_LOG for BookE

This doesn't affect QEMU which doesn't call the KVM_GET_FPU and
KVM_SET_FPU ioctls on POWER anyway since they are not supported,
and _buggily_ ignores anything but -EPERM for KVM_GET_DIRTY_LOG.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html

Signed-off-by: Greg Kurz <groug@kaod.org>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

authored by

Greg Kurz and committed by
Paul Mackerras
4e1b2ab7 5706d14d

+5 -5
+2 -2
arch/powerpc/kvm/book3s.c
··· 558 558 559 559 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 560 560 { 561 - return -ENOTSUPP; 561 + return -EOPNOTSUPP; 562 562 } 563 563 564 564 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 565 565 { 566 - return -ENOTSUPP; 566 + return -EOPNOTSUPP; 567 567 } 568 568 569 569 int kvmppc_get_one_reg(struct kvm_vcpu *vcpu, u64 id,
+3 -3
arch/powerpc/kvm/booke.c
··· 1747 1747 1748 1748 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 1749 1749 { 1750 - return -ENOTSUPP; 1750 + return -EOPNOTSUPP; 1751 1751 } 1752 1752 1753 1753 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 1754 1754 { 1755 - return -ENOTSUPP; 1755 + return -EOPNOTSUPP; 1756 1756 } 1757 1757 1758 1758 int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, ··· 1773 1773 1774 1774 int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) 1775 1775 { 1776 - return -ENOTSUPP; 1776 + return -EOPNOTSUPP; 1777 1777 } 1778 1778 1779 1779 void kvmppc_core_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)