From: Avi Kivity <avi@redhat.com>
To: Stephen Donnelly <sfdonnelly@gmail.com>
Cc: Cam Macdonell <cam@cs.ualberta.ca>,
"kvm@vger.kernel.org list" <kvm@vger.kernel.org>
Subject: Re: R/W HG memory mappings with kvm?
Date: Wed, 19 Aug 2009 15:14:10 +0300 [thread overview]
Message-ID: <4A8BEC92.6070105@redhat.com> (raw)
In-Reply-To: <5f370d430908122107j15acd2c7i96d476e69032fadd@mail.gmail.com>
On 08/13/2009 07:07 AM, Stephen Donnelly wrote:
>>> A less intrusive, but uglier, alternative is to call
>>> qemu_ram_alloc() and them mmap(MAP_FIXED) on top of that.
>>>
>> I did try this, but ended up with a BUG on the host in
>> /var/lib/dkms/kvm/84/build/x86/kvm_main.c:1266 gfn_to_pfn() on the
>> line "BUG_ON(!kvm_is_mmio_pfn(pfn));" when the guest accesses the bar.
>>
> It looks to me from the call trace like the guest is writing to the
> memory, gfn_to_pfn() from mmu_guess_page_from_pte_write() gets
> confused because of the mapping.
>
> Inside gfn_to_pfn:
>
> addr = gfn_to_hva(kvm, gfn); correctly returns the host virtual
> address of the external memory mapping.
>
> npages = get_user_pages_fast(addr, 1, 1, page); returns -EFAULT,
> presumably because (vma->vm_flags& (VM_IO | VM_PFNMAP)).
>
> It takes then unlikely branch, and checks the vma, but I don't
> understand what it is doing here: pfn = ((addr - vma->vm_start)>>
> PAGE_SHIFT) + vma->vm_pgoff;
>
It's calculating the pfn according to pfnmap rules.
> In my case addr == vma->vm_start, and vma->vm_pgoff == 0, so pfn ==0.
>
How did you set up that vma? It should point to the first pfn of your
special memory area.
> BUG_ON(!kvm_is_mmio_pfn(pfn)) then triggers.
>
That's correct behaviour. We expect a page that is not controlled by
the kernel here.
> Instrumenting inside gfn_to_pfn I see:
> gfn_to_pfn: gfn f2010 gpte f2010000 hva 7f3eac2b0000 pfn 0 npages -14
> gfn_to_pfn: vma ffff88022142af18 start 7f3eac2b0000 pgoff 0
>
> Any suggestions what should be happening here?
>
Well, we need to understand how that vma came into being and why pgoff == 0.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2009-08-19 12:14 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-05 22:41 R/W HG memory mappings with kvm? Stephen Donnelly
2009-07-06 7:38 ` Avi Kivity
2009-07-07 22:23 ` Stephen Donnelly
2009-07-08 4:36 ` Avi Kivity
2009-07-08 21:33 ` Stephen Donnelly
2009-07-09 8:10 ` Avi Kivity
2009-07-08 21:45 ` Cam Macdonell
2009-07-08 22:01 ` Stephen Donnelly
2009-07-09 6:01 ` Cam Macdonell
2009-07-09 22:38 ` Stephen Donnelly
2009-07-10 17:03 ` Cam Macdonell
2009-07-12 21:28 ` Stephen Donnelly
2009-07-14 22:25 ` [PATCH] Support shared memory device PCI device Cam Macdonell
[not found] ` <5f370d430907262256rd7f9fdalfbbec1f9492ce86@mail.gmail.com>
2009-07-27 14:48 ` R/W HG memory mappings with kvm? Cam Macdonell
2009-07-27 21:32 ` Stephen Donnelly
2009-07-28 8:54 ` Avi Kivity
2009-07-28 23:06 ` Stephen Donnelly
2009-08-13 4:07 ` Stephen Donnelly
2009-08-19 12:14 ` Avi Kivity [this message]
2009-08-23 21:59 ` Stephen Donnelly
2009-08-24 4:55 ` Avi Kivity
2009-08-26 10:22 ` Avi Kivity
2009-08-27 2:39 ` Stephen Donnelly
2009-08-27 2:34 ` Stephen Donnelly
2009-08-27 4:08 ` Avi Kivity
2009-08-30 22:33 ` Stephen Donnelly
2009-08-31 8:44 ` Avi Kivity
2009-08-31 21:13 ` Stephen Donnelly
2009-09-09 12:50 ` Avi Kivity
2009-07-29 23:52 ` Cam Macdonell
2009-07-30 9:31 ` Avi Kivity
2009-09-28 18:27 Tsuyoshi Ozawa
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=4A8BEC92.6070105@redhat.com \
--to=avi@redhat.com \
--cc=cam@cs.ualberta.ca \
--cc=kvm@vger.kernel.org \
--cc=sfdonnelly@gmail.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;
as well as URLs for NNTP newsgroup(s).