Skip to contentSkip to conversation

- Align RSE save area

PATCH In review Jack Steiner 2 participants 2 messages Jan 16, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 - Align RSE save area

Due to a bug in ia64_set_rbs_bot(), the VMA that is created for the RSE save area is not page aligned. The following shows the vma's of a process with a bad alignment for the RSE area (pagesize is 0x4000):

	vm_start            vm_end              vm_flags
	0x0000000000000000  0x0000000000004000  READ MAYREAD IO
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
	0x600007ffffffe000  0x6000080000002000  READ WRITE MAYREAD MAYWRITE GROWSUP
	0x60000ffffff58000  0x60000fffffffc000  READ WRITE MAYREAD MAYWRITE MAYEXEC GROWSDOWN

This is not expected nor correctly handled by the VM code.

When a process that has an unaligned VMA exits, the teardown of the process address space fails. The result is that a pte may be left in a pagetable page when the pagetable page is freed. Pagetable pages are assumed to be all zeros and are cached in a quicklist for subsequent reuse. Pagetable pages that are allocated from this quicklist not zeroed out on reuse (they are *suppose* to be zero).

The process that reuses the pagetable page will "inherit" the stale pages left over from the previous process that used the pagetable page. This was causing really weird failures.

Here is a proposed fix:

arch/ia64/mm/init.c +1 -1
@@ -98,7 +98,7 @@
 
 	if (stack_size > MAX_USER_STACK_SIZE)
 		stack_size = MAX_USER_STACK_SIZE;
-	current->thread.rbs_bot = STACK_TOP - stack_size;
+	current->thread.rbs_bot = PAGE_ALIGN(STACK_TOP - stack_size);
 }
 
 /*
Signature · 4 lines
Thanks

Jack Steiner ([email protected])          651-683-5302
Principal Engineer                      SGI - Silicon Graphics, Inc.
#1 lore raw

But the vm_start and vm_end for the vma mapping the rbs space are both page aligned (irrespective of rbs_bot value). Right? Rbs_bot needs to be just 16 byte aligned and that part is properly done in set_rbs_bot.

rohit

Quoted 9 lines

-----Original Message-----
From: [email protected] [mailto:linux-ia64- [email protected]] On Behalf Of Jack Steiner
Sent: Friday, January 16, 2004 12:48 PM
To: [email protected]; [email protected]
Subject: [PATCH] - Align RSE save area

Due to a bug in ia64_set_rbs_bot(), the VMA that is created for the

RSE

Quoted 6 lines

save area is not page aligned. The following shows the vma's of a process with a bad alignment for the RSE area (pagesize is 0x4000):

	vm_start            vm_end              vm_flags
	0x0000000000000000  0x0000000000004000  READ MAYREAD IO
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
	0x600007ffffffe000  0x6000080000002000  READ WRITE MAYREAD

MAYWRITE

Quoted 2 lines

GROWSUP

	0x60000ffffff58000  0x60000fffffffc000  READ WRITE MAYREAD

MAYWRITE

Quoted 8 lines

MAYEXEC GROWSDOWN

This is not expected nor correctly handled by the VM code.

When a process that has an unaligned VMA exits, the teardown of the process
address space fails. The result is that a pte may be left in a

pagetable

Quoted 2 lines

page
when the pagetable page is freed. Pagetable pages are assumed to be

all

Quoted 3 lines

zeros
and are cached in a quicklist for subsequent reuse. Pagetable pages that are allocated from this quicklist not zeroed out on reuse (they

are

Quoted 4 lines

*suppose*
to be zero).

The process that reuses the pagetable page will "inherit" the stale

pages

Quoted 27 lines

left
over from the previous process that used the pagetable page. This was causing
really weird failures.

Here is a proposed fix:

arch/ia64/mm/init.c +1 -2
@@ -98,7 +98,7 @@
 
 	if (stack_size > MAX_USER_STACK_SIZE)
 		stack_size = MAX_USER_STACK_SIZE;
-	current->thread.rbs_bot = STACK_TOP - stack_size;
+	current->thread.rbs_bot = PAGE_ALIGN(STACK_TOP - stack_size);
 }
 
 /*
 
 
 
--

Thanks

Quoted 6 lines

Jack Steiner ([email protected]) 651-683-5302
Principal Engineer SGI - Silicon Graphics, Inc.

-
To unsubscribe from this list: send the line "unsubscribe linux-ia64"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html