Coverage Report

Created: 2017-10-25 09:10

/root/src/xen/xen/arch/x86/mm/mem_paging.c
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 * arch/x86/mm/mem_paging.c
3
 *
4
 * Memory paging support.
5
 *
6
 * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp)
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
23
#include <asm/p2m.h>
24
#include <xen/guest_access.h>
25
#include <xen/vm_event.h>
26
#include <xsm/xsm.h>
27
28
int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg)
29
0
{
30
0
    int rc;
31
0
    xen_mem_paging_op_t mpo;
32
0
    struct domain *d;
33
0
    bool_t copyback = 0;
34
0
35
0
    if ( copy_from_guest(&mpo, arg, 1) )
36
0
        return -EFAULT;
37
0
38
0
    rc = rcu_lock_live_remote_domain_by_id(mpo.domain, &d);
39
0
    if ( rc )
40
0
        return rc;
41
0
42
0
    rc = xsm_mem_paging(XSM_DM_PRIV, d);
43
0
    if ( rc )
44
0
        goto out;
45
0
46
0
    rc = -ENODEV;
47
0
    if ( unlikely(!vm_event_check_ring(d->vm_event_paging)) )
48
0
        goto out;
49
0
50
0
    switch( mpo.op )
51
0
    {
52
0
    case XENMEM_paging_op_nominate:
53
0
        rc = p2m_mem_paging_nominate(d, mpo.gfn);
54
0
        break;
55
0
56
0
    case XENMEM_paging_op_evict:
57
0
        rc = p2m_mem_paging_evict(d, mpo.gfn);
58
0
        break;
59
0
60
0
    case XENMEM_paging_op_prep:
61
0
        rc = p2m_mem_paging_prep(d, mpo.gfn, mpo.buffer);
62
0
        if ( !rc )
63
0
            copyback = 1;
64
0
        break;
65
0
66
0
    default:
67
0
        rc = -ENOSYS;
68
0
        break;
69
0
    }
70
0
71
0
    if ( copyback && __copy_to_guest(arg, &mpo, 1) )
72
0
        rc = -EFAULT;
73
0
74
0
out:
75
0
    rcu_unlock_domain(d);
76
0
    return rc;
77
0
}
78
79
80
/*
81
 * Local variables:
82
 * mode: C
83
 * c-file-style: "BSD"
84
 * c-basic-offset: 4
85
 * indent-tabs-mode: nil
86
 * End:
87
 */