On Fri, Dec 01, 2017 at 02:45:56PM +0900, Masatake YAMATO wrote: > * kvm.c (kvm_ioctl): Handle KVM_SET_REGS and KVM_GET_REGES. > (kvm_ioctl_decode_regs): New function. > > Signed-off-by: Masatake YAMATO <[email protected]> > --- > kvm.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 52 insertions(+) > > diff --git a/kvm.c b/kvm.c > index 43746fef..69a8c97a 100644 > --- a/kvm.c > +++ b/kvm.c > @@ -72,6 +72,55 @@ kvm_ioctl_set_user_memory_region(struct tcb *const tcp, > const kernel_ulong_t arg > return RVAL_IOCTL_DECODED; > } > > +static int > +kvm_ioctl_decode_regs(struct tcb *const tcp, const unsigned int code, const > kernel_ulong_t arg) > +{ > +#ifdef X86_64
Wouldn't this work on X32 as well?
Let's avoid such ifdefs in the new code.
What I suggest is adding a check, e.g.
AC_CHECK_TYPES([struct kvm_regs],,, [#include <linux/kvm.h>])
to configure.ac and using #ifdef HAVE_STRUCT_KVM_REGS here instead.
> + struct kvm_regs regs;
> +
> + if (code == KVM_GET_REGS && entering(tcp))
> + return 0;
> +
> + if (umove(tcp, arg, ®s) < 0)
> + return RVAL_DECODED;
Let's use umove_or_printaddr the same way and for the same reason as
in the previous patch.
> + PRINT_FIELD_X(", {", regs, rax);
As struct kvm_regs is inherently arch-specific, let's introduce an
arch-specific function, e.g.
static void
arch_print_kvm_regs(struct tcb *const tcp,
const kernel_ulong_t addr,
const struct kvm_regs *const regs);
linux/*/arch_kvm.c would provide arch-specific decoders,
linux/arch_kvm.c would provide a stub arch_print_kvm_regs that just prints
the address, and this file just includes "arch_kvm.c".
--
ldv
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
