mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 0/6] sys_indirect RFC - sys_indirect introduction
@ 2007-06-29 21:48 Davide Libenzi
  2007-06-30  1:48 ` Ulrich Drepper
  0 siblings, 1 reply; 12+ messages in thread
From: Davide Libenzi @ 2007-06-29 21:48 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Andrew Morton, Linus Torvalds, Ulrich Drepper, Ingo Molnar

This patch-set implements the skeleton for a new sys_indirect() system call.
The reason for such system call would be to avoid the proliferation of new
system calls, introduced to only wrap old ones by setting/unsetting a given
context before/after the real system call.
The internal operation of sys_indirect() would be (pseudo-code):

	for_each_ctx(wrap_ctx, &user_ctxs) {
		save_prev_ctx(&saved_chain, tsk->xxx);
		tsk->xxx = wrap_ctx;
	}
	err = call_system_call(nr, params);
	for_each_saved_ctx(ctx, &saved_chain) {
		restore_ctx(tsk->xxx, ctx);
	}
	return err;

To made sys_indirect() decently flexible, and to avoid a sys_indirect2()
anytime soon, a simple "flags" parameter is clearly not sufficent to be
passed down with it.
To be flexible we need to allow 1) more than a simple "flags" to be passed
down 2) more than one context possibly to be set before the real system
call.  Also, the data structures passed down as new-context-to-be-set should
be compat-free, in order to simplify the compat code.
The prototype for sys_indirect() is:

	struct indirect_ctx {
		__u32 ctx;
	};

	long sys_indirect(unsigned int nr,
			const struct indirect_ctx **ctxs,
			unsigned int nctxs,
			const unsigned long *params);

The "struct indirect_ctx" is a stub structure that is supposed to be the
base for all the context set/unset operations.
An example usage for userspace POV (referring to the example in the next
patches) is:

[include/linux/indirect.h]
	#define SYSIND_CTX_OPENFLAGS	0
	struct sysind_ctx_OPENFLAGS {
		__u32 ctx;
		__u32 flags;
	};

[userspace]
	struct sysind_ctx_OPENFLAGS octx;
	struct indirect_ctx *ctxs[1];
	unsigned long params[6];
	
	octx.ctx = SYSIND_CTX_OPENFLAGS;
	octx.flags = O_CLOEXEC;
	ctxs[0] = (struct indirect_ctx *) &octx;
	params[0] = domain;
	params[1] = type;
	params[2] = proto;
	res = indirect(__NR_socket, ctxs, 1, params);


The sys_indirect() system call requires a small arch-dependent asm function
call_syscall() in order to call a system call by passing call number and
parameters (compat_call_syscall() is also needed for archs having 32 bit compat).
I currently implemented them for i386 and x86-64.
The following patches builds but are totally untested at the moment.
Comments?




- Davide



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-07-03  0:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-29 21:48 [patch 0/6] sys_indirect RFC - sys_indirect introduction Davide Libenzi
2007-06-30  1:48 ` Ulrich Drepper
2007-06-30 19:23   ` Davide Libenzi
2007-06-30 21:54     ` Ulrich Drepper
2007-06-30 22:27       ` Davide Libenzi
2007-06-30 22:32         ` Davide Libenzi
2007-07-01 16:25           ` Ulrich Drepper
2007-07-01 17:09             ` Davide Libenzi
2007-07-02 14:09               ` Ulrich Drepper
2007-07-02 22:37                 ` Davide Libenzi
2007-07-03  0:28                   ` Ulrich Drepper
2007-07-03  0:37                     ` Davide Libenzi

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

all inboxes | Powered by JetHome®