This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] add kexec_load() syscall

On 05/23/2012 10:37 AM, maximilian attems wrote:
Not sure how to add it properly, this is my first glibc touching,
hints howto do it better are appreciated.

Motivation is to axe the syscall maze in kexec-tools itself and
have this syscall supported in glibc.

Hi Maximilian,

the first question is whether this should be really in glibc. With kexec-tools as only user, we should discuss a bit whether we extend the ABI like this.

Regarding your contribution:
we have some documentation about patches at .

Your patch misses a ChangeLog entry describing what you do, see the ChangeLog file for examples. You can generate entries with Ctrl-x 4 a from emacs.

For larger changes, we would need the copyright assignment as well. Do you have one done?

system calls are added to syscalls.list. It looks like this call is available for all architectures, so you would add it to

With this prototype:
> +kexec_load (void *entry, unsigned long nr_segments,
> +		struct kexec_segment *segments, unsigned long flags)

The line to add would be:
kexec_load EXTRA kexec_load i:pipi kexec_load

And then glibc would add the syscall automatically.

--- misc/Makefile | 2 +- sysdeps/unix/sysv/linux/kexec_load.c | 30 ++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/sys/kexec.h | 20 ++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/kexec_load.c create mode 100644 sysdeps/unix/sysv/linux/sys/kexec.h

diff --git a/misc/Makefile b/misc/Makefile
index d1c0a02..4ce78d2 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -41,7 +41,7 @@ routines := brk sbrk sstk ioctl \
  	    getdtsz \
  	    gethostname sethostname getdomain setdomain \
  	    select pselect \
-	    acct chroot fsync sync fdatasync syncfs reboot \
+	    acct chroot fsync sync fdatasync syncfs reboot kexec_load \
  	    gethostid sethostid \
  	    revoke vhangup \
  	    swapon swapoff mktemp mkstemp mkstemp64 mkdtemp \

Changing the global file is wrong since this is a Linux specific file.

diff --git a/sysdeps/unix/sysv/linux/kexec_load.c b/sysdeps/unix/sysv/linux/kexec_load.c
new file mode 100644
index 0000000..8a38c03
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/kexec_load.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.

As said above, this file is not needed because of syscalls.list.

+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   Lesser General Public License for more details.
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+<>.  */
+/* Call kernel with additional two arguments the syscall requires.  */
+kexec_load (void *entry, unsigned long nr_segments,
+		struct kexec_segment *segments, unsigned long flags)
+  return INLINE_SYSCALL (kexec_load, entry, nr_segments, segments, flags);
diff --git a/sysdeps/unix/sysv/linux/sys/kexec.h b/sysdeps/unix/sysv/linux/sys/kexec.h
new file mode 100644
index 0000000..2ccd643
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sys/kexec.h

This file needs to add to sysdep_headers in sysdeps/unix/sysv/linux/Makefile

This file needs a header.
@@ -0,0 +1,20 @@
+#ifndef _SYS_KEXEC_H
+#define _SYS_KEXEC_H   1
+struct kexec_segment {
+	const void *buf;
+	size_t bufsz;
+	const void *mem;
+	size_t memsz;

Headers should in general work in any order you include them - even as first one.

Just include #include <features.h> first so that __BEGIN_DECLS and __THROW are defined.

Also include <sys/types.h> so that size_t is declared.

+static inline long kexec_load(void *__entry, unsigned long __nr_segments,
+		struct kexec_segment *__segments,
+		unsigned long __flags) __THROW;

static inline is wrong without an implementation.

Just say extern long int (we always add the int).

Also, the function needs a comment explaining the function and each parameter.

+#endif  /* _SYS_KEXEC_H */

thanks for the patch. Could you make the suggested changes and then also build glibc to see that the call is available, please?

 Andreas Jaeger aj@{,} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]