i386: hvf: miscellaneous cleanups
cover i386: hvf: miscellaneous cleanups
This is an initial set of (untested!) cleanups for the HVF code. If anyone could pick them up, I think they represent the bare minimum that has to be done before we can commit HVF support to master. It's by no means the end, but the existing MMU code in target/i386 could definitely stand a rewrite, and HVF could then use it as well.
They are available at git://github.com/bonzini/qemu.git, branch hvf.
Alex (both of them), Sergio, anyone else who can help?
Paolo
Paolo Bonzini (10):
i386: hvf: move all hvf files in the same directory
i386: hvf: header cleanup
i386: hvf: unify register enums between HVF and the rest
i386: hvf: remove more dead emulator code
i386: hvf: remove ZERO_INIT macro
i386: hvf: abort on decoding error
i386: hvf: simplify flag handling
i386: hvf: remove addr_t
i386: hvf: simplify and fix in/out handling
i386: hvf: cleanup x86_gen.h
target/i386/Makefile.objs | 2 +-
target/i386/cpu.h | 62 ++++---
target/i386/hvf-utils/panic.h | 45 +++++
target/i386/hvf-utils/x86_flags.h | 243 ---------------------------
target/i386/{hvf-utils => hvf}/Makefile.objs | 1 +
target/i386/{hvf-utils => hvf}/README.md | 0
target/i386/{ => hvf}/hvf-i386.h | 2 +-
target/i386/{hvf-all.c => hvf/hvf.c} | 36 ++--
target/i386/{hvf-utils => hvf}/vmcs.h | 0
target/i386/{hvf-utils => hvf}/vmx.h | 10 +-
target/i386/{hvf-utils => hvf}/x86.c | 23 +--
target/i386/{hvf-utils => hvf}/x86.h | 167 ++++++------------
target/i386/{hvf-utils => hvf}/x86_cpuid.c | 0
target/i386/{hvf-utils => hvf}/x86_cpuid.h | 0
target/i386/{hvf-utils => hvf}/x86_decode.c | 144 ++++++++--------
target/i386/{hvf-utils => hvf}/x86_decode.h | 23 ++-
target/i386/{hvf-utils => hvf}/x86_descr.c | 26 +--
target/i386/{hvf-utils => hvf}/x86_descr.h | 21 ++-
target/i386/{hvf-utils => hvf}/x86_emu.c | 238 ++++++++++----------------
target/i386/{hvf-utils => hvf}/x86_emu.h | 14 +-
target/i386/{hvf-utils => hvf}/x86_flags.c | 237 ++++++++++++--------------
target/i386/hvf/x86_flags.h | 77 +++++++++
target/i386/{hvf-utils => hvf}/x86_gen.h | 4 -
target/i386/{hvf-utils => hvf}/x86_mmu.c | 36 ++--
target/i386/{hvf-utils => hvf}/x86_mmu.h | 8 +-
target/i386/{hvf-utils => hvf}/x86_task.c | 65 +++----
target/i386/{hvf-utils => hvf}/x86_task.h | 0
target/i386/{hvf-utils => hvf}/x86hvf.c | 32 ++--
target/i386/{hvf-utils => hvf}/x86hvf.h | 0
29 files changed, 624 insertions(+), 892 deletions(-)
create mode 100644 target/i386/hvf-utils/panic.h
delete mode 100644 target/i386/hvf-utils/x86_flags.h
rename target/i386/{hvf-utils => hvf}/Makefile.objs (87%)
rename target/i386/{hvf-utils => hvf}/README.md (100%)
rename target/i386/{ => hvf}/hvf-i386.h (97%)
rename target/i386/{hvf-all.c => hvf/hvf.c} (97%)
rename target/i386/{hvf-utils => hvf}/vmcs.h (100%)
rename target/i386/{hvf-utils => hvf}/vmx.h (97%)
rename target/i386/{hvf-utils => hvf}/x86.c (88%)
rename target/i386/{hvf-utils => hvf}/x86.h (71%)
rename target/i386/{hvf-utils => hvf}/x86_cpuid.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_cpuid.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_decode.c (96%)
rename target/i386/{hvf-utils => hvf}/x86_decode.h (94%)
rename target/i386/{hvf-utils => hvf}/x86_descr.c (82%)
rename target/i386/{hvf-utils => hvf}/x86_descr.h (75%)
rename target/i386/{hvf-utils => hvf}/x86_emu.c (84%)
rename target/i386/{hvf-utils => hvf}/x86_emu.h (75%)
rename target/i386/{hvf-utils => hvf}/x86_flags.c (57%)
create mode 100644 target/i386/hvf/x86_flags.h
rename target/i386/{hvf-utils => hvf}/x86_gen.h (93%)
rename target/i386/{hvf-utils => hvf}/x86_mmu.c (85%)
rename target/i386/{hvf-utils => hvf}/x86_mmu.h (84%)
rename target/i386/{hvf-utils => hvf}/x86_task.c (81%)
rename target/i386/{hvf-utils => hvf}/x86_task.h (100%)
rename target/i386/{hvf-utils => hvf}/x86hvf.c (93%)
rename target/i386/{hvf-utils => hvf}/x86hvf.h (100%)Signature · 1 line
2.13.6
PATCH 1/10 i386: hvf: move all hvf files in the same directory
Just call it hvf/, no need for the "utils" suffix.
---
target/i386/Makefile.objs | 2 +-
target/i386/cpu.h | 2 +-
target/i386/{hvf-utils => hvf}/Makefile.objs | 1 +
target/i386/{hvf-utils => hvf}/README.md | 0
target/i386/{ => hvf}/hvf-i386.h | 2 +-
target/i386/{hvf-all.c => hvf/hvf.c} | 20 ++++++++++----------
target/i386/{hvf-utils => hvf}/vmcs.h | 0
target/i386/{hvf-utils => hvf}/vmx.h | 0
target/i386/{hvf-utils => hvf}/x86.c | 0
target/i386/{hvf-utils => hvf}/x86.h | 0
target/i386/{hvf-utils => hvf}/x86_cpuid.c | 0
target/i386/{hvf-utils => hvf}/x86_cpuid.h | 0
target/i386/{hvf-utils => hvf}/x86_decode.c | 0
target/i386/{hvf-utils => hvf}/x86_decode.h | 0
target/i386/{hvf-utils => hvf}/x86_descr.c | 0
target/i386/{hvf-utils => hvf}/x86_descr.h | 0
target/i386/{hvf-utils => hvf}/x86_emu.c | 0
target/i386/{hvf-utils => hvf}/x86_emu.h | 0
target/i386/{hvf-utils => hvf}/x86_flags.c | 0
target/i386/{hvf-utils => hvf}/x86_flags.h | 0
target/i386/{hvf-utils => hvf}/x86_gen.h | 0
target/i386/{hvf-utils => hvf}/x86_mmu.c | 0
target/i386/{hvf-utils => hvf}/x86_mmu.h | 0
target/i386/{hvf-utils => hvf}/x86_task.c | 20 ++++++++++----------
target/i386/{hvf-utils => hvf}/x86_task.h | 0
target/i386/{hvf-utils => hvf}/x86hvf.c | 0
target/i386/{hvf-utils => hvf}/x86hvf.h | 0
27 files changed, 24 insertions(+), 23 deletions(-)
rename target/i386/{hvf-utils => hvf}/Makefile.objs (87%)
rename target/i386/{hvf-utils => hvf}/README.md (100%)
rename target/i386/{ => hvf}/hvf-i386.h (97%)
rename target/i386/{hvf-all.c => hvf/hvf.c} (98%)
rename target/i386/{hvf-utils => hvf}/vmcs.h (100%)
rename target/i386/{hvf-utils => hvf}/vmx.h (100%)
rename target/i386/{hvf-utils => hvf}/x86.c (100%)
rename target/i386/{hvf-utils => hvf}/x86.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_cpuid.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_cpuid.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_decode.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_decode.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_descr.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_descr.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_emu.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_emu.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_flags.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_flags.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_gen.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_mmu.c (100%)
rename target/i386/{hvf-utils => hvf}/x86_mmu.h (100%)
rename target/i386/{hvf-utils => hvf}/x86_task.c (95%)
rename target/i386/{hvf-utils => hvf}/x86_task.h (100%)
rename target/i386/{hvf-utils => hvf}/x86hvf.c (100%)
rename target/i386/{hvf-utils => hvf}/x86hvf.h (100%)target/i386/Makefile.objs +1 -1
@@ -12,5 +12,5 @@ obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-windows.o endif ifdef CONFIG_DARWIN obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-darwin.o -obj-$(CONFIG_HVF) += hvf-utils/ hvf-all.o +obj-$(CONFIG_HVF) += hvf/ endif
target/i386/cpu.h +1 -1
@@ -24,7 +24,7 @@#include "cpu-qom.h" #include "hyperv-proto.h" #if defined(CONFIG_HVF ) -#include "target/i386/hvf-utils/x86.h" +#include "target/i386/hvf/x86.h" #endif #ifdef TARGET_X86_64
target/i386/hvf/Makefile.objs renamed from target/i386/hvf-utils/Makefile.objs +1 -0
@@ -1 +1,2 @@ +obj-y += hvf.o obj-y += x86.o x86_cpuid.o x86_decode.o x86_descr.o x86_emu.o x86_flags.o x86_mmu.o x86hvf.o x86_task.o
target/i386/hvf/README.md renamed from target/i386/hvf-utils/README.md +0 -0
target/i386/hvf/hvf-i386.h renamed from target/i386/hvf-i386.h +1 -1
@@ -18,7 +18,7 @@#include "sysemu/hvf.h" #include "cpu.h" -#include "hvf-utils/x86.h" +#include "x86.h" #define HVF_MAX_VCPU 0x10#define MAX_VM_ID 0x40
target/i386/hvf/hvf.c renamed from target/i386/hvf-all.c +10 -10
@@ -24,16 +24,16 @@#include "sysemu/hvf.h" #include "hvf-i386.h" -#include "hvf-utils/vmcs.h" -#include "hvf-utils/vmx.h" -#include "hvf-utils/x86.h" -#include "hvf-utils/x86_descr.h" -#include "hvf-utils/x86_mmu.h" -#include "hvf-utils/x86_decode.h" -#include "hvf-utils/x86_emu.h" -#include "hvf-utils/x86_cpuid.h" -#include "hvf-utils/x86_task.h" -#include "hvf-utils/x86hvf.h" +#include "vmcs.h" +#include "vmx.h" +#include "x86.h" +#include "x86_descr.h" +#include "x86_mmu.h" +#include "x86_decode.h" +#include "x86_emu.h" +#include "x86_cpuid.h" +#include "x86_task.h" +#include "x86hvf.h" #include <Hypervisor/hv.h> #include <Hypervisor/hv_vmx.h>
target/i386/hvf/vmcs.h renamed from target/i386/hvf-utils/vmcs.h +0 -0
target/i386/hvf/vmx.h renamed from target/i386/hvf-utils/vmx.h +0 -0
target/i386/hvf/x86.c renamed from target/i386/hvf-utils/x86.c +0 -0
target/i386/hvf/x86.h renamed from target/i386/hvf-utils/x86.h +0 -0
target/i386/hvf/x86_cpuid.c renamed from target/i386/hvf-utils/x86_cpuid.c +0 -0
target/i386/hvf/x86_cpuid.h renamed from target/i386/hvf-utils/x86_cpuid.h +0 -0
target/i386/hvf/x86_decode.c renamed from target/i386/hvf-utils/x86_decode.c +0 -0
target/i386/hvf/x86_decode.h renamed from target/i386/hvf-utils/x86_decode.h +0 -0
target/i386/hvf/x86_descr.c renamed from target/i386/hvf-utils/x86_descr.c +0 -0
target/i386/hvf/x86_descr.h renamed from target/i386/hvf-utils/x86_descr.h +0 -0
target/i386/hvf/x86_emu.c renamed from target/i386/hvf-utils/x86_emu.c +0 -0
target/i386/hvf/x86_emu.h renamed from target/i386/hvf-utils/x86_emu.h +0 -0
target/i386/hvf/x86_flags.c renamed from target/i386/hvf-utils/x86_flags.c +0 -0
target/i386/hvf/x86_flags.h renamed from target/i386/hvf-utils/x86_flags.h +0 -0
target/i386/hvf/x86_gen.h renamed from target/i386/hvf-utils/x86_gen.h +0 -0
target/i386/hvf/x86_mmu.c renamed from target/i386/hvf-utils/x86_mmu.c +0 -0
target/i386/hvf/x86_mmu.h renamed from target/i386/hvf-utils/x86_mmu.h +0 -0
target/i386/hvf/x86_task.c renamed from target/i386/hvf-utils/x86_task.c +10 -10
@@ -12,16 +12,16 @@#include "sysemu/hvf.h" #include "hvf-i386.h" -#include "hvf-utils/vmcs.h" -#include "hvf-utils/vmx.h" -#include "hvf-utils/x86.h" -#include "hvf-utils/x86_descr.h" -#include "hvf-utils/x86_mmu.h" -#include "hvf-utils/x86_decode.h" -#include "hvf-utils/x86_emu.h" -#include "hvf-utils/x86_cpuid.h" -#include "hvf-utils/x86_task.h" -#include "hvf-utils/x86hvf.h" +#include "vmcs.h" +#include "vmx.h" +#include "x86.h" +#include "x86_descr.h" +#include "x86_mmu.h" +#include "x86_decode.h" +#include "x86_emu.h" +#include "x86_cpuid.h" +#include "x86_task.h" +#include "x86hvf.h" #include <Hypervisor/hv.h> #include <Hypervisor/hv_vmx.h>
target/i386/hvf/x86_task.h renamed from target/i386/hvf-utils/x86_task.h +0 -0
target/i386/hvf/x86hvf.c renamed from target/i386/hvf-utils/x86hvf.c +0 -0
target/i386/hvf/x86hvf.h renamed from target/i386/hvf-utils/x86hvf.h +0 -0
Signature · 1 line
2.13.6
PATCH 2/10 i386: hvf: header cleanup
In reply to Paolo BonziniRemove inclusions of system headers and avoid "pragma once".
--- target/i386/hvf/x86.h | 8 +++----- target/i386/hvf/x86_decode.h | 9 ++++----- target/i386/hvf/x86_descr.h | 5 ++++- 3 files changed, 11 insertions(+), 11 deletions(-)
target/i386/hvf/x86.h +3 -5
@@ -16,12 +16,9 @@* License along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#pragma once +#ifndef HVF_X86_H +#define HVF_X86_H 1 -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <stdarg.h> #include "qemu-common.h" #include "x86_gen.h"
@@ -474,3 +471,4 @@ static inline uint64_t rdtscp(void) return tsc; } +#endif
target/i386/hvf/x86_decode.h +4 -5
@@ -15,12 +15,9 @@* License along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#pragma once +#ifndef HVF_X86_DECODE_H +#define HVF_X86_DECODE_H 1 -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <stdarg.h> #include "qemu-common.h" #include "x86.h" #include "cpu.h"
@@ -323,3 +320,5 @@ void calc_modrm_operand64(CPUX86State *env, struct x86_decode *decode, struct x86_decode_op *op);void set_addressing_size (CPUX86State *env,struct x86_decode *decode);void set_operand_size (CPUX86State *env,struct x86_decode *decode); + +#endif
target/i386/hvf/x86_descr.h +4 -1
@@ -16,7 +16,8 @@* License along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#pragma once +#ifndef HVF_X86_DESCR_H +#define HVF_X86_DESCR_H 1#include "x86.h"
@@ -53,3 +54,5 @@ uint32_t vmx_read_segment_ar(CPUState *cpu, x86_reg_segment seg);void vmx_segment_to_x86_descriptor (struct CPUState *cpu,struct vmx_segment *vmx_desc,struct x86_segment_descriptor *desc); + +#endif
Signature · 1 line
2.13.6
PATCH 6/10 i386: hvf: abort on decoding error
In reply to Paolo BonziniRather than unsupported situations, some VM_PANIC calls actually are caused by internal errors. Convert them to just abort.
--- target/i386/hvf/hvf.c | 2 +- target/i386/hvf/x86_emu.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-)
target/i386/hvf/hvf.c +1 -1
@@ -767,7 +767,7 @@ int hvf_vcpu_exec(CPUState *cpu) env->hvf_emul->fetch_rip = rip;decode_instruction (env, &decode); -VM_PANIC_ON (ins_len != decode.len); +assert (ins_len == decode.len);exec_instruction (env, &decode);store_regs (cpu);
target/i386/hvf/x86_emu.c +4 -6
@@ -146,7 +146,7 @@ addr_t read_reg(CPUX86State *env, int reg, int size)case 8 :return env->hvf_emul->regs[reg].rrx;default : -VM_PANIC_ON ("read_reg size" ); +abort (); }return 0 ; }
@@ -167,7 +167,7 @@ void write_reg(CPUX86State *env, int reg, addr_t val, int size) env->hvf_emul->regs[reg].rrx = val;break ;default : -VM_PANIC_ON ("write_reg size" ); +abort (); } }
@@ -189,8 +189,7 @@ addr_t read_val_from_reg(addr_t reg_ptr, int size) val = *(uint64_t *)reg_ptr;break ;default : -VM_PANIC_ON_EX (1 ,"read_val: Unknown size %d\n" , size); -break ; +abort (); }return val; }
@@ -211,8 +210,7 @@ void write_val_to_reg(addr_t reg_ptr, addr_t val, int size) *(uint64_t *)reg_ptr = val;break ;default : -VM_PANIC ("write_val: Unknown size\n" ); -break ; +abort (); } }
Signature · 1 line
2.13.6
PATCH 4/10 i386: hvf: remove more dead emulator code
In reply to Paolo Bonzini--- target/i386/hvf/hvf.c | 2 -- target/i386/hvf/x86.h | 5 ----- target/i386/hvf/x86_decode.c | 22 +++++++++++----------- target/i386/hvf/x86_emu.c | 25 ++++++++----------------- target/i386/hvf/x86_flags.c | 10 ---------- target/i386/hvf/x86_flags.h | 1 - target/i386/hvf/x86_mmu.c | 6 ++---- target/i386/hvf/x86_task.c | 10 ---------- 8 files changed, 21 insertions(+), 60 deletions(-)
target/i386/hvf/hvf.c +0 -2
@@ -739,7 +739,6 @@ int hvf_vcpu_exec(CPUState *cpu)uint32_t port = exit_qual >>16 ;/*uint32_t rep = (exit_qual & 0x20) != 0;*/ -#if 1 if (!string && in) {uint64_t val =0 ;load_regs (cpu);
@@ -762,7 +761,6 @@ int hvf_vcpu_exec(CPUState *cpu)macvm_set_rip (cpu, rip + ins_len);break ; } -#endif struct x86_decode decode;load_regs (cpu);
target/i386/hvf/x86.h +0 -5
@@ -103,10 +103,6 @@ typedef struct x86_reg_flags { }; } __attribute__ ((__packed__)) x86_reg_flags; -typedef struct x86_efer { -uint64_t efer; -} __attribute__ ((__packed__ ))x86_efer ; - typedef enum x86_reg_cr0 { CR0_PE = (1L << 0), CR0_MP = (1L << 1),
@@ -306,7 +302,6 @@ typedef struct HVFX86EmulatorState {struct x86_register regs[16 ];struct x86_reg_flags rflags;struct lazy_flags lflags; -struct x86_efer efer;uint8_t mmio_buf[4096 ]; } HVFX86EmulatorState;
target/i386/hvf/x86_decode.c +11 -11
@@ -630,7 +630,7 @@ static void decode_aegroup(CPUX86State *env, struct x86_decode *decode) }break ;default : -VM_PANIC_ON_EX (1 ,"0xae: reg %d\n" , decode->modrm.reg); +VM_PANIC_EX ("0xae: reg %d\n" , decode->modrm.reg);break ; } }
@@ -654,14 +654,14 @@ static void decode_d9_4(CPUX86State *env, struct x86_decode *decode) decode->cmd =X86_DECODE_CMD_FABS ;break ;case 0xe4 : -VM_PANIC_ON_EX (1 ,"FTST" ); +VM_PANIC ("FTST" );break ;case 0xe5 :/* FXAM */ decode->cmd =X86_DECODE_CMD_FXAM ;break ;default : -VM_PANIC_ON_EX (1 ,"FLDENV" ); +VM_PANIC ("FLDENV" );break ; } }
@@ -670,16 +670,16 @@ static void decode_db_4(CPUX86State *env, struct x86_decode *decode) {switch (decode->modrm.modrm) {case 0xe0 : -VM_PANIC_ON_EX (1 ,"unhandled FNENI: %x %x\n" , decode->opcode[0 ], - decode->modrm.modrm); +VM_PANIC_EX ("unhandled FNENI: %x %x\n" , decode->opcode[0 ], + decode->modrm.modrm);break ;case 0xe1 : -VM_PANIC_ON_EX (1 ,"unhandled FNDISI: %x %x\n" , decode->opcode[0 ], - decode->modrm.modrm); +VM_PANIC_EX ("unhandled FNDISI: %x %x\n" , decode->opcode[0 ], + decode->modrm.modrm);break ;case 0xe2 : -VM_PANIC_ON_EX (1 ,"unhandled FCLEX: %x %x\n" , decode->opcode[0 ], - decode->modrm.modrm); +VM_PANIC_EX ("unhandled FCLEX: %x %x\n" , decode->opcode[0 ], + decode->modrm.modrm);break ;case 0xe3 : decode->cmd =X86_DECODE_CMD_FNINIT ;
@@ -688,8 +688,8 @@ static void decode_db_4(CPUX86State *env, struct x86_decode *decode) decode->cmd =X86_DECODE_CMD_FNSETPM ;break ;default : -VM_PANIC_ON_EX (1 ,"unhandled fpu opcode: %x %x\n" , decode->opcode[0 ], - decode->modrm.modrm); +VM_PANIC_EX ("unhandled fpu opcode: %x %x\n" , decode->opcode[0 ], + decode->modrm.modrm);break ; } }
target/i386/hvf/x86_emu.c +8 -17
@@ -837,7 +837,6 @@ void simulate_wrmsr(struct CPUState *cpu)abort ();break ;case MSR_EFER : - env->hvf_emul->efer.efer = data;/*printf("new efer %llx\n", EFER(cpu));*/ wvmcs (cpu->hvf_fd,VMCS_GUEST_IA32_EFER , data);if (data &MSR_EFER_NXE ) {
@@ -1511,23 +1510,15 @@ bool exec_instruction(struct CPUX86State *env, struct x86_decode *ins)printf("%d, %llx: exec_instruction %s\n", hvf_vcpu_id(cpu), RIP(cpu), decode_cmd_to_string(ins->cmd));*/ -if (0 && ins->is_fpu) { -VM_PANIC ("emulate fpu\n" ); - }else { -if (!_cmd_handler[ins->cmd].handler) { -printf ("Unimplemented handler (%llx) for %d (%x %x) \n" ,RIP (env), - ins->cmd, ins->opcode[0 ], - ins->opcode_len >1 ? ins->opcode[1 ] :0 ); -RIP (env) += ins->len; -return true; - } - -VM_PANIC_ON_EX (!_cmd_handler[ins->cmd].handler, -"Unimplemented handler (%llx) for %d (%x %x) \n" ,RIP (env), - ins->cmd, ins->opcode[0 ], - ins->opcode_len >1 ? ins->opcode[1 ] :0 ); - _cmd_handler[ins->cmd].handler (env, ins); +if (!_cmd_handler[ins->cmd].handler) { +printf ("Unimplemented handler (%llx) for %d (%x %x) \n" ,RIP (env), + ins->cmd, ins->opcode[0 ], + ins->opcode_len >1 ? ins->opcode[1 ] :0 ); +RIP (env) += ins->len; +return true; } + + _cmd_handler[ins->cmd].handler (env, ins);return true; }
target/i386/hvf/x86_flags.c +0 -10
@@ -301,16 +301,6 @@ void set_SF(CPUX86State *env, bool val) env->hvf_emul->lflags.auxbits ^= (temp_sf ^ val) <<LF_BIT_SD ; } -void set_OSZAPC (CPUX86State *env,uint32_t flags32) -{ -set_OF (env, env->hvf_emul->rflags.of); -set_SF (env, env->hvf_emul->rflags.sf); -set_ZF (env, env->hvf_emul->rflags.zf); -set_AF (env, env->hvf_emul->rflags.af); -set_PF (env, env->hvf_emul->rflags.pf); -set_CF (env, env->hvf_emul->rflags.cf); -} -void lflags_to_rflags (CPUX86State *env) { env->hvf_emul->rflags.cf =get_CF (env);
target/i386/hvf/x86_flags.h +0 -1
@@ -190,7 +190,6 @@ bool get_SF(CPUX86State *env);void set_SF (CPUX86State *env,bool val);bool get_OF (CPUX86State *env);void set_OF (CPUX86State *env,bool val); -void set_OSZAPC (CPUX86State *env,uint32_t flags32);void SET_FLAGS_OxxxxC (CPUX86State *env,uint32_t new_of,uint32_t new_cf);
target/i386/hvf/x86_mmu.c +2 -4
@@ -238,8 +238,7 @@ void vmx_write_mem(struct CPUState *cpu, addr_t gva, void *data, int bytes)int copy =MIN (bytes,0x1000 - (gva &0xfff ));if (!mmu_gva_to_gpa (cpu, gva, &gpa)) { -VM_PANIC_ON_EX (1 ,"%s: mmu_gva_to_gpa %llx failed\n" , __func__, - gva); +VM_PANIC_EX ("%s: mmu_gva_to_gpa %llx failed\n" , __func__, gva); }else {address_space_rw (&address_space_memory, gpa,MEMTXATTRS_UNSPECIFIED , data, copy,1 );
@@ -260,8 +259,7 @@ void vmx_read_mem(struct CPUState *cpu, void *data, addr_t gva, int bytes)int copy =MIN (bytes,0x1000 - (gva &0xfff ));if (!mmu_gva_to_gpa (cpu, gva, &gpa)) { -VM_PANIC_ON_EX (1 ,"%s: mmu_gva_to_gpa %llx failed\n" , __func__, - gva); +VM_PANIC_EX ("%s: mmu_gva_to_gpa %llx failed\n" , __func__, gva); }address_space_rw (&address_space_memory, gpa,MEMTXATTRS_UNSPECIFIED , data, copy,0 );
target/i386/hvf/x86_task.c +0 -10
@@ -90,16 +90,6 @@ static void load_state_from_tss32(CPUState *cpu, struct x86_tss_segment32 *tss)vmx_write_segment_selector (cpu, (x68_segment_selector ){{tss->ds}},R_DS );vmx_write_segment_selector (cpu, (x68_segment_selector ){{tss->fs}},R_FS );vmx_write_segment_selector (cpu, (x68_segment_selector ){{tss->gs}},R_GS ); - -#if 0 -load_segment (cpu,R_LDTR , tss->ldt); -load_segment (cpu,R_ES , tss->es); -load_segment (cpu,R_CS , tss->cs); -load_segment (cpu,R_SS , tss->ss); -load_segment (cpu,R_DS , tss->ds); -load_segment (cpu,R_FS , tss->fs); -load_segment (cpu,R_GS , tss->gs); -#endif } static int task_switch_32(CPUState *cpu, x68_segment_selector tss_sel, x68_segment_selector old_tss_sel,
Signature · 1 line
2.13.6
PATCH 5/10 i386: hvf: remove ZERO_INIT macro
In reply to Paolo Bonzini--- target/i386/hvf/x86.c | 3 ++- target/i386/hvf/x86_decode.c | 3 +-- target/i386/hvf/x86_gen.h | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-)
target/i386/hvf/x86.c +2 -1
@@ -53,7 +53,8 @@ bool x86_read_segment_descriptor(struct CPUState *cpu,addr_t base;uint32_t limit; -ZERO_INIT (*desc); +memset (desc,0 ,sizeof (*desc)); +/* valid gdt descriptors start from index 1 */ if (!sel.index &&GDT_SEL == sel.ti) {return false;
target/i386/hvf/x86_decode.c +1 -2
@@ -2090,8 +2090,7 @@ static void decode_opcodes(CPUX86State *env, struct x86_decode *decode)uint32_t decode_instruction (CPUX86State *env,struct x86_decode *decode) { -ZERO_INIT (*decode); - +memset (decode,0 ,sizeof (*decode));decode_prefix (env, decode);set_addressing_size (env, decode);set_operand_size (env, decode);
target/i386/hvf/x86_gen.h +0 -2
@@ -48,6 +48,4 @@ typedef uint64_t addr_t; } \ } -#define ZERO_INIT (obj) memset((void *) &obj, 0, sizeof(obj)) -#endif
Signature · 1 line
2.13.6
PATCH 9/10 i386: hvf: simplify and fix in/out handling
In reply to Paolo BonziniReading a 32-bit port should clear the upper 32-bits of the register.
--- target/i386/hvf/hvf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/i386/hvf/hvf.c +4 -4
@@ -748,16 +748,16 @@ int hvf_vcpu_exec(CPUState *cpu) }else if (size ==2 ) {AX (env) = val; }else if (size ==4 ) { -RAX (env) = (uint32_t )val; +RRX (env) = (uint32_t )val; }else { -VM_PANIC ("size" ); +RRX (env) = (uint64_t )val; }RIP (env) += ins_len;store_regs (cpu);break ; }else if (!string && !in) { -RAX (env) =rreg (cpu->hvf_fd,HV_X86_RAX ); -hvf_handle_io (env, port, &RAX (env),1 , size,1 ); +RRX (env) =rreg (cpu->hvf_fd,HV_X86_RAX ); +hvf_handle_io (env, port, &RRX (env),1 , size,1 );macvm_set_rip (cpu, rip + ins_len);break ; }
Signature · 1 line
2.13.6
PATCH 10/10 i386: hvf: cleanup x86_gen.h
In reply to Paolo BonziniThis only includes VM_PANIC now. No need to include it from headers.
--- target/i386/hvf-utils/panic.h | 45 +++++++++++++++++++++++++++++++++++++++++++ target/i386/hvf/x86.h | 1 - target/i386/hvf/x86_decode.c | 3 +-- target/i386/hvf/x86_emu.c | 2 +- target/i386/hvf/x86_flags.c | 1 + target/i386/hvf/x86_flags.h | 1 - target/i386/hvf/x86_mmu.c | 1 + target/i386/hvf/x86_mmu.h | 2 -- target/i386/hvf/x86_task.c | 1 + 9 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 target/i386/hvf-utils/panic.h
target/i386/hvf-utils/panic.h new file +45 -0
@@ -0,0 +1,45 @@ +/* +* Copyright (C) 2016 Veertu Inc, +* Copyright (C) 2017 Google Inc, +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef HVF_PANIC_H +#define HVF_PANIC_H + +#define VM_PANIC (x) {\ + printf("%s\n", x); \ + abort(); \ +} + +#define VM_PANIC_ON (x) {\ + if (x) { \ + printf("%s\n", #x); \ + abort(); \ + } \ +} + +#define VM_PANIC_EX (...) {\ + printf(__VA_ARGS__); \ + abort(); \ +} + +#define VM_PANIC_ON_EX (x, ...) {\ + if (x) { \ + printf(__VA_ARGS__); \ + abort(); \ + } \ +} + +#endif
target/i386/hvf/x86.h +0 -1
@@ -20,7 +20,6 @@#define HVF_X86_H 1#include "qemu-common.h" -#include "x86_gen.h" typedef struct x86_register { union {
target/i386/hvf/x86_decode.c +1 -2
@@ -17,11 +17,10 @@*/ #include "qemu/osdep.h" - +#include "panic.h" #include "x86_decode.h" #include "string.h" #include "vmx.h" -#include "x86_gen.h" #include "x86_mmu.h" #include "x86_descr.h"
target/i386/hvf/x86_emu.c +1 -1
@@ -36,7 +36,7 @@///////////////////////////////////////////////////////////////////////// #include "qemu/osdep.h" - +#include "panic.h" #include "qemu-common.h" #include "x86_decode.h" #include "x86.h"
target/i386/hvf/x86_flags.c +1 -0
@@ -22,6 +22,7 @@*/ #include "qemu/osdep.h" +#include "panic.h" #include "qemu-common.h" #include "cpu.h"
target/i386/hvf/x86_flags.h +0 -1
@@ -23,7 +23,6 @@#ifndef __X86_FLAGS_H__#define __X86_FLAGS_H__ -#include "x86_gen.h" #include "cpu.h" void lflags_to_rflags (CPUX86State *env);void rflags_to_lflags (CPUX86State *env);
target/i386/hvf/x86_mmu.c +1 -0
@@ -16,6 +16,7 @@* License along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "panic.h" #include "qemu-common.h" #include "x86.h"
target/i386/hvf/x86_mmu.h +0 -2
@@ -18,8 +18,6 @@#ifndef __X86_MMU_H__#define __X86_MMU_H__ -#include "x86_gen.h" -#define PT_PRESENT (1 << 0)#define PT_WRITE (1 << 1)#define PT_USER (1 << 2)
target/i386/hvf/x86_task.c +1 -0
@@ -7,6 +7,7 @@// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. #include "qemu/osdep.h" +#include "panic.h" #include "qemu-common.h" #include "qemu/error-report.h"
Signature · 1 line
2.13.6
PATCH 3/10 i386: hvf: unify register enums between HVF and the rest
In reply to Paolo Bonzini--- target/i386/cpu.h | 60 +++++++++++------- target/i386/hvf/vmx.h | 10 +-- target/i386/hvf/x86.c | 10 +-- target/i386/hvf/x86.h | 145 +++++++++++++------------------------------ target/i386/hvf/x86_decode.c | 80 ++++++++++++------------ target/i386/hvf/x86_decode.h | 2 +- target/i386/hvf/x86_descr.c | 26 ++++---- target/i386/hvf/x86_descr.h | 16 ++--- target/i386/hvf/x86_emu.c | 66 ++++++++++---------- target/i386/hvf/x86_task.c | 48 +++++++------- target/i386/hvf/x86hvf.c | 32 +++++----- 11 files changed, 224 insertions(+), 271 deletions(-)
target/i386/cpu.h +36 -24
@@ -59,30 +59,42 @@#include "fpu/softfloat.h" #endif -#define R_EAX 0 -#define R_ECX 1 -#define R_EDX 2 -#define R_EBX 3 -#define R_ESP 4 -#define R_EBP 5 -#define R_ESI 6 -#define R_EDI 7 - -#define R_AL 0 -#define R_CL 1 -#define R_DL 2 -#define R_BL 3 -#define R_AH 4 -#define R_CH 5 -#define R_DH 6 -#define R_BH 7 - -#define R_ES 0 -#define R_CS 1 -#define R_SS 2 -#define R_DS 3 -#define R_FS 4 -#define R_GS 5 +enum { +R_RAX =0 , +R_RCX =1 , +R_RDX =2 , +R_RBX =3 , +R_RSP =4 , +R_RBP =5 , +R_RSI =6 , +R_RDI =7 , +R_R8 =8 , +R_R9 =9 , +R_R10 =10 , +R_R11 =11 , +R_R12 =12 , +R_R13 =13 , +R_R14 =14 , +R_R15 =15 , + +R_AL =0 , +R_CL =1 , +R_DL =2 , +R_BL =3 , +R_AH =4 , +R_CH =5 , +R_DH =6 , +R_BH =7 , +}; + +typedef enum X86Seg { +R_ES =0 , +R_CS =1 , +R_SS =2 , +R_DS =3 , +R_FS =4 , +R_GS =5 , +}X86Seg ;/* segment descriptor fields */ #define DESC_G_SHIFT 23
target/i386/hvf/vmx.h +5 -5
@@ -88,14 +88,14 @@ static void enter_long_mode(hv_vcpuid_t vcpu, uint64_t cr0, uint64_t efer) {uint64_t entry_ctls; - efer |=EFER_LMA ; + efer |=MSR_EFER_LMA ;wvmcs (vcpu,VMCS_GUEST_IA32_EFER , efer); entry_ctls =rvmcs (vcpu,VMCS_ENTRY_CTLS );wvmcs (vcpu,VMCS_ENTRY_CTLS ,rvmcs (vcpu,VMCS_ENTRY_CTLS ) |VM_ENTRY_GUEST_LMA );uint64_t guest_tr_ar =rvmcs (vcpu,VMCS_GUEST_TR_ACCESS_RIGHTS ); -if ((efer &EFER_LME ) && +if ((efer &MSR_EFER_LME ) && (guest_tr_ar &AR_TYPE_MASK ) !=AR_TYPE_BUSY_64_TSS ) {wvmcs (vcpu,VMCS_GUEST_TR_ACCESS_RIGHTS , (guest_tr_ar & ~AR_TYPE_MASK ) |AR_TYPE_BUSY_64_TSS );
@@ -109,7 +109,7 @@ static void exit_long_mode(hv_vcpuid_t vcpu, uint64_t cr0, uint64_t efer) entry_ctls =rvmcs (vcpu,VMCS_ENTRY_CTLS );wvmcs (vcpu,VMCS_ENTRY_CTLS , entry_ctls & ~VM_ENTRY_GUEST_LMA ); - efer &= ~EFER_LMA ; + efer &= ~MSR_EFER_LMA ;wvmcs (vcpu,VMCS_GUEST_IA32_EFER , efer); }
@@ -121,7 +121,7 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)uint64_t old_cr0 =rvmcs (vcpu,VMCS_GUEST_CR0 );if ((cr0 &CR0_PG ) && (rvmcs (vcpu,VMCS_GUEST_CR4 ) &CR4_PAE ) && - !(efer &EFER_LME )) { + !(efer &MSR_EFER_LME )) { address_space_rw(&address_space_memory, rvmcs(vcpu, VMCS_GUEST_CR3) & ~0x1f, MEMTXATTRS_UNSPECIFIED,
@@ -138,7 +138,7 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0) cr0 &= ~CR0_CD ;wvmcs (vcpu,VMCS_GUEST_CR0 , cr0 |CR0_NE |CR0_ET ); -if (efer &EFER_LME ) { +if (efer &MSR_EFER_LME ) {if (!(old_cr0 &CR0_PG ) && (cr0 &CR0_PG )) {enter_long_mode (vcpu, cr0, efer); }
target/i386/hvf/x86.c +5 -5
@@ -134,13 +134,13 @@ bool x86_is_v8086(struct CPUState *cpu)bool x86_is_long_mode (struct CPUState *cpu) { -return rvmcs (cpu->hvf_fd,VMCS_GUEST_IA32_EFER ) &EFER_LMA ; +return rvmcs (cpu->hvf_fd,VMCS_GUEST_IA32_EFER ) &MSR_EFER_LMA ; }bool x86_is_long64_mode (struct CPUState *cpu) {struct vmx_segment desc; -vmx_read_segment_descriptor (cpu, &desc,REG_SEG_CS ); +vmx_read_segment_descriptor (cpu, &desc,R_CS );return x86_is_long_mode (cpu) && ((desc.ar >>13 ) &1 ); }
@@ -157,13 +157,13 @@ bool x86_is_pae_enabled(struct CPUState *cpu)return cr4 &CR4_PAE ; } -addr_t linear_addr (struct CPUState *cpu,addr_t addr,x86_reg_segment seg) +addr_t linear_addr (struct CPUState *cpu,addr_t addr,X86Seg seg) {return vmx_read_segment_base (cpu, seg) + addr; }addr_t linear_addr_size (struct CPUState *cpu,addr_t addr,int size, -x86_reg_segment seg) +X86Seg seg) {switch (size) {case 2 :
@@ -180,5 +180,5 @@ addr_t linear_addr_size(struct CPUState *cpu, addr_t addr, int size,addr_t linear_rip (struct CPUState *cpu,addr_t rip) { -return linear_addr (cpu, rip,REG_SEG_CS ); +return linear_addr (cpu, rip,R_CS ); }
target/i386/hvf/x86.h +43 -102
178 lines not on this page · raw message
target/i386/hvf/x86_decode.c +40 -40
222 lines not on this page · raw message
target/i386/hvf/x86_decode.h +1 -1
@@ -309,7 +309,7 @@ addr_t get_reg_val(CPUX86State *env, int reg, int is_extended, int size);void calc_modrm_operand (CPUX86State *env,struct x86_decode *decode,struct x86_decode_op *op);addr_t decode_linear_addr (CPUX86State *env,struct x86_decode *decode, -addr_t addr,x86_reg_segment seg); +addr_t addr,enum X86Seg seg);void init_decoder (void ); void calc_modrm_operand16(CPUX86State *env, struct x86_decode *decode,
target/i386/hvf/x86_descr.c +13 -13
@@ -21,12 +21,12 @@#include "vmx.h" #include "x86_descr.h" -#define VMX_SEGMENT_FIELD (seg) \ - [REG_SEG_##seg] = { \ - .selector = VMCS_GUEST_##seg##_SELECTOR, \ - .base = VMCS_GUEST_##seg##_BASE, \ - .limit = VMCS_GUEST_##seg##_LIMIT, \ - .ar_bytes = VMCS_GUEST_##seg##_ACCESS_RIGHTS, \ +#define VMX_SEGMENT_FIELD (seg) \ + [R_##seg] = { \ + .selector = VMCS_GUEST_##seg##_SELECTOR, \ + .base = VMCS_GUEST_##seg##_BASE, \ + .limit = VMCS_GUEST_##seg##_LIMIT, \ + .ar_bytes = VMCS_GUEST_##seg##_ACCESS_RIGHTS, \ } static const struct vmx_segment_field {
@@ -45,34 +45,34 @@ static const struct vmx_segment_field { VMX_SEGMENT_FIELD(TR), }; -uint32_t vmx_read_segment_limit (CPUState *cpu,x86_reg_segment seg) +uint32_t vmx_read_segment_limit (CPUState *cpu,X86Seg seg) {return (uint32_t )rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].limit); } -uint32_t vmx_read_segment_ar (CPUState *cpu,x86_reg_segment seg) +uint32_t vmx_read_segment_ar (CPUState *cpu,X86Seg seg) {return (uint32_t )rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].ar_bytes); } -uint64_t vmx_read_segment_base (CPUState *cpu,x86_reg_segment seg) +uint64_t vmx_read_segment_base (CPUState *cpu,X86Seg seg) {return rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].base); } -x68_segment_selector vmx_read_segment_selector (CPUState *cpu,x86_reg_segment seg) +x68_segment_selector vmx_read_segment_selector (CPUState *cpu,X86Seg seg) {x68_segment_selector sel; sel.sel =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].selector);return sel; } -void vmx_write_segment_selector (struct CPUState *cpu,x68_segment_selector selector,x86_reg_segment seg) +void vmx_write_segment_selector (struct CPUState *cpu,x68_segment_selector selector,X86Seg seg) {wvmcs (cpu->hvf_fd, vmx_segment_fields[seg].selector, selector.sel); } -void vmx_read_segment_descriptor (struct CPUState *cpu,struct vmx_segment *desc,x86_reg_segment seg) +void vmx_read_segment_descriptor (struct CPUState *cpu,struct vmx_segment *desc,X86Seg seg) { desc->sel =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].selector); desc->base =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].base);
@@ -80,7 +80,7 @@ void vmx_read_segment_descriptor(struct CPUState *cpu, struct vmx_segment *desc, desc->ar =rvmcs (cpu->hvf_fd, vmx_segment_fields[seg].ar_bytes); } -void vmx_write_segment_descriptor (CPUState *cpu,struct vmx_segment *desc,x86_reg_segment seg) +void vmx_write_segment_descriptor (CPUState *cpu,struct vmx_segment *desc,X86Seg seg) {const struct vmx_segment_field *sf = &vmx_segment_fields[seg];
target/i386/hvf/x86_descr.h +8 -8
@@ -30,18 +30,18 @@ typedef struct vmx_segment {/* deal with vmstate descriptors */ void vmx_read_segment_descriptor (struct CPUState *cpu, -struct vmx_segment *desc,x86_reg_segment seg); +struct vmx_segment *desc,enum X86Seg seg);void vmx_write_segment_descriptor (CPUState *cpu,struct vmx_segment *desc, -x86_reg_segment seg); +enum X86Seg seg);x68_segment_selector vmx_read_segment_selector (struct CPUState *cpu, -x86_reg_segment seg); +enum X86Seg seg);void vmx_write_segment_selector (struct CPUState *cpu,x68_segment_selector selector, -x86_reg_segment seg); +enum X86Seg seg); -uint64_t vmx_read_segment_base (struct CPUState *cpu,x86_reg_segment seg); -void vmx_write_segment_base (struct CPUState *cpu,x86_reg_segment seg, +uint64_t vmx_read_segment_base (struct CPUState *cpu,enum X86Seg seg); +void vmx_write_segment_base (struct CPUState *cpu,enum X86Seg seg,uint64_t base); void x86_segment_descriptor_to_vmx(struct CPUState *cpu,
@@ -49,8 +49,8 @@ void x86_segment_descriptor_to_vmx(struct CPUState *cpu,struct x86_segment_descriptor *desc, struct vmx_segment *vmx_desc); -uint32_t vmx_read_segment_limit (CPUState *cpu,x86_reg_segment seg); -uint32_t vmx_read_segment_ar (CPUState *cpu,x86_reg_segment seg); +uint32_t vmx_read_segment_limit (CPUState *cpu,enum X86Seg seg); +uint32_t vmx_read_segment_ar (CPUState *cpu,enum X86Seg seg);void vmx_segment_to_x86_descriptor (struct CPUState *cpu,struct vmx_segment *vmx_desc,struct x86_segment_descriptor *desc);
target/i386/hvf/x86_emu.c +33 -33
169 lines not on this page · raw message
target/i386/hvf/x86_task.c +24 -24
80 lines not on this page · raw message
target/i386/hvf/x86hvf.c +16 -16
@@ -107,28 +107,28 @@ void hvf_put_segments(CPUState *cpu_state)macvm_set_cr0 (cpu_state->hvf_fd, env->cr[0 ]);hvf_set_segment (cpu_state, &seg, &env->segs[R_CS ], false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_CS ); +vmx_write_segment_descriptor (cpu_state, &seg,R_CS );hvf_set_segment (cpu_state, &seg, &env->segs[R_DS ], false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_DS ); +vmx_write_segment_descriptor (cpu_state, &seg,R_DS );hvf_set_segment (cpu_state, &seg, &env->segs[R_ES ], false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_ES ); +vmx_write_segment_descriptor (cpu_state, &seg,R_ES );hvf_set_segment (cpu_state, &seg, &env->segs[R_SS ], false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_SS ); +vmx_write_segment_descriptor (cpu_state, &seg,R_SS );hvf_set_segment (cpu_state, &seg, &env->segs[R_FS ], false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_FS ); +vmx_write_segment_descriptor (cpu_state, &seg,R_FS );hvf_set_segment (cpu_state, &seg, &env->segs[R_GS ], false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_GS ); +vmx_write_segment_descriptor (cpu_state, &seg,R_GS );hvf_set_segment (cpu_state, &seg, &env->tr, true); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_TR ); +vmx_write_segment_descriptor (cpu_state, &seg,R_TR );hvf_set_segment (cpu_state, &seg, &env->ldt, false); -vmx_write_segment_descriptor (cpu_state, &seg,REG_SEG_LDTR ); +vmx_write_segment_descriptor (cpu_state, &seg,R_LDTR );hv_vcpu_flush (cpu_state->hvf_fd); }
@@ -183,28 +183,28 @@ void hvf_get_segments(CPUState *cpu_state) env->interrupt_injected =-1 ; -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_CS ); +vmx_read_segment_descriptor (cpu_state, &seg,R_CS );hvf_get_segment (&env->segs[R_CS ], &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_DS ); +vmx_read_segment_descriptor (cpu_state, &seg,R_DS );hvf_get_segment (&env->segs[R_DS ], &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_ES ); +vmx_read_segment_descriptor (cpu_state, &seg,R_ES );hvf_get_segment (&env->segs[R_ES ], &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_FS ); +vmx_read_segment_descriptor (cpu_state, &seg,R_FS );hvf_get_segment (&env->segs[R_FS ], &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_GS ); +vmx_read_segment_descriptor (cpu_state, &seg,R_GS );hvf_get_segment (&env->segs[R_GS ], &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_SS ); +vmx_read_segment_descriptor (cpu_state, &seg,R_SS );hvf_get_segment (&env->segs[R_SS ], &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_TR ); +vmx_read_segment_descriptor (cpu_state, &seg,R_TR );hvf_get_segment (&env->tr, &seg); -vmx_read_segment_descriptor (cpu_state, &seg,REG_SEG_LDTR ); +vmx_read_segment_descriptor (cpu_state, &seg,R_LDTR );hvf_get_segment (&env->ldt, &seg); env->idt.limit =rvmcs (cpu_state->hvf_fd,VMCS_GUEST_IDTR_LIMIT );
Signature · 1 line
2.13.6
Quoted 4 lines · Paolo Bonzini
Alex (both of them), Sergio, anyone else who can help?
Very interested in this (and thanks!) but it will be a while before I have a sensible number of cycles available to play with this one again.
Signature · 1 line
Alex Bligh