[patch] sys_subpage_prot for powerpc linux

simon at transitive.com simon at transitive.com
Mon Aug 11 14:36:21 UTC 2008


The PowerPC specific system call sys_subpage_prot was released in linux
2.6.25.  This is a basic implmenetation of that.  For those who aren't
aware of it's functionality, it basically allows read/write inhibition
of a 4KB granularity within 64K pages offered by the OS.  The third
parameter may be zero, indicating inhibition bits are to be cleared,
otherwise it contains a vector of 32bit integers, each representing the
inhibition data for a 64K page.

I've basically copied the formatting rules from other system calls with
varying length parameter arrays.

Thanks,
Si

diff -cr a/linux/powerpc/syscallent.h b/linux/powerpc/syscallent.h
*** a/linux/powerpc/syscallent.h	Tue Jul 22 01:22:05 2008
--- b/linux/powerpc/syscallent.h	Mon Aug 11 15:14:54 2008
***************
*** 339,345 ****
  	{ 1,	TD,	sys_eventfd,		"eventfd"		}, /* 307 */
  	{ 5,	0,	printargs,		"SYS_308"		}, /* 308 */
  	{ 5,	0,	printargs,		"SYS_309"		}, /* 309 */
! 	{ 5,	0,	printargs,		"SYS_310"		}, /* 310 */
  	{ 5,	0,	printargs,		"SYS_311"		}, /* 311 */
  	{ 5,	0,	printargs,		"SYS_312"		}, /* 312 */
  	{ 5,	0,	printargs,		"SYS_313"		}, /* 313 */
--- 339,345 ----
  	{ 1,	TD,	sys_eventfd,		"eventfd"		}, /* 307 */
  	{ 5,	0,	printargs,		"SYS_308"		}, /* 308 */
  	{ 5,	0,	printargs,		"SYS_309"		}, /* 309 */
! 	{ 3,    0,      sys_subpage_prot,       "subpage_prot"          }, /* 310 */
  	{ 5,	0,	printargs,		"SYS_311"		}, /* 311 */
  	{ 5,	0,	printargs,		"SYS_312"		}, /* 312 */
  	{ 5,	0,	printargs,		"SYS_313"		}, /* 313 */
diff -cr a/linux/syscall.h b/linux/syscall.h
*** a/linux/syscall.h	Tue May 20 05:56:22 2008
--- b/linux/syscall.h	Mon Aug 11 15:14:54 2008
***************
*** 320,322 ****
--- 320,326 ----
  #endif
  
  int sys_pread64(), sys_pwrite64();
+ 
+ #ifdef __powerpc__
+ int sys_subpage_prot();
+ #endif
diff -cr a/mem.c b/mem.c
*** a/mem.c	Tue May 20 02:11:56 2008
--- b/mem.c	Mon Aug 11 15:14:54 2008
***************
*** 883,885 ****
--- 883,937 ----
  	return 0;
  }
  #endif
+ 
+ #if defined(LINUX) && defined(__powerpc__)
+ int
+ sys_subpage_prot(tcp)
+ struct tcb *tcp;
+ {
+ 	unsigned long cur, end, abbrev_end, entries;
+ 	unsigned int entry, error = 0;
+   
+ 	if(entering(tcp)) {
+ 		tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
+ 		entries = tcp->u_arg[1] >> 16;
+ 		if(!entries || !tcp->u_arg[2]) {
+ 			tprintf("{}");
+ 			return 0;
+ 		}
+ 		cur = tcp->u_arg[2];
+ 		end = cur + (sizeof(int) * entries);
+ 		if(!verbose(tcp) || end < tcp->u_arg[2]) {
+ 			tprintf("%#lx", tcp->u_arg[2]);
+ 			return 0;
+ 		}
+ 		if(abbrev(tcp)) {
+ 			abbrev_end = cur + (sizeof(int) * max_strlen);
+ 			if(abbrev_end > end)
+ 				abbrev_end = end;
+ 		} else {
+ 			abbrev_end = end;
+ 		}
+ 		tprintf("{");
+ 		for(; cur < end; cur += sizeof(int)) {
+ 			if(cur > tcp->u_arg[2])
+ 				tprintf(", ");
+ 			if(cur >= abbrev_end) {
+ 				tprintf("...");
+ 				break;
+ 			}
+ 			if(umove(tcp, cur, &entry) < 0) {
+ 				tprintf("?");
+ 				error = 1;
+ 				break;
+ 			} else {
+ 				tprintf("0x%08x", entry);
+ 			}
+ 		}
+ 		if(error)
+ 			tprintf("%#lx", cur);
+ 		tprintf("}");
+ 	}
+ 	return 0;
+ }
+ #endif




More information about the Strace-devel mailing list