/root/src/xen/xen/arch/x86/x86_64/cpufreq.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * cpufreq.c -- adapt 32b compat guest to 64b hypervisor. |
3 | | * |
4 | | * Copyright (C) 2008, Liu Jinsong <jinsong.liu@intel.com> |
5 | | * |
6 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
7 | | * |
8 | | * This program is free software; you can redistribute it and/or modify |
9 | | * it under the terms of the GNU General Public License as published by |
10 | | * the Free Software Foundation; either version 2 of the License, or (at |
11 | | * your option) any later version. |
12 | | * |
13 | | * This program is distributed in the hope that it will be useful, but |
14 | | * WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU General Public License along |
19 | | * with this program; If not, see <http://www.gnu.org/licenses/>. |
20 | | * |
21 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
22 | | */ |
23 | | #include <xen/types.h> |
24 | | #include <xen/xmalloc.h> |
25 | | #include <xen/guest_access.h> |
26 | | #include <xen/pmstat.h> |
27 | | #include <compat/platform.h> |
28 | | |
29 | | DEFINE_XEN_GUEST_HANDLE(compat_processor_px_t); |
30 | | |
31 | | int |
32 | | compat_set_px_pminfo(uint32_t cpu, struct compat_processor_performance *perf) |
33 | 0 | { |
34 | 0 | struct xen_processor_performance *xen_perf; |
35 | 0 | unsigned long xlat_page_current; |
36 | 0 |
|
37 | 0 | xlat_malloc_init(xlat_page_current); |
38 | 0 |
|
39 | 0 | xen_perf = xlat_malloc_array(xlat_page_current, |
40 | 0 | struct xen_processor_performance, 1); |
41 | 0 | if ( unlikely(xen_perf == NULL) ) |
42 | 0 | return -EFAULT; |
43 | 0 |
|
44 | 0 | #define XLAT_processor_performance_HNDL_states(_d_, _s_) do { \ |
45 | 0 | XEN_GUEST_HANDLE(compat_processor_px_t) states; \ |
46 | 0 | XEN_GUEST_HANDLE_PARAM(xen_processor_px_t) states_t; \ |
47 | 0 | if ( unlikely(!compat_handle_okay((_s_)->states, (_s_)->state_count)) ) \ |
48 | 0 | return -EFAULT; \ |
49 | 0 | guest_from_compat_handle(states, (_s_)->states); \ |
50 | 0 | states_t = guest_handle_cast(states, xen_processor_px_t); \ |
51 | 0 | (_d_)->states = guest_handle_from_param(states_t, xen_processor_px_t); \ |
52 | 0 | } while (0) |
53 | 0 |
|
54 | 0 | XLAT_processor_performance(xen_perf, perf); |
55 | 0 | #undef XLAT_processor_performance_HNDL_states |
56 | 0 |
|
57 | 0 | return set_px_pminfo(cpu, xen_perf); |
58 | 0 | } |