From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: "Christian Borntraeger" <borntraeger@de.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
david@redhat.com, "Cornelia Huck" <cohuck@redhat.com>
Subject: [PATCH v1 4/4] KVM: s390: vsie: use common code functions for pinning
Date: Wed, 30 Aug 2017 18:06:03 +0200 [thread overview]
Message-ID: <20170830160603.5452-5-david@redhat.com> (raw)
In-Reply-To: <20170830160603.5452-1-david@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
arch/s390/kvm/vsie.c | 19 +++++--------------
include/linux/kvm_host.h | 1 +
virt/kvm/kvm_main.c | 4 ++--
3 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index b5eec30eb37d..a21763b4c229 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -445,17 +445,12 @@ static int map_prefix(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa)
{
struct page *page;
- hva_t hva;
- int rc;
- hva = gfn_to_hva(kvm, gpa_to_gfn(gpa));
- if (kvm_is_error_hva(hva))
- return -EINVAL;
- rc = get_user_pages_fast(hva, 1, 1, &page);
- if (rc < 0)
- return rc;
- else if (rc != 1)
+ page = gfn_to_page(kvm, gpa_to_gfn(gpa));
+ if (PTR_ERR(page) == -ENOMEM)
return -ENOMEM;
+ if (is_error_page(page))
+ return -EINVAL;
*hpa = (hpa_t) page_to_virt(page) + (gpa & ~PAGE_MASK);
return 0;
}
@@ -463,11 +458,7 @@ static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa)
/* Unpins a page previously pinned via pin_guest_page, marking it as dirty. */
static void unpin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t hpa)
{
- struct page *page;
-
- page = virt_to_page(hpa);
- set_page_dirty_lock(page);
- put_page(page);
+ kvm_release_pfn_dirty(hpa >> PAGE_SHIFT);
/* mark the page always as dirty for migration */
mark_page_dirty(kvm, gpa_to_gfn(gpa));
}
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 6882538eda32..2e754b7c282c 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -667,6 +667,7 @@ kvm_pfn_t __gfn_to_pfn_memslot(struct kvm_memory_slot *slot, gfn_t gfn,
bool *writable);
void kvm_release_pfn_clean(kvm_pfn_t pfn);
+void kvm_release_pfn_dirty(kvm_pfn_t pfn);
void kvm_set_pfn_dirty(kvm_pfn_t pfn);
void kvm_set_pfn_accessed(kvm_pfn_t pfn);
void kvm_get_pfn(kvm_pfn_t pfn);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1b3fa3fc1a78..dc422a007b25 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -122,7 +122,6 @@ static void hardware_disable_all(void);
static void kvm_io_bus_destroy(struct kvm_io_bus *bus);
-static void kvm_release_pfn_dirty(kvm_pfn_t pfn);
static void mark_page_dirty_in_slot(struct kvm_memory_slot *memslot, gfn_t gfn);
__visible bool kvm_rebooting;
@@ -1720,11 +1719,12 @@ void kvm_release_page_dirty(struct page *page)
}
EXPORT_SYMBOL_GPL(kvm_release_page_dirty);
-static void kvm_release_pfn_dirty(kvm_pfn_t pfn)
+void kvm_release_pfn_dirty(kvm_pfn_t pfn)
{
kvm_set_pfn_dirty(pfn);
kvm_release_pfn_clean(pfn);
}
+EXPORT_SYMBOL_GPL(kvm_release_pfn_dirty);
void kvm_set_pfn_dirty(kvm_pfn_t pfn)
{
--
2.13.5
next prev parent reply other threads:[~2017-08-30 16:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 16:05 [PATCH v1 0/4] s390x: one fix and three cleanups David Hildenbrand
2017-08-30 16:06 ` [PATCH v1 1/4] KVM: s390: guestdbg: fix range check David Hildenbrand
2017-08-31 10:13 ` Cornelia Huck
2017-08-31 10:36 ` Christian Borntraeger
2017-08-30 16:06 ` [PATCH v1 2/4] KVM: s390: use WARN_ON_ONCE only for checking David Hildenbrand
2017-08-31 10:16 ` Cornelia Huck
2017-08-31 10:55 ` Christian Borntraeger
2017-08-30 16:06 ` [PATCH v1 3/4] KVM: s390: vsie: cleanup mcck reinjection David Hildenbrand
2017-08-31 11:01 ` Christian Borntraeger
2017-08-31 11:11 ` Cornelia Huck
2017-08-30 16:06 ` David Hildenbrand [this message]
2017-08-31 11:44 ` [PATCH v1 4/4] KVM: s390: vsie: use common code functions for pinning Christian Borntraeger
2017-08-31 12:13 ` David Hildenbrand
2017-08-31 12:22 ` Christian Borntraeger
2017-08-31 13:00 ` David Hildenbrand
2017-09-01 12:49 ` Christian Borntraeger
2017-09-01 13:18 ` David Hildenbrand
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=20170830160603.5452-5-david@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox