Re: [PATCH V3 1/2] kvm/x86 : add coalesced pio support

From: Radim KrÄmÃÅ
Date: Wed Aug 29 2018 - 11:14:42 EST


2018-08-24 19:20+0800, Peng Hao:
> Signed-off-by: Peng Hao <peng.hao2@xxxxxxxxxx>
> ---
> include/uapi/linux/kvm.h | 5 +++--
> virt/kvm/coalesced_mmio.c | 8 +++++---
> virt/kvm/kvm_main.c | 2 ++
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index b6270a3..9cc56d3 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -420,13 +420,13 @@ struct kvm_run {
> struct kvm_coalesced_mmio_zone {
> __u64 addr;
> __u32 size;
> - __u32 pad;
> + __u32 pio;

I would prefer to have this as a slightly more compatible

union {
__u32 pad;
__u32 pio;
};

> };
>
> struct kvm_coalesced_mmio {
> __u64 phys_addr;
> __u32 len;
> - __u32 pad;
> + __u32 pio;

Also, please add a check that "pio <= 1".

This would catch most cases where userspace passed garbage in that field
and we'd also make the remaining bits available for future features.

Thanks.