* [PATCH 0 of 2] New HVMOPs for PV-on-HVM drivers @ 2010-07-09 13:30 Tim Deegan 2010-07-09 13:30 ` [PATCH 1 of 2] Add a new HVMOP which allows an HVM guest to get the current Tim Deegan 2010-07-09 13:30 ` [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records Tim Deegan 0 siblings, 2 replies; 6+ messages in thread From: Tim Deegan @ 2010-07-09 13:30 UTC (permalink / raw) To: xen-devel These patches add two HVM operations that can be used by the XCP PV drivers. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1 of 2] Add a new HVMOP which allows an HVM guest to get the current 2010-07-09 13:30 [PATCH 0 of 2] New HVMOPs for PV-on-HVM drivers Tim Deegan @ 2010-07-09 13:30 ` Tim Deegan 2010-07-09 13:30 ` [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records Tim Deegan 1 sibling, 0 replies; 6+ messages in thread From: Tim Deegan @ 2010-07-09 13:30 UTC (permalink / raw) To: xen-devel [-- Attachment #1: Type: text/plain, Size: 243 bytes --] Xen absolute system time, so that it can use SCHEDOP_poll in a sensible fashion. HVM PV drivers can't use the normal PV clock because they might have TSC offsets that hey don't know about. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> [-- Attachment #2: xen-unstable.hg-2.patch --] [-- Type: text/x-patch, Size: 1710 bytes --] # HG changeset patch # User Tim Deegan <Tim.Deegan@citrix.com> # Date 1278682007 -3600 # Node ID dc3138d60b40baf38016a9b58f438598580a407f # Parent a672af698bc387ea92070fc3ef337e8c2fbb716e Add a new HVMOP which allows an HVM guest to get the current Xen absolute system time, so that it can use SCHEDOP_poll in a sensible fashion. HVM PV drivers can't use the normal PV clock because they might have TSC offsets that hey don't know about. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> diff -r a672af698bc3 -r dc3138d60b40 xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Fri Jul 09 12:35:58 2010 +0100 +++ b/xen/arch/x86/hvm/hvm.c Fri Jul 09 14:26:47 2010 +0100 @@ -3188,6 +3188,15 @@ break; } + case HVMOP_get_time: { + xen_hvm_get_time_t gxt; + + gxt.now = NOW(); + if ( copy_to_guest(arg, &gxt, 1) ) + rc = -EFAULT; + break; + } + default: { gdprintk(XENLOG_WARNING, "Bad HVM op %ld.\n", op); diff -r a672af698bc3 -r dc3138d60b40 xen/include/public/hvm/hvm_op.h --- a/xen/include/public/hvm/hvm_op.h Fri Jul 09 12:35:58 2010 +0100 +++ b/xen/include/public/hvm/hvm_op.h Fri Jul 09 14:26:47 2010 +0100 @@ -138,6 +138,14 @@ typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t; DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t); +/* Get the current Xen time, in nanoseconds since system boot. */ +#define HVMOP_get_time 10 +struct xen_hvm_get_time { + uint64_t now; /* OUT */ +}; +typedef struct xen_hvm_get_time xen_hvm_get_time_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t); + #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ [-- Attachment #3: Type: text/plain, Size: 138 bytes --] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records 2010-07-09 13:30 [PATCH 0 of 2] New HVMOPs for PV-on-HVM drivers Tim Deegan 2010-07-09 13:30 ` [PATCH 1 of 2] Add a new HVMOP which allows an HVM guest to get the current Tim Deegan @ 2010-07-09 13:30 ` Tim Deegan 2010-07-09 14:44 ` Jan Beulich 1 sibling, 1 reply; 6+ messages in thread From: Tim Deegan @ 2010-07-09 13:30 UTC (permalink / raw) To: xen-devel [-- Attachment #1: Type: text/plain, Size: 52 bytes --] Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> [-- Attachment #2: xen-unstable.hg-2.patch --] [-- Type: text/x-patch, Size: 2326 bytes --] # HG changeset patch # User Tim Deegan <Tim.Deegan@citrix.com> # Date 1278682148 -3600 # Node ID ed89d064acc184b0c10a60ffb4c67c493dfb3c8b # Parent dc3138d60b40baf38016a9b58f438598580a407f Add a hypercall to allow HVM PV drivers to insert xentrace records. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> diff -r dc3138d60b40 -r ed89d064acc1 xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Fri Jul 09 14:26:47 2010 +0100 +++ b/xen/arch/x86/hvm/hvm.c Fri Jul 09 14:29:08 2010 +0100 @@ -3197,6 +3197,22 @@ break; } + case HVMOP_xentrace: { + xen_hvm_xentrace_t tr; + + if ( copy_from_guest(&tr, arg, 1 ) ) + return -EFAULT; + + if ( tr.extra_bytes > 28 || tr.event >= 0x1000 ) + return -EINVAL; + + /* Cycles will be taken at the vmexit and vmenter */ + trace_var(tr.event | TRC_GUEST, 0 /*!cycles*/, + tr.extra_bytes, + (unsigned char *)tr.extra); + break; + } + default: { gdprintk(XENLOG_WARNING, "Bad HVM op %ld.\n", op); diff -r dc3138d60b40 -r ed89d064acc1 xen/include/public/hvm/hvm_op.h --- a/xen/include/public/hvm/hvm_op.h Fri Jul 09 14:26:47 2010 +0100 +++ b/xen/include/public/hvm/hvm_op.h Fri Jul 09 14:29:08 2010 +0100 @@ -146,6 +146,14 @@ typedef struct xen_hvm_get_time xen_hvm_get_time_t; DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t); +#define HVMOP_xentrace 11 +struct xen_hvm_xentrace { + uint16_t event, extra_bytes; + uint8_t extra[28]; +}; +typedef struct xen_hvm_xentrace xen_hvm_xentrace_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t); + #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ diff -r dc3138d60b40 -r ed89d064acc1 xen/include/public/trace.h --- a/xen/include/public/trace.h Fri Jul 09 14:26:47 2010 +0100 +++ b/xen/include/public/trace.h Fri Jul 09 14:29:08 2010 +0100 @@ -39,6 +39,7 @@ #define TRC_PV 0x0020f000 /* Xen PV traces */ #define TRC_SHADOW 0x0040f000 /* Xen shadow tracing */ #define TRC_PM 0x0080f000 /* Xen power management trace */ +#define TRC_GUEST 0x0800f000 /* Guest-generated traces */ #define TRC_ALL 0x0ffff000 #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff) #define TRC_HD_CYCLE_FLAG (1UL<<31) [-- Attachment #3: Type: text/plain, Size: 138 bytes --] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records 2010-07-09 13:30 ` [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records Tim Deegan @ 2010-07-09 14:44 ` Jan Beulich 2010-07-09 15:07 ` Tim Deegan 0 siblings, 1 reply; 6+ messages in thread From: Jan Beulich @ 2010-07-09 14:44 UTC (permalink / raw) To: Tim Deegan, xen-devel >>> On 09.07.10 at 15:30, Tim Deegan <Tim.Deegan@citrix.com> wrote: >+ if ( tr.extra_bytes > 28 || tr.event >= 0x1000 ) Couldn't you use TRACE_EXTRA_MAX * sizeof(u32) instead of the literal 28? The literal 0x1000 also doesn't look nice - I'm no sure though whether this really is (1 << TRC_SUBCLS_SHIFT). Jan ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records 2010-07-09 14:44 ` Jan Beulich @ 2010-07-09 15:07 ` Tim Deegan 2010-07-09 16:02 ` Jan Beulich 0 siblings, 1 reply; 6+ messages in thread From: Tim Deegan @ 2010-07-09 15:07 UTC (permalink / raw) To: Jan Beulich; +Cc: xen-devel@lists.xensource.com [-- Attachment #1: Type: text/plain, Size: 692 bytes --] At 15:44 +0100 on 09 Jul (1278690260), Jan Beulich wrote: > >>> On 09.07.10 at 15:30, Tim Deegan <Tim.Deegan@citrix.com> wrote: > >+ if ( tr.extra_bytes > 28 || tr.event >= 0x1000 ) > > Couldn't you use TRACE_EXTRA_MAX * sizeof(u32) instead of the > literal 28? Indeed I should. > The literal 0x1000 also doesn't look nice - I'm no sure though > whether this really is (1 << TRC_SUBCLS_SHIFT). Yes it is (the guest's not allowed to define the class or subclass of the trace entry). How about the attached patch instead? Cheers, Tim. -- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) [-- Attachment #2: hvm-op-trace --] [-- Type: text/plain, Size: 2270 bytes --] diff -r dc3138d60b40 xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Fri Jul 09 14:26:47 2010 +0100 +++ b/xen/arch/x86/hvm/hvm.c Fri Jul 09 16:05:35 2010 +0100 @@ -3197,6 +3197,23 @@ break; } + case HVMOP_xentrace: { + xen_hvm_xentrace_t tr; + + if ( copy_from_guest(&tr, arg, 1 ) ) + return -EFAULT; + + if ( tr.extra_bytes > sizeof(tr.extra) + || (tr.event & ~((1u<<TRC_SUBCLS_SHIFT)-1)) ) + return -EINVAL; + + /* Cycles will be taken at the vmexit and vmenter */ + trace_var(tr.event | TRC_GUEST, 0 /*!cycles*/, + tr.extra_bytes, + (unsigned char *)tr.extra); + break; + } + default: { gdprintk(XENLOG_WARNING, "Bad HVM op %ld.\n", op); diff -r dc3138d60b40 xen/include/public/hvm/hvm_op.h --- a/xen/include/public/hvm/hvm_op.h Fri Jul 09 14:26:47 2010 +0100 +++ b/xen/include/public/hvm/hvm_op.h Fri Jul 09 16:05:35 2010 +0100 @@ -22,6 +22,7 @@ #define __XEN_PUBLIC_HVM_HVM_OP_H__ #include "../xen.h" +#include "../trace.h" /* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */ #define HVMOP_set_param 0 @@ -146,6 +147,14 @@ typedef struct xen_hvm_get_time xen_hvm_get_time_t; DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t); +#define HVMOP_xentrace 11 +struct xen_hvm_xentrace { + uint16_t event, extra_bytes; + uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)]; +}; +typedef struct xen_hvm_xentrace xen_hvm_xentrace_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t); + #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ diff -r dc3138d60b40 xen/include/public/trace.h --- a/xen/include/public/trace.h Fri Jul 09 14:26:47 2010 +0100 +++ b/xen/include/public/trace.h Fri Jul 09 16:05:35 2010 +0100 @@ -39,6 +39,7 @@ #define TRC_PV 0x0020f000 /* Xen PV traces */ #define TRC_SHADOW 0x0040f000 /* Xen shadow tracing */ #define TRC_PM 0x0080f000 /* Xen power management trace */ +#define TRC_GUEST 0x0800f000 /* Guest-generated traces */ #define TRC_ALL 0x0ffff000 #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff) #define TRC_HD_CYCLE_FLAG (1UL<<31) [-- Attachment #3: Type: text/plain, Size: 138 bytes --] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records 2010-07-09 15:07 ` Tim Deegan @ 2010-07-09 16:02 ` Jan Beulich 0 siblings, 0 replies; 6+ messages in thread From: Jan Beulich @ 2010-07-09 16:02 UTC (permalink / raw) To: Tim Deegan; +Cc: xen-devel@lists.xensource.com >>> On 09.07.10 at 17:07, Tim Deegan <Tim.Deegan@citrix.com> wrote: > At 15:44 +0100 on 09 Jul (1278690260), Jan Beulich wrote: >> >>> On 09.07.10 at 15:30, Tim Deegan <Tim.Deegan@citrix.com> wrote: >> >+ if ( tr.extra_bytes > 28 || tr.event >= 0x1000 ) >> >> Couldn't you use TRACE_EXTRA_MAX * sizeof(u32) instead of the >> literal 28? > > Indeed I should. > >> The literal 0x1000 also doesn't look nice - I'm no sure though >> whether this really is (1 << TRC_SUBCLS_SHIFT). > > Yes it is (the guest's not allowed to define the class or subclass of > the trace entry). How about the attached patch instead? Great, thanks! Jan ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-09 16:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-07-09 13:30 [PATCH 0 of 2] New HVMOPs for PV-on-HVM drivers Tim Deegan 2010-07-09 13:30 ` [PATCH 1 of 2] Add a new HVMOP which allows an HVM guest to get the current Tim Deegan 2010-07-09 13:30 ` [PATCH 2 of 2] Add a hypercall to allow HVM PV drivers to insert xentrace records Tim Deegan 2010-07-09 14:44 ` Jan Beulich 2010-07-09 15:07 ` Tim Deegan 2010-07-09 16:02 ` Jan Beulich
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).