[PATCH 7/8] kvm: decode the argument for KVM_{SET, GET}_SREGS ioctl command

Dmitry V. Levin ldv at altlinux.org
Fri Dec 1 23:26:09 UTC 2017


On Sat, Dec 02, 2017 at 04:05:31AM +0900, Masatake YAMATO wrote:
> * configure.ac (AC_CHECK_TYPES): Add struct kvm_sregs.
> * kvm.c (kvm_ioctl_decode_regs_segment): New function.
> (kvm_ioctl) <KVM_SET_SREGS, KVM_GET_SREGS>: Use it.
> * linux/arch_kvm.c (arch_print_kvm_sregs): New function.
> * linux/x86_64/arch_kvm.c (arch_print_kvm_sregs): New function.
> (kvm_ioctl_decode_regs_dtable): Ditto.
> (kvm_ioctl_decode_regs_segment): Ditto.
> 
> Changes in v2:
> * Decode only if struct kvm_sregs is available.
> * Put arch-specific and generic stub decoders to arch_kvm.c.
> * Use umove_or_printaddr instead of umove.
> 
>     Above 3 items are suggested by ldv.
> 
> * Use more const modifiers.
> 
> Signed-off-by: Masatake YAMATO <yamato at redhat.com>
> ---
>  configure.ac            |  5 +++-
>  kvm.c                   | 23 +++++++++++++++++
>  linux/arch_kvm.c        |  8 ++++++
>  linux/x86_64/arch_kvm.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 103 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 93d4bd73..b0ddfd17 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -541,7 +541,10 @@ AC_CHECK_TYPES([struct statfs64], [
>  
>  AC_CHECK_TYPES([struct blk_user_trace_setup],,, [#include <linux/blktrace_api.h>])
>  
> -AC_CHECK_TYPES([struct kvm_regs],,, [#include <linux/kvm.h>])
> +AC_CHECK_TYPES(m4_normalize([
> +		struct kvm_regs,
> +		struct kvm_sregs
> +		]),,, [#include <linux/kvm.h>])
>  
>  AC_CHECK_HEADERS([linux/btrfs.h], [
>  	AC_CHECK_MEMBERS(m4_normalize([
> diff --git a/kvm.c b/kvm.c
> index a4bab9d4..32c278ac 100644
> --- a/kvm.c
> +++ b/kvm.c
> @@ -84,6 +84,26 @@ kvm_ioctl_decode_regs(struct tcb *const tcp, const unsigned int code, const kern
>  #endif
>  }
>  
> +static int
> +kvm_ioctl_decode_sregs(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg)
> +{
> +#ifdef HAVE_STRUCT_KVM_REGS
> +	struct kvm_sregs sregs;

Like in case of struct kvm_regs, struct kvm_sregs also seems to be present
in linux/kvm.h since the beginning, so the same reasoning applies here as well.


-- 
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/4eec67f8/attachment.bin>


More information about the Strace-devel mailing list