From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mukesh Rathor Subject: [V0 PATCH 4/6] AMD-PVH: Do not get/set vlapic TPR Date: Fri, 12 Dec 2014 18:58:25 -0800 Message-ID: <1418439507-16027-5-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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xzcuw-00051w-7d for xen-devel@lists.xenproject.org; Sat, 13 Dec 2014 02:58:50 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sBD2wihl010987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 13 Dec 2014 02:58:45 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id sBD2whhF021474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 13 Dec 2014 02:58:44 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sBD2whco007049 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 PVH doesn't use apic emulation hence vlapic->regs ptr is not set for it. Signed-off-by: Mukesh Rathor --- xen/arch/x86/hvm/svm/svm.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index dac16f4..4bb4ff2 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1052,7 +1052,7 @@ static void noreturn svm_do_resume(struct vcpu *v) hvm_asid_flush_vcpu(v); } - if ( !vcpu_guestmode ) + if ( !vcpu_guestmode && vcpu_vlapic(v)->regs ) { vintr_t intr; @@ -2247,7 +2247,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs) * NB. We need to preserve the low bits of the TPR to make checked builds * of Windows work, even though they don't actually do anything. */ - if ( !vcpu_guestmode ) { + if ( !vcpu_guestmode && vcpu_vlapic(v)->regs ) { intr = vmcb_get_vintr(vmcb); vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, ((intr.fields.tpr & 0x0F) << 4) | @@ -2628,15 +2628,18 @@ void svm_vmexit_handler(struct cpu_user_regs *regs) } out: - if ( vcpu_guestmode ) - /* Don't clobber TPR of the nested guest. */ - return; - - /* The exit may have updated the TPR: reflect this in the hardware vtpr */ - intr = vmcb_get_vintr(vmcb); - intr.fields.tpr = - (vlapic_get_reg(vcpu_vlapic(v), APIC_TASKPRI) & 0xFF) >> 4; - vmcb_set_vintr(vmcb, intr); + /* Don't clobber TPR of the nested guest. */ + if ( vcpu_guestmode && vcpu_vlapic(v)->regs ) + { + /* + * The exit may have updated the TPR: reflect this in the hardware + * vtpr. + */ + intr = vmcb_get_vintr(vmcb); + intr.fields.tpr = + (vlapic_get_reg(vcpu_vlapic(v), APIC_TASKPRI) & 0xFF) >> 4; + vmcb_set_vintr(vmcb, intr); + } } void svm_trace_vmentry(void) -- 1.8.3.1