[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1321567050-13197-3-git-send-email-ddaney.cavm@gmail.com>
Date: Thu, 17 Nov 2011 13:57:30 -0800
From: David Daney <ddaney.cavm@...il.com>
To: linux-mips@...ux-mips.org, ralf@...ux-mips.org,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Cc: David Daney <david.daney@...ium.com>,
David Rientjes <rientjes@...gle.com>
Subject: [PATCH v2 2/2] hugetlb: Provide safer dummy values for HPAGE_MASK and HPAGE_SIZE
From: David Daney <david.daney@...ium.com>
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 <rientjes@...gle.com>
Signed-off-by: David Daney <david.daney@...ium.com>
---
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 */
-#define HPAGE_SIZE PAGE_SIZE
+/* 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; })
#endif
--
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists