Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K3tQK-0008BM-7M for qemu-devel@nongnu.org; Wed, 04 Jun 2008 09:53:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K3tQJ-0008B4-KW for qemu-devel@nongnu.org; Wed, 04 Jun 2008 09:53:07 -0400 Received: from [199.232.76.173] (port=45093 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K3tQJ-0008B0-H0 for qemu-devel@nongnu.org; Wed, 04 Jun 2008 09:53:07 -0400 Received: from savannah.gnu.org ([199.232.41.3]:45700 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K3tQJ-0000vz-5w for qemu-devel@nongnu.org; Wed, 04 Jun 2008 09:53:07 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1K3tQI-0001iK-LP for qemu-devel@nongnu.org; Wed, 04 Jun 2008 13:53:06 +0000 Received: from bellard by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1K3tQI-0001iF-AN for qemu-devel@nongnu.org; Wed, 04 Jun 2008 13:53:06 +0000 MIME-Version: 1.0 Errors-To: bellard Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Fabrice Bellard Message-Id: Date: Wed, 04 Jun 2008 13:53:06 +0000 Subject: [Qemu-devel] [4660] 32 bit SVM fixes - INVLPG and INVLPGA updates Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4660 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4660 Author: bellard Date: 2008-06-04 13:53:05 +0000 (Wed, 04 Jun 2008) Log Message: ----------- 32 bit SVM fixes - INVLPG and INVLPGA updates Modified Paths: -------------- trunk/target-i386/exec.h trunk/target-i386/helper.h trunk/target-i386/op_helper.c trunk/target-i386/translate.c Modified: trunk/target-i386/exec.h =================================================================== --- trunk/target-i386/exec.h 2008-06-04 13:35:58 UTC (rev 4659) +++ trunk/target-i386/exec.h 2008-06-04 13:53:05 UTC (rev 4660) @@ -61,7 +61,6 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0); void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3); void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4); -void cpu_x86_flush_tlb(CPUX86State *env, target_ulong addr); int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, int is_write, int mmu_idx, int is_softmmu); void tlb_fill(target_ulong addr, int is_write, int mmu_idx, Modified: trunk/target-i386/helper.h =================================================================== --- trunk/target-i386/helper.h 2008-06-04 13:35:58 UTC (rev 4659) +++ trunk/target-i386/helper.h 2008-06-04 13:53:05 UTC (rev 4660) @@ -102,14 +102,14 @@ DEF_HELPER(void, helper_vmexit, (uint32_t exit_code, uint64_t exit_info_1)) DEF_HELPER(void, helper_svm_check_io, (uint32_t port, uint32_t param, uint32_t next_eip_addend)) -DEF_HELPER(void, helper_vmrun, (void)) +DEF_HELPER(void, helper_vmrun, (int aflag)) DEF_HELPER(void, helper_vmmcall, (void)) -DEF_HELPER(void, helper_vmload, (void)) -DEF_HELPER(void, helper_vmsave, (void)) +DEF_HELPER(void, helper_vmload, (int aflag)) +DEF_HELPER(void, helper_vmsave, (int aflag)) DEF_HELPER(void, helper_stgi, (void)) DEF_HELPER(void, helper_clgi, (void)) DEF_HELPER(void, helper_skinit, (void)) -DEF_HELPER(void, helper_invlpga, (void)) +DEF_HELPER(void, helper_invlpga, (int aflag)) /* x86 FPU */ Modified: trunk/target-i386/op_helper.c =================================================================== --- trunk/target-i386/op_helper.c 2008-06-04 13:35:58 UTC (rev 4659) +++ trunk/target-i386/op_helper.c 2008-06-04 13:53:05 UTC (rev 4660) @@ -2994,7 +2994,7 @@ void helper_invlpg(target_ulong addr) { helper_svm_check_intercept_param(SVM_EXIT_INVLPG, 0); - cpu_x86_flush_tlb(env, addr); + tlb_flush_page(env, addr); } void helper_rdtsc(void) @@ -4721,16 +4721,16 @@ #if defined(CONFIG_USER_ONLY) -void helper_vmrun(void) +void helper_vmrun(int aflag) { } void helper_vmmcall(void) { } -void helper_vmload(void) +void helper_vmload(int aflag) { } -void helper_vmsave(void) +void helper_vmsave(int aflag) { } void helper_stgi(void) @@ -4742,7 +4742,7 @@ void helper_skinit(void) { } -void helper_invlpga(void) +void helper_invlpga(int aflag) { } void helper_vmexit(uint32_t exit_code, uint64_t exit_info_1) @@ -4791,7 +4791,7 @@ sc->base, sc->limit, sc->flags); } -void helper_vmrun(void) +void helper_vmrun(int aflag) { target_ulong addr; uint32_t event_inj; @@ -4799,7 +4799,11 @@ helper_svm_check_intercept_param(SVM_EXIT_VMRUN, 0); - addr = EAX; + if (aflag == 2) + addr = EAX; + else + addr = (uint32_t)EAX; + if (loglevel & CPU_LOG_TB_IN_ASM) fprintf(logfile,"vmrun! " TARGET_FMT_lx "\n", addr); @@ -4970,13 +4974,16 @@ raise_exception(EXCP06_ILLOP); } -void helper_vmload(void) +void helper_vmload(int aflag) { target_ulong addr; helper_svm_check_intercept_param(SVM_EXIT_VMLOAD, 0); - /* XXX: invalid in 32 bit */ - addr = EAX; + if (aflag == 2) + addr = EAX; + else + addr = (uint32_t)EAX; + if (loglevel & CPU_LOG_TB_IN_ASM) fprintf(logfile,"vmload! " TARGET_FMT_lx "\nFS: %016" PRIx64 " | " TARGET_FMT_lx "\n", addr, ldq_phys(addr + offsetof(struct vmcb, save.fs.base)), @@ -5003,11 +5010,16 @@ env->sysenter_eip = ldq_phys(addr + offsetof(struct vmcb, save.sysenter_eip)); } -void helper_vmsave(void) +void helper_vmsave(int aflag) { target_ulong addr; helper_svm_check_intercept_param(SVM_EXIT_VMSAVE, 0); - addr = EAX; + + if (aflag == 2) + addr = EAX; + else + addr = (uint32_t)EAX; + if (loglevel & CPU_LOG_TB_IN_ASM) fprintf(logfile,"vmsave! " TARGET_FMT_lx "\nFS: %016" PRIx64 " | " TARGET_FMT_lx "\n", addr, ldq_phys(addr + offsetof(struct vmcb, save.fs.base)), @@ -5050,15 +5062,22 @@ { helper_svm_check_intercept_param(SVM_EXIT_SKINIT, 0); /* XXX: not implemented */ - if (loglevel & CPU_LOG_TB_IN_ASM) - fprintf(logfile,"skinit!\n"); raise_exception(EXCP06_ILLOP); } -void helper_invlpga(void) +void helper_invlpga(int aflag) { + target_ulong addr; helper_svm_check_intercept_param(SVM_EXIT_INVLPGA, 0); - tlb_flush(env, 0); + + if (aflag == 2) + addr = EAX; + else + addr = (uint32_t)EAX; + + /* XXX: could use the ASID to see if it is needed to do the + flush */ + tlb_flush_page(env, addr); } void helper_svm_check_intercept_param(uint32_t type, uint64_t param) Modified: trunk/target-i386/translate.c =================================================================== --- trunk/target-i386/translate.c 2008-06-04 13:35:58 UTC (rev 4659) +++ trunk/target-i386/translate.c 2008-06-04 13:53:05 UTC (rev 4660) @@ -6569,7 +6569,8 @@ gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base); break; } else { - tcg_gen_helper_0_0(helper_vmrun); + tcg_gen_helper_0_1(helper_vmrun, + tcg_const_i32(s->aflag)); s->cc_op = CC_OP_EFLAGS; gen_eob(s); } @@ -6586,7 +6587,8 @@ gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base); break; } else { - tcg_gen_helper_0_0(helper_vmload); + tcg_gen_helper_0_1(helper_vmload, + tcg_const_i32(s->aflag)); } break; case 3: /* VMSAVE */ @@ -6596,7 +6598,8 @@ gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base); break; } else { - tcg_gen_helper_0_0(helper_vmsave); + tcg_gen_helper_0_1(helper_vmsave, + tcg_const_i32(s->aflag)); } break; case 4: /* STGI */ @@ -6635,7 +6638,8 @@ gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base); break; } else { - tcg_gen_helper_0_0(helper_invlpga); + tcg_gen_helper_0_1(helper_invlpga, + tcg_const_i32(s->aflag)); } break; default: