Coverage Report

Created: 2017-10-25 09:10

/root/src/xen/xen/include/asm/shadow.h
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 * include/asm-x86/shadow.h
3
 * 
4
 * Parts of this code are Copyright (c) 2006 by XenSource Inc.
5
 * Parts of this code are Copyright (c) 2006 by Michael A Fetterman
6
 * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
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
11
 * (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * 
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#ifndef _XEN_SHADOW_H
23
#define _XEN_SHADOW_H
24
25
#include <public/domctl.h>
26
#include <xen/sched.h>
27
#include <xen/perfc.h>
28
#include <xen/domain_page.h>
29
#include <asm/flushtlb.h>
30
#include <asm/paging.h>
31
#include <asm/p2m.h>
32
33
/*****************************************************************************
34
 * Macros to tell which shadow paging mode a domain is in*/
35
36
15
#define shadow_mode_enabled(_d)    paging_mode_shadow(_d)
37
0
#define shadow_mode_refcounts(_d) (paging_mode_shadow(_d) && \
38
0
                                   paging_mode_refcounts(_d))
39
#define shadow_mode_log_dirty(_d) (paging_mode_shadow(_d) && \
40
                                   paging_mode_log_dirty(_d))
41
0
#define shadow_mode_translate(_d) (paging_mode_shadow(_d) && \
42
0
                                   paging_mode_translate(_d))
43
0
#define shadow_mode_external(_d)  (paging_mode_shadow(_d) && \
44
0
                                   paging_mode_external(_d))
45
46
/*****************************************************************************
47
 * Entry points into the shadow code */
48
49
/* Set up the shadow-specific parts of a domain struct at start of day.
50
 * Called from paging_domain_init(). */
51
int shadow_domain_init(struct domain *d, unsigned int domcr_flags);
52
53
/* Setup the shadow-specific parts of a vcpu struct. It is called by
54
 * paging_vcpu_init() in paging.c */
55
void shadow_vcpu_init(struct vcpu *v);
56
57
#ifdef CONFIG_SHADOW_PAGING
58
59
/* Enable an arbitrary shadow mode.  Call once at domain creation. */
60
int shadow_enable(struct domain *d, u32 mode);
61
62
/* Enable VRAM dirty bit tracking. */
63
int shadow_track_dirty_vram(struct domain *d,
64
                            unsigned long first_pfn,
65
                            unsigned long nr,
66
                            XEN_GUEST_HANDLE_PARAM(void) dirty_bitmap);
67
68
/* Handler for shadow control ops: operations from user-space to enable
69
 * and disable ephemeral shadow modes (test mode and log-dirty mode) and
70
 * manipulate the log-dirty bitmap. */
71
int shadow_domctl(struct domain *d, 
72
                  struct xen_domctl_shadow_op *sc,
73
                  XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl);
74
75
/* Call when destroying a domain */
76
void shadow_teardown(struct domain *d, bool *preempted);
77
78
/* Call once all of the references to the domain have gone away */
79
void shadow_final_teardown(struct domain *d);
80
81
void sh_remove_shadows(struct domain *d, mfn_t gmfn, int fast, int all);
82
83
/* Discard _all_ mappings from the domain's shadows. */
84
void shadow_blow_tables_per_domain(struct domain *d);
85
86
/* Set the pool of shadow pages to the required number of pages.
87
 * Input will be rounded up to at least shadow_min_acceptable_pages(),
88
 * plus space for the p2m table.
89
 * Returns 0 for success, non-zero for failure. */
90
int shadow_set_allocation(struct domain *d, unsigned int pages,
91
                          bool *preempted);
92
93
#else /* !CONFIG_SHADOW_PAGING */
94
95
#define shadow_teardown(d, p) ASSERT(is_pv_domain(d))
96
#define shadow_final_teardown(d) ASSERT(is_pv_domain(d))
97
#define shadow_enable(d, mode) \
98
    ({ ASSERT(is_pv_domain(d)); -EOPNOTSUPP; })
99
#define shadow_track_dirty_vram(d, begin_pfn, nr, bitmap) \
100
    ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; })
101
#define shadow_set_allocation(d, pages, preempted) \
102
    ({ ASSERT_UNREACHABLE(); -EOPNOTSUPP; })
103
104
static inline void sh_remove_shadows(struct domain *d, mfn_t gmfn,
105
                                     int fast, int all) {}
106
107
static inline void shadow_blow_tables_per_domain(struct domain *d) {}
108
109
static inline int shadow_domctl(struct domain *d,
110
                                struct xen_domctl_shadow_op *sc,
111
                                XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
112
{
113
    return -EINVAL;
114
}
115
116
#endif /* CONFIG_SHADOW_PAGING */
117
118
/* Remove all shadows of the guest mfn. */
119
static inline void shadow_remove_all_shadows(struct domain *d, mfn_t gmfn)
120
0
{
121
0
    /* See the comment about locking in sh_remove_shadows */
122
0
    sh_remove_shadows(d, gmfn, 0 /* Be thorough */, 1 /* Must succeed */);
123
0
}
Unexecuted instantiation: mm.c:shadow_remove_all_shadows
Unexecuted instantiation: dm.c:shadow_remove_all_shadows
Unexecuted instantiation: hvm.c:shadow_remove_all_shadows
Unexecuted instantiation: io.c:shadow_remove_all_shadows
Unexecuted instantiation: vmcs.c:shadow_remove_all_shadows
Unexecuted instantiation: paging.c:shadow_remove_all_shadows
Unexecuted instantiation: common.c:shadow_remove_all_shadows
Unexecuted instantiation: multi.c:shadow_remove_all_shadows
124
125
#endif /* _XEN_SHADOW_H */
126
127
/*
128
 * Local variables:
129
 * mode: C
130
 * c-file-style: "BSD"
131
 * c-basic-offset: 4
132
 * indent-tabs-mode: nil
133
 * End:
134
 */