All of lore.kernel.org
 help / color / mirror / Atom feed
From: "bhe@redhat.com" <bhe@redhat.com>
To: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: "kexec@lists.infradead.org" <kexec@lists.infradead.org>
Subject: Re: [Patch v2] get MODULES_VADDR by KERNEL_IMAGE_SIZE for x86_64
Date: Wed, 24 Sep 2014 16:02:00 +0800	[thread overview]
Message-ID: <20140924080200.GG8697@dhcp-16-116.nay.redhat.com> (raw)
In-Reply-To: <0910DD04CBD6DE4193FCF86B9C00BE9701D4942B@BPXM01GP.gisp.nec.co.jp>

On 09/24/14 at 07:55am, Atsushi Kumagai wrote:
> Hello Baoquan,
> 
> This patch looks good to me, I'll merge it into v1.5.8.


Thanks, Atsushi!
> 
> 
> Thanks
> Atsushi Kumagai
> 
> >In x86_64, since v2.6.26 the KERNEL_IMAGE_SIZE is changed to 512M, and
> >accordingly the MODULES_VADDR is changed to 0xffffffffa0000000. Before
> >that, KERNEL_IMAGE_SIZE is 128M, and MODULES_VADDR is 0xffffffff88000000.
> >
> >However, in v3.12 Kees Cook introduced kaslr to randomise the location
> >of kernel. And the kernel text mapping addr space is enlarged from 512M
> >to 1G. That means now KERNEL_IMAGE_SIZE is variable, its value is 512M
> >with kaslr support not compiled in and 1G with kaslr support compiled
> >in. Accordingly the MODULES_VADDR is changed too to be:
> >
> >So when kaslr is compiled in and enabled, the kernel text mapping addr
> >space and modules vaddr space need be adjusted. Otherwise makedumpfile
> >will collapse since the addr for some symbols is not correct.
> >
> >Hence KERNEL_IMAGE_SIZE need be exported to vmcoreinfo and got in
> >makedumpfile to help calculate MODULES_VADDR.
> >
> >v1->v2:
> >    Fix a code bug Atsushi found.
> >
> >Signed-off-by: Baoquan He <bhe@redhat.com>
> >---
> > makedumpfile.c | 10 ++++++++++
> > makedumpfile.h |  5 ++++-
> > 2 files changed, 14 insertions(+), 1 deletion(-)
> >
> >diff --git a/makedumpfile.c b/makedumpfile.c
> >index b4d43d8..65c893f 100644
> >--- a/makedumpfile.c
> >+++ b/makedumpfile.c
> >@@ -1564,6 +1564,14 @@ get_value_for_old_linux(void)
> > 			NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE) =
> > 			PAGE_BUDDY_MAPCOUNT_VALUE_v2_6_39_to_latest_version;
> > 	}
> >+#ifdef __x86_64__
> >+	if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
> >+		if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
> >+			NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_ORIG;
> >+		else
> >+			NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_2_6_26;
> >+	}
> >+#endif
> > 	if (SIZE(pageflags) == NOT_FOUND_STRUCTURE) {
> > 		if (info->kernel_version >= KERNEL_VERSION(2, 6, 27))
> > 			SIZE(pageflags) =
> >@@ -1813,6 +1821,7 @@ write_vmcoreinfo_data(void)
> > 	WRITE_NUMBER("PG_hwpoison", PG_hwpoison);
> >
> > 	WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
> >+	WRITE_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
> >
> > 	/*
> > 	 * write the source file of 1st kernel
> >@@ -2147,6 +2156,7 @@ read_vmcoreinfo(void)
> > 	READ_SRCFILE("pud_t", pud_t);
> >
> > 	READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
> >+	READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
> >
> > 	return TRUE;
> > }
> >diff --git a/makedumpfile.h b/makedumpfile.h
> >index 96830b0..a3d86e7 100644
> >--- a/makedumpfile.h
> >+++ b/makedumpfile.h
> >@@ -549,7 +549,9 @@ do { \
> > #define VMEMMAP_END_2_6_31	(0xffffeaffffffffff) /* 2.6.31, or later  */
> >
> > #define __START_KERNEL_map	(0xffffffff80000000)
> >-#define MODULES_VADDR		(0xffffffff88000000)
> >+#define KERNEL_IMAGE_SIZE_ORIG	(0x0000000008000000) /* 2.6.25, or former */
> >+#define KERNEL_IMAGE_SIZE_2_6_26	(0x0000000020000000) /* 2.6.26, or later  */
> >+#define MODULES_VADDR          (__START_KERNEL_map + NUMBER(KERNEL_IMAGE_SIZE))
> > #define MODULES_END		(0xfffffffffff00000)
> > #define KVBASE			PAGE_OFFSET
> > #define _SECTION_SIZE_BITS	(27)
> >@@ -1531,6 +1533,7 @@ struct number_table {
> > 	long    PG_hwpoison;
> >
> > 	long	PAGE_BUDDY_MAPCOUNT_VALUE;
> >+	long	KERNEL_IMAGE_SIZE;
> > 	long	SECTION_SIZE_BITS;
> > 	long	MAX_PHYSMEM_BITS;
> > };
> >--
> >1.8.5.3

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

  reply	other threads:[~2014-09-24  8:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23  3:25 [Patch v2] get MODULES_VADDR by KERNEL_IMAGE_SIZE for x86_64 Baoquan He
2014-09-24  7:55 ` Atsushi Kumagai
2014-09-24  8:02   ` bhe [this message]
2014-10-20  7:17     ` Atsushi Kumagai
2014-10-20 11:12       ` bhe

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=20140924080200.GG8697@dhcp-16-116.nay.redhat.com \
    --to=bhe@redhat.com \
    --cc=kexec@lists.infradead.org \
    --cc=kumagai-atsushi@mxc.nes.nec.co.jp \
    /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.