Deleted Added
full compact
vmcb.c (271152) vmcb.c (271203)
1/*-
2 * Copyright (c) 2013 Anish Gupta (akgupt3@gmail.com)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2013 Anish Gupta (akgupt3@gmail.com)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: projects/bhyve_svm/sys/amd64/vmm/amd/vmcb.c 271152 2014-09-05 03:33:16Z neel $");
28__FBSDID("$FreeBSD: projects/bhyve_svm/sys/amd64/vmm/amd/vmcb.c 271203 2014-09-06 19:02:52Z neel $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/cpuset.h>
33
34#include <machine/segments.h>
35#include <machine/specialreg.h>
36#include <machine/vmm.h>

--- 9 unchanged lines hidden (view full) ---

46 * - instructions or events in the guest to intercept
47 * - control bits that modify execution environment of the guest
48 * - guest processor state (e.g. general purpose registers)
49 */
50
51/*
52 * Initialize SVM h/w context i.e. the VMCB control and saved state areas.
53 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/cpuset.h>
33
34#include <machine/segments.h>
35#include <machine/specialreg.h>
36#include <machine/vmm.h>

--- 9 unchanged lines hidden (view full) ---

46 * - instructions or events in the guest to intercept
47 * - control bits that modify execution environment of the guest
48 * - guest processor state (e.g. general purpose registers)
49 */
50
51/*
52 * Initialize SVM h/w context i.e. the VMCB control and saved state areas.
53 */
54int
54void
55svm_init_vmcb(struct vmcb *vmcb, uint64_t iopm_base_pa, uint64_t msrpm_base_pa,
55svm_init_vmcb(struct vmcb *vmcb, uint64_t iopm_base_pa, uint64_t msrpm_base_pa,
56 uint64_t np_pml4, uint32_t asid)
56 uint64_t np_pml4)
57{
58 struct vmcb_ctrl *ctrl;
59 struct vmcb_state *state;
60 uint16_t cr_shadow;
61
62 ctrl = &vmcb->ctrl;
63 state = &vmcb->state;
64

--- 28 unchanged lines hidden (view full) ---

93 VMCB_INTCPT_SHUTDOWN;
94
95 /*
96 * From section "Canonicalization and Consistency Checks" in APMv2
97 * the VMRUN intercept bit must be set to pass the consistency check.
98 */
99 ctrl->ctrl2 = VMCB_INTCPT_VMRUN;
100
57{
58 struct vmcb_ctrl *ctrl;
59 struct vmcb_state *state;
60 uint16_t cr_shadow;
61
62 ctrl = &vmcb->ctrl;
63 state = &vmcb->state;
64

--- 28 unchanged lines hidden (view full) ---

93 VMCB_INTCPT_SHUTDOWN;
94
95 /*
96 * From section "Canonicalization and Consistency Checks" in APMv2
97 * the VMRUN intercept bit must be set to pass the consistency check.
98 */
99 ctrl->ctrl2 = VMCB_INTCPT_VMRUN;
100
101 ctrl->asid = asid;
101 /*
102 * The ASID will be set to a non-zero value just before VMRUN.
103 */
104 ctrl->asid = 0;
102
103 /*
104 * Section 15.21.1, Interrupt Masking in EFLAGS
105 * Section 15.21.2, Virtualizing APIC.TPR
106 *
107 * This must be set for %rflag and %cr8 isolation of guest and host.
108 */
109 ctrl->v_intr_masking = 1;

--- 9 unchanged lines hidden (view full) ---

119 state->g_pat = PAT_VALUE(0, PAT_WRITE_BACK) |
120 PAT_VALUE(1, PAT_WRITE_THROUGH) |
121 PAT_VALUE(2, PAT_UNCACHED) |
122 PAT_VALUE(3, PAT_UNCACHEABLE) |
123 PAT_VALUE(4, PAT_WRITE_BACK) |
124 PAT_VALUE(5, PAT_WRITE_THROUGH) |
125 PAT_VALUE(6, PAT_UNCACHED) |
126 PAT_VALUE(7, PAT_UNCACHEABLE);
105
106 /*
107 * Section 15.21.1, Interrupt Masking in EFLAGS
108 * Section 15.21.2, Virtualizing APIC.TPR
109 *
110 * This must be set for %rflag and %cr8 isolation of guest and host.
111 */
112 ctrl->v_intr_masking = 1;

--- 9 unchanged lines hidden (view full) ---

122 state->g_pat = PAT_VALUE(0, PAT_WRITE_BACK) |
123 PAT_VALUE(1, PAT_WRITE_THROUGH) |
124 PAT_VALUE(2, PAT_UNCACHED) |
125 PAT_VALUE(3, PAT_UNCACHEABLE) |
126 PAT_VALUE(4, PAT_WRITE_BACK) |
127 PAT_VALUE(5, PAT_WRITE_THROUGH) |
128 PAT_VALUE(6, PAT_UNCACHED) |
129 PAT_VALUE(7, PAT_UNCACHEABLE);
127
128 return (0);
129}
130
131/*
132 * Read from segment selector, control and general purpose register of VMCB.
133 */
134int
135vmcb_read(struct vmcb *vmcb, int ident, uint64_t *retval)
136{

--- 250 unchanged lines hidden ---
130}
131
132/*
133 * Read from segment selector, control and general purpose register of VMCB.
134 */
135int
136vmcb_read(struct vmcb *vmcb, int ident, uint64_t *retval)
137{

--- 250 unchanged lines hidden ---