1 /* 2 * Alternate p2m HVM 3 * Copyright (c) 2014, Intel Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * You should have received a copy of the GNU General Public License along with 15 * this program; If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __ASM_X86_ALTP2M_H 19 #define __ASM_X86_ALTP2M_H 20 21 #ifdef CONFIG_HVM 22 23 #include <xen/types.h> 24 #include <xen/sched.h> /* for struct vcpu, struct domain */ 25 #include <asm/hvm/vcpu.h> /* for vcpu_altp2m */ 26 27 /* Alternate p2m HVM on/off per domain */ altp2m_active(const struct domain * d)28static inline bool altp2m_active(const struct domain *d) 29 { 30 return d->arch.altp2m_active; 31 } 32 33 /* Alternate p2m VCPU */ 34 void altp2m_vcpu_initialise(struct vcpu *v); 35 void altp2m_vcpu_destroy(struct vcpu *v); 36 37 int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn); 38 void altp2m_vcpu_disable_ve(struct vcpu *v); 39 altp2m_vcpu_idx(const struct vcpu * v)40static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) 41 { 42 return vcpu_altp2m(v).p2midx; 43 } 44 #else 45 altp2m_active(const struct domain * d)46static inline bool altp2m_active(const struct domain *d) 47 { 48 return false; 49 } 50 51 /* Only declaration is needed. DCE will optimise it out when linking. */ 52 uint16_t altp2m_vcpu_idx(const struct vcpu *v); 53 void altp2m_vcpu_disable_ve(struct vcpu *v); 54 55 #endif 56 57 #endif /* __ASM_X86_ALTP2M_H */ 58