Skip to contentSkip to conversation

drivers: xen: unmap Enlighten page before jumping to Linux

PATCH Superseded Dmytro Firsov 2 participants 5 messages Jul 19, 2022 Xen hypervisor interface

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: xen: unmap Enlighten page before jumping to Linux

This commit fixes issue with usage of Xen hypervisor shared info page. Previously U-boot did not unmap it at the end of OS boot process. It leads to repeated mapping during Enlighten initialization in Linux. Xen did not prevent guest from this, so it works but causes weird wierd issues - one memory page, that was returned by memalign in U-boot for Enlighten mapping was not returned to allocator and contained shared info values during Linux run. Also Linux mapped it to another place in memory again.

Now code, that restricts repeated mapping of Enlighten page, is about to be merged to Xen:
https://lore.kernel.org/xen-devel/[email protected]/

So, without unmapping in U-boot, Linux will fail to start. As discussed on the xen-devel mailing list, to fix this issue the code should:
1) Unmap the page
2) Populate the area with memory using XENMEM_populate_physmap

This patch adds page unmapping via XENMEM_remove_from_physmap, fills hole in address space where page was mapped via XENMEM_populate_physmap and return this address to memory allocator for freeing.

---
 drivers/xen/hypervisor.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
drivers/xen/hypervisor.c +31 -0
index 2560894832..9ac377b618 100644
@@ -144,6 +144,36 @@ struct shared_info *map_shared_info(void *p)
 	return HYPERVISOR_shared_info;
 }
 
+void unmap_shared_info(void)
+{
+	xen_pfn_t shared_info_pfn = virt_to_pfn(HYPERVISOR_shared_info);
+	struct xen_remove_from_physmap xrfp;
+	struct xen_memory_reservation reservation;
+	xen_ulong_t nr_exts = 1;
+
+	xrfp.domid = DOMID_SELF;
+	xrfp.gpfn = shared_info_pfn;
+	if (HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrfp) != 0)
+		BUG();
+
+	/*
+	 * After remove from physmap there will be a hole in address space on
+	 * HYPERVISOR_shared_info address, so to free memory allocated with
+	 * memalign and prevent exceptions during access to this page we need to
+	 * fill this 4KB hole with XENMEM_populate_physmap before jumping to Linux.
+	 */
+	reservation.domid = DOMID_SELF;
+	reservation.extent_order = 0;
+	reservation.address_bits = 0;
+	set_xen_guest_handle(reservation.extent_start, &shared_info_pfn);
+	reservation.nr_extents = nr_exts;
+	if (HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation) != nr_exts)
+		BUG();
+
+	/* Now we can return this to memory allocator */
+	free(HYPERVISOR_shared_info);
+}
+
 void do_hypervisor_callback(struct pt_regs *regs)
 {
 	unsigned long l1, l2, l1i, l2i;
@@ -251,4 +281,5 @@ void xen_fini(void)
 	fini_gnttab();
 	fini_xenbus();
 	fini_events();
+	unmap_shared_info();
 }
Signature · 1 line
2.25.1
#1 lore raw

Hi Dmytro,

Quoted 7 lines · Dmytro Firsov

This commit fixes issue with usage of Xen hypervisor shared info page. Previously U-boot did not unmap it at the end of OS boot process. It leads to repeated mapping during Enlighten initialization in Linux. Xen did not prevent guest from this, so it works but causes weird wierd issues - one memory page, that was returned by memalign in U-boot for Enlighten mapping was not returned to allocator and contained shared info values during Linux run.

I can't quite parse this. Do you mean the page will be marked as reserved for Linux and therefore it will never reach Linux's page allocator?

Quoted 7 lines

Also Linux mapped it to another
place in memory again. >
Now code, that restricts repeated mapping of Enlighten page, is about to be merged to Xen:
https://lore.kernel.org/xen-devel/[email protected]/

So, without unmapping in U-boot, Linux will fail to start.

Hmmm... From a discussion with Oleksandr, I was under the impression that this patch would also be necessary without the Xen patch merged. This was in order to prevent a corruption of the shared page [1].

Quoted 8 lines

As discussed
on the xen-devel mailing list, to fix this issue the code should:
1) Unmap the page
2) Populate the area with memory using XENMEM_populate_physmap

This patch adds page unmapping via XENMEM_remove_from_physmap, fills hole in address space where page was mapped via XENMEM_populate_physmap and return this address to memory allocator for freeing.

Is U-boot mapping other shared page from Xen (e.g. grant-table...)?

Quoted 11 lines
---
  drivers/xen/hypervisor.c | 31 +++++++++++++++++++++++++++++++
  1 file changed, 31 insertions(+)
drivers/xen/hypervisor.c +0 -0
index 2560894832..9ac377b618 100644

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 149

Quoted 6 lines
drivers/xen/hypervisor.c +3 -0
@@ -144,6 +144,36 @@ struct shared_info *map_shared_info(void *p)
  	return HYPERVISOR_shared_info;
  }
 
+void unmap_shared_info(void)
+{
+	xen_pfn_t shared_info_pfn = virt_to_pfn(HYPERVISOR_shared_info);

Somewhat unrelated to this patch. Can U-boot be compiled with 16K/64K page granularity?

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 151

Quoted 2 lines
drivers/xen/hypervisor.c +2 -0
+	struct xen_remove_from_physmap xrfp;
+	struct xen_memory_reservation reservation;

AFAICT, there some paddings in the two structure. So I would suggest to zero the structure (including paddings).

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 157

Quoted 6 lines
drivers/xen/hypervisor.c +6 -0
+	xen_ulong_t nr_exts = 1;
+
+	xrfp.domid = DOMID_SELF;
+	xrfp.gpfn = shared_info_pfn;
+	if (HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrfp) != 0)
+		BUG();

If I am not mistaken, U-boot provide a panic() helper. So I would suggest to use it as this would be useful to print with the error returned.

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 160

Quoted 3 lines
drivers/xen/hypervisor.c +3 -0
+
+	/*
+	 * After remove from physmap there will be a hole in address space on

Typo: s/remove/removing/

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 171

Quoted 11 lines
drivers/xen/hypervisor.c +11 -0
+	 * HYPERVISOR_shared_info address, so to free memory allocated with
+	 * memalign and prevent exceptions during access to this page we need to
+	 * fill this 4KB hole with XENMEM_populate_physmap before jumping to Linux.
+	 */
+	reservation.domid = DOMID_SELF;
+	reservation.extent_order = 0;
+	reservation.address_bits = 0;
+	set_xen_guest_handle(reservation.extent_start, &shared_info_pfn);
+	reservation.nr_extents = nr_exts;
+	if (HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation) != nr_exts)
+		BUG();

Same here regarding using panic() rather than BUG()

Quoted 9 lines
drivers/xen/hypervisor.c +5 -0
+
+	/* Now we can return this to memory allocator */
+	free(HYPERVISOR_shared_info);
+}
+
  void do_hypervisor_callback(struct pt_regs *regs)
  {
  	unsigned long l1, l2, l1i, l2i;

drivers/xen/hypervisor.c void xen_fini(void) · line 285

Quoted 5 lines
drivers/xen/hypervisor.c +1 -0
@@ -251,4 +281,5 @@ void xen_fini(void)
  	fini_gnttab();
  	fini_xenbus();
  	fini_events();
+	unmap_shared_info();
  }

[1] https://github.com/xen-troops/u-boot/commit/f759b151116af204a5ab02ace82c09300cd6233a#

Signature · 1 line
Julien Grall
#2 lore raw
Quoted 11 lines · Julien Grall

Hi Dmytro,

Quoted 7 lines · Dmytro Firsov

This commit fixes issue with usage of Xen hypervisor shared info page. Previously U-boot did not unmap it at the end of OS boot process. It leads to repeated mapping during Enlighten initialization in Linux. Xen did not prevent guest from this, so it works but causes weird wierd issues - one memory page, that was returned by memalign in U-boot for Enlighten mapping was not returned to allocator and contained shared info values during Linux run.

Quoted 4 lines

I can't quite parse this. Do you mean the page will be marked as reserved for Linux and therefore it will never reach Linux's page allocator?

No, U-boot memory allocator uses real RAM pages and one of them will be used for shared_info. Previously U-boot did not unmap it when jumped to Linux. So, during Linux run, one of the pages that is marked as RAM in device-tree will contain shared_info values. I don't know how it worked previously, but it definitely will cause weird issue when Linux will try to use it as regular RAM page.

Quoted 7 lines
Quoted 7 lines

Also Linux mapped it to another
place in memory again. >
Now code, that restricts repeated mapping of Enlighten page, is about to be merged to Xen:
https://urldefense.com/v3/__https://lore.kernel.org/xen-devel/[email protected]/__;!!GF_29dbcQIUBPA!2OWttkgakR7s6GUn6e60EweRQ44H-TyI-8wWzhX0vWzR33BJE_z-x_AZ0S5VBBnXwwQ73-eIQ-sNcGLf$
[lore[.]kernel[.]org]

Quoted 6 lines
Quoted 1 line

So, without unmapping in U-boot, Linux will fail to start.

Hmmm... From a discussion with Oleksandr, I was under the impression that this patch would also be necessary without the Xen patch merged. This was in order to prevent a corruption of the shared page [1].

Yes, definitely, but with new patches this problem becomes critical and it will block Linux boot. General problem is explained in previous section. This patch is needed to U-boot even without new patches to Xen, but problem became visible only after them.

Quoted 10 lines
Quoted 8 lines

As discussed
on the xen-devel mailing list, to fix this issue the code should:
    1) Unmap the page
    2) Populate the area with memory using XENMEM_populate_physmap

This patch adds page unmapping via XENMEM_remove_from_physmap, fills hole in address space where page was mapped via XENMEM_populate_physmap and return this address to memory allocator for freeing.

Is U-boot mapping other shared page from Xen (e.g. grant-table...)?

Yes, but only shared_info is mapped with XENMEM_add_to_physmap, so other drivers are not affected.

Quoted 7 lines
Quoted 7 lines

---
  drivers/xen/hypervisor.c | 31 +++++++++++++++++++++++++++++++

  1 file changed, 31 insertions(+)
Quoted 13 lines

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 148

Quoted 10 lines
drivers/xen/hypervisor.c +2 -0
index 2560894832..9ac377b618 100644
@@ -144,6 +144,36 @@ struct shared_info *map_shared_info(void *p)
       return HYPERVISOR_shared_info;
   }
   +void unmap_shared_info(void)
+{
+    xen_pfn_t shared_info_pfn = virt_to_pfn(HYPERVISOR_shared_info);

Somewhat unrelated to this patch. Can U-boot be compiled with 16K/64K page granularity?

I am using it on Armv8 and U-boot have hardcoded PAGE_SHIFT==12, and PAGE_SIZE==(1<<PAGE_SHIFT)==4K

So, 16K/64K is not possible in current implementation for Armv8.

Quoted 6 lines

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 151

Quoted 3 lines
drivers/xen/hypervisor.c +2 -0
+    struct xen_remove_from_physmap xrfp;
+    struct xen_memory_reservation reservation;

AFAICT, there some paddings in the two structure. So I would suggest to zero the structure (including paddings).

I did not see any padding in these structs definition in U-boot, so all fields are initialized. But I can add zeroing with memset in next version to be sure in this if structures will change.

Quoted 11 lines

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 157

Quoted 7 lines
drivers/xen/hypervisor.c +6 -0
+    xen_ulong_t nr_exts = 1;
+
+    xrfp.domid = DOMID_SELF;
+    xrfp.gpfn = shared_info_pfn;
+    if (HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrfp) != 0)
+        BUG();

If I am not mistaken, U-boot provide a panic() helper. So I would suggest to use it as this would be useful to print with the error returned.

Agree, will be fixed in next version.

Quoted 7 lines
Quoted 5 lines
drivers/xen/hypervisor.c +3 -0
+
+    /*
+     * After remove from physmap there will be a hole in address 

space on

Typo: s/remove/removing/

Agree, will be fixed in next version.

Quoted 16 lines
Quoted 15 lines

+     * HYPERVISOR_shared_info address, so to free memory allocated with +     * memalign and prevent exceptions during access to this page we need to
+     * fill this 4KB hole with XENMEM_populate_physmap before jumping to Linux.
+     */
+    reservation.domid = DOMID_SELF;
+    reservation.extent_order = 0;
+    reservation.address_bits = 0;
+    set_xen_guest_handle(reservation.extent_start, &shared_info_pfn); +    reservation.nr_extents = nr_exts;
+    if (HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation) != nr_exts)
+        BUG();

Quoted 1 line

Same here regarding using panic() rather than BUG()

Agree, will be fixed in next version.

Quoted 20 lines
Quoted 10 lines
drivers/xen/hypervisor.c +5 -0
+
+    /* Now we can return this to memory allocator */
+    free(HYPERVISOR_shared_info);
+}
+

  void do_hypervisor_callback(struct pt_regs *regs) {
      unsigned long l1, l2, l1i, l2i;

drivers/xen/hypervisor.c void xen_fini(void) · line 285

Quoted 5 lines
drivers/xen/hypervisor.c +1 -0
@@ -251,4 +281,5 @@ void xen_fini(void)
       fini_gnttab();
       fini_xenbus();
       fini_events();
+    unmap_shared_info();
   }

[1]
https://urldefense.com/v3/__https://github.com/xen-troops/u-boot/commit/f759b151116af204a5ab02ace82c09300cd6233a*__;Iw!!GF_29dbcQIUBPA!2OWttkgakR7s6GUn6e60EweRQ44H-TyI-8wWzhX0vWzR33BJE_z-x_AZ0S5VBBnXwwQ73-eIQ_0Hh8nA$
[github[.]com]

#3 lore raw

Hi,

Quoted 17 lines · Dmytro Firsov
Quoted 11 lines · Julien Grall

Hi Dmytro,

Quoted 7 lines · Dmytro Firsov

This commit fixes issue with usage of Xen hypervisor shared info page. Previously U-boot did not unmap it at the end of OS boot process. It leads to repeated mapping during Enlighten initialization in Linux. Xen did not prevent guest from this, so it works but causes weird wierd issues - one memory page, that was returned by memalign in U-boot for Enlighten mapping was not returned to allocator and contained shared info values during Linux run.

Quoted 4 lines

I can't quite parse this. Do you mean the page will be marked as reserved for Linux and therefore it will never reach Linux's page allocator?

Quoted 6 lines

No, U-boot memory allocator uses real RAM pages and one of them will be used for shared_info. Previously U-boot did not unmap it when jumped to Linux. So, during Linux run, one of the pages that is marked as RAM in device-tree will contain shared_info values. I don't know how it worked previously, but it definitely will cause weird issue when Linux will try to use it as regular RAM page.

Ok. I would suggest to reword the commit message.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Also Linux mapped it to another
place in memory again. >
Now code, that restricts repeated mapping of Enlighten page, is about to be merged to Xen:
https://urldefense.com/v3/__https://lore.kernel.org/xen-devel/[email protected]/__;!!GF_29dbcQIUBPA!2OWttkgakR7s6GUn6e60EweRQ44H-TyI-8wWzhX0vWzR33BJE_z-x_AZ0S5VBBnXwwQ73-eIQ-sNcGLf$
[lore[.]kernel[.]org]

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

So, without unmapping in U-boot, Linux will fail to start.

Hmmm... From a discussion with Oleksandr, I was under the impression that this patch would also be necessary without the Xen patch merged. This was in order to prevent a corruption of the shared page [1].

Yes, definitely, but with new patches this problem becomes critical

I would argue that it was more critical before because you would end up with some random corruption of the shared page. At least, Oleksandr patch bring up some certainty because now Linux can't boot.

Quoted 4 lines

and
it will block Linux boot. General problem is explained in previous section. This patch is needed to U-boot even without new patches to Xen, but problem became visible only after them.

See above, I think the commit message should focus on the corruption rather than Xen forbidding double map. So it is clear that this patch is not to paper over a new issue in Xen (which would technically be a regression) but fixing a *real* problem on any Xen version.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

As discussed
on the xen-devel mailing list, to fix this issue the code should:
    1) Unmap the page
    2) Populate the area with memory using XENMEM_populate_physmap

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This patch adds page unmapping via XENMEM_remove_from_physmap, fills hole in address space where page was mapped via XENMEM_populate_physmap and return this address to memory allocator for freeing.

Is U-boot mapping other shared page from Xen (e.g. grant-table...)?

Yes, but only shared_info is mapped with XENMEM_add_to_physmap, so other drivers are not affected.

Hmmmm... A grep in u-boot source shows that XENMEM_add_to_physmap is used to map grant-table frame. However, the driver seems to use the unallocated address space provided by Xen. So you are fine there.

Quoted 30 lines
Quoted 9 lines
Quoted 9 lines
---
   drivers/xen/hypervisor.c | 31 +++++++++++++++++++++++++++++++
   1 file changed, 31 insertions(+)
Quoted 13 lines

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 148

Quoted 10 lines
drivers/xen/hypervisor.c +2 -0
index 2560894832..9ac377b618 100644
@@ -144,6 +144,36 @@ struct shared_info *map_shared_info(void *p)
       return HYPERVISOR_shared_info;
   }
   +void unmap_shared_info(void)
+{
+    xen_pfn_t shared_info_pfn = virt_to_pfn(HYPERVISOR_shared_info);

Somewhat unrelated to this patch. Can U-boot be compiled with 16K/64K page granularity?

I am using it on Armv8 and U-boot have hardcoded PAGE_SHIFT==12, and PAGE_SIZE==(1<<PAGE_SHIFT)==4K

So, 16K/64K is not possible in current implementation for Armv8.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

drivers/xen/hypervisor.c struct shared_info *map_shared_info(void *p) · line 151

Quoted 2 lines
drivers/xen/hypervisor.c +2 -0
+    struct xen_remove_from_physmap xrfp;
+    struct xen_memory_reservation reservation;

AFAICT, there some paddings in the two structure. So I would suggest to zero the structure (including paddings).

I did not see any padding in these structs definition in U-boot, so all fields are initialized.

There are no explicit padding but there are some implicit one. If you use pahole, you will see:

struct xen_remove_from_physmap {
        domid_t                    domid;                /*     0     2 */

        /* XXX 6 bytes hole, try to pack */

        xen_pfn_t                  gpfn;                 /*     8     8 */

        /* size: 16, cachelines: 1, members: 2 */
        /* sum members: 10, holes: 1, sum holes: 6 */
        /* last cacheline: 16 bytes */
};
struct xen_memory_reservation {
        __guest_handle_64_xen_pfn_t extent_start;        /*     0     8 */
        xen_ulong_t                nr_extents;           /*     8     8 */
        unsigned int               extent_order;         /*    16     4 */
        unsigned int               mem_flags;            /*    20     4 */
        domid_t                    domid;                /*    24     2 */

        /* Force padding: */
        domid_t                    :16;
        domid_t                    :16;
        domid_t                    :16;

        /* size: 32, cachelines: 1, members: 5 */
        /* padding: 6 */
        /* last cacheline: 32 bytes */
};
Quoted 2 lines

But I can add zeroing with memset in next version to be sure in this if structures will change.

AFAIK, = {} should also do the job.

Cheers,

Signature · 1 line
Julien Grall
#4 lore raw
Quoted 52 lines · Julien Grall

Hi,

Quoted 18 lines · Dmytro Firsov
Quoted 12 lines · Julien Grall

Hi Dmytro,

Quoted 8 lines · Dmytro Firsov

This commit fixes issue with usage of Xen hypervisor shared info page. Previously U-boot did not unmap it at the end of OS boot process. It leads to repeated mapping during Enlighten initialization in Linux. Xen did not prevent guest from this, so it works but causes weird wierd issues - one memory page, that was returned by memalign in U-boot
for Enlighten mapping was not returned to allocator and contained shared info values during Linux run.

Quoted 4 lines

I can't quite parse this. Do you mean the page will be marked as reserved for Linux and therefore it will never reach Linux's page allocator?

Quoted 6 lines

No, U-boot memory allocator uses real RAM pages and one of them will be used for shared_info. Previously U-boot did not unmap it when jumped to Linux. So, during Linux run, one of the pages that is marked as RAM in device-tree will contain shared_info values. I don't know how it worked previously, but it definitely will cause weird issue when Linux will try to use it as regular RAM page.

Ok. I would suggest to reword the commit message.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Also Linux mapped it to another
place in memory again. >
Now code, that restricts repeated mapping of Enlighten page, is about to be merged to Xen:
https://urldefense.com/v3/__https://lore.kernel.org/xen-devel/[email protected]/__;!!GF_29dbcQIUBPA!2OWttkgakR7s6GUn6e60EweRQ44H-TyI-8wWzhX0vWzR33BJE_z-x_AZ0S5VBBnXwwQ73-eIQ-sNcGLf$

[lore[.]kernel[.]org]

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

So, without unmapping in U-boot, Linux will fail to start.

Hmmm... From a discussion with Oleksandr, I was under the impression that this patch would also be necessary without the Xen patch merged. This was in order to prevent a corruption of the shared page [1].

Yes, definitely, but with new patches this problem becomes critical

I would argue that it was more critical before because you would end up with some random corruption of the shared page. At least, Oleksandr patch bring up some certainty because now Linux can't boot.

Quoted 8 lines
Quoted 4 lines

and
it will block Linux boot. General problem is explained in previous section. This patch is needed to U-boot even without new patches to Xen, but problem became visible only after them.

See above, I think the commit message should focus on the corruption rather than Xen forbidding double map. So it is clear that this patch is not to paper over a new issue in Xen (which would technically be a regression) but fixing a *real* problem on any Xen version.

Okay, I argee. I will reword commit message with focus on corruption.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

As discussed
on the xen-devel mailing list, to fix this issue the code should:
     1) Unmap the page
     2) Populate the area with memory using XENMEM_populate_physmap

This patch adds page unmapping via XENMEM_remove_from_physmap, fills hole in address space where page was mapped via XENMEM_populate_physmap
and return this address to memory allocator for freeing.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is U-boot mapping other shared page from Xen (e.g. grant-table...)?

Yes, but only shared_info is mapped with XENMEM_add_to_physmap, so other drivers are not affected.

Hmmmm... A grep in u-boot source shows that XENMEM_add_to_physmap is used to map grant-table frame. However, the driver seems to use the unallocated address space provided by Xen. So you are fine there.

Yes, grant-tables are mapped outside of actual RAM, so there is no such problem.

Quoted 45 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

+    struct xen_remove_from_physmap xrfp;
+    struct xen_memory_reservation reservation;

AFAICT, there some paddings in the two structure. So I would suggest to zero the structure (including paddings).

I did not see any padding in these structs definition in U-boot, so all fields are initialized.

There are no explicit padding but there are some implicit one. If you use pahole, you will see:

struct xen_remove_from_physmap {
        domid_t                    domid;                /* 0     2 */

        /* XXX 6 bytes hole, try to pack */

        xen_pfn_t                  gpfn;                 /* 8     8 */

        /* size: 16, cachelines: 1, members: 2 */ /* sum members: 10, holes: 1, sum holes: 6 */ /* last cacheline: 16 bytes */
};

struct xen_memory_reservation {
        __guest_handle_64_xen_pfn_t extent_start;        /* 0     8 */ xen_ulong_t                nr_extents;           /* 8     8 */ unsigned int               extent_order;         /* 16     4 */ unsigned int               mem_flags;            /* 20     4 */ domid_t                    domid;                /* 24     2 */

        /* Force padding: */
        domid_t                    :16;
        domid_t                    :16;
        domid_t                    :16;

        /* size: 32, cachelines: 1, members: 5 */
        /* padding: 6 */
        /* last cacheline: 32 bytes */
};

Quoted 4 lines
Quoted 2 lines

But I can add zeroing with memset in next version to be sure in this if structures will change.

AFAIK, = {} should also do the job.

Okay, thanks, I will add this to second version.

Quoted 3 lines

Cheers,