[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] LLVM optimizations and .init variables usage



Hello,

As some of you know might already know by discussions on IRC newer
versions of Xen compiled with LLVM will trigger a page fault shortly
after boot.

This is due to the usage of opt_bootscrub in init_heap_pages.
opt_bootscrub is defined in the .init section, while init_heap_pages
is not an init function it reads opt_bootscrub depending on the
system_state. LLVM generated code will attempt to load opt_bootscrub
regardless of the value of system_state, under the assumption that
loading a regular global variable have no side effects.

There have been several suggestions about how to solve this:

 - Mark the variable as volatile, or use something like ACCESS_ONCE.
 - Use the weak attribute.
 - Don't declare opt_bootscrub as init. This is AFAIK what Linux would
   do, since init variables can only be used in init functions.

The LLVM bug report is at:

https://bugs.llvm.org/show_bug.cgi?id=39707

I wonder whether we should try to patch this by either using the
volatile or the weak workaround, but then new usages that trigger
similar bugs could be introduced again. Maybe Xen should follow suit
with Linux and limit the usage of init variables to init functions,
this is likely to be safe (since it's what Linux does), and thus would
prevent future similar issues.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.