From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: kexec: Clear notes during setup Date: Fri, 4 May 2012 12:42:29 +0100 Message-ID: <4FA3C0A5.7030309@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050301060803020709070907" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" Cc: Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org --------------050301060803020709070907 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit I know that xen-unstable is on a feature freeze, and this is not strictly a bugfix (yet; see below), but as it is safe and designed to help clarity in the case of a crash, so I request that it be considered for inclusion. I have constructed an artificial case where the information reported in 1 per-cpu crash note was stale by using low_crashinfo mode, crashing Xen, allowing it to reboot, offlining a CPU then re-crashing Xen. This leaves stale register state written into the offlined CPU crash information. In this case, the information was stale but correct, due to the predictable nature of the Xen crash path from the 'C' debug key, but there is no guarantee that in the case of a real crash, the same will still be true. -- Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer T: +44 (0)1223 225 900, http://www.citrix.com --------------050301060803020709070907 Content-Type: text/x-patch; name="kexec-clear-notes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kexec-clear-notes.patch" # HG changeset patch # Parent 98fe3b2a572d4ffe704124e75c7aa8d94dbb51bc kexec: clear notes during setup Explicity zero the memory backing the crash notes during setup. This allows the crash environment to be rather more certain whether the crash notes were actually written, rather than trusting that the memory was clear beforehand. Signed-off-by: Andrew Cooper diff -r 98fe3b2a572d xen/common/kexec.c --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -401,7 +401,7 @@ static int kexec_init_cpu_notes(const un /* If we dont care about the position of allocation, malloc. */ if ( low_crashinfo_mode == LOW_CRASHINFO_NONE ) - note = xmalloc_bytes(nr_bytes); + note = xzalloc_bytes(nr_bytes); /* Protect the write into crash_notes[] with a spinlock, as this function * is on a hotplug path and a hypercall path. */ @@ -505,7 +505,7 @@ static int __init kexec_init(void) if ( low_crashinfo_mode > LOW_CRASHINFO_NONE ) { - size_t crash_heap_size; + size_t crash_heap_size, i; /* This calculation is safe even if the machine is booted in * uniprocessor mode. */ @@ -520,6 +520,9 @@ static int __init kexec_init(void) if ( ! crash_heap_current ) return -ENOMEM; + for ( i=0; i< (crash_heap_size >> PAGE_SHIFT); ++i ) + clear_page(crash_heap_current + (i << PAGE_SHIFT)); + crash_heap_end = crash_heap_current + crash_heap_size; } --------------050301060803020709070907 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------050301060803020709070907--