aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2012-09-03 08:17:50 +0200
committerJan Beulich <jbeulich@suse.com>2012-09-03 08:17:50 +0200
commitaa1c1f4c57720d3f8426aab89cf8217dd687a651 (patch)
tree969de4287a76a9d956f7607bb6cc48bdc2814b2b
parent5fdfc1eedd92bc5358ee3b6e63efb0d60fb835c4 (diff)
downloadxen-aa1c1f4c57720d3f8426aab89cf8217dd687a651.tar.gz
xen-aa1c1f4c57720d3f8426aab89cf8217dd687a651.tar.bz2
xen-aa1c1f4c57720d3f8426aab89cf8217dd687a651.zip
x86: comment opaque expression in __page_to_virt()
mm.h's __page_to_virt() has a rather opaque expression. Comment it. Reported-By: Ian Campbell <ian.campbell@citrix.com> Suggested-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
-rw-r--r--xen/include/asm-x86/mm.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
index 4cba2765fb..2ed53d9416 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -323,6 +323,12 @@ static inline struct page_info *__virt_to_page(const void *v)
static inline void *__page_to_virt(const struct page_info *pg)
{
ASSERT((unsigned long)pg - FRAMETABLE_VIRT_START < FRAMETABLE_VIRT_END);
+ /*
+ * (sizeof(*pg) & -sizeof(*pg)) selects the LS bit of sizeof(*pg). The
+ * division and re-multiplication avoids one shift when sizeof(*pg) is a
+ * power of two (otherwise there would be a right shift followed by a
+ * left shift, which the compiler can't know it can fold into one).
+ */
return (void *)(DIRECTMAP_VIRT_START +
((unsigned long)pg - FRAMETABLE_VIRT_START) /
(sizeof(*pg) / (sizeof(*pg) & -sizeof(*pg))) *