Skip to contentSkip to conversation

xen kernel: build failure

DISCUSSION Christoph Egger 5 participants 9 messages Oct 25, 2011 – Nov 28, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

makes xen kernel compile again.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#1 lore raw
Quoted 7 lines · Christoph Egger

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some reason, in your build environment.

I can't reproduce this.

Quoted 5 lines

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

-- Keir

Quoted 3 lines

Christoph

#2 lore raw
Quoted 5 lines · Keir Fraser
Quoted 3 lines · Christoph Egger

Hi,

Quoted 7 lines
Quoted 4 lines

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some reason, in your build environment.

Oh, local changes caused this. Thanks for the hint.

Christoph

Quoted 21 lines

I can't reproduce this.

Quoted 5 lines

Removing the line

BUILD_BUG_ON(sizeof(*d)> PAGE_SIZE);

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

-- Keir

Quoted 3 lines

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#3 lore raw
In reply to Keir Fraser
Quoted 17 lines · Keir Fraser
Quoted 7 lines · Christoph Egger

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some reason, in your build environment.

I can't reproduce this.

Quoted 2 lines

Removing the line

Quoted 8 lines
Quoted 3 lines

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

Is there a reason for that? What would be the recommended to add something into the struct domain now if we can't make it bigger than a page.

Jean

Quoted 13 lines

 -- Keir

Quoted 3 lines

Christoph

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Jean Guyader
Quoted 19 lines · Keir Fraser
Quoted 7 lines · Christoph Egger

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some reason, in your build environment.

I can't reproduce this.

Quoted 4 lines

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

Is there a reason for that?

Of course there is: Post-boot there shouldn't be any allocations of order greater than zero. This is a generally advisable thing, given that Xen can't reclaim memory arbitrarily from domains, and in particular also necessary for tmem.

Quoted 2 lines

What would be the recommended to add something
into the struct domain now if we can't make it bigger than a page.

Put a pointer to your data (or larger parts that are already there) instead of the data itself into struct domain, and allocate it separately. (You may have seen a patch from Olaf Hering late yesterday or earlier today that moved the mem_event pieces out of there for this very reason.)

#8 lore raw
In reply to Jean Guyader
Quoted 6 lines · Jean Guyader
Quoted 6 lines
Quoted 5 lines

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

makes xen kernel compile again.

Quoted 7 lines
Quoted 4 lines

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

Is there a reason for that? What would be the recommended to add something into the struct domain now if we can't make it bigger than a page.

If the thing being added is sufficiently large and self-contained, it could be allocated separately and a pointer added to the domain struct. Else a large logical piece of the domain struct needs to be split off. Would have to check what would be a nice large piece -- arch.{hvm,pv} for example. Jan might also have an opinion, as he already did some work on shrinking the domain struct.

-- Keir

#5 lore raw
In reply to Jan Beulich
Quoted 35 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Jean Guyader
Quoted 19 lines · Keir Fraser
Quoted 7 lines · Christoph Egger

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some reason, in your build environment.

I can't reproduce this.

Quoted 4 lines

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

Is there a reason for that?

Of course there is: Post-boot there shouldn't be any allocations of order greater than zero. This is a generally advisable thing, given that Xen can't reclaim memory arbitrarily from domains, and in particular also necessary for tmem.

Quoted 10 lines
Quoted 2 lines

What would be the recommended to add something
into the struct domain now if we can't make it bigger than a page.

Put a pointer to your data (or larger parts that are already there) instead of the data itself into struct domain, and allocate it separately. (You may have seen a patch from Olaf Hering late yesterday or earlier today that moved the mem_event pieces out of there for this very reason.)

I've printed sizeof (struct domain) on boot with xen-unstable and it's exactly a PAGE big. That mean that if I want a add a value to the struct domain (event a pointer) I will have to make some room first.

Jean

#6 lore raw
Quoted 47 lines · Jean Guyader
Quoted 35 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Jean Guyader
Quoted 19 lines · Keir Fraser
Quoted 7 lines · Christoph Egger

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some reason, in your build environment.

I can't reproduce this.

Quoted 4 lines

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

Is there a reason for that?

Of course there is: Post-boot there shouldn't be any allocations of order greater than zero. This is a generally advisable thing, given that Xen can't reclaim memory arbitrarily from domains, and in particular also necessary for tmem.

Quoted 10 lines
Quoted 2 lines

What would be the recommended to add something
into the struct domain now if we can't make it bigger than a page.

Put a pointer to your data (or larger parts that are already there) instead of the data itself into struct domain, and allocate it separately. (You may have seen a patch from Olaf Hering late yesterday or earlier today that moved the mem_event pieces out of there for this very reason.)

Quoted 4 lines

I've printed sizeof (struct domain) on boot with xen-unstable and it's exactly a PAGE big. That mean that if I want a add a value to the struct domain (event a pointer) I will have to make some room first.

I can see two candidates, that could be turned into pointers in arch_domain for x86:

    /* nestedhvm: translate l2 guest physical to host physical */
    struct p2m_domain *nested_p2m[MAX_NESTEDP2M];
    mm_lock_t nested_p2m_lock;
or
    struct PITState vpit;

Let me know which one I should pick. Maybe I should modify both to save some space for later.

Jean

#7 lore raw
Quoted 58 lines
Quoted 1 line
Quoted 1 line · Jean Guyader
Quoted 6 lines · Jean Guyader
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Jean Guyader
Quoted 3 lines · Keir Fraser
Quoted 1 line · Christoph Egger
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Hi,

Compiling the xen kernel fails with:

xen/arch/x86/domain.c: In function 'alloc_domain_struct' xen/arch/x86/domain.c:191: error: negative width in bit-field '<anonymous>'

Problem is that struct domain has grown bigger than a page for some

reason,

Quoted 33 lines
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines

in your build environment.

I can't reproduce this.

Quoted 4 lines

Removing the line

BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

makes xen kernel compile again.

But not actually work properly. We only allocate a single page for the domain struct. If the struct is bigger than a page, you'll get memory corruption at run time.

Is there a reason for that?

Of course there is: Post-boot there shouldn't be any allocations of order greater than zero. This is a generally advisable thing, given that Xen can't reclaim memory arbitrarily from domains, and in particular also necessary for tmem.

Quoted 10 lines
Quoted 2 lines

What would be the recommended to add something
into the struct domain now if we can't make it bigger than a page.

Put a pointer to your data (or larger parts that are already there) instead of the data itself into struct domain, and allocate it separately. (You may have seen a patch from Olaf Hering late yesterday or earlier today that moved the mem_event pieces out of there for this very reason.)

Quoted 4 lines

I've printed sizeof (struct domain) on boot with xen-unstable and it's exactly a PAGE big. That mean that if I want a add a value to the struct domain (event a pointer) I will have to make some room first.

I can see two candidates, that could be turned into pointers in arch_domain for x86:

Quoted 8 lines
    /* nestedhvm: translate l2 guest physical to host physical */
    struct p2m_domain *nested_p2m[MAX_NESTEDP2M];
    mm_lock_t nested_p2m_lock;
or
    struct PITState vpit;

Let me know which one I should pick. Maybe I should modify both to save some space for later.

As written earlier, I think you should leverage Olaf Hering's patch to split out the three "struct mem_event_domain" instances. Other candidates would be the watchdog related items or the evtchn array (the latter would need to be converted to a simple pointer anyway at some point in order to support more than 4096 event channels per domain).

Jan