All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Daniel Kiper <daniel.kiper@oracle.com>
Cc: Keir Fraser <keir@xen.org>,
	kexec@lists.infradead.org, xen-devel@lists.xen.org
Subject: Re: [Xen-devel] [PATCHv4 0/8] kexec: extend kexec hypercall for use with pv-ops kernels
Date: Thu, 18 Apr 2013 18:38:39 +0100	[thread overview]
Message-ID: <51702F9F.30500@citrix.com> (raw)
In-Reply-To: <20130417123437.GA906@debian70-amd64.local.net-space.pl>

On 17/04/13 13:34, Daniel Kiper wrote:
> 
> kexec -e still does not work. I see in my console:
> 
> I'm in purgatory
> sha256 digests do not match :(

I have now fixed this.  Xen was not probably zeroing out trailing pages
(only partial pages) when loading a default image (crash was fine).

The kernel does this by allocating and clearing pages and then
relocating these as normal but it's wasteful to allocate a bunch of
empty pages so I added a IND_ZERO entry type for the indirection pages
which gets the relocation code to zero the destination.

See the kexec-v5 branch at:

http://xenbits.xen.org/gitweb/?p=people/dvrabel/xen.git;a=summary

I shall repost this series again once the 4.4 development window is open.

--- a/xen/arch/x86/x86_64/kexec_reloc.S
+++ b/xen/arch/x86/x86_64/kexec_reloc.S
@@ -130,13 +130,18 @@ relocate_pages:
         jmp     3f
 2:
         testq   $0x8,   %rcx  /* is it the source indicator? */
-        jz      0b            /* Ignore it otherwise */
+        jz      2f
         movq    %rcx,   %rsi  /* For ever source page do a copy */
         andq    $0xfffffffffffff000, %rsi
-
         movq    $512,   %rcx
         rep movsq
-
+        jmp     0b
+2:
+        testq   $0x10,  %rcx  /* is it the zero indicator? */
+        jz      0b            /* Ignore it otherwise */
+        movq    $512,   %rcx  /* Zero the destination page. */
+        xorq    %rax,   %rax
+        rep stosq
         jmp     0b
 3:
         ret
diff --git a/xen/common/kimage.c b/xen/common/kimage.c
index 86261ca..1cc0ef7 100644
--- a/xen/common/kimage.c
+++ b/xen/common/kimage.c
@@ -661,7 +661,7 @@ static int kimage_load_normal_segment(struct
kexec_image *image,
 {
     unsigned long to_copy;
     unsigned long src_offset;
-    paddr_t dest;
+    paddr_t dest, end;
     int ret;

     to_copy = segment->buf_size;
@@ -675,15 +675,13 @@ static int kimage_load_normal_segment(struct
kexec_image *image,
     while ( to_copy )
     {
         unsigned long dest_mfn;
-        size_t dest_off;
         struct page_info *page;
         void *dest_va;
         size_t size;

         dest_mfn = dest >> PAGE_SHIFT;
-        dest_off = dest & ~PAGE_MASK;

-        size = min(PAGE_SIZE - dest_off, to_copy);
+        size = min_t(unsigned long, PAGE_SIZE, to_copy);

         page = kimage_alloc_page(image, dest);
         if ( !page )
@@ -693,16 +691,21 @@ static int kimage_load_normal_segment(struct
kexec_image *image,
             return ret;

         dest_va = __map_domain_page(page);
-        ret = copy_from_guest_offset(dest_va + dest_off, segment->buf,
src_offset, size);
+        ret = copy_from_guest_offset(dest_va, segment->buf, src_offset,
size);
         unmap_domain_page(dest_va);
         if ( ret )
             return -EFAULT;

         to_copy -= size;
         src_offset += size;
-        dest += size;
+        dest += PAGE_SIZE;
     }

+    /* Remainder of the destination should be zeroed. */
+    end = segment->dest_maddr + segment->dest_size;
+    for ( ; dest < end; dest += PAGE_SIZE )
+        kimage_add_entry(image, IND_ZERO);
+
     return 0;
 }

--- a/xen/include/xen/kimage.h
+++ b/xen/include/xen/kimage.h
@@ -14,6 +14,7 @@ typedef paddr_t kimage_entry_t;
 #define IND_INDIRECTION  0x2
 #define IND_DONE         0x4
 #define IND_SOURCE       0x8
+#define IND_ZERO        0x10

 struct kexec_image {
     uint8_t type;

David

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2013-04-18 17:38 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 17:13 [PATCHv4 0/8] kexec: extend kexec hypercall for use with pv-ops kernels David Vrabel
2013-04-16 17:13 ` [PATCH 1/8] x86: give FIX_EFI_MPF its own fixmap entry David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-16 17:13 ` [PATCH 2/8] xen: make GUEST_HANDLE_64() and uint64_aligned_t available everywhere David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-16 17:13 ` [PATCH 3/8] kexec: add public interface for improved load/unload sub-ops David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-16 17:13 ` [PATCH 4/8] kexec: add infrastructure for handling kexec images David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-16 17:13 ` [PATCH 5/8] kexec: extend hypercall with improved load/unload ops David Vrabel
2013-04-16 17:13   ` David Vrabel
2013-04-17  8:55   ` Jan Beulich
2013-04-17  8:55   ` [Xen-devel] " Jan Beulich
2013-04-17 10:11     ` David Vrabel
2013-04-17 10:11     ` [Xen-devel] " David Vrabel
2013-04-17 10:20       ` Jan Beulich
2013-04-17 10:20       ` Jan Beulich
2013-04-17 12:51   ` Daniel Kiper
2013-04-18 16:29     ` David Vrabel
2013-04-19  8:08       ` Daniel Kiper
2013-04-19  8:08       ` Daniel Kiper
2013-04-18 16:29     ` David Vrabel
2013-04-17 12:51   ` Daniel Kiper
2013-04-16 17:13 ` [PATCH 6/8] xen: kexec crash image when dom0 crashes David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-16 17:13 ` [PATCH 7/8] libxc: add hypercall buffer arrays David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-16 17:13 ` [PATCH 8/8] libxc: add API for kexec hypercall David Vrabel
2013-04-16 17:13 ` David Vrabel
2013-04-17 12:34 ` [PATCHv4 0/8] kexec: extend kexec hypercall for use with pv-ops kernels Daniel Kiper
2013-04-17 12:34 ` Daniel Kiper
2013-04-17 14:15   ` David Vrabel
2013-04-17 14:15   ` David Vrabel
2013-04-17 14:53     ` Daniel Kiper
2013-04-17 14:53     ` Daniel Kiper
2013-04-18 17:38   ` David Vrabel [this message]
2013-04-19 13:22     ` [Xen-devel] " Daniel Kiper
2013-04-19 13:22     ` Daniel Kiper
2013-04-18 17:38   ` David Vrabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51702F9F.30500@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=daniel.kiper@oracle.com \
    --cc=keir@xen.org \
    --cc=kexec@lists.infradead.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.