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 #include <asm/hvm/support.h> 19 #include <asm/hvm/hvm.h> 20 #include <asm/p2m.h> 21 #include <asm/altp2m.h> 22 23 void altp2m_vcpu_reset(struct vcpu * v)24altp2m_vcpu_reset(struct vcpu *v) 25 { 26 struct altp2mvcpu *av = &vcpu_altp2m(v); 27 28 av->p2midx = INVALID_ALTP2M; 29 av->veinfo_gfn = INVALID_GFN; 30 } 31 32 void altp2m_vcpu_initialise(struct vcpu * v)33altp2m_vcpu_initialise(struct vcpu *v) 34 { 35 if ( v != current ) 36 vcpu_pause(v); 37 38 altp2m_vcpu_reset(v); 39 vcpu_altp2m(v).p2midx = 0; 40 atomic_inc(&p2m_get_altp2m(v)->active_vcpus); 41 42 altp2m_vcpu_update_p2m(v); 43 44 if ( v != current ) 45 vcpu_unpause(v); 46 } 47 48 void altp2m_vcpu_destroy(struct vcpu * v)49altp2m_vcpu_destroy(struct vcpu *v) 50 { 51 struct p2m_domain *p2m; 52 53 if ( v != current ) 54 vcpu_pause(v); 55 56 if ( (p2m = p2m_get_altp2m(v)) ) 57 atomic_dec(&p2m->active_vcpus); 58 59 altp2m_vcpu_reset(v); 60 61 altp2m_vcpu_update_p2m(v); 62 altp2m_vcpu_update_vmfunc_ve(v); 63 64 if ( v != current ) 65 vcpu_unpause(v); 66 } 67 68 /* 69 * Local variables: 70 * mode: C 71 * c-file-style: "BSD" 72 * c-basic-offset: 4 73 * tab-width: 4 74 * indent-tabs-mode: nil 75 * End: 76 */ 77