Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/vmm_instruction_emul.c
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| #include <sys/errno.h> | #include <sys/errno.h> | ||||
| #include <sys/_iovec.h> | #include <sys/_iovec.h> | ||||
| #include <machine/vmm.h> | #include <machine/vmm.h> | ||||
| #include <err.h> | #include <err.h> | ||||
| #include <assert.h> | #include <assert.h> | ||||
| #include <stdbool.h> | #include <stdbool.h> | ||||
| #include <stddef.h> | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <string.h> | |||||
| #include <strings.h> | #include <strings.h> | ||||
| #include <vmmapi.h> | #include <vmmapi.h> | ||||
| #define KASSERT(exp,msg) assert((exp)) | #define KASSERT(exp,msg) assert((exp)) | ||||
| #define panic(...) errx(4, __VA_ARGS__) | #define panic(...) errx(4, __VA_ARGS__) | ||||
| #endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
| #include <machine/vmm_instruction_emul.h> | #include <machine/vmm_instruction_emul.h> | ||||
| #include <x86/psl.h> | #include <x86/psl.h> | ||||
| ▲ Show 20 Lines • Show All 1,920 Lines • ▼ Show 20 Lines | vie_calculate_gla(enum vm_cpu_mode cpu_mode, enum vm_reg_name seg, | ||||
| * Truncate 'firstoff' to the effective address size before adding | * Truncate 'firstoff' to the effective address size before adding | ||||
| * it to the segment base. | * it to the segment base. | ||||
| */ | */ | ||||
| firstoff &= vie_size2mask(addrsize); | firstoff &= vie_size2mask(addrsize); | ||||
| *gla = (segbase + firstoff) & vie_size2mask(glasize); | *gla = (segbase + firstoff) & vie_size2mask(glasize); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| /* | |||||
| * Prepare a partially decoded vie for a 2nd attempt. | |||||
| */ | |||||
| void | void | ||||
| vie_init(struct vie *vie, const char *inst_bytes, int inst_length) | vie_restart(struct vie *vie) | ||||
| { | { | ||||
| KASSERT(inst_length >= 0 && inst_length <= VIE_INST_SIZE, | _Static_assert( | ||||
| ("%s: invalid instruction length (%d)", __func__, inst_length)); | offsetof(struct vie, inst) < offsetof(struct vie, vie_startzero) && | ||||
| offsetof(struct vie, num_valid) < offsetof(struct vie, vie_startzero), | |||||
| "restart should not erase instruction length or contents"); | |||||
| bzero(vie, sizeof(struct vie)); | memset((char *)vie + offsetof(struct vie, vie_startzero), 0, | ||||
| sizeof(*vie) - offsetof(struct vie, vie_startzero)); | |||||
| vie->base_register = VM_REG_LAST; | vie->base_register = VM_REG_LAST; | ||||
| vie->index_register = VM_REG_LAST; | vie->index_register = VM_REG_LAST; | ||||
| vie->segment_register = VM_REG_LAST; | vie->segment_register = VM_REG_LAST; | ||||
| } | |||||
| if (inst_length) { | void | ||||
| bcopy(inst_bytes, vie->inst, inst_length); | 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)); | |||||
| vie_restart(vie); | |||||
| memset(vie->inst, 0, sizeof(vie->inst)); | |||||
| if (inst_length != 0) | |||||
| memcpy(vie->inst, inst_bytes, inst_length); | |||||
| vie->num_valid = inst_length; | vie->num_valid = inst_length; | ||||
| } | |||||
| } | } | ||||
| #ifdef _KERNEL | #ifdef _KERNEL | ||||
| static int | static int | ||||
| pf_error_code(int usermode, int prot, int rsvd, uint64_t pte) | pf_error_code(int usermode, int prot, int rsvd, uint64_t pte) | ||||
| { | { | ||||
| int error_code = 0; | int error_code = 0; | ||||
| ▲ Show 20 Lines • Show All 906 Lines • Show Last 20 Lines | |||||