[4605] SVM rework
Revision: 4605
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4605 Author: bellard Date: 2008-05-28 16:16:54 +0000 (Wed, 28 May 2008)
Log Message:
-----------
SVM rework
Modified Paths:
--------------
trunk/cpu-exec.c
trunk/target-i386/TODO
trunk/target-i386/cpu.h
trunk/target-i386/helper.c
trunk/target-i386/helper.h
trunk/target-i386/op_helper.c
trunk/target-i386/svm.h
trunk/target-i386/translate.cModified: trunk/cpu-exec.c
===================================================================
cpu-exec.c +0 -1
@@ -171,7 +171,6 @@#if defined(TARGET_I386 ) flags = env->hflags; flags |= (env->eflags & (IOPL_MASK |TF_MASK |VM_MASK )); - flags |= env->intercept; cs_base = env->segs[R_CS ].base; pc = cs_base + env->eip;#elif defined(TARGET_ARM )
Modified: trunk/target-i386/TODO
===================================================================
target-i386/TODO +1 -3
@@ -1,9 +1,7 @@ Correctness issues: - some eflags manipulation incorrectly reset the bit 0x2. -- SVM: rework the implementation: simplify code, move most intercept - tests as dynamic, correct segment access, verify exception safety, - cpu save/restore, SMM save/restore. +- SVM: test, cpu save/restore, SMM save/restore. - x86_64: lcall/ljmp intel/amd differences ? - better code fetch (different exception handling + CS.limit support) - user/kernel PUSHL/POPL in helper.c
Modified: trunk/target-i386/cpu.h
===================================================================
target-i386/cpu.h +6 -0
@@ -149,6 +149,8 @@#define HF_GIF_SHIFT 20/* if set CPU takes interrupts */ #define HF_HIF_SHIFT 21/* shadow copy of IF_MASK when in SVM */ #define HF_NMI_SHIFT 22/* CPU serving NMI */ +#define HF_SVME_SHIFT 23/* SVME enabled (copy of EFER.SVME */ +#define HF_SVMI_SHIFT 24/* SVM intercepts are active */ #define HF_CPL_MASK (3 << HF_CPL_SHIFT)#define HF_SOFTMMU_MASK (1 << HF_SOFTMMU_SHIFT)
@@ -169,6 +171,8 @@#define HF_GIF_MASK (1 << HF_GIF_SHIFT)#define HF_HIF_MASK (1 << HF_HIF_SHIFT)#define HF_NMI_MASK (1 << HF_NMI_SHIFT) +#define HF_SVME_MASK (1 << HF_SVME_SHIFT) +#define HF_SVMI_MASK (1 << HF_SVMI_SHIFT)#define CR0_PE_MASK (1 << 0)#define CR0_MP_MASK (1 << 1)
@@ -242,6 +246,7 @@#define MSR_EFER_LME (1 << 8)#define MSR_EFER_LMA (1 << 10)#define MSR_EFER_NXE (1 << 11) +#define MSR_EFER_SVME (1 << 12)#define MSR_EFER_FFXSR (1 << 14)#define MSR_STAR 0xc0000081
@@ -322,6 +327,7 @@#define CPUID_EXT3_3DNOWPREFETCH (1 << 8)#define CPUID_EXT3_OSVW (1 << 9)#define CPUID_EXT3_IBS (1 << 10) +#define CPUID_EXT3_SKINIT (1 << 12)#define EXCP00_DIVZ 0#define EXCP01_SSTP 1
Modified: trunk/target-i386/helper.c
===================================================================
target-i386/helper.c +4 -5
@@ -1096,16 +1096,15 @@ (env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) error_code |=PG_ERROR_I_D_MASK ; -if (INTERCEPTEDl (_exceptions,1 <<EXCP0E_PAGE )) { - stq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); +if (env->intercept_exceptions & (1 <<EXCP0E_PAGE )) { +/* cr2 is not modified in case of exceptions */ + stq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), + addr); }else { env->cr[2 ] = addr; } env->error_code = error_code; env->exception_index =EXCP0E_PAGE ; -/* the VMM will handle this */ -if (INTERCEPTEDl (_exceptions,1 <<EXCP0E_PAGE )) -return 2 ;return 1 ; }
Modified: trunk/target-i386/helper.h
===================================================================
target-i386/helper.h +2 -1
@@ -43,7 +43,8 @@ DEF_HELPER(void, helper_iret_real, (int shift)) DEF_HELPER(void, helper_iret_protected, (int shift, int next_eip)) DEF_HELPER(void, helper_lret_protected, (int shift, int addend)) -DEF_HELPER(void, helper_movl_crN_T0, (int reg, target_ulong t0)) +DEF_HELPER(target_ulong, helper_read_crN, (int reg)) +DEF_HELPER(void, helper_write_crN, (int reg, target_ulong t0)) DEF_HELPER(void, helper_lmsw, (target_ulong t0)) DEF_HELPER(void, helper_clts, (void)) #if !defined(CONFIG_USER_ONLY)
Modified: trunk/target-i386/op_helper.c
===================================================================
target-i386/op_helper.c +182 -119
577 lines not on this page · raw message
Modified: trunk/target-i386/svm.h
===================================================================
target-i386/svm.h +87 -212
319 lines not on this page · raw message
Modified: trunk/target-i386/translate.c
===================================================================
target-i386/translate.c +101 -137
448 lines not on this page · raw message
Quoted 10 lines · Fabrice Bellard
Revision: 4605
http://svn.sv.gnu.org/viewvc/? view=rev&root=qemu&revision=4605 Author: bellard Date: 2008-05-28 16:16:54 +0000 (Wed, 28 May 2008)Log Message:
-----------
SVM rework
Quoted 10 lines
Modified Paths:
--------------
trunk/cpu-exec.c
trunk/target-i386/TODO
trunk/target-i386/cpu.h
trunk/target-i386/helper.c
trunk/target-i386/helper.h
trunk/target-i386/op_helper.c
trunk/target-i386/svm.h
trunk/target-i386/translate.c
Wow, thanks a lot Fabrice!
I think tb->flags can now be reverted to a 32 bit value, as it no longer needs to keep all the intercept information.
Quoted 6 lines · Alexander Graf
[...]
Quoted 3 lines
Log Message:
-----------
SVM rework[...]
Wow, thanks a lot Fabrice!
At this point my SVM modifications are untested. I plan to make some basic tests soon.
Quoted 1 line
I think
tb->flagscan now be reverted to a 32 bit value, as it no longer needs to keep all the intercept information.
Right. Moreover there are still some bits which must be moved to another variable and modifications pending for the cpu_save/cpu_restore() (in particular the change for the 'halted' flag).
Fabrice.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Fabrice Bellard
Quoted 6 lines · Alexander Graf
[...]
Quoted 3 lines
Log Message:
-----------
SVM rework[...]
Wow, thanks a lot Fabrice!At this point my SVM modifications are untested. I plan to make some basic tests soon.
So far activating SVM does not work and I only receive an #UD on CLGI. I'll need to create a testbed again too, as I lost my previous one.
Alex