From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: [PATCH 4/5] svm: implement CR access part of DecodeAssist Date: Fri, 15 Apr 2011 14:23:25 +0200 Message-ID: <4DA838BD.5040503@amd.com> References: <4DA83719.5080106@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040509030800050108030706" Return-path: In-Reply-To: <4DA83719.5080106@amd.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel List-Id: xen-devel@lists.xenproject.org --------------040509030800050108030706 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Newer SVM implementations (Bulldozer) now give the used general purpose register on a MOV-CR intercept explictly. This avoids fetching and decoding the instruction from guest's memory and speeds up some Windows guest, which exercise CR8 quite often. Signed-off-by: Andre Przywara --------------040509030800050108030706 Content-Type: text/plain; name="da_4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="da_4.patch" Content-Description: da_4.patch commit 11fcadf1400313770480d6d5c4edcc1472c77b0c Author: Andre Przywara Date: Sun Jul 25 15:07:35 2010 +0200 svm: implement CR access part of DecodeAssist Newer SVM implementations (Bulldozer) now give the used general purpose register on a MOV-CR intercept explictly. This avoids fetching and decoding the instruction from guest's memory and speeds up some Windows guest, which exercise CR8 quite often. Signed-off-by: Andre Przywara diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 861c2c7..c406bd3 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1130,6 +1130,25 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs) __update_guest_eip(regs, inst_len); } +static int svm_vmexit_do_cr_access(struct vmcb_struct *vmcb, + struct cpu_user_regs *regs) +{ + int gp, cr, dir; + + cr = vmcb->exitcode - VMEXIT_CR0_READ; + dir = (cr > 15); + cr = cr % 16; + gp = vmcb->exitinfo1 & 0x0F; + + if (dir) + hvm_mov_to_cr(gp, cr, regs); + else + hvm_mov_from_cr(cr, gp, regs); + + __update_guest_eip(regs, vmcb->nextrip - vmcb->rip); + return 0; +} + static void svm_dr_access(struct vcpu *v, struct cpu_user_regs *regs) { HVMTRACE_0D(DR_WRITE); @@ -1906,9 +1925,18 @@ asmlinkage void svm_vmexit_handler(struct cpu_user_regs *regs) __update_guest_eip(regs, vmcb->exitinfo2 - vmcb->rip); break; } - /* fallthrough to emulation if a string instruction */ + if ( !handle_mmio() ) + hvm_inject_exception(TRAP_gp_fault, 0, 0); + break; + case VMEXIT_CR0_READ ... VMEXIT_CR15_READ: case VMEXIT_CR0_WRITE ... VMEXIT_CR15_WRITE: + if ((vmcb->exitinfo1 & (1ULL << 63) && + svm_vmexit_do_cr_access(vmcb, regs)) || + !handle_mmio() ) + hvm_inject_exception(TRAP_gp_fault, 0, 0); + break; + case VMEXIT_INVLPG: case VMEXIT_INVLPGA: if ( !handle_mmio() ) --------------040509030800050108030706 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------040509030800050108030706--