1 #include "xc_sr_common_x86.h"
2 
write_tsc_info(struct xc_sr_context * ctx)3 int write_tsc_info(struct xc_sr_context *ctx)
4 {
5     xc_interface *xch = ctx->xch;
6     struct xc_sr_rec_tsc_info tsc = { 0 };
7     struct xc_sr_record rec =
8     {
9         .type = REC_TYPE_TSC_INFO,
10         .length = sizeof(tsc),
11         .data = &tsc
12     };
13 
14     if ( xc_domain_get_tsc_info(xch, ctx->domid, &tsc.mode,
15                                 &tsc.nsec, &tsc.khz, &tsc.incarnation) < 0 )
16     {
17         PERROR("Unable to obtain TSC information");
18         return -1;
19     }
20 
21     return write_record(ctx, &rec);
22 }
23 
handle_tsc_info(struct xc_sr_context * ctx,struct xc_sr_record * rec)24 int handle_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec)
25 {
26     xc_interface *xch = ctx->xch;
27     struct xc_sr_rec_tsc_info *tsc = rec->data;
28 
29     if ( rec->length != sizeof(*tsc) )
30     {
31         ERROR("TSC_INFO record wrong size: length %u, expected %zu",
32               rec->length, sizeof(*tsc));
33         return -1;
34     }
35 
36     if ( xc_domain_set_tsc_info(xch, ctx->domid, tsc->mode,
37                                 tsc->nsec, tsc->khz, tsc->incarnation) )
38     {
39         PERROR("Unable to set TSC information");
40         return -1;
41     }
42 
43     return 0;
44 }
45 
46 /*
47  * Local variables:
48  * mode: C
49  * c-file-style: "BSD"
50  * c-basic-offset: 4
51  * tab-width: 4
52  * indent-tabs-mode: nil
53  * End:
54  */
55