linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix vm_fault_t cast in VM_FAULT_GET_HINDEX()
@ 2019-03-27 20:41 Jann Horn
  0 siblings, 0 replies; only message in thread
From: Jann Horn @ 2019-03-27 20:41 UTC (permalink / raw)
  To: Andrew Morton, jannh
  Cc: Souptick Joarder, Matthew Wilcox, Vlastimil Babka,
	Kirill A. Shutemov, Rik van Riel, linux-kernel, linux-mm

Symmetrically to VM_FAULT_SET_HINDEX(), we need a force-cast in
VM_FAULT_GET_HINDEX() to tell sparse that this is intentional.

Sparse complains about the current code when building a kernel with
CONFIG_MEMORY_FAILURE:

arch/x86/mm/fault.c:1058:53: warning: restricted vm_fault_t degrades to
integer

Fixes: 3d3539018d2c ("mm: create the new vm_fault_t type")
Signed-off-by: Jann Horn <jannh@google.com>
---
 include/linux/mm_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 7eade9132f02..4ef4bbe78a1d 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -671,7 +671,7 @@ enum vm_fault_reason {
 
 /* Encode hstate index for a hwpoisoned large page */
 #define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16))
-#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf)
+#define VM_FAULT_GET_HINDEX(x) (((__force unsigned int)(x) >> 16) & 0xf)
 
 #define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS |	\
 			VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON |	\
-- 
2.21.0.392.gf8f6787159e-goog


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-27 20:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27 20:41 [PATCH] mm: fix vm_fault_t cast in VM_FAULT_GET_HINDEX() Jann Horn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox