aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/vmm/vmm_instruction_emul.c
diff options
context:
space:
mode:
authorNeel Natu <neel@FreeBSD.org>2014-09-13 22:16:40 +0000
committerNeel Natu <neel@FreeBSD.org>2014-09-13 22:16:40 +0000
commitc2a875f97078392b2f0364d4f284dfdfc2389377 (patch)
tree70a00007f69968f48c3915bfacf511d0235b5081 /sys/amd64/vmm/vmm_instruction_emul.c
parent442a04ca833b3ace4813c496e5f458f5c4795e71 (diff)
downloadsrc-c2a875f97078392b2f0364d4f284dfdfc2389377.tar.gz
src-c2a875f97078392b2f0364d4f284dfdfc2389377.zip
AMD processors that have the SVM decode assist capability will store the
instruction bytes in the VMCB on a nested page fault. This is useful because it saves having to walk the guest page tables to fetch the instruction. vie_init() now takes two additional parameters 'inst_bytes' and 'inst_len' that map directly to 'vie->inst[]' and 'vie->num_valid'. The instruction emulation handler skips calling 'vmm_fetch_instruction()' if 'vie->num_valid' is non-zero. The use of this capability can be turned off by setting the sysctl/tunable 'hw.vmm.svm.disable_npf_assist' to '1'. Reviewed by: Anish Gupta (akgupt3@gmail.com) Discussed with: grehan
Notes
Notes: svn path=/projects/bhyve_svm/; revision=271554
Diffstat (limited to 'sys/amd64/vmm/vmm_instruction_emul.c')
-rw-r--r--sys/amd64/vmm/vmm_instruction_emul.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c
index 185b198f658d..60e7a572ae7d 100644
--- a/sys/amd64/vmm/vmm_instruction_emul.c
+++ b/sys/amd64/vmm/vmm_instruction_emul.c
@@ -1025,13 +1025,20 @@ vie_calculate_gla(enum vm_cpu_mode cpu_mode, enum vm_reg_name seg,
#ifdef _KERNEL
void
-vie_init(struct vie *vie)
+vie_init(struct vie *vie, const char *inst_bytes, int inst_length)
{
+ KASSERT(inst_length >= 0 && inst_length <= VIE_INST_SIZE,
+ ("%s: invalid instruction length (%d)", __func__, inst_length));
bzero(vie, sizeof(struct vie));
vie->base_register = VM_REG_LAST;
vie->index_register = VM_REG_LAST;
+
+ if (inst_length) {
+ bcopy(inst_bytes, vie->inst, inst_length);
+ vie->num_valid = inst_length;
+ }
}
static int