From nobody Sat May 4 03:28:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560776163; cv=none; d=zoho.com; s=zohoarc; b=fQtQkYN8IjN5XmcHwpNR/mQLMQYL2LOboRs8OBVmTx0CvvSYs7nqq0Ndb8n5xdqqBIF3Hur6h3QxzG72607T2M7GGKnY2cwOuUDHOPlffKXgCgi3Utq3br0imyFNBBXGO6rKKRj2ookSXE7tR0utcXK0pOcNW5qNT6pdtNUq4Go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560776163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=B/25lQ2M5bVpozCYJnO7H+S1is6lU9bvVsD/amkt3Tw=; b=nDF3jhM+EVrpMxDmIM78Ok9Yw25XcUcDyhsrZjDi6FhLRXSeasGC9IbnmUJfZ0PFz/2gZrKnQaJNSlFKHQ3Plb4aMGd5Z3/I2HjzpV+mbAG4HKP56Vu72OpodnuzHc9u7vRFUWmkL+xwf+11ydixm+2luatsW9rw5P9QJwFLNxg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560776163634486.5071076196615; Mon, 17 Jun 2019 05:56:03 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hcr9q-0002Lk-JP; Mon, 17 Jun 2019 12:54:46 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hcr9o-0002Lf-Nb for xen-devel@lists.xenproject.org; Mon, 17 Jun 2019 12:54:44 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1396042f-90ff-11e9-8980-bc764e045a96; Mon, 17 Jun 2019 12:54:43 +0000 (UTC) X-Inumbo-ID: 1396042f-90ff-11e9-8980-bc764e045a96 Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: PLSOq16NuV9vyrTibMrM2sT10ts7W+SDnc76MZHBG4CbMxsleI+xpkCSDqRzLZ7GiDE3aXXX3E F64IGkogs2+FkkrO1DWCoxzsrtzOqhSgCOjNs2Mkvsn3aEKY1kWTKItkeukAFX6c+b8wwXHM+5 h27zDklHo0wIu0738P37LUro88u6d3zc4FE/KtD3IRqG+DM1vRMMizQ+fd0QeAok9J/YPwwBzq rI04K5Fb1T5JpAvujHzGybeaIfZIrI2gBVqD15pQcDGOWTE7ZZ52oW4F0GVzqFw5JiHbpXG5wA 9Ic= X-SBRS: 2.7 X-MesageID: 1819360 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,385,1557201600"; d="scan'208";a="1819360" From: Andrew Cooper To: Xen-devel Date: Mon, 17 Jun 2019 13:54:39 +0100 Message-ID: <1560776079-9866-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/svm: Fix svm_vmcb_dump() when used in current context X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich , Wei Liu , Andrew Cooper , Suravee Suthikulpanit , Boris Ostrovsky , Brian Woods , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" VMExit doesn't switch all state. The FS/GS/TS/LDTR/GSBASE segment information, and SYSCALL/SYSENTER MSRs may still be cached in hardware, rat= her than up-to-date in the VMCB. Export svm_sync_vmcb() via svmdebug.h so svm_vmcb_dump() can use it, and br= ing the VMCB into sync in current context. As a minor optimisation, switch svm_sync_vmcb() to use svm_vm{load,save}_pa= (), as svm->vmcb_pa is always in correct, and this avoids a redundant __pa() translation behind the scenes. Signed-off-by: Andrew Cooper Acked-by: Brian Woods Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Boris Ostrovsky CC: Suravee Suthikulpanit CC: Brian Woods --- xen/arch/x86/hvm/svm/svm.c | 6 +++--- xen/arch/x86/hvm/svm/svmdebug.c | 9 +++++++++ xen/include/asm-x86/hvm/svm/svmdebug.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index cd6a6b3..0eac9ce 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -627,21 +627,21 @@ static void svm_cpuid_policy_changed(struct vcpu *v) cp->extd.ibpb ? MSR_INTERCEPT_NONE : MSR_INTERCEPT_R= W); } =20 -static void svm_sync_vmcb(struct vcpu *v, enum vmcb_sync_state new_state) +void svm_sync_vmcb(struct vcpu *v, enum vmcb_sync_state new_state) { struct svm_vcpu *svm =3D &v->arch.hvm.svm; =20 if ( new_state =3D=3D vmcb_needs_vmsave ) { if ( svm->vmcb_sync_state =3D=3D vmcb_needs_vmload ) - svm_vmload(svm->vmcb); + svm_vmload_pa(svm->vmcb_pa); =20 svm->vmcb_sync_state =3D new_state; } else { if ( svm->vmcb_sync_state =3D=3D vmcb_needs_vmsave ) - svm_vmsave(svm->vmcb); + svm_vmsave_pa(svm->vmcb_pa); =20 if ( svm->vmcb_sync_state !=3D vmcb_needs_vmload ) svm->vmcb_sync_state =3D new_state; diff --git a/xen/arch/x86/hvm/svm/svmdebug.c b/xen/arch/x86/hvm/svm/svmdebu= g.c index d35e405..4293d8d 100644 --- a/xen/arch/x86/hvm/svm/svmdebug.c +++ b/xen/arch/x86/hvm/svm/svmdebug.c @@ -29,6 +29,15 @@ static void svm_dump_sel(const char *name, const struct = segment_register *s) =20 void svm_vmcb_dump(const char *from, const struct vmcb_struct *vmcb) { + struct vcpu *curr =3D current; + + /* + * If we are dumping the VMCB currently in context, some guest state m= ay + * still be cached in hardware. Retrieve it. + */ + if ( vmcb =3D=3D curr->arch.hvm.svm.vmcb ) + svm_sync_vmcb(curr, vmcb_in_sync); + printk("Dumping guest's current state at %s...\n", from); printk("Size of VMCB =3D %zu, paddr =3D %"PRIpaddr", vaddr =3D %p\n", sizeof(struct vmcb_struct), virt_to_maddr(vmcb), vmcb); diff --git a/xen/include/asm-x86/hvm/svm/svmdebug.h b/xen/include/asm-x86/h= vm/svm/svmdebug.h index 658cdd3..330c1d9 100644 --- a/xen/include/asm-x86/hvm/svm/svmdebug.h +++ b/xen/include/asm-x86/hvm/svm/svmdebug.h @@ -22,6 +22,7 @@ #include #include =20 +void svm_sync_vmcb(struct vcpu *v, enum vmcb_sync_state new_state); void svm_vmcb_dump(const char *from, const struct vmcb_struct *vmcb); bool svm_vmcb_isvalid(const char *from, const struct vmcb_struct *vmcb, const struct vcpu *v, bool verbose); --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel