svn commit: r248855 - in head/sys/amd64: include vmm

Neel Natu neel at FreeBSD.org
Thu Mar 28 21:26:20 UTC 2013


Author: neel
Date: Thu Mar 28 21:26:19 2013
New Revision: 248855
URL: http://svnweb.freebsd.org/changeset/base/248855

Log:
  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)

Modified:
  head/sys/amd64/include/vmm_instruction_emul.h
  head/sys/amd64/vmm/vmm_instruction_emul.c

Modified: head/sys/amd64/include/vmm_instruction_emul.h
==============================================================================
--- head/sys/amd64/include/vmm_instruction_emul.h	Thu Mar 28 21:02:49 2013	(r248854)
+++ head/sys/amd64/include/vmm_instruction_emul.h	Thu Mar 28 21:26:19 2013	(r248855)
@@ -107,6 +107,18 @@ int vmm_fetch_instruction(struct vm *vm,
 			  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 */

Modified: head/sys/amd64/vmm/vmm_instruction_emul.c
==============================================================================
--- head/sys/amd64/vmm/vmm_instruction_emul.c	Thu Mar 28 21:02:49 2013	(r248854)
+++ head/sys/amd64/vmm/vmm_instruction_emul.c	Thu Mar 28 21:26:19 2013	(r248855)
@@ -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, uin
 
 	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, in
 	if (decode_immediate(vie))
 		return (-1);
 
-#ifdef VERIFY_GLA
 	if (verify_gla(vm, cpuid, gla, vie))
 		return (-1);
-#endif
 
 	vie->decoded = 1;	/* success */
 


More information about the svn-src-all mailing list