From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xen.org
Cc: andres@gridcentric.ca, tim@xen.org
Subject: [PATCH 1 of 2] Use get page from gfn also in svm code
Date: Fri, 27 Apr 2012 10:36:21 -0400 [thread overview]
Message-ID: <42634eca923f4861984d.1335537381@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1335537380@xdev.gridcentric.ca>
xen/arch/x86/hvm/svm/svm.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
And clean up some unnecessary uses of get_gfn locked.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
diff -r 310e84676db3 -r 42634eca923f xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -232,8 +232,7 @@ static int svm_vmcb_save(struct vcpu *v,
static int svm_vmcb_restore(struct vcpu *v, struct hvm_hw_cpu *c)
{
- unsigned long mfn = 0;
- p2m_type_t p2mt;
+ struct page_info *page = NULL;
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
struct p2m_domain *p2m = p2m_get_hostp2m(v->domain);
@@ -250,10 +249,10 @@ static int svm_vmcb_restore(struct vcpu
{
if ( c->cr0 & X86_CR0_PG )
{
- mfn = mfn_x(get_gfn(v->domain, c->cr3 >> PAGE_SHIFT, &p2mt));
- if ( !p2m_is_ram(p2mt) || !get_page(mfn_to_page(mfn), v->domain) )
+ page = get_page_from_gfn(v->domain, c->cr3 >> PAGE_SHIFT,
+ NULL, P2M_ALLOC);
+ if ( !page )
{
- put_gfn(v->domain, c->cr3 >> PAGE_SHIFT);
gdprintk(XENLOG_ERR, "Invalid CR3 value=0x%"PRIx64"\n",
c->cr3);
return -EINVAL;
@@ -263,9 +262,8 @@ static int svm_vmcb_restore(struct vcpu
if ( v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PG )
put_page(pagetable_get_page(v->arch.guest_table));
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( c->cr0 & X86_CR0_PG )
- put_gfn(v->domain, c->cr3 >> PAGE_SHIFT);
+ v->arch.guest_table =
+ page ? pagetable_from_page(page) : pagetable_null();
}
v->arch.hvm_vcpu.guest_cr[0] = c->cr0 | X86_CR0_ET;
@@ -1321,8 +1319,7 @@ static void svm_do_nested_pgfault(struct
p2m = p2m_get_p2m(v);
_d.gpa = gpa;
_d.qualification = 0;
- mfn = get_gfn_type_access(p2m, gfn, &_d.p2mt, &p2ma, 0, NULL);
- __put_gfn(p2m, gfn);
+ mfn = __get_gfn_type_access(p2m, gfn, &_d.p2mt, &p2ma, 0, NULL, 0);
_d.mfn = mfn_x(mfn);
__trace_var(TRC_HVM_NPF, 0, sizeof(_d), &_d);
@@ -1343,8 +1340,7 @@ static void svm_do_nested_pgfault(struct
if ( p2m == NULL )
p2m = p2m_get_p2m(v);
/* Everything else is an error. */
- mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL);
- __put_gfn(p2m, gfn);
+ mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0);
gdprintk(XENLOG_ERR,
"SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n",
gpa, mfn_x(mfn), p2mt);
next prev parent reply other threads:[~2012-04-27 14:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-27 14:36 [PATCH 0 of 2] RFC More get-page-from-gfn Andres Lagar-Cavilla
2012-04-27 14:36 ` Andres Lagar-Cavilla [this message]
2012-04-27 14:36 ` [PATCH 2 of 2] Expand use of get_page_from_gfn Andres Lagar-Cavilla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42634eca923f4861984d.1335537381@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=andres@gridcentric.ca \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.