Re: [GIT PULL] KVM patches for Linux 6.1-rc2

From: Linus Torvalds
Date: Sun Oct 23 2022 - 18:15:44 EST


On Sun, Oct 23, 2022 at 10:43 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> x86:
>
> - add compat implementation for KVM_X86_SET_MSR_FILTER ioctl

Side note: this should probably have used

compat_uptr_t bitmap;
...
.bitmap = compat_ptr(cr->bitmap),

instead of doing that

__u32 bitmap;
...
.bitmap = (__u8 *)(ulong)cr->bitmap,

because not only are those casts really ugly, using that
'compat_uptr_t" and "compat_ptr()" helper also really explains what is
going on.

compat_ptr() also happens to get the address space right (ie it
returns a "void __user *" pointer). But since the non-compat 'struct
kvm_msr_filter_range' bitmap member doesn't get that right either
(because it uses the same type for kernel pointers as for user
pointers - ugly uglt), that isn't such a big deal. The kvm code
clearly doesn't do proper user pointer typing, and just uses random
casts instead.

Linus