kexec support for Linux/m68k (tools part)
Subsystems (2)
v2 cover kexec support for Linux/m68k (tools part)
kexec support for Linux/m68k (tools part)
This is a set of patches to add kexec support for m68k to kexec-tools.
- Kexec only, no kdump support yet (do you have enough RAM to keep a crashdump kernel in memory at all times? ;-)
Patches:
- [PATCH 1/3] kexec: Let slurp_file_len() return the number of bytes
- v2: no changes
- [PATCH 2/3] kexec: Extract slurp_fd()
- v2: new patch
- [PATCH 3/3] kexec: Add m68k support
- v2:
- Fix handling of virtual and physical addresses, for machines where memory doesn't start at zero,
- Print a warning if the kernel size exceeds 4 MiB, as current kernels cannot handle that,
- Check struct bootversion at the start of the kernel, and print a warning if it cannot be found or doesn't match,
- Replace literal 4096 by PAGE_SIZE,
- Handle removal of page zero at the ELF program segment level, as m68kboot does,
- Remove -PAGE_SIZE for the ramdisk location now the bug in locate_hole() is fixed,
- Use endian-correct types for bootinfo,
- Remove unused -? option handling, cfr. commit bf9d0f055c791a26b2237b5a12b48ae1b7e0d550 ("kexec: Remove unused -? option handling"),
- Use <asm/bootinfo.h> instead of our own definitions.
Notes:
- Based on git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
- Tagged bootinfo is read from /proc/bootinfo by default, but this can be overridden using --bootinfo. No bootinfo editor is provided. The kexec command will replace/delete command line and ramdisk tags in the bootinfo.
Have fun!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH v2 1/3 kexec: Let slurp_file_len() return the number of bytes read
Add an optional output parameter to slurp_file_len() so it can return the actual number of bytes read.
--- kexec/arch/i386/crashdump-x86.c | 5 ++--- kexec/kexec.c | 4 +++- kexec/kexec.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
kexec/arch/i386/crashdump-x86.c +2 -3
@@ -121,7 +121,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),struct mem_ehdr ehdr;struct mem_phdr *phdr, *end_phdr;int align; -unsigned long size; +off_t size;uint32_t elf_flags =0 ;if (elf_info->machine !=EM_X86_64 )
@@ -131,8 +131,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),return 0 ; align =getpagesize (); - size =KCORE_ELF_HEADERS_SIZE ; - buf =slurp_file_len (kcore, size); + buf =slurp_file_len (kcore,KCORE_ELF_HEADERS_SIZE , &size);if (!buf) {fprintf (stderr,"Cannot read %s: %s\n" , kcore,strerror (errno));return -1 ;
kexec/kexec.c +3 -1
@@ -537,7 +537,7 @@ char *slurp_file(const char *filename, off_t *r_size)/* This functions reads either specified number of bytes from the file or lesser if EOF is met. */ -char *slurp_file_len (const char *filename,off_t size) +char *slurp_file_len (const char *filename,off_t size,off_t *nread) {int fd;char *buf;
@@ -575,6 +575,8 @@ char *slurp_file_len(const char *filename, off_t size)die ("Close of %s failed: %s\n" , filename,strerror (errno)); } +if (nread) + *nread = progress;return buf; }
kexec/kexec.h +1 -1
@@ -237,7 +237,7 @@ extern void die(const char *fmt, ...)extern void *xmalloc (size_t size);extern void *xrealloc (void *ptr,size_t size);extern char *slurp_file (const char *filename,off_t *r_size); -extern char *slurp_file_len (const char *filename,off_t size); +extern char *slurp_file_len (const char *filename,off_t size,off_t *nread);extern char *slurp_decompress_file (const char *filename,off_t *r_size);extern unsigned long virt_to_phys (unsigned long addr); extern void add_segment(struct kexec_info *info,
Signature · 1 line
1.7.9.5
PATCH v2 2/3 kexec: Extract slurp_fd()
In reply to Geert UytterhoevenFactor out the common part of slurp_file() and slurp_file_len() into a new helper function slurp_fd().
--- kexec/kexec.c | 92 +++++++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 49 deletions(-)
kexec/kexec.c +43 -49
@@ -469,14 +469,46 @@ static int add_backup_segments(struct kexec_info *info,return 0 ; } +static char *slurp_fd (int fd,const char *filename,off_t size,off_t *nread) +{ +char *buf; +off_t progress; +ssize_t result; + + buf =xmalloc (size); + progress =0 ; +while (progress < size) { + result =read (fd, buf + progress, size - progress); +if (result <0 ) { +if ((errno ==EINTR ) || (errno ==EAGAIN )) +continue ; +fprintf (stderr,"Read on %s failed: %s\n" , filename, +strerror (errno)); +free (buf); +close (fd); +return NULL ; + } +if (result ==0 ) +/* EOF */ +break ; + progress += result; + } + result =close (fd); +if (result <0 ) +die ("Close of %s failed: %s\n" , filename,strerror (errno)); + +if (nread) + *nread = progress; +return buf; +} +char *slurp_file (const char *filename,off_t *r_size) {int fd;char *buf; -off_t size, progress, err; +off_t size, err, nread;ssize_t result;struct stat stats; -if (!filename) { *r_size =0 ;
@@ -512,25 +544,14 @@ char *slurp_file(const char *filename, off_t *r_size) size = stats.st_size; } + buf =slurp_fd (fd, filename, size, &nread); +if (!buf) +die ("Cannot read %s" , filename); + +if (nread != size) +die ("Read on %s ended before stat said it should\n" , filename); + *r_size = size; - buf =xmalloc (size); - progress =0 ; -while (progress < size) { - result =read (fd, buf + progress, size - progress); -if (result <0 ) { -if ((errno ==EINTR ) || (errno ==EAGAIN )) -continue ; -die ("read on %s of %ld bytes failed: %s\n" , filename, - (size - progress)+0UL ,strerror (errno)); - } -if (result ==0 ) -die ("read on %s ended before stat said it should\n" , filename); - progress += result; - } - result =close (fd); -if (result <0 ) { -die ("Close of %s failed: %s\n" , filename,strerror (errno)); - }return buf; }
@@ -540,9 +561,6 @@ char *slurp_file(const char *filename, off_t *r_size)char *slurp_file_len (const char *filename,off_t size,off_t *nread) {int fd; -char *buf; -off_t progress; -ssize_t result;if (!filename)return 0 ;
@@ -552,32 +570,8 @@ char *slurp_file_len(const char *filename, off_t size, off_t *nread) strerror(errno));return 0 ; } - buf =xmalloc (size); - progress =0 ; -while (progress < size) { - result =read (fd, buf + progress, size - progress); -if (result <0 ) { -if ((errno ==EINTR ) || (errno ==EAGAIN )) -continue ; -fprintf (stderr,"read on %s of %ld bytes failed: %s\n" , - filename, (size - progress)+0UL , -strerror (errno)); -free (buf); -return 0 ; - } -if (result ==0 ) -/* EOF */ -break ; - progress += result; - } - result =close (fd); -if (result <0 ) { -die ("Close of %s failed: %s\n" , - filename,strerror (errno)); - } -if (nread) - *nread = progress; -return buf; + +return slurp_fd (fd, filename, size, nread); }char *slurp_decompress_file (const char *filename,off_t *r_size)
Signature · 1 line
1.7.9.5
PATCH v2 3/3 kexec: Add m68k support
In reply to Geert Uytterhoeven---
v2:
- Fix handling of virtual and physical addresses, for machines where memory doesn't start at zero,
- Print a warning if the kernel size exceeds 4 MiB, as current kernels cannot handle that,
- Check struct bootversion at the start of the kernel, and print a warning if it cannot be found or doesn't match,
- Replace literal 4096 by PAGE_SIZE,
- Handle removal of page zero at the ELF program segment level, as m68kboot does,
- Remove -PAGE_SIZE for the ramdisk location now the bug in locate_hole() is fixed,
- Use endian-correct types for bootinfo,
- Remove unused -? option handling, cfr. commit
bf9d0f055c791a26b2237b5a12b48ae1b7e0d550 ("kexec: Remove unused -?
option handling"),
- Use <asm/bootinfo.h> instead of our own definitions.
---
configure.ac | 2 +-
kexec/Makefile | 1 +
kexec/arch/m68k/Makefile | 14 ++
kexec/arch/m68k/bootinfo.c | 262 ++++++++++++++++++++++++++++++++
kexec/arch/m68k/bootinfo.h | 43 ++++++
kexec/arch/m68k/include/arch/options.h | 45 ++++++
kexec/arch/m68k/kexec-elf-m68k.c | 182 ++++++++++++++++++++++
kexec/arch/m68k/kexec-elf-rel-m68k.c | 37 +++++
kexec/arch/m68k/kexec-m68k.c | 104 +++++++++++++
kexec/arch/m68k/kexec-m68k.h | 9 ++
kexec/kexec-syscall.h | 7 +
11 files changed, 705 insertions(+), 1 deletion(-)
create mode 100644 kexec/arch/m68k/Makefile
create mode 100644 kexec/arch/m68k/bootinfo.c
create mode 100644 kexec/arch/m68k/bootinfo.h
create mode 100644 kexec/arch/m68k/include/arch/options.h
create mode 100644 kexec/arch/m68k/kexec-elf-m68k.c
create mode 100644 kexec/arch/m68k/kexec-elf-rel-m68k.c
create mode 100644 kexec/arch/m68k/kexec-m68k.c
create mode 100644 kexec/arch/m68k/kexec-m68k.hconfigure.ac +1 -1
@@ -45,7 +45,7 @@ case $target_cpu in cris|crisv32 ) ARCH="cris" ;; - ia64|x86_64|alpha ) + ia64|x86_64|alpha|m68k ) ARCH="$target_cpu" ;; * )
kexec/Makefile +1 -0
@@ -72,6 +72,7 @@ include $(srcdir)/kexec/arch/alpha/Makefile include $(srcdir)/kexec/arch/arm/Makefile include $(srcdir)/kexec/arch/i386/Makefile include $(srcdir)/kexec/arch/ia64/Makefile +include $(srcdir)/kexec/arch/m68k/Makefile include $(srcdir)/kexec/arch/mips/Makefile include $(srcdir)/kexec/arch/cris/Makefile include $(srcdir)/kexec/arch/ppc/Makefile
kexec/arch/m68k/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# kexec m68k (linux booting linux) +# +m68k_KEXEC_SRCS = kexec/arch/m68k/kexec-m68k.c +m68k_KEXEC_SRCS += kexec/arch/m68k/kexec-elf-m68k.c +m68k_KEXEC_SRCS += kexec/arch/m68k/kexec-elf-rel-m68k.c +m68k_KEXEC_SRCS += kexec/arch/m68k/bootinfo.c + +m68k_ADD_SEGMENT = +m68k_VIRT_TO_PHYS = + +dist += kexec/arch/m68k/Makefile $(m68k_KEXEC_SRCS) \ + kexec/arch/m68k/kexec-m68k.h \ + kexec/arch/m68k/include/arch/options.h
kexec/arch/m68k/bootinfo.c new file +262 -0
262 lines not on this page · raw message
kexec/arch/m68k/bootinfo.h new file +43 -0
43 lines not on this page · raw message
kexec/arch/m68k/include/arch/options.h new file +45 -0
45 lines not on this page · raw message
kexec/arch/m68k/kexec-elf-m68k.c new file +182 -0
182 lines not on this page · raw message
kexec/arch/m68k/kexec-elf-rel-m68k.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* kexec-elf-rel-m68k.c - kexec Elf relocation routines +* +* Copyright (C) 2013 Geert Uytterhoeven +* +* This source code is licensed under the GNU General Public License, +* Version 2. See the file COPYING for more details. +*/ + +#include <stdio.h> +#include <elf.h> +#include "../../kexec.h" +#include "../../kexec-elf.h" + +int machine_verify_elf_rel (struct mem_ehdr *ehdr) +{ +if (ehdr->ei_data !=ELFDATA2MSB ) +return 0 ; +if (ehdr->ei_class !=ELFCLASS32 ) +return 0 ; +if (ehdr->e_machine !=EM_68K ) +return 0 ; +return 1 ; +} + +void machine_apply_elf_rel (struct mem_ehdr *UNUSED (ehdr ),unsigned long r_type, +void *UNUSED (location ), +unsigned long UNUSED (address ), +unsigned long UNUSED (value )) +{ +switch (r_type) { +default : +die ("Unknown rela relocation: %lu\n" , r_type); +break ; + } +return ; +}
kexec/arch/m68k/kexec-m68k.c new file +104 -0
104 lines not on this page · raw message
kexec/arch/m68k/kexec-m68k.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef KEXEC_M68K_H +#define KEXEC_M68K_H + +int elf_m68k_probe (const char *buf,off_t len); +int elf_m68k_load (int argc,char **argv,const char *buf,off_t len, +struct kexec_info *info); +void elf_m68k_usage (void ); + +#endif /* KEXEC_M68K_H */
kexec/kexec-syscall.h +7 -0
@@ -45,6 +45,9 @@#if defined(__mips__)#define __NR_kexec_load 4311#endif +#ifdef __m68k__ +#define __NR_kexec_load 313 +#endif #ifndef __NR_kexec_load#error Unknown processor architecture. Needs a kexec_load syscall number.#endif
@@ -67,6 +70,7 @@ static inline long kexec_load(void *entry, unsigned long nr_segments,*/ #define KEXEC_ARCH_DEFAULT ( 0 << 16)#define KEXEC_ARCH_386 ( 3 << 16) +#define KEXEC_ARCH_68K ( 4 << 16)#define KEXEC_ARCH_X86_64 (62 << 16)#define KEXEC_ARCH_PPC (20 << 16)#define KEXEC_ARCH_PPC64 (21 << 16)
@@ -114,5 +118,8 @@ static inline long kexec_load(void *entry, unsigned long nr_segments,#if defined(__mips__)#define KEXEC_ARCH_NATIVE KEXEC_ARCH_MIPS#endif +#ifdef __m68k__ +#define KEXEC_ARCH_NATIVE KEXEC_ARCH_68K +#endif #endif /* KEXEC_SYSCALL_H */
Signature · 1 line
1.7.9.5
PATCH 1/1 kexec: distribute kexec/arch/m68k/bootinfo.h
--- kexec/arch/m68k/Makefile | 1 + 1 file changed, 1 insertion(+)
kexec/arch/m68k/Makefile +1 -0
@@ -10,5 +10,6 @@ m68k_ADD_SEGMENT = m68k_VIRT_TO_PHYS = dist += kexec/arch/m68k/Makefile $(m68k_KEXEC_SRCS) \ + kexec/arch/m68k/bootinfo.h \ kexec/arch/m68k/kexec-m68k.h \ kexec/arch/m68k/include/arch/options.h
Signature · 6 lines
2.1.1 -- Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
PATCH 1/1 kexec: distribute kexec/arch/m68k/bootinfo.h
In reply to Geert Uytterhoeven--- kexec/arch/m68k/Makefile | 1 + 1 file changed, 1 insertion(+)
kexec/arch/m68k/Makefile +1 -0
@@ -10,5 +10,6 @@ m68k_ADD_SEGMENT = m68k_VIRT_TO_PHYS = dist += kexec/arch/m68k/Makefile $(m68k_KEXEC_SRCS) \ + kexec/arch/m68k/bootinfo.h \ kexec/arch/m68k/kexec-m68k.h \ kexec/arch/m68k/include/arch/options.h
Signature · 6 lines
2.1.2 -- Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Simon Horman
AppliedRe: [PATCH] kexec: distribute kexec/arch/m68k/bootinfo.h
Thanks, applied. Sorry for missing this earlier.
Quoted 24 lines · Andreas Schwab
Signed-off-by Andreas Schwab <[email protected]>--- kexec/arch/m68k/Makefile | 1 + 1 file changed, 1 insertion(+)kexec/arch/m68k/Makefile +1
-0@@ -10,5 +10,6 @@ m68k_ADD_SEGMENT = m68k_VIRT_TO_PHYS = dist += kexec/arch/m68k/Makefile $(m68k_KEXEC_SRCS) \ + kexec/arch/m68k/bootinfo.h \ kexec/arch/m68k/kexec-m68k.h \ kexec/arch/m68k/include/arch/options.hSignature · 6 lines
2.1.2 -- Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 31 lines · Geert Uytterhoeven
kexec support for Linux/m68k (tools part)
This is a set of patches to add kexec support for m68k to kexec-tools.
- Kexec only, no kdump support yet (do you have enough RAM to keep a crashdump kernel in memory at all times? ;-)
Patches:
- [PATCH 1/3] kexec: Letslurp_file_len()return the number of bytes
- v2: no changes
- [PATCH 2/3] kexec: Extractslurp_fd()
- v2: new patch
- [PATCH 3/3] kexec: Add m68k support
- v2:
- Fix handling of virtual and physical addresses, for machines where memory doesn't start at zero,
- Print a warning if the kernel size exceeds 4 MiB, as current kernels cannot handle that,
- Check struct bootversion at the start of the kernel, and print a warning if it cannot be found or doesn't match,
- Replace literal 4096 byPAGE_SIZE,
- Handle removal of page zero at the ELF program segment level, as m68kboot does,
- Remove -PAGE_SIZE for the ramdisk location now the bug inlocate_hole()is fixed,
- Use endian-correct types for bootinfo,
- Remove unused -? option handling, cfr. commitbf9d0f055c791a26b2237b5a12b48ae1b7e0d550("kexec: Remove unused -? option handling"),
- Use <asm/bootinfo.h> instead of our own definitions.
Quoted 7 lines
Notes:
- Based ongit://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git- Tagged bootinfo is read from
/proc/bootinfoby default, but this can be overridden using --bootinfo. No bootinfo editor is provided. The kexec command will replace/delete command line and ramdisk tags in the bootinfo.
Thanks,
I've taken a quick look over this and it seems reasonable to me. However, I wonder if I should wait for review of the kernel-side to be completed before applying the kexec-tools patches.
Let me know what you think.
Quoted 1 line · Simon Horman
I've taken a quick look over this and it seems reasonable to me.
Thanks!
Quoted 4 lines
However, I wonder if I should wait for review of the kernel-side to be completed before applying the kexec-tools patches.
Let me know what you think.
The kexec-tools part seems to be stable. The issues to be sorted out are on the kernel side.
However, it doesn't hurt to wait a little bit more to apply this. We m68k people are patient and used to multi-year development ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 8 lines · Geert Uytterhoeven
Quoted 1 line · Simon Horman
I've taken a quick look over this and it seems reasonable to me.
Thanks!
Quoted 3 lines
However, I wonder if I should wait for review of the kernel-side to be completed before applying the kexec-tools patches.
Quoted 7 lines
Quoted 1 line
Let me know what you think.
The kexec-tools part seems to be stable. The issues to be sorted out are on the kernel side.
However, it doesn't hurt to wait a little bit more to apply this. We m68k people are patient and used to multi-year development ;-)
It is said that patience is a virtue :^)
As the kexec-tools portion of this change isn't useful without the kernel portion I think I would like to wait before applying this series. Please repost once the kernel changes have been merged or if you would like them re-considered for any other reason.
Hi Simon,
Quoted 11 lines · Simon Horman
Quoted 10 lines · Geert Uytterhoeven
Quoted 1 line · Simon Horman
I've taken a quick look over this and it seems reasonable to me.
Thanks!
Quoted 4 lines
However, I wonder if I should wait for review of the kernel-side to be completed before applying the kexec-tools patches.
Let me know what you think.
Quoted 7 lines
Quoted 2 lines
The kexec-tools part seems to be stable. The issues to be sorted out are on the kernel side.
As the kexec-tools portion of this change isn't useful without the kernel portion I think I would like to wait before applying this series. Please repost once the kernel changes have been merged or if you would like them re-considered for any other reason.
The kernel part is working now.
I didn't make any changes to kexec-tools for v3.
Do you want me to resend them anyway, or can you just take v2?
Thanks again!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 22 lines · Geert Uytterhoeven
Hi Simon,
Quoted 11 lines · Simon Horman
Quoted 10 lines · Geert Uytterhoeven
Quoted 1 line · Simon Horman
I've taken a quick look over this and it seems reasonable to me.
Thanks!
Quoted 4 lines
However, I wonder if I should wait for review of the kernel-side to be completed before applying the kexec-tools patches.
Let me know what you think.
Quoted 7 lines
Quoted 2 lines
The kexec-tools part seems to be stable. The issues to be sorted out are on the kernel side.
As the kexec-tools portion of this change isn't useful without the kernel portion I think I would like to wait before applying this series. Please repost once the kernel changes have been merged or if you would like them re-considered for any other reason.
Quoted 4 lines
The kernel part is working now.
I didn't make any changes to kexec-tools for v3.
Do you want me to resend them anyway, or can you just take v2?
Sorry for being slow, I will take v2.
Simon Horman
AppliedQuoted 6 lines · Geert Uytterhoeven
kexec support for Linux/m68k (tools part)
This is a set of patches to add kexec support for m68k to kexec-tools.
- Kexec only, no kdump support yet (do you have enough RAM to keep a crashdump kernel in memory at all times? ;-)
Thanks, applied.
Hi Simon,
Quoted 9 lines · Simon Horman
Quoted 6 lines · Geert Uytterhoeven
kexec support for Linux/m68k (tools part)
This is a set of patches to add kexec support for m68k to kexec-tools.
- Kexec only, no kdump support yet (do you have enough RAM to keep a crashdump kernel in memory at all times? ;-)
Thanks, applied.
Thanks, I have queued the kernel counterpart for 3.14.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 6 lines · Geert Uytterhoeven
Hi Simon,
Quoted 3 lines · Simon Horman
Quoted 2 lines · Geert Uytterhoeven
kexec support for Linux/m68k (tools part)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
This is a set of patches to add kexec support for m68k to kexec-tools.
- Kexec only, no kdump support yet (do you have enough RAM to keep a crashdump kernel in memory at all times? ;-)
Thanks, applied.
Thanks, I have queued the kernel counterpart for 3.14.
Great. It sounds like it would be ideal if a new kexec-tools release coincided with the release of v3.14 of the kernel.