All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about grant table.
@ 2009-02-24  2:58 Jeniffer, Loren
  2009-02-24  5:45 ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Jeniffer, Loren @ 2009-02-24  2:58 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1109 bytes --]

hi list,

Question about grant table. "The Definitive Guide to the Xen Hypervisor,
Ch 4.3"

struct grant_entry {
/* GTF_xxx: various type and flag information. [XEN,GST] */
uint16_t flags;
/* The domain being granted foreign privileges. [GST] */
domid_t domid;
/*
* GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
* GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
*/
uint32_t frame;
};

The book says :

The last two fields in this are quite simple; they identify the domain
to which the rights are granted, and the page frame the entry refers to.
The domain (domid) is always filled in by the domain creating the entry.
If the domain is granting access to one of its own frames, the relevant
frame must be identified by the guest. _If the entry relates to a
transfer, the hypervisor will fill in the frame number after the transfer._

----------------------------------

I want to know what the last sentence means.
If some page is supposed to be transfered to some domain, why the
sending domain fill in the frame number ?
Why does the hypervisor do this ?


[-- Attachment #1.2: Type: text/html, Size: 1737 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Question about grant table
@ 2012-04-23 21:13 Ruslan Nikolaev
  2012-04-24  7:58 ` Jan Beulich
  0 siblings, 1 reply; 6+ messages in thread
From: Ruslan Nikolaev @ 2012-04-23 21:13 UTC (permalink / raw)
  To: xen-devel

Hi

I have a question regarding a grant table. I have a case when I have some shared (between domains) pages mapped to the user space. I created a special driver which implements mmap(). That, in turns, will execute gnttab_map_refs(). This all works fine until I want to do something like exec().

After I do exec(), I want to mmap() the *same* pages (i.e. using the same grant references) to some new user address space which is chosen by mmap(). During exec(), it will invalidate user address space, and  release() from mmu_notifier will be called. This means, that my driver will execute gnttab_unmap_refs. After exec() succeeded, I invoke mmap() again which will do gnttab_map_refs().

At this point I get kernel errors like this:
[  198.939095] BUG: Bad page map in process a.out  pte:80000002457f1167 pmd:245094067
[  198.939099] page:ffffea000915fc40 count:1 mapcount:-1 mapping:          (null) index:0xffff8802d958f720
[  198.939102] page flags: 0x8000000000000814(referenced|dirty|private)
[  198.939109] addr:00007fd302f40000 vm_flags:000e00fb anon_vma:          (null) mapping:ffff8802d782f760 index:0
[  198.939124] vma->vm_ops->fault: 0x0
[  198.939128] vma->vm_file->f_op->mmap: syscall_driver_mmap+0x0/0xc9 [syscall_driver]


So, I have two questions in this regard:
1. Does gnttab_unmap_refs removes grant references, so that I cannot use them any longer? What would be proper way to preserve grant references but at the same time unmap from the current user address space shared pages?

2. What happens to the counters like count, mapcount when I do gnttab_map_refs() and gnntab_unmap_refs()?

Thanks,
Ruslan

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: Getting a bus address for granted page in dom0
@ 2006-11-07 11:26 Keir Fraser
  2006-11-07 15:34 ` Kieran Mansley
  0 siblings, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2006-11-07 11:26 UTC (permalink / raw)
  To: Kieran Mansley, xen-devel

On 6/11/06 14:55, "Kieran Mansley" <kmansley@solarflare.com> wrote:

>> I pass a grant from domU to dom0, and map it in to dom0 using
>> xenbus_map_ring_valloc().  This gives me a "struct vm_struct" which
>> isn't terribly useful as most of it isn't filled out, but it does have a
>> virtual address for the page in dom0.  I need to pass this page to a PCI
>> device, and so would like to use something like pci_map_single() (or
>> dma_map_page()) to convert this virtual address into a bus address.
>> However, neither of these seem to be working as one might hope: they
>> always return the same value regardless of the address you pass in (at
>> least for the valid addresses that I've tried).

Map_ring_valloc() maps the page into the vmalloc area of the kernel address
space. Thus it has no 'struct page' backing it and none of the DMA macros
will work. 

Do you need to map the rings into dom0 addr space at all? If not just do a
GNTMAP_device_map yourself, and this will return a dev_bus_addr that you can
poke into hardware. If you go this route you avoid using the Linux DMA
interfaces altogether.

If you need to be able to use those macros then you need to map the grant
into Linux lowmem. You'll then have a 'struct page' associated with the
virtual address you mapped at, and so long as you update the
physical_to_machine_mapping table you should find the DMA API starts to work
for you.

 -- Keir

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-24 10:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24  2:58 Question about grant table Jeniffer, Loren
2009-02-24  5:45 ` Keir Fraser
  -- strict thread matches above, loose matches on Subject: below --
2012-04-23 21:13 Ruslan Nikolaev
2012-04-24  7:58 ` Jan Beulich
2012-04-24 10:02   ` Ruslan Nikolaev
2006-11-07 11:26 Getting a bus address for granted page in dom0 Keir Fraser
2006-11-07 15:34 ` Kieran Mansley
2007-06-19  1:19   ` question about grant table tgh

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.