1 /******************************************************************************
2  * include/asm-x86/mem_access.h
3  *
4  * Memory access support.
5  *
6  * Copyright (c) 2011 GridCentric Inc. (Andres Lagar-Cavilla)
7  * Copyright (c) 2007 Advanced Micro Devices (Wei Huang)
8  * Parts of this code are Copyright (c) 2006-2007 by XenSource Inc.
9  * Parts of this code are Copyright (c) 2006 by Michael A Fetterman
10  * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef __ASM_X86_MEM_ACCESS_H__
27 #define __ASM_X86_MEM_ACCESS_H__
28 
29 /*
30  * Setup vm_event request based on the access (gla is -1ull if not available).
31  * Handles the rw2rx conversion. Boolean return value indicates if event type
32  * is syncronous (aka. requires vCPU pause). If the req_ptr has been populated,
33  * then the caller should use monitor_traps to send the event on the MONITOR
34  * ring. Once having released get_gfn* locks caller must also xfree the
35  * request.
36  */
37 bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
38                           struct npfec npfec,
39                           struct vm_event_st **req_ptr);
40 
41 /* Check for emulation and mark vcpu for skipping one instruction
42  * upon rescheduling if required. */
43 bool p2m_mem_access_emulate_check(struct vcpu *v,
44                                   const struct vm_event_st *rsp);
45 
46 /* Sanity check for mem_access hardware support */
47 bool p2m_mem_access_sanity_check(const struct domain *d);
48 
49 int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve,
50                         unsigned int altp2m_idx);
51 
52 struct xen_hvm_altp2m_suppress_ve_multi;
53 int p2m_set_suppress_ve_multi(struct domain *d,
54                               struct xen_hvm_altp2m_suppress_ve_multi *suppress_ve);
55 
56 int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve,
57                         unsigned int altp2m_idx);
58 
59 #endif /*__ASM_X86_MEM_ACCESS_H__ */
60 
61 /*
62  * Local variables:
63  * mode: C
64  * c-file-style: "BSD"
65  * c-basic-offset: 4
66  * indent-tabs-mode: nil
67  * End:
68  */
69