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)
This commit is contained in:
Neel Natu 2013-03-28 21:26:19 +00:00
parent bea2eefca4
commit 66f71b7d24
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=248855
2 changed files with 16 additions and 5 deletions

View File

@ -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 */

View File

@ -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 */