public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: kexec@lists.infradead.org
Cc: Norbert Trapp <Norbert.Trapp@ts.fujitsu.com>
Subject: [PATCHv3 6/9] Fix domain pickled_id computation for xen-3.4+
Date: Fri, 24 Aug 2012 17:42:32 +0200	[thread overview]
Message-ID: <201208241742.33067.ptesarik@suse.cz> (raw)

Originally, Xen stored the 32-bit address of the domain structure in struct
page_info. On x86-64, the physical address was stored, but since all heap
objects were allocated in the 1:1 mapping which started at 0xffff830000000000,
the end result was the same as if we simply chopped off the high bits (actual
implementation in makedumpfile).

Then, during the development of Xen-3.4, this logic was changed several times
for x86-64:

changeset 39517e863cc8 widened the _domain field to 64 bits and stored the
        virtual address of struct domain instead of physical address
changeset beba88f6f90d removed the pickle/unpickle macros
changeset 0858f961c77a changed _domain back from unsigned long to u32,
        *and* stores the MFN of struct domain instead

All the above changes went into Xen-3.4, and the relation between a domain
address and the contents of the _domain field hasn't changed since then.
That means, when the MADDR space was compressed in Xen-4.0, the type of the
_domain field was changed to _pdx_t, which was specifically invented to
preserve its calculation from the struct domain address.

To sum it up:

1. For all Xen versions before Xen-3.4, the _domain field contains the address
   of struct domain (with high bits chopped for x86-64).
2. For all Xen versions starting with Xen-3.4, the _domain field can be
   computed from struct domain address as:
        (addr - DIRECTMAP_VIRT_START) >> PAGE_SHIFT

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 arch/x86_64.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -405,12 +405,26 @@ int get_xen_info_x86_64(void)
 {
 	int i;
 
-	/*
-	 * pickled_id == domain addr for x86_64
-	 */
-	for (i = 0; i < info->num_domain; i++) {
-		info->domain_list[i].pickled_id =
-			info->domain_list[i].domain_addr;
+	if (info->xen_crash_info.com &&
+	    (info->xen_crash_info.com->xen_major_version >= 4 ||
+	     (info->xen_crash_info.com->xen_major_version == 3 &&
+	      info->xen_crash_info.com->xen_minor_version >= 4))) {
+		/*
+		 * cf. changeset 0858f961c77a
+		 */
+		for (i = 0; i < info->num_domain; i++) {
+			info->domain_list[i].pickled_id =
+				(info->domain_list[i].domain_addr -
+				 DIRECTMAP_VIRT_START) >> PAGESHIFT();
+		}
+	} else {
+		/*
+		 * pickled_id == domain addr for x86_64
+		 */
+		for (i = 0; i < info->num_domain; i++) {
+			info->domain_list[i].pickled_id =
+				info->domain_list[i].domain_addr;
+		}
 	}
 
 	return TRUE;



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

                 reply	other threads:[~2012-08-24 15:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201208241742.33067.ptesarik@suse.cz \
    --to=ptesarik@suse.cz \
    --cc=Norbert.Trapp@ts.fujitsu.com \
    --cc=kexec@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox