| To: | linux-mips@linux-mips.org, ralf@linux-mips.org, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org |
|---|---|
| Subject: | [PATCH v2 2/2] hugetlb: Provide safer dummy values for HPAGE_MASK and HPAGE_SIZE |
| From: | David Daney <ddaney.cavm@gmail.com> |
| Date: | Thu, 17 Nov 2011 13:57:30 -0800 |
| Cc: | David Daney <david.daney@cavium.com>, David Rientjes <rientjes@google.com> |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; 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: | <1321567050-13197-1-git-send-email-ddaney.cavm@gmail.com> |
| References: | <1321567050-13197-1-git-send-email-ddaney.cavm@gmail.com> |
| Sender: | linux-mips-bounce@linux-mips.org |
From: David Daney <david.daney@cavium.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@google.com>
Signed-off-by: David Daney <david.daney@cavium.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
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH] ath9k: rename ath9k_platform.h to ath_platform.h, Kalle Valo |
|---|---|
| Next by Date: | [PATCH v2 1/2] hugetlb: Provide a default HPAGE_SHIFT if !CONFIG_HUGETLB_PAGE, David Daney |
| Previous by Thread: | [PATCH v2 0/2] Dummy HPAGE_* constants for !CONFIG_HUGETLB_PAGE, David Daney |
| Next by Thread: | Re: [PATCH v2 2/2] hugetlb: Provide safer dummy values for HPAGE_MASK and HPAGE_SIZE, Andrew Morton |
| Indexes: | [Date] [Thread] [Top] [All Lists] |