From: Gregory Haskins <ghaskins@novell.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Gregory Haskins <ghaskins@novell.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
avi@redhat.com, glommer@redhat.com
Subject: Re: [KVM PATCH] KVM: introduce "xinterface" API for external interaction with guests
Date: Thu, 16 Jul 2009 11:47:34 -0400 [thread overview]
Message-ID: <4A5F4B96.6050409@novell.com> (raw)
In-Reply-To: <4A5F4945.3080202@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2371 bytes --]
Anthony Liguori wrote:
> Gregory Haskins wrote:
>> +/*
>> + * ------------
>> + * XINTERFACE (External Interface)
>> + * -------------
>> + */
>> +
>> +static struct kvm *
>> +intf_to_kvm(struct kvm_xinterface *intf)
>> +{
>> + return container_of(intf, struct kvm, xinterface);
>> +}
>> +
>> +static unsigned long
>> +xinterface_gpa_to_hva(struct kvm_xinterface *intf, unsigned long gpa)
>> +{
>> + struct kvm *kvm = intf_to_kvm(intf);
>> + unsigned long addr;
>> +
>> + addr = gfn_to_hva(kvm, gpa >> PAGE_SHIFT);
>> + if (kvm_is_error_hva(addr))
>> + return 0;
>> +
>> + return addr + offset_in_page(gpa);
>> +}
>> +
>> +static struct page *
>> +xinterface_gpa_to_page(struct kvm_xinterface *intf, unsigned long gpa)
>> +{
>> + struct kvm *kvm = intf_to_kvm(intf);
>> + struct page *page;
>> +
>> + page = gfn_to_page(kvm, gpa >> PAGE_SHIFT);
>> + if (page == bad_page)
>> + return ERR_PTR(-EINVAL);
>> +
>> + return page;
>> +}
>> +
>> +static void
>> +xinterface_release(struct kvm_xinterface *intf)
>> +{
>> + struct kvm *kvm = intf_to_kvm(intf);
>> +
>> + kvm_put_kvm(kvm);
>> +}
>> +
>> +struct kvm_xinterface_ops _kvm_xinterface_ops = {
>> + .gpa_to_hva = xinterface_gpa_to_hva,
>> + .gpa_to_page = xinterface_gpa_to_page,
>> + .release = xinterface_release,
>> +};
>>
>
> How do you deal with locking?
>
> The mappings (gpa_to_page) are not fixed. They can and do change very
> often. The interface doesn't seem to attempt to cope with this.
Hmm, well I used to need gpa_to_page() in the older version of vbus that
did explicit hypercalls, but I don't actually use it today in v4. I
left it in because it seems like it might be useful in general (perhaps
for Michael). However, if this ends up being a real problem I suppose
we can just drop that vtable entry and let the guy that actually needs
it deal with the issues ;) I really only require gpa_to_hva() in the
short-term.
That said, I think the assumption that was made when I was using this
was that a proper ref for the page was acquired by the gfn_to_page() and
dropped by the caller. This was always used in the context of a
hypercall/vmexit so presumably the gpa should be considered stable
across that call. Is that not true?
Regards,
-Greg
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 266 bytes --]
next prev parent reply other threads:[~2009-07-16 15:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-16 15:19 [KVM PATCH] xinterface Gregory Haskins
2009-07-16 15:19 ` [KVM PATCH] KVM: introduce "xinterface" API for external interaction with guests Gregory Haskins
2009-07-16 15:30 ` Sam Ravnborg
2009-07-16 15:31 ` Gregory Haskins
2009-07-16 15:37 ` Anthony Liguori
2009-07-16 15:47 ` Gregory Haskins [this message]
2009-07-16 16:09 ` Anthony Liguori
2009-07-16 16:52 ` Arnd Bergmann
2009-07-16 18:22 ` Gregory Haskins
2009-07-16 18:53 ` Gregory Haskins
2009-07-16 19:38 ` Zan Lynx
2009-07-16 19:48 ` Gregory Haskins
2009-07-16 19:46 ` Arnd Bergmann
2009-07-17 0:25 ` Gregory Haskins
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=4A5F4B96.6050409@novell.com \
--to=ghaskins@novell.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=glommer@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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.