From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mukesh Rathor Subject: [V0 PATCH 3/6] AMD-PVH: call hvm_emulate_one instead of handle_mmio Date: Fri, 12 Dec 2014 18:58:24 -0800 Message-ID: <1418439507-16027-4-git-send-email-mukesh.rathor@oracle.com> References: <1418439507-16027-1-git-send-email-mukesh.rathor@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xzcut-00051O-NY for xen-devel@lists.xenproject.org; Sat, 13 Dec 2014 02:58:47 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sBD2widI020515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 13 Dec 2014 02:58:44 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id sBD2whii021475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 13 Dec 2014 02:58:43 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id sBD2whdN021462 for ; Sat, 13 Dec 2014 02:58:43 GMT In-Reply-To: <1418439507-16027-1-git-send-email-mukesh.rathor@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: boris.ostrovsky@oracle.com, elena.ufimtseva@oracle.com Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Certain IOIO instructions and CR access instructions like lmsw/clts etc need to be emulated. handle_mmio is incorrectly called to accomplish this. Create svm_emulate() to call hvm_emulate_one which is more appropriate, and works for pvh as well. handle_mmio call is forbidden for pvh. Signed-off-by: Mukesh Rathor --- xen/arch/x86/hvm/svm/svm.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 4ff4a96..dac16f4 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2209,6 +2209,18 @@ static struct hvm_function_table __initdata svm_function_table = { .nhvm_hap_walk_L1_p2m = nsvm_hap_walk_L1_p2m, }; +static void svm_emulate(struct cpu_user_regs *regs) +{ + int rc; + struct hvm_emulate_ctxt ctxt; + + hvm_emulate_prepare(&ctxt, regs); + rc = hvm_emulate_one(&ctxt); + + if ( rc != X86EMUL_OKAY ) + hvm_inject_hw_exception(TRAP_gp_fault, 0); +} + void svm_vmexit_handler(struct cpu_user_regs *regs) { uint64_t exit_reason; @@ -2470,16 +2482,16 @@ void svm_vmexit_handler(struct cpu_user_regs *regs) if ( handle_pio(port, bytes, dir) ) __update_guest_eip(regs, vmcb->exitinfo2 - vmcb->rip); } - else if ( !handle_mmio() ) - hvm_inject_hw_exception(TRAP_gp_fault, 0); + else + svm_emulate(regs); break; case VMEXIT_CR0_READ ... VMEXIT_CR15_READ: case VMEXIT_CR0_WRITE ... VMEXIT_CR15_WRITE: if ( cpu_has_svm_decode && (vmcb->exitinfo1 & (1ULL << 63)) ) svm_vmexit_do_cr_access(vmcb, regs); - else if ( !handle_mmio() ) - hvm_inject_hw_exception(TRAP_gp_fault, 0); + else + svm_emulate(regs); break; case VMEXIT_INVLPG: -- 1.8.3.1