Kexec / Kdump: Release 20061016 (xen-unstable-11760)
cover Kexec / Kdump: Release 20061016 (xen-unstable-11760)
[PATCH 00/04] Kexec / Kdump: Release 20061016 (xen-unstable-11760)
This is the 20061016 release of the Kexec / Kdump patches for x86 Xen.
Test Results:
Kexec Kexec Kexec Kexec Kdump
Hardware Xen -> Xen -> bzImage -> Xen -> Xen ->
Arch Platform Xen bzImage Xen vmlinux vmlinux
i386 A PASS PASS PASS PASS PASS i386 B (VMX) PASS PASS PASS PASS PASS i386 C (SVM) PASS PASS PASS PASS PASS
i386/PAE A PASS PASS PASS PASS PASS i386/PAE B (VMX) PASS PASS PASS PASS PASS i386/PAE C (SVM) PASS PASS PASS PASS PASS
x86_64 D PASS PASS PASS PASS PASS x86_64 B (VMX) PASS PASS PASS PASS PASS x86_64 C (SVM) PASS PASS PASS PASS PASS
The tests were made with version 46ecc6c6c77b1fab20b08286209631a00eb1049e of kexec-tools from the kexec-tools-testing tree which can be found here:
http://www.kernel.org/git/?p=linux/kernel/git/horms/kexec-tools-testing.git
Hardware Platforms:
A: i386 - VA Linux 1220, 2 x Pentium III 866 Mhz, 2 GB
B: Intel VT - Shuttle XPC SD36G5, 1 x Pentium D 930, 1 GB
C: AMD VT - Shuttle XPC SK22G2, 1 x Athlon64 x2 3800+, 1 GB
D: x86_64 - TYAN Transport GX28 B2881, 2 x Opteron 244 1.8 GHz, 2 GB
Changes:
20061016 - Release 20061016 for xen-unstable-11760
- "Avoid overwriting the current pgd (V4)" patches accepted upstream
- Included in Linux-2.6.19-rc1
- Up-ported Xen code to build on top of merged patches
- Implemented and tested VT-extension support for x86:
- Intel VMX / IVT "Vanderpool" support for x86_32 and x86_64
- AMD SVM / AMD-V "Pacifica" support for x86_32 and x86_64
- Command line parameter is now the same as for Linux:
- For instance, "crashkernel=64M@32M" reserves a 64 MB window at 32 MB
- x86 and ia64 patches are now separated, this release is x86-only
- The x86 port is from this release handled by Magnus Damm
- The ia64 port is handled by Simon Horman
20060931 - Take XIV for xen-unstable-11296 posted by Simon Horman
Enjoy!
/ magnus
PATCH 1/4 Kexec / Kdump: Generic code
[PATCH 01/04] Kexec / Kdump: Generic code
This patch implements the generic portion of the Kexec / Kdump port to Xen.
---
Applies on top of xen-unstable-11760.
linux-2.6-xen-sparse/drivers/xen/core/Makefile | 1 linux-2.6-xen-sparse/drivers/xen/core/reboot.c | 4 patches/linux-2.6.16.29/series | 1 linux-2.6-xen-sparse/drivers/xen/core/crash.c | 49 ++ linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c | 76 +++ patches/linux-2.6.16.29/kexec-generic.patch | 283 ++++++++++++ xen/arch/ia64/xen/crash.c | 26 + xen/arch/ia64/xen/machine_kexec.c | 41 + xen/arch/powerpc/crash.c | 26 + xen/arch/powerpc/machine_kexec.c | 41 + xen/arch/x86/crash.c | 26 + xen/arch/x86/machine_kexec.c | 41 + xen/common/kexec.c | 260 +++++++++++ xen/include/asm-ia64/kexec.h | 32 + xen/include/asm-x86/kexec.h | 31 + xen/include/public/kexec.h | 84 +++ xen/include/xen/elfcore.h | 73 +++ xen/include/xen/kexec.h | 30 + xen/arch/ia64/xen/Makefile | 2 xen/arch/powerpc/Makefile | 2 xen/arch/x86/Makefile | 2 xen/common/Makefile | 1 xen/common/page_alloc.c | 33 - xen/drivers/char/console.c | 3 xen/include/xen/hypercall.h | 6 xen/include/xen/mm.h | 1 26 files changed, 1164 insertions(+), 11 deletions(-)
linux-2.6-xen-sparse/drivers/xen/core/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o obj-$(CONFIG_XEN_SKBUFF) += skbuff.o obj-$(CONFIG_XEN_REBOOT) += reboot.o obj-$(CONFIG_XEN_SMPBOOT) += smpboot.o +obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o
linux-2.6-xen-sparse/drivers/xen/core/crash.c new file +49 -0
49 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c new file +76 -0
76 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/core/reboot.c +4 -0
@@ -65,6 +65,10 @@ void machine_power_off(void)HYPERVISOR_shutdown (SHUTDOWN_poweroff); } +#ifdef CONFIG_KEXEC +void machine_shutdown (void ) { } +#endif +int reboot_thru_bios =0 ;/* for dmi_scan.c */ EXPORT_SYMBOL (machine_restart);EXPORT_SYMBOL (machine_halt);
patches/linux-2.6.16.29/kexec-generic.patch new file +283 -0
283 lines not on this page · raw message
patches/linux-2.6.16.29/series +1 -0
@@ -1,3 +1,4 @@ +kexec-generic.patch blktap-aio-16_03_06.patch device_bind.patch fix-hz-suspend.patch
xen/arch/ia64/xen/Makefile +2 -0
@@ -25,5 +25,7 @@ obj-y += xensetup.o obj-y += xentime.o obj-y += flushd.o obj-y += privop_stat.o +obj-y += machine_kexec.o +obj-y += crash.o obj-$(crash_debug) += gdbstub.o
xen/arch/ia64/xen/crash.c new file +26 -0
@@ -0,0 +1,26 @@ +/********************************************************************** +* arch/ia64/xen/crash.c +* +* Created By: Horms +* +*/ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/kexec.h> + +void machine_crash_shutdown (struct cpu_user_regs *regs) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/ +
xen/arch/ia64/xen/machine_kexec.c new file +41 -0
41 lines not on this page · raw message
xen/arch/powerpc/Makefile +2 -0
@@ -40,6 +40,8 @@ obj-y += smp-tbsync.o obj-y += sysctl.o obj-y += time.o obj-y += usercopy.o +obj-y += machine_kexec.o +obj-y += crash.o obj-$(debug) += 0opt.o obj-$(crash_debug) += gdbstub.o
xen/arch/powerpc/crash.c new file +26 -0
@@ -0,0 +1,26 @@ +/********************************************************************** +* arch/powerpc/crash.c +* +* Created By: Horms +* +*/ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/kexec.h> + +void machine_crash_shutdown (struct cpu_user_regs *regs) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/ +
xen/arch/powerpc/machine_kexec.c new file +41 -0
41 lines not on this page · raw message
xen/arch/x86/Makefile +2 -0
@@ -41,6 +41,8 @@ obj-y += trampoline.o obj-y += traps.o obj-y += usercopy.o obj-y += x86_emulate.o +obj-y += machine_kexec.o +obj-y += crash.o obj-$(crash_debug) += gdbstub.o
xen/arch/x86/crash.c new file +26 -0
@@ -0,0 +1,26 @@ +/****************************************************************************** +* arch/x86/crash.c +* +* Created By: Horms +* +* Should be based heavily on arch/i386/kernel/crash.c from Linux 2.6.16 +*/ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/xen.h> + +void machine_crash_shutdown (struct cpu_user_regs *regs) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/x86/machine_kexec.c new file +41 -0
41 lines not on this page · raw message
xen/common/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-y += event_channel.o obj-y += grant_table.o obj-y += kernel.o obj-y += keyhandler.o +obj-y += kexec.o obj-y += lib.o obj-y += memory.o obj-y += multicall.o
xen/common/kexec.c new file +260 -0
260 lines not on this page · raw message
xen/common/page_alloc.c +22 -11
@@ -213,24 +213,35 @@ void init_boot_pages(paddr_t ps, paddr_t } } +unsigned long alloc_boot_pages_at (unsigned long nr_pfns,unsigned long pfn_at) +{ +unsigned long i; + +for ( i =0 ; i < nr_pfns; i++ ) +if (allocated_in_map (pfn_at + i) ) +break ; + +if ( i == nr_pfns ) + { +map_alloc (pfn_at, nr_pfns); +return pfn_at; + } + +return 0 ; +} +unsigned long alloc_boot_pages (unsigned long nr_pfns,unsigned long pfn_align) { -unsigned long pg, i; +unsigned long pg, i =0 ;for ( pg =0 ; (pg + nr_pfns) < max_page; pg += pfn_align ) { -for ( i =0 ; i < nr_pfns; i++ ) -if (allocated_in_map (pg + i) ) -break ; - -if ( i == nr_pfns ) - { -map_alloc (pg, nr_pfns); -return pg; - } + i =alloc_boot_pages_at (nr_pfns, pg); +if (i !=0 ) +break ; } -return 0 ; +return i; }
xen/drivers/char/console.c +3 -0
@@ -613,6 +613,7 @@ void panic(const char *fmt, ...)char buf[128 ];unsigned long flags;static DEFINE_SPINLOCK (lock); +extern void crash_kexec (struct cpu_user_regs *regs);debugtrace_dump ();
@@ -635,6 +636,8 @@ void panic(const char *fmt, ...)debugger_trap_immediate (); +crash_kexec (NULL ); +if ( opt_noreboot ) {machine_halt ();
xen/include/asm-ia64/kexec.h new file +32 -0
@@ -0,0 +1,32 @@ +/****************************************************************************** +* include/asm-ia64/kexec.h +* +* Created By: Horms +* +*/ + +#ifndef __IA64_KEXEC_H__ +#define __IA64_KEXEC_H__ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/xen.h> + +static void crash_setup_regs (struct cpu_user_regs *newregs, +struct cpu_user_regs *oldregs) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +#endif /* __IA64_KEXEC_H__ */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/ +
xen/include/asm-x86/kexec.h new file +31 -0
@@ -0,0 +1,31 @@ +/****************************************************************************** +* include/asm-x86/kexec.h +* +* Created By: Horms +* +*/ + +#ifndef __X86_KEXEC_H__ +#define __X86_KEXEC_H__ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/xen.h> + +static void crash_setup_regs (struct cpu_user_regs *newregs, +struct cpu_user_regs *oldregs) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +#endif /* __X86_KEXEC_H__ */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/public/kexec.h new file +84 -0
84 lines not on this page · raw message
xen/include/xen/elfcore.h new file +73 -0
73 lines not on this page · raw message
xen/include/xen/hypercall.h +6 -0
@@ -102,4 +102,10 @@ do_hvm_op( unsigned long op, XEN_GUEST_HANDLE(void) arg); +extern long +do_kexec_op ( +unsigned long op, +int arg1, +XEN_GUEST_HANDLE (void ) arg); +#endif /* __XEN_HYPERCALL_H__ */
xen/include/xen/kexec.h new file +30 -0
@@ -0,0 +1,30 @@ +/****************************************************************************** +* include/xen/kexec.h - Internal archtecture independant portion +* +* Created By: Horms <[email protected]> +* +*/ + +#include <public/kexec.h> + +#define MAX_NOTE_BYTES 1024 + +typedef u32 note_buf_t [MAX_NOTE_BYTES /4 ]; +DECLARE_PER_CPU (note_buf_t, crash_notes); + +int machine_kexec_load (int type,xen_kexec_image_t *image); +void machine_kexec_unload (int type,xen_kexec_image_t *image); +void machine_kexec_reserved (xen_kexec_reserve_t *reservation); +void machine_kexec (xen_kexec_image_t *image); +void machine_shutdown (xen_kexec_image_t *image); +void machine_crash_shutdown (cpu_user_regs_t *regs); + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/xen/mm.h +1 -0
@@ -40,6 +40,7 @@ struct page_info;paddr_t init_boot_allocator (paddr_t bitmap_start);void init_boot_pages (paddr_t ps,paddr_t pe);unsigned long alloc_boot_pages (unsigned long nr_pfns,unsigned long pfn_align); +unsigned long alloc_boot_pages_at (unsigned long nr_pfns,unsigned long pfn_at);void end_boot_allocator (void );/* Generic allocator. These functions are *not* interrupt-safe. */
Re: [PATCH 01/04] Kexec / Kdump: Generic code
Some comments:
No need for IO-APIC work on the guest side of the kexec interfaces (e.g., don't call disable_IO_APIC()).
What's the second argument to the hypercall for? There's no clear explanation of what the TYPE parameter means, and currently it is only ever specified as TYPE_CRASH. So what's TYPE_DEFAULT for? And do we really need to avoid copy_to/from_guest so it can't be folded into the structural parameter?
The comment attached to every use of xchg() is dubious. We don't specify warn_unused_result on that function so there's no good reason for the compiler to complain about discarding the result. If it's a reproducible problem it needs investigating. We shouldn't work around a broken compiler.
Attribution at the top of many files: 'Horms' is a bit vague. Could we have a full name? A company name? An email address?
-- Keir
Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 10 lines · Keir Fraser
Some comments:
No need for IO-APIC work on the guest side of the kexec interfaces (e.g., don't call
disable_IO_APIC()).What's the second argument to the hypercall for? There's no clear explanation of what the TYPE parameter means, and currently it is only ever specified as
TYPE_CRASH. So what'sTYPE_DEFAULTfor? And do we really need to avoid copy_to/from_guest so it can't be folded into the structural parameter?
TYPE_DEFAULT is kexec, TYPE_CRASH is kdump.
Its just to avoid a from_guest. If you think that isn't worthwhile we can fold it into the structural parameter.
Quoted 4 lines
The comment attached to every use of
xchg()is dubious. We don't specifywarn_unused_resulton that function so there's no good reason for the compiler to complain about discarding the result. If it's a reproducible problem it needs investigating. We shouldn't work around a broken compiler.
I certainly saw the problem. I'll do some more investigations.
... Actually now that I think about it for a moment, perhaps it was inheriting -Wall from CFLAGS in my environment. If that is the case, then I think the work-around I added is valid.:wq
Quoted 2 lines
Attribution at the top of many files: 'Horms' is a bit vague. Could we have a full name? A company name? An email address?
Sure.
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/
Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 4 lines · Horms
TYPE_DEFAULTis kexec,TYPE_CRASHis kdump.Its just to avoid a
from_guest. If you think that isn't worthwhile we can fold it into the structural parameter.
Yes please. This isn't performance critical. Folding will make the interface better match other hypercalls.
Quoted 5 lines
I certainly saw the problem. I'll do some more investigations.
... Actually now that I think about it for a moment, perhaps it was inheriting -Wall from CFLAGS in my environment. If that is the case, then I think the work-around I added is valid.:wq
Xen is always built with -Wall. I simply don't believe this can be a valid warning message. There's nothing special about __xchg() that should cause complaint when its return value is discarded (a common thing to do in C). Can you repro the problem on vanilla versions of gcc (straight from gnu.org)?
-- Keir
Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 5 lines · Keir Fraser
On 17/10/06 2:25 am, "Horms" <[email protected]> wrote:
Quoted 7 lines
Quoted 4 lines
TYPE_DEFAULTis kexec,TYPE_CRASHis kdump.Its just to avoid a
from_guest. If you think that isn't worthwhile we can fold it into the structural parameter.Yes please. This isn't performance critical. Folding will make the interface better match other hypercalls.
The main thing that I am concerned about is, that in the case that dom0 panics, and we are asking the hypercall to take a dump for us, do we really want a copy_from guest in that path? It seems to me that its best to have that path as simple as possible. But I do argree that it comes at the expense of making the interface a bit unclean.
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/
Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 9 lines · Horms
Quoted 2 lines
Yes please. This isn't performance critical. Folding will make the interface better match other hypercalls.
The main thing that I am concerned about is, that in the case that dom0 panics, and we are asking the hypercall to take a dump for us, do we really want a
copy_fromguest in that path? It seems to me that its best to have that path as simple as possible. But I do argree that it comes at the expense of making the interface a bit unclean.
We need to assume that kernel address space hasn't been too badly compromised, or we couldn't execute as far as making the hypercall. A failed copy_from_guest() in the crash hypercall could simply cause you to use the guest_cpu_user_regs() instead. So you still crash, but the crash site is now the hypercall call site.
-- Keir
Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 12 lines · Keir Fraser
Quoted 9 lines · Horms
Quoted 2 lines
Yes please. This isn't performance critical. Folding will make the interface better match other hypercalls.
The main thing that I am concerned about is, that in the case that dom0 panics, and we are asking the hypercall to take a dump for us, do we really want a
copy_fromguest in that path? It seems to me that its best to have that path as simple as possible. But I do argree that it comes at the expense of making the interface a bit unclean.
Quoted 5 lines
We need to assume that kernel address space hasn't been too badly compromised, or we couldn't execute as far as making the hypercall. A failed
copy_from_guest()in the crash hypercall could simply cause you to use theguest_cpu_user_regs()instead. So you still crash, but the crash site is now the hypercall call site.
Indeed, that is true. I do think there is some value in avoiding guest_cpu_user_regs(), but its theoretical at best. Magnus and I will fold the arguments as you requested.
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/
Re: [PATCH 01/04] Kexec / Kdump: Generic code
In reply to Keir FraserHi Keir, thanks for the comments!
Quoted 4 lines · Keir Fraser
Some comments:
No need for IO-APIC work on the guest side of the kexec interfaces (e.g., don't call
disable_IO_APIC()).
Ok, good idea.
Quoted 6 lines
What's the second argument to the hypercall for? There's no clear explanation of what the TYPE parameter means, and currently it is only ever specified as
TYPE_CRASH. So what'sTYPE_DEFAULTfor? And do we really need to avoid copy_to/from_guest so it can't be folded into the structural parameter?
Quoted 7 lines
The comment attached to every use of
xchg()is dubious. We don't specifywarn_unused_resulton that function so there's no good reason for the compiler to complain about discarding the result. If it's a reproducible problem it needs investigating. We shouldn't work around a broken compiler.Attribution at the top of many files: 'Horms' is a bit vague. Could we have a full name? A company name? An email address?
I agree with all your observations. The purpose of this release was to quickly release something that supports VT hardware and applies to a working x86_64 changeset.
Now when the release is done I'd like to focus on fixing the issues you've brought up together with scratching some itches that I've listed below:
- Headers and comments cleanup.
- Merge load and unload hypercall - make unload same as load NULL.
- Investigate xen/common/kexec.c locking - clean up the code.
- Merge crash and smp code - it may be possible to share cpu stopping code.
- Try to move the ELF notes out of the hypervisor - this is intrusive and complicated.
My plan is to spend the week fixing these things and post a new release some time next week.
Thanks!
/ magnus
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
In reply to Keir FraserQuoted 4 lines · Keir Fraser
The comment attached to every use of
xchg()is dubious. We don't specifywarn_unused_resulton that function so there's no good reason for the compiler to complain about discarding the result. If it's a reproducible problem it needs investigating. We shouldn't work around a broken compiler.
Ok, this seems to be a new 'feature' of gcc4, which has widened the class of things it will complain about with -Wunused-value. Basically any cast of a value causes the compiler to see an expression whose value must not be discarded -- what a pain! This seems to me that it could mean that ignoring return value of any function becomes potentially dangerous, as the function may be a macro that includes a cast on the return value.
I think the fix is -Wno-unused-value. :-) It's about the least useful of the -Wunused-<foo> warnings anyway.
I'll check this in, so please just get rid of the if(xchg()) hacky workaround.
-- Keir
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 13 lines
Quoted 5 lines
The comment attached to every use of
xchg()is dubious. We don't specifywarn_unused_resulton that function so there's no good reason for the compiler to complain about discarding the result. If it's a reproducible problem it needs investigating. We shouldn't work around a broken compiler.Ok, this seems to be a new 'feature' of gcc4, which has widened the class of things it will complain about with -Wunused-value. Basically any cast of a value causes the compiler to see an expression whose value must not be discarded -- what a pain! This seems to me that it could mean that ignoring return value of any function becomes potentially dangerous, as the function may be a macro that includes a cast on the return value.
Quoted 5 lines
I think the fix is -Wno-unused-value. :-) It's about the least useful of the -Wunused-<foo> warnings anyway.
I'll check this in, so please just get rid of the if(xchg()) hacky workaround.
If you wanted to leave the warning on, you should be able to cast to (void) instead of using the if
(void)xchg(&kexec_crash_lock, 0))
in order to explicitly indicate the value is unused. Alternatively I imagine there's a gcc attribute somewhere to tell it not to worry about unused returns from xchg (like for printf)
Cheers,
Mark
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 4 lines · Mark Williamson
If you wanted to leave the warning on, you should be able to cast to (void) instead of using the if
(void)xchg(&kexec_crash_lock, 0))
This would be fine if the problem were known to be restricted to xchg(), but it's not. For example, on my build box ignoring the return value of strncmp() can in some cases trigger the same warning. This is because of some optimisation trickery which includes casting the return value of a memcpy() to char *. Because callers are usually unaware of such trickery, ignoring the return value of any function that produces a return value becomes hazardous.
Quoted 3 lines
in order to explicitly indicate the value is unused. Alternatively I imagine there's a gcc attribute somewhere to tell it not to worry about unused returns from xchg (like for printf)
Which attribute would this be? There's one to force a warning, but I don't believe there's one to force the opposite. Anyway, this problem is caused by a cast of the return value, so it's not actually a property of the C function itself.
-- Keir
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 3 lines
This would be fine if the problem were known to be restricted to
xchg(), but it's not. For example, on my build box ignoring the return value ofstrncmp()can in some cases trigger the same warning.
Does that happen in the tree at the moment? In any case, I guess it's not something we want to bite us in the bum in future!
Quoted 5 lines
This is because of
some optimisation trickery which includes casting the return value of amemcpy()to char *. Because callers are usually unaware of such trickery, ignoring the return value of any function that produces a return value becomes hazardous.
Oh sorry, I see. How icky.
Quoted 4 lines
Which attribute would this be? There's one to force a warning, but I don't believe there's one to force the opposite. Anyway, this problem is caused by a cast of the return value, so it's not actually a property of the C function itself.
Ah, I hadn't understood that it was caused by the cast in the definition of xchg. What a pain!
I've not actually been able to repoduce this problem in test cases with gcc 4.0.0, so I assume it's a more recent addition - what's your compiler version?
Do you know if the warn_unused_result attribute will override
the -Wno-unused-value and generate a warning anyhow? There's probably only a few functions we'd want this warning on - if anyone cared about switching these warnings off a fairly small patch could anotate the relevant ones.
Cheers,
Mark
Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel!
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 3 lines · Mark Williamson
I've not actually been able to repoduce this problem in test cases with gcc 4.0.0, so I assume it's a more recent addition - what's your compiler version?
Gcc 4.1.1 definitely has the problem. The strncmp() error I saw was caused by its definition on Debian 3.1 (latest stable; hardly cutting edge).
Quoted 4 lines
Do you know if the
warn_unused_resultattribute will override
the -Wno-unused-value and generate a warning anyhow? There's probably only a few functions we'd want this warning on - if anyone cared about switching these warnings off a fairly small patch could anotate the relevant ones.
Warn_unused_result seems to trigger from a totally different code path that's unaffected by -Wno-unused-value. I definitely think that unused-value is not as generally useful as unused-{function,label,variable}. unused-{value,parameter} both have a tendency for false positives.
-- Keir
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
In reply to Keir FraserQuoted 14 lines · Keir Fraser
Quoted 4 lines · Keir Fraser
The comment attached to every use of
xchg()is dubious. We don't specifywarn_unused_resulton that function so there's no good reason for the compiler to complain about discarding the result. If it's a reproducible problem it needs investigating. We shouldn't work around a broken compiler.Ok, this seems to be a new 'feature' of gcc4, which has widened the class of things it will complain about with -Wunused-value. Basically any cast of a value causes the compiler to see an expression whose value must not be discarded -- what a pain! This seems to me that it could mean that ignoring return value of any function becomes potentially dangerous, as the function may be a macro that includes a cast on the return value.
Quoted 5 lines
I think the fix is -Wno-unused-value. :-) It's about the least useful of the -Wunused-<foo> warnings anyway.
I'll check this in, so please just get rid of the if(xchg()) hacky workaround.
I have to say that I entirely disagree with your solution. I think the solution is to get rid of -Werror. But I will remove the if(xchg()) foo as you request.
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 6 lines · Horms
Quoted 2 lines
I'll check this in, so please just get rid of the if(xchg()) hacky workaround.
I have to say that I entirely disagree with your solution. I think the solution is to get rid of -Werror. But I will remove the if(xchg()) foo as you request.
Holy crap! Getting rid of Werror makes Wall much less useful. We're too lazy to scan build output for warnings if they don't break the build.
The GCC developers have basically broken the unused-value checking, at least for Linux-style code which is heavy on macro usage. If a particular warning option is no longer useful, the correct answer is to switch it off.
-- Keir
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
Quoted 9 lines · Keir Fraser
Quoted 6 lines · Horms
Quoted 2 lines
I'll check this in, so please just get rid of the if(xchg()) hacky workaround.
I have to say that I entirely disagree with your solution. I think the solution is to get rid of -Werror. But I will remove the if(xchg()) foo as you request.
Quoted 6 lines
Holy crap! Getting rid of Werror makes Wall much less useful. We're too lazy to scan build output for warnings if they don't break the build.
The GCC developers have basically broken the unused-value checking, at least for Linux-style code which is heavy on macro usage. If a particular warning option is no longer useful, the correct answer is to switch it off.
I'm quite happy with that argument. However I personally prefer a severity differenation between warnings and errors, that is all.
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/
Re: Re: [PATCH 01/04] Kexec / Kdump: Generic code
In reply to Keir FraserQuoted 10 lines · Keir Fraser
Quoted 5 lines · Horms
Quoted 2 lines
I'll check this in, so please just get rid of the if(xchg()) hacky workaround.
I have to say that I entirely disagree with your solution. I think the solution is to get rid of -Werror. But I will remove the if(xchg()) foo as you request.
Holy crap! Getting rid of Werror makes Wall much less useful. We're too lazy to scan build output for warnings if they don't break the build.
I wrote a script that I used when I was working on kaffe. It would scan the build output, and sort warnings based on the -W option that produces them. It'd then give output sorted by warning option, and file. Made it much easier to work with.
I should put that up someplace.
Was really handy when a warning was in some .h file, so would be shown several thousand times in the build log, but was really only one problem.
PATCH 2/4 Kexec / Kdump: Code shared between x86_32 and x86_64
In reply to Magnus Damm[PATCH 02/04] Kexec / Kdump: Code shared between x86_32 and x86_64
This patch contains Kexec / Kdump code shared between x86_32 and x86_64.
---
Applies on top of xen-unstable-11760.
patches/linux-2.6.16.29/series | 2 patches/linux-2.6.16.29/git-2a..f7.patch | 62 +++ patches/linux-2.6.16.29/git-2e..11.patch | 93 +++++ xen/arch/x86/x86_32/machine_kexec.c | 26 + xen/arch/x86/x86_64/machine_kexec.c | 27 + xen/include/asm-x86/elf.h | 27 + xen/include/asm-x86/x86_32/elf.h | 28 + xen/include/asm-x86/x86_32/kexec.h | 48 ++ xen/include/asm-x86/x86_64/elf.h | 28 + xen/include/asm-x86/x86_64/kexec.h | 33 + xen/arch/x86/crash.c | 178 +++++++++- xen/arch/x86/machine_kexec.c | 72 +++- xen/arch/x86/setup.c | 73 +++- xen/arch/x86/traps.c | 3 xen/arch/x86/x86_32/Makefile | 1 xen/arch/x86/x86_64/Makefile | 1 xen/include/asm-x86/fixmap.h | 3 xen/include/asm-x86/hypercall.h | 5 xen/include/asm-x86/kexec.h | 13 xen/include/public/kexec.h | 7 xen/include/xen/elfcore.h | 3 21 files changed, 706 insertions(+), 27 deletions(-)
patches/linux-2.6.16.29/git-2a8a3d5b65e86ec1dfef7d268c64a909eab94af7.patch new file +62 -0
@@ -0,0 +1,62 @@ +From: Eric W. Biederman <[email protected]> +Date: Sun, 30 Jul 2006 10:03:20 +0000 (-0700) +Subject: [PATCH] machine_kexec.c: Fix the description of segment handling +X-Git-Tag: v2.6.18-rc4 +X-Git-Url: http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=2a8a3d5b65e86ec1dfef7d268c64a909eab94af7 + +[PATCH] machine_kexec.c: Fix the description of segment handling + +One of my original comments in machine_kexec was unclear +and this should fix it. + +Signed-off-by: Eric W. Biederman <[email protected]> +Cc: Andi Kleen <[email protected]> +Acked-by: Horms <[email protected]> +Signed-off-by: Andrew Morton <[email protected]> +Signed-off-by: Linus Torvalds <[email protected]> +--- + +--- a/arch/i386/kernel/machine_kexec.c ++++ b/arch/i386/kernel/machine_kexec.c +@@ -189,14 +189,11 @@ NORET_TYPE void machine_kexec(struct kim + memcpy((void *)reboot_code_buffer, relocate_new_kernel, + relocate_new_kernel_size); + +- /* The segment registers are funny things, they are +- * automatically loaded from a table, in memory wherever you +- * set them to a specific selector, but this table is never +- * accessed again you set the segment to a different selector. +- * +- * The more common model is are caches where the behide +- * the scenes work is done, but is also dropped at arbitrary +- * times. ++ /* The segment registers are funny things, they have both a ++ * visible and an invisible part. Whenever the visible part is ++ * set to a specific selector, the invisible part is loaded ++ * with from a table in memory. At no other time is the ++ * descriptor table in memory accessed. + * + * I take advantage of this here by force loading the + * segments, before I zap the gdt with an invalid value. +--- a/arch/x86_64/kernel/machine_kexec.c ++++ b/arch/x86_64/kernel/machine_kexec.c +@@ -207,14 +207,11 @@ NORET_TYPE void machine_kexec(struct kim + __flush_tlb(); + + +- /* The segment registers are funny things, they are +- * automatically loaded from a table, in memory wherever you +- * set them to a specific selector, but this table is never +- * accessed again unless you set the segment to a different selector. +- * +- * The more common model are caches where the behide +- * the scenes work is done, but is also dropped at arbitrary +- * times. ++ /* The segment registers are funny things, they have both a ++ * visible and an invisible part. Whenever the visible part is ++ * set to a specific selector, the invisible part is loaded ++ * with from a table in memory. At no other time is the ++ * descriptor table in memory accessed. + * + * I take advantage of this here by force loading the + * segments, before I zap the gdt with an invalid value.
patches/linux-2.6.16.29/git-2efe55a9cec8418f0e0cde3dc3787a42fddc4411.patch new file +93 -0
93 lines not on this page · raw message
patches/linux-2.6.16.29/series +2 -0
@@ -1,4 +1,6 @@ kexec-generic.patch +git-2efe55a9cec8418f0e0cde3dc3787a42fddc4411.patch +git-2a8a3d5b65e86ec1dfef7d268c64a909eab94af7.patch blktap-aio-16_03_06.patch device_bind.patch fix-hz-suspend.patch
xen/arch/x86/crash.c +175 -3
191 lines not on this page · raw message
xen/arch/x86/machine_kexec.c +63 -9
93 lines not on this page · raw message
xen/arch/x86/setup.c +64 -9
103 lines not on this page · raw message
xen/arch/x86/traps.c +3 -0
@@ -105,6 +105,8 @@ unsigned long do_get_debugreg(int reg);static int debug_stack_lines =20 ;integer_param ("debug_stack_lines" , debug_stack_lines); +extern void crash_kexec (struct cpu_user_regs *regs); +#ifdef CONFIG_X86_32 #define stack_words_per_line 8#define ESP_BEFORE_EXCEPTION (regs) ((unsigned long *)®s->esp)
@@ -1595,6 +1597,7 @@ static void unknown_nmi_error(unsigned cprintk ("Uhhuh. NMI received for unknown reason %02x.\n" , reason);printk ("Dazed and confused, but trying to continue\n" );printk ("Do you have a strange power saving mode enabled?\n" ); +crash_kexec (NULL ); } }
xen/arch/x86/x86_32/Makefile +1 -0
@@ -3,5 +3,6 @@ obj-y += entry.o obj-y += mm.o obj-y += seg_fixup.o obj-y += traps.o +obj-y += machine_kexec.o obj-$(supervisor_mode_kernel) += supervisor_mode_kernel.o
xen/arch/x86/x86_32/machine_kexec.c new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/x86/x86_32/machine_kexec.c +* Handle transition of Linux booting another kernel +* +* Created By: Horms <[email protected]> +* +* Should be losely based on arch/i386/kernel/machine_kexec.c +*/ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <public/kexec.h> + +void machine_kexec (xen_kexec_image_t *image) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/x86/x86_64/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-y += entry.o obj-y += mm.o obj-y += traps.o +obj-y += machine_kexec.o
xen/arch/x86/x86_64/machine_kexec.c new file +27 -0
@@ -0,0 +1,27 @@ +/****************************************************************************** +* arch/x86/x86_64/machine_kexec.c +* Handle transition of Linux booting another kernel +* +* Created By: Horms <[email protected]> +* +* Should be losely based on arch/x86_64/kernel/machine_kexec.c +*/ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/kexec.h> + +void machine_kexec (xen_kexec_image_t *image) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-x86/elf.h new file +27 -0
@@ -0,0 +1,27 @@ +/****************************************************************************** +* include/asm-x86/elf.h +* +* Created By: Horms +* +*/ + +#ifndef __X86_ELF_H__ +#define __X86_ELF_H__ + +#ifdef __x86_64__ +#include <asm/x86_64/elf.h> +#else +#include <asm/x86_32/elf.h> +#endif + +#endif /* __X86_ELF_H__ */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-x86/fixmap.h +3 -0
@@ -16,6 +16,7 @@#include <asm/apicdef.h> #include <asm/acpi.h> #include <asm/page.h> +#include <public/kexec.h> /* * Here we define all the compile-time 'special' virtual
@@ -36,6 +37,8 @@ enum fixed_addresses {FIX_ACPI_END =FIX_ACPI_BEGIN +FIX_ACPI_PAGES -1 ,FIX_HPET_BASE ,FIX_CYCLONE_TIMER , +FIX_KEXEC_BASE_0 , +FIX_KEXEC_BASE_END =FIX_KEXEC_BASE_0 + (KEXEC_XEN_NO_PAGES >>1 )-1 , __end_of_fixed_addresses };
xen/include/asm-x86/hypercall.h +5 -0
@@ -6,6 +6,7 @@#define __ASM_X86_HYPERCALL_H__#include <public/physdev.h> +#include <xen/types.h> extern long do_event_channel_op_compat(
@@ -87,6 +88,10 @@ extern longarch_do_vcpu_op ( int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg); +extern int +do_kexec ( +unsigned long op,unsigned arg1,XEN_GUEST_HANDLE (void ) uarg); +#ifdef __x86_64__ extern long
xen/include/asm-x86/kexec.h +7 -6
@@ -8,15 +8,16 @@#ifndef __X86_KEXEC_H__#define __X86_KEXEC_H__ -#include <xen/lib.h> /* for printk() used in stub */ +#include <asm/processor.h> #include <xen/types.h> +#include <xen/string.h> #include <public/xen.h> -static void crash_setup_regs (struct cpu_user_regs *newregs, -struct cpu_user_regs *oldregs) -{ -printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); -} +#ifdef __x86_64__ +#include <asm/x86_64/kexec.h> +#else +#include <asm/x86_32/kexec.h> +#endif #endif /* __X86_KEXEC_H__ */
xen/include/asm-x86/x86_32/elf.h new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* include/asm-x86/x86_32/elf.h +* +* Created By: Horms +* +* Should pull be based on include/asm-i386/elf.h:ELF_CORE_COPY_REGS +* from Linux 2.6.16 +*/ + +#ifndef __X86_ELF_X86_32_H__ +#define __X86_ELF_X86_32_H__ + +#include <xen/lib.h> /* for printk() used in stub */ + +#define ELF_CORE_COPY_REGS (pr_reg, regs) \ + printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__); + +#endif /* __X86_ELF_X86_32_H__ */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-x86/x86_32/kexec.h new file +48 -0
48 lines not on this page · raw message
xen/include/asm-x86/x86_64/elf.h new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* include/asm-x86/x86_64/elf.h +* +* Created By: Horms +* +* Should pull be based on include/asm-x86_64/elf.h:ELF_CORE_COPY_REGS +* from Linux 2.6.16 +*/ + +#ifndef __X86_ELF_X86_64_H__ +#define __X86_ELF_X86_64_H__ + +#include <xen/lib.h> /* for printk() used in stub */ + +#define ELF_CORE_COPY_REGS (pr_reg, regs) \ + printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__); + +#endif /* __X86_ELF_X86_64_H__ */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-x86/x86_64/kexec.h new file +33 -0
@@ -0,0 +1,33 @@ +/****************************************************************************** +* include/asm-x86/x86_64/kexec.h +* +* Created By: Horms +* +* Should be based heavily on include/asm-x86_64/kexec.h from Linux 2.6.16 +* +*/ + +#ifndef __X86_64_KEXEC_H__ +#define __X86_64_KEXEC_H__ + +#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> +#include <public/xen.h> + +static void crash_setup_regs (struct cpu_user_regs *newregs, +struct cpu_user_regs *oldregs) +{ +printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +} + +#endif /* __X86_64_KEXEC_H__ */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/public/kexec.h +7 -0
@@ -11,6 +11,10 @@#include "xen.h" +#if defined(__i386__) || defined(__x86_64__) +#define KEXEC_XEN_NO_PAGES 17 +#endif +/* * Prototype for this hypercall is: * int kexec_op(int cmd, int type, void *extra_args)
@@ -43,6 +47,9 @@*/ #define KEXEC_CMD_kexec_load 1typedef struct xen_kexec_image { +#if defined(__i386__) || defined(__x86_64__) +unsigned long page_list[KEXEC_XEN_NO_PAGES ]; +#endif unsigned long indirection_page;unsigned long start_address; }xen_kexec_image_t ;
xen/include/xen/elfcore.h +3 -0
@@ -16,6 +16,9 @@#include <public/xen.h> #define NT_PRSTATUS 1 +#define NT_XEN_DOM0_CR3 0x10000001/* XXX: Hopefully this is unused, +feel free to change to a +better/different value */ typedef struct {
PATCH 3/4 Kexec / Kdump: x86_32 specific code
In reply to Magnus Damm[PATCH 03/04] Kexec / Kdump: x86_32 specific code
This patch contains the x86_32 implementation of Kexec / Kdump for Xen.
---
Applies on top of xen-unstable-11760.
buildconfigs/linux-defconfig_xen_x86_32 | 2 linux-2.6-xen-sparse/arch/i386/Kconfig | 2 linux-2.6-xen-sparse/arch/i386/kernel/Makefile | 2 linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c | 25 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h | 8 patches/linux-2.6.16.29/series | 3 linux-2.6-xen-sparse/include/asm-i386/kexec-xen.h | 57 + patches/linux-2.6.16.29/git-35..cc9.patch | 401 +++++++ patches/linux-2.6.16.29/linux-2.6.19-rc1-kexe..code-i386.patch | 169 ++++ patches/linux-2.6.16.29/linux-2.6.19-rc1-kexec-xen-i386.patch | 54 + xen/arch/x86/crash.c | 47 + xen/arch/x86/x86_32/entry.S | 2 xen/arch/x86/x86_32/machine_kexec.c | 25 xen/include/asm-x86/x86_32/elf.h | 32 xen/include/asm-x86/x86_32/kexec.h | 65 + 15 files changed, 863 insertions(+), 31 deletions(-)
buildconfigs/linux-defconfig_xen_x86_32 +2 -0
@@ -183,6 +183,7 @@ CONFIG_MTRR=y CONFIG_REGPARM=y CONFIG_SECCOMP=y CONFIG_HZ_100=y +CONFIG_KEXEC=y # CONFIG_HZ_250 is not set # CONFIG_HZ_1000 is not set CONFIG_HZ=100
@@ -1036,6 +1037,7 @@ CONFIG_DNOTIFY=y # CONFIG_PROC_FS=y CONFIG_PROC_KCORE=y +# CONFIG_PROC_VMCORE is not set CONFIG_SYSFS=y CONFIG_TMPFS=y # CONFIG_HUGETLB_PAGE is not set
linux-2.6-xen-sparse/arch/i386/Kconfig +1 -1
@@ -726,7 +726,7 @@ source kernel/Kconfig.hz config KEXEC bool "kexec system call (EXPERIMENTAL)" - depends on EXPERIMENTAL && !X86_XEN + depends on EXPERIMENTAL && !XEN_UNPRIVILEGED_GUEST help kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot
linux-2.6-xen-sparse/arch/i386/kernel/Makefile +1 -1
@@ -89,7 +89,7 @@ include $(srctree)/scripts/Makefile.xen obj-y += fixup.o microcode-$(subst m,y,$(CONFIG_MICROCODE)) := microcode-xen.o -n-obj-xen := i8259.o timers/ reboot.o smpboot.o trampoline.o +n-obj-xen := i8259.o timers/ reboot.o smpboot.o trampoline.o crash.o obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) obj-y := $(call cherrypickxen, $(obj-y))
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c +24 -1
@@ -69,6 +69,10 @@#include "setup_arch_pre.h" #include <bios_ebda.h> +#ifdef CONFIG_XEN +#include <xen/interface/kexec.h> +#endif +/* Forward Declaration. */ void __init find_max_pfn (void );
@@ -943,6 +947,7 @@ static void __init parse_cmdline_early (* after a kernel panic. */ else if (!memcmp(from, "crashkernel=", 12)) { +#ifndef CONFIG_XEN unsigned long size, base; size =memparse (from+12 , &from);if (*from =='@' ) {
@@ -953,6 +958,10 @@ static void __init parse_cmdline_early ( crashk_res.start = base; crashk_res.end = base + size -1 ; } +#else +printk ("Ignoring crashkernel command line, " +"parameter will be supplied by xen\n" ); +#endif }#endif #ifdef CONFIG_PROC_VMCORE
@@ -1322,9 +1331,22 @@ void __init setup_bootmem_allocator(void }#endif #ifdef CONFIG_KEXEC +#ifndef CONFIG_XEN if (crashk_res.start != crashk_res.end)reserve_bootmem (crashk_res.start, crashk_res.end - crashk_res.start +1 ); +#else + { +xen_kexec_reserve_t reservation; +BUG_ON (HYPERVISOR_kexec (KEXEC_CMD_kexec_reserve,0 , + &reservation)); +if (reservation.size) { + crashk_res.start = reservation.start; + crashk_res.end = reservation.start + + reservation.size -1 ; + } + } +#endif #endif if (!xen_feature (XENFEAT_auto_translated_physmap))
@@ -1389,7 +1411,8 @@ legacy_init_iomem_resources(struct e820erequest_resource (res, data_resource);#endif #ifdef CONFIG_KEXEC -request_resource (res, &crashk_res); +if (crashk_res.start != crashk_res.end) +request_resource (res, &crashk_res);#endif } }
linux-2.6-xen-sparse/include/asm-i386/kexec-xen.h new file +57 -0
57 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h +8 -0
@@ -385,5 +385,13 @@ HYPERVISOR_xenoprof_op( return _hypercall2(int, xenoprof_op, op, arg); } +static inline int +HYPERVISOR_kexec ( +unsigned long op,unsigned int arg1,void * extra_args) +{ +return _hypercall3 (int, kexec_op, op, arg1, extra_args); +} + +#endif /* __HYPERCALL_H__ */
patches/linux-2.6.16.29/git-3566561bfadffcb5dbc85d576be80c0dbf2cccc9.patch new file +401 -0
401 lines not on this page · raw message
patches/linux-2.6.16.29/linux-2.6.19-rc1-kexec-move_segment_code-i386.patch new file +169 -0
169 lines not on this page · raw message
patches/linux-2.6.16.29/linux-2.6.19-rc1-kexec-xen-i386.patch new file +54 -0
54 lines not on this page · raw message
patches/linux-2.6.16.29/series +3 -0
@@ -1,6 +1,9 @@ kexec-generic.patch git-2efe55a9cec8418f0e0cde3dc3787a42fddc4411.patch git-2a8a3d5b65e86ec1dfef7d268c64a909eab94af7.patch +git-3566561bfadffcb5dbc85d576be80c0dbf2cccc9.patch +linux-2.6.19-rc1-kexec-move_segment_code-i386.patch +linux-2.6.19-rc1-kexec-xen-i386.patch blktap-aio-16_03_06.patch device_bind.patch fix-hz-suspend.patch
xen/arch/x86/crash.c +47 -0
65 lines not on this page · raw message
xen/arch/x86/x86_32/entry.S +2 -0
@@ -672,6 +672,7 @@ ENTRY(hypercall_table) .long do_hvm_op .long do_sysctl /* 35 */ .long do_domctl + .long do_kexec_op .rept NR_hypercalls-((.-hypercall_table)/4) .long do_ni_hypercall .endr
@@ -714,6 +715,7 @@ ENTRY(hypercall_args_table) .byte 2 /* do_hvm_op */ .byte 1 /* do_sysctl */ /* 35 */ .byte 1 /* do_domctl */ + .byte 1 /* do_kexec_op */ .rept NR_hypercalls-(.-hypercall_args_table) .byte 0 /* do_ni_hypercall */ .endr
xen/arch/x86/x86_32/machine_kexec.c +18 -7
@@ -1,18 +1,29 @@ -/* +/****************************************************************************** * arch/x86/x86_32/machine_kexec.c -* Handle transition of Linux booting another kernel -* -* Created By: Horms <[email protected]> +* +* Created By: Horms * -* Should be losely based on arch/i386/kernel/machine_kexec.c +* Based heavily on arch/i386/machine_kexec.c from Linux 2.6.16 */ -#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> #include <public/kexec.h> +#include <asm/fixmap.h> +#include <asm/processor.h> + +typedef asmlinkage void (*relocate_new_kernel_t)( +unsigned long indirection_page, +unsigned long control_page, +unsigned long start_address, +unsigned int has_pae);void machine_kexec (xen_kexec_image_t *image) { -printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +relocate_new_kernel_t rnk; + + rnk = (relocate_new_kernel_t )fix_to_virt (FIX_KEXEC_BASE_0 ); + (*rnk)(image->indirection_page, (unsigned long )image->page_list, + image->start_address, (unsigned long )cpu_has_pae); }/*
xen/include/asm-x86/x86_32/elf.h +27 -5
@@ -3,17 +3,39 @@* * Created By: Horms * -* Should pull be based on include/asm-i386/elf.h:ELF_CORE_COPY_REGS -* from Linux 2.6.16 +* Based heavily on include/asm-i386/elf.h and +* include/asm-i386/system.h from Linux 2.6.16 */ #ifndef __X86_ELF_X86_32_H__#define __X86_ELF_X86_32_H__ -#include <xen/lib.h> /* for printk() used in stub */ +/* XXX: Xen doesn't have orig_eax. For kdump, on a dom0 crash, the values +* for the crashing CPU could could be passed down from dom0, but is that +* neccessary? +* Also, I'm not sure why fs and gs are derived from the CPU +* rather than regs */ -#define ELF_CORE_COPY_REGS (pr_reg, regs) \ - printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__); +#define ELF_CORE_COPY_REGS (pr_reg, regs) do { \ + unsigned i; \ + pr_reg[0] = regs->ebx; \ + pr_reg[1] = regs->ecx; \ + pr_reg[2] = regs->edx; \ + pr_reg[3] = regs->esi; \ + pr_reg[4] = regs->edi; \ + pr_reg[5] = regs->ebp; \ + pr_reg[6] = regs->eax; \ + pr_reg[7] = regs->ds; \ + pr_reg[8] = regs->es; \ + asm volatile("mov %%fs,%0":"=rm" (i)); pr_reg[9] = i; \ + asm volatile("mov %%gs,%0":"=rm" (i)); pr_reg[10] = i; \ + pr_reg[11] = 0;/* regs->orig_eax; */ \ + pr_reg[12 ] = regs->eip; \ + pr_reg[13 ] = regs->cs; \ + pr_reg[14 ] = regs->eflags; \ + pr_reg[15 ] = regs->esp; \ + pr_reg[16 ] = regs->ss; \ +} while(0);#endif /* __X86_ELF_X86_32_H__ */
xen/include/asm-x86/x86_32/kexec.h +49 -16
88 lines not on this page · raw message
PATCH 4/4 Kexec / Kdump: x86_64 specific code
In reply to Magnus Damm[PATCH 04/04] Kexec / Kdump: x86_64 specific code
This patch contains the x86_64 implementation of Kexec / Kdump for Xen.
---
Applies on top of xen-unstable-11760.
buildconfigs/linux-defconfig_xen_x86_64 | 1 linux-2.6-xen-sparse/arch/x86_64/Kconfig | 2 linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile | 2 linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c | 27 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h | 7 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/ptrace.h | 2 patches/linux-2.6.16.29/series | 3 linux-2.6-xen-sparse/include/asm-x86_64/kexec-xen.h | 64 + patches/linux-2.6.16.29/git-4b..1f.patch | 375 ++++++ patches/linux-2.6.16.29/linux-2.6.19-rc1-kexe..code-x86_64.patch | 161 ++++ patches/linux-2.6.16.29/linux-2.6.19-rc1-kexec-xen-x86_64.patch | 162 ++++ xen/arch/x86/x86_64/entry.S | 2 xen/arch/x86/x86_64/machine_kexec.c | 19 xen/include/asm-x86/x86_64/elf.h | 48 + xen/include/asm-x86/x86_64/kexec.h | 33 xen/include/public/kexec.h | 3 16 files changed, 897 insertions(+), 14 deletions(-)
buildconfigs/linux-defconfig_xen_x86_64 +1 -0
@@ -138,6 +138,7 @@ CONFIG_SWIOTLB=y CONFIG_PHYSICAL_START=0x100000 CONFIG_SECCOMP=y CONFIG_HZ_100=y +CONFIG_KEXEC=y # CONFIG_HZ_250 is not set # CONFIG_HZ_1000 is not set CONFIG_HZ=100
linux-2.6-xen-sparse/arch/x86_64/Kconfig +1 -1
@@ -435,7 +435,7 @@ config X86_MCE_AMD config KEXEC bool "kexec system call (EXPERIMENTAL)" - depends on EXPERIMENTAL && !X86_64_XEN + depends on EXPERIMENTAL && !XEN_UNPRIVILEGED_GUEST help kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot
linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile +1 -1
@@ -59,7 +59,7 @@ pci-dma-y += ../../i386/kernel/pci-dma microcode-$(subst m,y,$(CONFIG_MICROCODE)) := ../../i386/kernel/microcode-xen.o quirks-y := ../../i386/kernel/quirks-xen.o -n-obj-xen := i8259.o reboot.o i8237.o smpboot.o trampoline.o +n-obj-xen := i8259.o reboot.o i8237.o smpboot.o trampoline.o crash.o include $(srctree)/scripts/Makefile.xen
linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c +27 -0
@@ -80,6 +80,10 @@#include <asm/mach-xen/setup_arch_post.h> #include <xen/interface/memory.h> +#ifdef CONFIG_XEN +#include <xen/interface/kexec.h> +#endif +extern unsigned long start_pfn;extern struct edid_info edid_info;
@@ -450,6 +454,7 @@ static __init void parse_cmdline_early (* after a kernel panic. */ else if (!memcmp(from, "crashkernel=", 12)) { +#ifndef CONFIG_XEN unsigned long size, base; size =memparse (from+12 , &from);if (*from =='@' ) {
@@ -460,6 +465,10 @@ static __init void parse_cmdline_early ( crashk_res.start = base; crashk_res.end = base + size -1 ; } +#else +printk ("Ignoring crashkernel command line, " +"parameter will be supplied by xen\n" ); +#endif }#endif
@@ -812,10 +821,23 @@ void __init setup_arch(char **cmdline_p)#endif #endif /* !CONFIG_XEN */ #ifdef CONFIG_KEXEC +#ifndef CONFIG_XEN if (crashk_res.start != crashk_res.end) {reserve_bootmem (crashk_res.start, crashk_res.end - crashk_res.start +1 ); } +#else + { +xen_kexec_reserve_t reservation; +BUG_ON (HYPERVISOR_kexec (KEXEC_CMD_kexec_reserve,0 , + &reservation)); +if (reservation.size) { + crashk_res.start = reservation.start; + crashk_res.end = reservation.start + + reservation.size -1 ; + } + } +#endif #endif paging_init ();
@@ -954,6 +976,11 @@ void __init setup_arch(char **cmdline_p)iommu_hole_init ();#endif +#ifdef CONFIG_KEXEC +if (crashk_res.start != crashk_res.end) +request_resource (&ioport_resource, &crashk_res); +#endif +#ifdef CONFIG_XEN {struct physdev_set_iopl set_iopl;
linux-2.6-xen-sparse/include/asm-x86_64/kexec-xen.h new file +64 -0
64 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h +7 -0
@@ -386,4 +386,11 @@ HYPERVISOR_xenoprof_op( return _hypercall2(int, xenoprof_op, op, arg); } +static inline int +HYPERVISOR_kexec ( +unsigned long op,unsigned int arg1,void * extra_args) +{ +return _hypercall3 (int, kexec_op, op, arg1, extra_args); +} +#endif /* __HYPERCALL_H__ */
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/ptrace.h +2 -0
@@ -90,6 +90,8 @@ extern unsigned long profile_pc(struct p#define profile_pc (regs) instruction_pointer(regs)#endif +#include <linux/compiler.h> +void signal_fault (struct pt_regs *regs,void __user *frame,char *where);struct task_struct ;
patches/linux-2.6.16.29/git-4bfaaef01a1badb9e8ffb0c0a37cd2379008d21f.patch new file +375 -0
375 lines not on this page · raw message
patches/linux-2.6.16.29/linux-2.6.19-rc1-kexec-move_segment_code-x86_64.patch new file +161 -0
161 lines not on this page · raw message
patches/linux-2.6.16.29/linux-2.6.19-rc1-kexec-xen-x86_64.patch new file +162 -0
162 lines not on this page · raw message
patches/linux-2.6.16.29/series +3 -0
@@ -4,6 +4,9 @@ git-2a8a3d5b65e86ec1dfef7d268c64a909eab9 git-3566561bfadffcb5dbc85d576be80c0dbf2cccc9.patch linux-2.6.19-rc1-kexec-move_segment_code-i386.patch linux-2.6.19-rc1-kexec-xen-i386.patch +git-4bfaaef01a1badb9e8ffb0c0a37cd2379008d21f.patch +linux-2.6.19-rc1-kexec-move_segment_code-x86_64.patch +linux-2.6.19-rc1-kexec-xen-x86_64.patch blktap-aio-16_03_06.patch device_bind.patch fix-hz-suspend.patch
xen/arch/x86/x86_64/entry.S +2 -0
@@ -573,6 +573,7 @@ ENTRY(hypercall_table) .quad do_hvm_op .quad do_sysctl /* 35 */ .quad do_domctl + .quad do_kexec_op .rept NR_hypercalls-((.-hypercall_table)/8) .quad do_ni_hypercall .endr
@@ -615,6 +616,7 @@ ENTRY(hypercall_args_table) .byte 2 /* do_hvm_op */ .byte 1 /* do_sysctl */ /* 35 */ .byte 1 /* do_domctl */ + .byte 3 /* do_kexec */ .rept NR_hypercalls-(.-hypercall_args_table) .byte 0 /* do_ni_hypercall */ .endr
xen/arch/x86/x86_64/machine_kexec.c +14 -5
@@ -4,18 +4,27 @@* * Created By: Horms <[email protected]> * -* Should be losely based on arch/x86_64/kernel/machine_kexec.c +* Losely based on arch/x86_64/kernel/machine_kexec.c */ - -#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/types.h> #include <public/kexec.h> +#include <asm/fixmap.h> + +typedef void (*relocate_new_kernel_t )( +unsigned long indirection_page, +unsigned long page_list, +unsigned long start_address);void machine_kexec (xen_kexec_image_t *image) { -printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); -} +relocate_new_kernel_t rnk; + rnk = (relocate_new_kernel_t )fix_to_virt (FIX_KEXEC_BASE_0 ); + (*rnk)(image->indirection_page, (unsigned long )image->page_list, + image->start_address); + } +/* * Local variables: * mode: C
xen/include/asm-x86/x86_64/elf.h +43 -5
60 lines not on this page · raw message
xen/include/asm-x86/x86_64/kexec.h +31 -2
@@ -10,14 +10,43 @@#ifndef __X86_64_KEXEC_H__#define __X86_64_KEXEC_H__ -#include <xen/lib.h> /* for printk() used in stub */ +#include <xen/lib.h> #include <xen/types.h> #include <public/xen.h> +/* +* Saving the registers of the cpu on which panic occured in +* crash_kexec to save a valid sp. The registers of other cpus +* will be saved in machine_crash_shutdown while shooting down them. +*/ static void crash_setup_regs (struct cpu_user_regs *newregs,struct cpu_user_regs *oldregs) { -printk ("STUB: " __FILE__": %s: not implemented\n" , __FUNCTION__); +if (oldregs) +memcpy (newregs, oldregs,sizeof (*newregs)); +else { + __asm__ __volatile__("movq %%rbx,%0" :"=m" (newregs->rbx)); + __asm__ __volatile__("movq %%rcx,%0" :"=m" (newregs->rcx)); + __asm__ __volatile__("movq %%rdx,%0" :"=m" (newregs->rdx)); + __asm__ __volatile__("movq %%rsi,%0" :"=m" (newregs->rsi)); + __asm__ __volatile__("movq %%rdi,%0" :"=m" (newregs->rdi)); + __asm__ __volatile__("movq %%rbp,%0" :"=m" (newregs->rbp)); + __asm__ __volatile__("movq %%rax,%0" :"=m" (newregs->rax)); + __asm__ __volatile__("movq %%rsp,%0" :"=m" (newregs->rsp)); + __asm__ __volatile__("movq %%r8,%0" :"=m" (newregs->r8)); + __asm__ __volatile__("movq %%r9,%0" :"=m" (newregs->r9)); + __asm__ __volatile__("movq %%r10,%0" :"=m" (newregs->r10)); + __asm__ __volatile__("movq %%r11,%0" :"=m" (newregs->r11)); + __asm__ __volatile__("movq %%r12,%0" :"=m" (newregs->r12)); + __asm__ __volatile__("movq %%r13,%0" :"=m" (newregs->r13)); + __asm__ __volatile__("movq %%r14,%0" :"=m" (newregs->r14)); + __asm__ __volatile__("movq %%r15,%0" :"=m" (newregs->r15)); + __asm__ __volatile__("movl %%ss, %%eax;" :"=a" (newregs->ss)); + __asm__ __volatile__("movl %%cs, %%eax;" :"=a" (newregs->cs)); + __asm__ __volatile__("pushfq; popq %0" :"=m" (newregs->eflags)); + + newregs->rip = (unsigned long )current_text_addr (); + } }#endif /* __X86_64_KEXEC_H__ */
xen/include/public/kexec.h +3 -0
@@ -50,6 +50,9 @@ typedef struct xen_kexec_image {#if defined(__i386__) || defined(__x86_64__)unsigned long page_list[KEXEC_XEN_NO_PAGES ];#endif +#if defined(__x86_64__) +unsigned long page_table_b; +#endif unsigned long indirection_page;unsigned long start_address; } xen_kexec_image_t;