[Top] [All Lists]

[PATCH v2 2/2] hugetlb: Provide safer dummy values for HPAGE_MASK and HP

To:,, Andrew Morton <>,
Subject: [PATCH v2 2/2] hugetlb: Provide safer dummy values for HPAGE_MASK and HPAGE_SIZE
From: David Daney <>
Date: Thu, 17 Nov 2011 13:57:30 -0800
Cc: David Daney <>, David Rientjes <>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=tAJyELo+gobkkRdyu5c/rvFRQf97UzCn3GjdNBRp850=; b=FY09QKDtgT+aoUlTbjFcrH7+3vpHF8mxBH3mS7xE8SmG073LXNPtwBVdIOuU6P7ugm /HnVF2zgIC4jF/HYCBItwuFa4RDNb7q+DK7XV+M+sOTNDqq4SRbbdO0yL/WbFJbAgQSG cxiOwrbBe7dIylDDb10+d/t9/Armj3+sWE4Hg=
In-reply-to: <>
References: <>
From: David Daney <>

It was pointed out by David Rientjes that the dummy values for
HPAGE_MASK and HPAGE_SIZE are quite unsafe.  It they are inadvertently
used with !CONFIG_HUGETLB_PAGE, compilation would succeed, but the
resulting code would surly not do anything sensible.

Place BUG() in the these dummy definitions, as we do in similar
circumstances in other places, so any abuse can be easily detected.

Since the only sane place to use these symbols when
!CONFIG_HUGETLB_PAGE is on dead code paths, the BUG() cause any actual
code to be emitted by the compiler.

Cc: David Rientjes <>
Signed-off-by: David Daney <>
 include/linux/hugetlb.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 380451c..3ed6dbd 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -111,8 +111,9 @@ static inline void copy_huge_page(struct page *dst, struct 
page *src)
 #define hugetlb_change_protection(vma, address, end, newprot)
 #ifndef HPAGE_MASK
-#define HPAGE_MASK     PAGE_MASK               /* Keep the compiler happy */
+/* Keep the compiler happy with some dummy (but BUGgy) values */
+#define HPAGE_MASK     ({BUG(); 0; })
+#define HPAGE_SIZE     ({BUG(); 0; })
 #define HPAGE_SHIFT    ({BUG(); 0; })

<Prev in Thread] Current Thread [Next in Thread>