[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v11 3/9] tools: provide interface for generic MSR access
Xen added a new sysctl hypercall for generic MSR access, and this is the tool side change to wrapper the hypercall into xc APIs. Signed-off-by: Dongxiao Xu <dongxiao.xu@xxxxxxxxx> --- tools/libxc/Makefile | 1 + tools/libxc/xc_msr_x86.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ tools/libxc/xenctrl.h | 6 ++++++ 3 files changed, 60 insertions(+) create mode 100644 tools/libxc/xc_msr_x86.c diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index a74b19e..fec4aca 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -35,6 +35,7 @@ CTRL_SRCS-y += xc_kexec.c CTRL_SRCS-y += xtl_core.c CTRL_SRCS-y += xtl_logger_stdio.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c +CTRL_SRCS-$(CONFIG_X86) += xc_msr_x86.c CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c diff --git a/tools/libxc/xc_msr_x86.c b/tools/libxc/xc_msr_x86.c new file mode 100644 index 0000000..46e77dd --- /dev/null +++ b/tools/libxc/xc_msr_x86.c @@ -0,0 +1,53 @@ +/* + * xc_msr_x86.c + * + * Generic MSR access API + * + * Copyright (C) 2014 Intel Corporation + * Author Dongxiao Xu <dongxiao.xu@xxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "xc_private.h" + +int xc_msr_op(xc_interface *xch, uint32_t cpu, + uint32_t nr_ops, xc_msr_data_t *msr_data) +{ + int rc; + DECLARE_SYSCTL; + DECLARE_HYPERCALL_BOUNCE(msr_data, nr_ops * sizeof(*msr_data), + XC_HYPERCALL_BUFFER_BOUNCE_BOTH); + + if ( xc_hypercall_bounce_pre(xch, msr_data) ) + return -1; + + sysctl.cmd = XEN_SYSCTL_msr_op; + sysctl.u.msr_op.nr_ops = nr_ops; + sysctl.u.msr_op.cpu = cpu; + set_xen_guest_handle(sysctl.u.msr_op.msr_data, msr_data); + + rc = do_sysctl(xch, &sysctl); + + xc_hypercall_bounce_post(xch, msr_data); + + return rc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 02129f7..50625ca 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -2424,4 +2424,10 @@ int xc_kexec_load(xc_interface *xch, uint8_t type, uint16_t arch, */ int xc_kexec_unload(xc_interface *xch, int type); +#if defined(__i386__) || defined(__x86_64__) +typedef xen_sysctl_msr_data_t xc_msr_data_t; +int xc_msr_op(xc_interface *xch, uint32_t cpu, + uint32_t nr_ops, xc_msr_data_t *msr_data); +#endif + #endif /* XENCTRL_H */ -- 1.8.1.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |