summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-03-28 21:26:19 +0000
committerneel <neel@FreeBSD.org>2013-03-28 21:26:19 +0000
commit29b9bf0372f0e21c26723e7ad338ef3395022924 (patch)
treeafb2ba58313bcb030230a5dedb3fdf50556bd25a /sys/amd64
parent82d58114889a20fcd15b9f51da2e60600642ed77 (diff)
downloadFreeBSD-src-29b9bf0372f0e21c26723e7ad338ef3395022924.zip
FreeBSD-src-29b9bf0372f0e21c26723e7ad338ef3395022924.tar.gz
Allow caller to skip 'guest linear address' validation when doing instruction
decode. This is to accomodate hardware assist implementations that do not provide the 'guest linear address' as part of nested page fault collateral. Submitted by: Anish Gupta (akgupt3 at gmail dot com)
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/include/vmm_instruction_emul.h12
-rw-r--r--sys/amd64/vmm/vmm_instruction_emul.c9
2 files changed, 16 insertions, 5 deletions
diff --git a/sys/amd64/include/vmm_instruction_emul.h b/sys/amd64/include/vmm_instruction_emul.h
index 4c7a346..a812a73 100644
--- a/sys/amd64/include/vmm_instruction_emul.h
+++ b/sys/amd64/include/vmm_instruction_emul.h
@@ -107,6 +107,18 @@ int vmm_fetch_instruction(struct vm *vm, int cpuid,
uint64_t rip, int inst_length, uint64_t cr3,
struct vie *vie);
+/*
+ * Decode the instruction fetched into 'vie' so it can be emulated.
+ *
+ * 'gla' is the guest linear address provided by the hardware assist
+ * that caused the nested page table fault. It is used to verify that
+ * the software instruction decoding is in agreement with the hardware.
+ *
+ * Some hardware assists do not provide the 'gla' to the hypervisor.
+ * To skip the 'gla' verification for this or any other reason pass
+ * in VIE_INVALID_GLA instead.
+ */
+#define VIE_INVALID_GLA (1UL << 63) /* a non-canonical address */
int vmm_decode_instruction(struct vm *vm, int cpuid,
uint64_t gla, struct vie *vie);
#endif /* _KERNEL */
diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c
index 40748ea..7b480bd 100644
--- a/sys/amd64/vmm/vmm_instruction_emul.c
+++ b/sys/amd64/vmm/vmm_instruction_emul.c
@@ -790,18 +790,20 @@ decode_immediate(struct vie *vie)
return (0);
}
-#define VERIFY_GLA
/*
* Verify that the 'guest linear address' provided as collateral of the nested
* page table fault matches with our instruction decoding.
*/
-#ifdef VERIFY_GLA
static int
verify_gla(struct vm *vm, int cpuid, uint64_t gla, struct vie *vie)
{
int error;
uint64_t base, idx;
+ /* Skip 'gla' verification */
+ if (gla == VIE_INVALID_GLA)
+ return (0);
+
base = 0;
if (vie->base_register != VM_REG_LAST) {
error = vm_get_register(vm, cpuid, vie->base_register, &base);
@@ -832,7 +834,6 @@ verify_gla(struct vm *vm, int cpuid, uint64_t gla, struct vie *vie)
return (0);
}
-#endif /* VERIFY_GLA */
int
vmm_decode_instruction(struct vm *vm, int cpuid, uint64_t gla, struct vie *vie)
@@ -856,10 +857,8 @@ vmm_decode_instruction(struct vm *vm, int cpuid, uint64_t gla, struct vie *vie)
if (decode_immediate(vie))
return (-1);
-#ifdef VERIFY_GLA
if (verify_gla(vm, cpuid, gla, vie))
return (-1);
-#endif
vie->decoded = 1; /* success */
OpenPOWER on IntegriCloud