Skip to contentSkip to conversation

Guest page hinting: unused / free pages on s390.

PATCH New Martin Schwidefsky 1 participant 1 message Aug 24, 2006

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

PATCH 2/9 Guest page hinting: unused / free pages on s390.

[patch 2/9] Guest page hinting: unused / free pages on s390.

s390 uses the milli-coded ESSA instruction to set the page state. The page state is formed by four guest page states called block usage states and three host page states called block content states.

This patch uses none of the host states and only two of the guest states:
- stable (S): there is essential content in the page
- unused (U): there is no usefull content and any access to the page will cause an addressing exception.

Since the access of unused pages causes addressing exceptions we need to take care with /dev/mem. The copy_{from_to}_user functions need to be able to cope with addressing exceptions for the kernel address space.

---

 arch/s390/Kconfig              |    3 ++
 arch/s390/kernel/head64.S      |   10 +++++++
 arch/s390/lib/uaccess.S        |   18 ++++++++-----
 arch/s390/lib/uaccess64.S      |   18 ++++++++-----
 include/asm-s390/page-states.h |   55 +++++++++++++++++++++++++++++++++++++++++
 include/asm-s390/setup.h       |    1 
 6 files changed, 93 insertions(+), 12 deletions(-)
arch/s390/Kconfig +3 -0
diff -urpN linux-2.6/arch/s390/Kconfig linux-2.6-patched/arch/s390/Kconfig
@@ -463,6 +463,9 @@ config KEXEC
 	  current kernel, and to start another kernel.  It is like a reboot
 	  but is independent of hardware/microcode support.
 
+config PAGE_STATES
+	bool "Enable support for guest page hinting."
+
 endmenu
 
 source "net/Kconfig"
arch/s390/kernel/head64.S +10 -0
diff -urpN linux-2.6/arch/s390/kernel/head64.S linux-2.6-patched/arch/s390/kernel/head64.S
@@ -240,6 +240,16 @@ startup_continue:
 	oi	7(%r12),0x80		# set IDTE flag
 0:
 
+#
+# find out if we have the ESSA instruction
+#
+	la	%r1,0f-.LPG1(%r13)	# set program check address
+	stg	%r1,__LC_PGM_NEW_PSW+8
+	lghi	%r1,0
+	.long	0xb9ab0001		# essa get state
+	oi	6(%r12),0x01		# set ESSA flag
+0:
+
         lpswe .Lentry-.LPG1(13)         # jump to _stext in primary-space,
                                         # virtual and never return ...
         .align 16
arch/s390/lib/uaccess64.S +12 -6
diff -urpN linux-2.6/arch/s390/lib/uaccess64.S linux-2.6-patched/arch/s390/lib/uaccess64.S
@@ -20,14 +20,14 @@
 __copy_from_user_asm:
 	slgr	%r0,%r0
 0:	mvcp	0(%r3,%r2),0(%r4),%r0
-	jnz	1f
+7:	jnz	1f
 	slgr	%r2,%r2
 	br	%r14
 1:	la	%r2,256(%r2)
 	la	%r4,256(%r4)
 	aghi	%r3,-256
 2:	mvcp	0(%r3,%r2),0(%r4),%r0
-	jnz	1b
+8:	jnz	1b
 3:	slgr	%r2,%r2
 	br	%r14
 4:	lghi	%r0,-4096
@@ -39,13 +39,16 @@ __copy_from_user_asm:
 	jnh	6f		# no, the current page faulted
 	# move with the reduced length which is < 256
 5:	mvcp	0(%r5,%r2),0(%r4),%r0
-	slgr	%r3,%r5
+9:	slgr	%r3,%r5
 6:	lgr	%r2,%r3
 	br	%r14
         .section __ex_table,"a"
 	.quad	0b,4b
 	.quad	2b,4b
 	.quad	5b,6b
+	.quad	7b,6b
+	.quad	8b,6b
+	.quad	9b,6b
         .previous
 
         .align 4
@@ -55,14 +58,14 @@ __copy_from_user_asm:
 __copy_to_user_asm:
 	slgr	%r0,%r0
 0:	mvcs	0(%r3,%r4),0(%r2),%r0
-	jnz	1f
+7:	jnz	1f
 	slgr	%r2,%r2
 	br	%r14
 1:	la	%r2,256(%r2)
 	la	%r4,256(%r4)
 	aghi	%r3,-256
 2:	mvcs	0(%r3,%r4),0(%r2),%r0
-	jnz	1b
+8:	jnz	1b
 3:	slgr	%r2,%r2
 	br	%r14
 4:	lghi	%r0,-4096
@@ -74,13 +77,16 @@ __copy_to_user_asm:
 	jnh	6f		# no, the current page faulted
 	# move with the reduced length which is < 256
 5:	mvcs	0(%r5,%r4),0(%r2),%r0
-	slgr	%r3,%r5
+9:	slgr	%r3,%r5
 6:	lgr	%r2,%r3
 	br	%r14
         .section __ex_table,"a"
 	.quad	0b,4b
 	.quad	2b,4b
 	.quad	5b,6b
+	.quad	7b,6b
+	.quad	8b,6b
+	.quad	9b,6b
         .previous
 
         .align 4
arch/s390/lib/uaccess.S +12 -6
diff -urpN linux-2.6/arch/s390/lib/uaccess.S linux-2.6-patched/arch/s390/lib/uaccess.S
@@ -20,14 +20,14 @@
 __copy_from_user_asm:
 	slr	%r0,%r0
 0:	mvcp	0(%r3,%r2),0(%r4),%r0
-	jnz	1f
+7:	jnz	1f
 	slr	%r2,%r2
 	br	%r14
 1:	la	%r2,256(%r2)
 	la	%r4,256(%r4)
 	ahi	%r3,-256
 2:	mvcp	0(%r3,%r2),0(%r4),%r0
-	jnz	1b
+8:	jnz	1b
 3:	slr	%r2,%r2
 	br	%r14
 4:	lhi	%r0,-4096
@@ -39,13 +39,16 @@ __copy_from_user_asm:
 	jnh	6f		# no, the current page faulted
 	# move with the reduced length which is < 256
 5:	mvcp	0(%r5,%r2),0(%r4),%r0
-	slr	%r3,%r5
+9:	slr	%r3,%r5
 6:	lr	%r2,%r3
 	br	%r14
         .section __ex_table,"a"
 	.long	0b,4b
 	.long	2b,4b
 	.long	5b,6b
+	.long	7b,6b
+	.long	8b,6b
+	.long	9b,6b
         .previous
 
         .align 4
@@ -55,14 +58,14 @@ __copy_from_user_asm:
 __copy_to_user_asm:
 	slr	%r0,%r0
 0:	mvcs	0(%r3,%r4),0(%r2),%r0
-	jnz	1f
+7:	jnz	1f
 	slr	%r2,%r2
 	br	%r14
 1:	la	%r2,256(%r2)
 	la	%r4,256(%r4)
 	ahi	%r3,-256
 2:	mvcs	0(%r3,%r4),0(%r2),%r0
-	jnz	1b
+8:	jnz	1b
 3:	slr	%r2,%r2
 	br	%r14
 4:	lhi	%r0,-4096
@@ -74,13 +77,16 @@ __copy_to_user_asm:
 	jnh	6f		# no, the current page faulted
 	# move with the reduced length which is < 256
 5:	mvcs	0(%r5,%r4),0(%r2),%r0
-	slr	%r3,%r5
+9:	slr	%r3,%r5
 6:	lr	%r2,%r3
 	br	%r14
         .section __ex_table,"a"
 	.long	0b,4b
 	.long	2b,4b
 	.long	5b,6b
+	.long	7b,6b
+	.long	8b,6b
+	.long	9b,6b
         .previous
 
         .align 4
include/asm-s390/page-states.h +55 -0

55 lines not on this page · raw message

include/asm-s390/setup.h +1 -0
diff -urpN linux-2.6/include/asm-s390/setup.h linux-2.6-patched/include/asm-s390/setup.h
@@ -39,6 +39,7 @@ extern unsigned long machine_flags;
 #define MACHINE_IS_P390		(machine_flags & 4)
 #define MACHINE_HAS_MVPG	(machine_flags & 16)
 #define MACHINE_HAS_IDTE	(machine_flags & 128)
+#define MACHINE_HAS_ESSA	(machine_flags & 256)
 
 #ifndef __s390x__
 #define MACHINE_HAS_IEEE	(machine_flags & 2)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>