Skip to contentSkip to conversation

x86/mm: Give the correct initail value to the pmd_idx

PATCH In review Minfei Huang 2 participants 2 messages Nov 6, 2014 – Nov 11, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Give the correct initail value to the pmd_idx

The variable value is undefined from the stack eara. So it makes sense to init the variable to run process correctly.

If the variable pmd_idx inits the value more than PTRS_PER_PMD, the count may be smaller than the correct value, and the allocated page may be not enough for pte entry.

The kernel may panic cause by the undefine variable which is allocated from stack.

---
 arch/x86/mm/init_32.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/mm/init_32.c +1 -0
index c8140e1..c23ab1e 100644
@@ -137,6 +137,7 @@ page_table_range_init_count(unsigned long start, unsigned long end)
 
 	vaddr = start;
 	pgd_idx = pgd_index(vaddr);
+	pmd_idx = pmd_index(vaddr);
 
 	for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd_idx++) {
 		for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
Signature · 1 line
1.8.3.1
#1 lore raw

Could someone who help me review my patch?

Thanks
Minfei

Quoted 35 lines · Minfei Huang

The variable value is undefined from the stack eara. So it makes sense to init the variable to run process correctly.

If the variable pmd_idx inits the value more than PTRS_PER_PMD, the count may be smaller than the correct value, and the allocated page may be not enough for pte entry.

The kernel may panic cause by the undefine variable which is allocated from stack.

---
 arch/x86/mm/init_32.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/mm/init_32.c +1 -0
index c8140e1..c23ab1e 100644
@@ -137,6 +137,7 @@ page_table_range_init_count(unsigned long start, unsigned long end)
 
 	vaddr = start;
 	pgd_idx = pgd_index(vaddr);
+	pmd_idx = pmd_index(vaddr);
 
 	for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd_idx++) {
 		for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
Signature · 7 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/