[PATCH 5/8] kvm: decode the argument for KVM_SET_USER_MEMORY_REGION ioctl command
Dmitry V. Levin
ldv at altlinux.org
Fri Dec 1 23:22:25 UTC 2017
On Sat, Dec 02, 2017 at 04:05:29AM +0900, Masatake YAMATO wrote:
> * xlat/kvm_mem_flags.in: New file.
> * kvm.c (kvm_ioctl_set_user_memory_region): New function.
> (kvm_ioctl) <KVM_SET_USER_MEMORY_REGION>: Use it.
> (top-level): Include print_fields.h and xlat/kvm_mem_flags.h.
It should rather be
* kvm.c: Include print_fields.h and xlat/kvm_mem_flags.h.
(kvm_ioctl_set_user_memory_region): New function.
(kvm_ioctl) <KVM_SET_USER_MEMORY_REGION>: Use it.
> Change in v2:
> * Use umove_or_printaddr instead of umove because umove_or_printaddr
> performs verbose(tcp) check and prints the zero address nicely.
> Suggested by ldv.
>
> Signed-off-by: Masatake YAMATO <yamato at redhat.com>
> ---
> kvm.c | 23 +++++++++++++++++++++++
> xlat/kvm_mem_flags.in | 2 ++
> 2 files changed, 25 insertions(+)
> create mode 100644 xlat/kvm_mem_flags.in
>
> diff --git a/kvm.c b/kvm.c
> index f725f9df..19779c84 100644
> --- a/kvm.c
> +++ b/kvm.c
> @@ -32,6 +32,7 @@
>
> #ifdef HAVE_LINUX_KVM_H
> #include <linux/kvm.h>
> +#include "print_fields.h"
>
> static int
> kvm_ioctl_create_vcpu(struct tcb *const tcp, const kernel_ulong_t arg)
> @@ -42,6 +43,26 @@ kvm_ioctl_create_vcpu(struct tcb *const tcp, const kernel_ulong_t arg)
> return RVAL_IOCTL_DECODED | RVAL_FD;
> }
>
> +#include "xlat/kvm_mem_flags.h"
> +static int
> +kvm_ioctl_set_user_memory_region(struct tcb *const tcp, const kernel_ulong_t arg)
> +{
> + struct kvm_userspace_memory_region u_memory_region;
struct kvm_userspace_memory_region was introduced by kernel commit
v2.6.25-rc1~1138^2~222, a few releases after the kernel commit
v2.6.20-rc1~15^2~39 that introduced linux/kvm.h itself.
That is, there might be a valid (although quite old and useless) version
of linux/kvm.h without struct kvm_userspace_memory_region, so there has
to be a check for its availability, just to avoid compile time errors.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20171202/1079b3cf/attachment.bin>
More information about the Strace-devel
mailing list