Change to v1 xen grants.

This commit is contained in:
Vladimir Serbinenko 2013-12-17 13:55:47 +01:00
parent 2c384f1e6e
commit 296f76068d
3 changed files with 16 additions and 13 deletions

View file

@ -1,3 +1,7 @@
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
Change to v1 xen grants.
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com> 2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/i386/xen/relocator.S: Fix hypercall ABI violation. * grub-core/lib/i386/xen/relocator.S: Fix hypercall ABI violation.

View file

@ -35,7 +35,7 @@ struct start_info *grub_xen_start_page_addr;
volatile struct xencons_interface *grub_xen_xcons; volatile struct xencons_interface *grub_xen_xcons;
volatile struct shared_info *grub_xen_shared_info; volatile struct shared_info *grub_xen_shared_info;
volatile struct xenstore_domain_interface *grub_xen_xenstore; volatile struct xenstore_domain_interface *grub_xen_xenstore;
volatile grant_entry_v2_t *grub_xen_grant_table; volatile grant_entry_v1_t *grub_xen_grant_table;
static const grub_size_t total_grants = static const grub_size_t total_grants =
GRUB_XEN_PAGE_SIZE / sizeof (grub_xen_grant_table[0]); GRUB_XEN_PAGE_SIZE / sizeof (grub_xen_grant_table[0]);
grub_size_t grub_xen_n_allocated_shared_pages; grub_size_t grub_xen_n_allocated_shared_pages;
@ -53,12 +53,12 @@ grub_xen_alloc_shared_page (domid_t dom, grub_xen_grant_t * grnum)
{ {
void *ret; void *ret;
grub_xen_mfn_t mfn; grub_xen_mfn_t mfn;
volatile grant_entry_v2_t *entry; volatile grant_entry_v1_t *entry;
/* Avoid 0. */ /* Avoid 0. */
for (entry = grub_xen_grant_table; for (entry = grub_xen_grant_table;
entry < grub_xen_grant_table + total_grants; entry++) entry < grub_xen_grant_table + total_grants; entry++)
if (!entry->hdr.flags) if (!entry->flags)
break; break;
if (entry == grub_xen_grant_table + total_grants) if (entry == grub_xen_grant_table + total_grants)
@ -71,11 +71,10 @@ grub_xen_alloc_shared_page (domid_t dom, grub_xen_grant_t * grnum)
return NULL; return NULL;
grub_memset (ret, 0, GRUB_XEN_PAGE_SIZE); grub_memset (ret, 0, GRUB_XEN_PAGE_SIZE);
mfn = grub_xen_ptr2mfn (ret); mfn = grub_xen_ptr2mfn (ret);
entry->full_page.pad0 = 0; entry->frame = mfn;
entry->full_page.frame = mfn; entry->domid = dom;
entry->full_page.hdr.domid = dom;
mb (); mb ();
entry->full_page.hdr.flags = GTF_permit_access; entry->flags = GTF_permit_access;
mb (); mb ();
*grnum = entry - grub_xen_grant_table; *grnum = entry - grub_xen_grant_table;
grub_xen_n_allocated_shared_pages++; grub_xen_n_allocated_shared_pages++;
@ -86,17 +85,17 @@ void
grub_xen_free_shared_page (void *ptr) grub_xen_free_shared_page (void *ptr)
{ {
grub_xen_mfn_t mfn; grub_xen_mfn_t mfn;
volatile grant_entry_v2_t *entry; volatile grant_entry_v1_t *entry;
mfn = grub_xen_ptr2mfn (ptr); mfn = grub_xen_ptr2mfn (ptr);
for (entry = grub_xen_grant_table + 1; for (entry = grub_xen_grant_table + 1;
entry < grub_xen_grant_table + total_grants; entry++) entry < grub_xen_grant_table + total_grants; entry++)
if (entry->hdr.flags && entry->full_page.frame == mfn) if (entry->flags && entry->frame == mfn)
{ {
mb (); mb ();
entry->hdr.flags = 0; entry->flags = 0;
mb (); mb ();
entry->full_page.frame = 0; entry->frame = 0;
mb (); mb ();
} }
grub_xen_n_allocated_shared_pages--; grub_xen_n_allocated_shared_pages--;
@ -373,7 +372,7 @@ map_all_pages (void)
grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver));
gnttab_setver.version = 2; gnttab_setver.version = 1;
grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1); grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1);
grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup)); grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup));

View file

@ -53,7 +53,7 @@ extern grub_size_t EXPORT_VAR (grub_xen_n_allocated_shared_pages);
extern volatile struct xencons_interface *grub_xen_xcons; extern volatile struct xencons_interface *grub_xen_xcons;
extern volatile struct shared_info *EXPORT_VAR (grub_xen_shared_info); extern volatile struct shared_info *EXPORT_VAR (grub_xen_shared_info);
extern volatile struct xenstore_domain_interface *grub_xen_xenstore; extern volatile struct xenstore_domain_interface *grub_xen_xenstore;
extern volatile grant_entry_v2_t *grub_xen_grant_table; extern volatile grant_entry_v1_t *grub_xen_grant_table;
void EXPORT_FUNC (grub_xen_store_send) (const void *buf_, grub_size_t len); void EXPORT_FUNC (grub_xen_store_send) (const void *buf_, grub_size_t len);
void EXPORT_FUNC (grub_xen_store_recv) (void *buf_, grub_size_t len); void EXPORT_FUNC (grub_xen_store_recv) (void *buf_, grub_size_t len);