All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Allow Xen Dom0 page filtering
@ 2014-03-27 17:49 Petr Tesarik
  2014-03-27 18:06 ` Petr Tesarik
  0 siblings, 1 reply; 16+ messages in thread
From: Petr Tesarik @ 2014-03-27 17:49 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec

Trying to use makedumpfile on a Xen Dom0 ELF file currently fails, but there
are in fact only a few missing pieces. With the following two patches, I was
able to produce a dump even with high dump levels (-d17 and -d31).

Needless to say, this can reduce the size of Dom0 dumps considerably.

Petr Tesarik (2):
  Earlier initialization of dom0_mapnr
  Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable

 makedumpfile.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

-- 
1.8.4.5


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 0/2] Allow Xen Dom0 page filtering
  2014-03-27 17:49 [PATCH 0/2] Allow Xen Dom0 page filtering Petr Tesarik
@ 2014-03-27 18:06 ` Petr Tesarik
  2014-03-27 18:06   ` [PATCH 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
  2014-03-27 18:06   ` [PATCH " Petr Tesarik
  0 siblings, 2 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-27 18:06 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, Petr Tesarik

I'm resending this, now with correct mail threading. Sorry for the noise.

Trying to use makedumpfile on a Xen Dom0 ELF file currently fails, but there
are in fact only a few missing pieces. With the following two patches, I was
able to produce a dump even with high dump levels (-d17 and -d31).

Needless to say, this can reduce the size of Dom0 dumps considerably.

Petr Tesarik (2):
  Earlier initialization of dom0_mapnr
  Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable

 makedumpfile.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

-- 
1.8.4.5


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/2] Earlier initialization of dom0_mapnr
  2014-03-27 18:06 ` Petr Tesarik
@ 2014-03-27 18:06   ` Petr Tesarik
  2014-03-28  8:18     ` Atsushi Kumagai
  2014-03-27 18:06   ` [PATCH " Petr Tesarik
  1 sibling, 1 reply; 16+ messages in thread
From: Petr Tesarik @ 2014-03-27 18:06 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, Petr Tesarik

Xen dumps fail, because the p2m mapping is initialized too late.
The dependency goes like this:

- Xen uses FLATMEM
- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
- get_dom0_mapnr() needs p2m mappings to read from a VADDR
- the p2m list is initialized in get_machdep_info()

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index e91583d..d3f5237 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3128,6 +3128,12 @@ out:
 	if (!get_max_mapnr())
 		return FALSE;
 
+	if (debug_info && !get_machdep_info())
+		return FALSE;
+
+	if (is_xen_memory() && !get_dom0_mapnr())
+		return FALSE;
+
 	if (info->flag_cyclic) {
 		if (info->bufsize_cyclic == 0) {
 			if (!calculate_cyclic_buffer_size())
@@ -3185,9 +3191,6 @@ out:
 		if (info->flag_sadump)
 			(void) sadump_virt_phys_base();
 
-		if (!get_machdep_info())
-			return FALSE;
-
 		if (info->flag_sadump) {
 			int online_cpus;
 
@@ -3233,9 +3236,6 @@ out:
 			return FALSE;
 	}
 
-	if (is_xen_memory() && !get_dom0_mapnr())
-		return FALSE;
-
 	if (!get_value_for_old_linux())
 		return FALSE;
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable
  2014-03-27 18:06 ` Petr Tesarik
  2014-03-27 18:06   ` [PATCH 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
@ 2014-03-27 18:06   ` Petr Tesarik
  1 sibling, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-27 18:06 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, Petr Tesarik

If max_pfn symbol is not exported in the Dom0 kernel's VMCOREINFO, the
maximum PFN can be determined from the size of the mapping between PFN
and MFN.

Using this approach, filtering works for Xen kernels without debuginfo
(and even without adding more lines to VMCOREINFO).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index d3f5237..92e8a6a 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -189,9 +189,30 @@ get_dom0_mapnr()
 		}
 
 		info->dom0_mapnr = max_pfn;
-		DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
+	} else if (info->p2m_frames) {
+		unsigned long mfns[MFNS_PER_FRAME];
+		unsigned long mfn_idx = info->p2m_frames - 1;
+		unsigned long long maddr;
+		unsigned i;
+
+		maddr = pfn_to_paddr(info->p2m_mfn_frame_list[mfn_idx]);
+		if (!readmem(MADDR_XEN, maddr, &mfns, sizeof(mfns))) {
+			ERRMSG("Can't read %ld domain-0 mfns at 0x%llu\n",
+				(long)MFNS_PER_FRAME, maddr);
+			return FALSE;
+		}
+
+		for (i = 0; i < MFNS_PER_FRAME; ++i)
+			if (!mfns[i])
+				break;
+
+		info->dom0_mapnr = mfn_idx * MFNS_PER_FRAME + i;
+	} else {
+		/* dom0_mapnr is unavailable, which may be non-critical */
+		return TRUE;
 	}
 
+	DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
 	return TRUE;
 }
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* RE: [PATCH 1/2] Earlier initialization of dom0_mapnr
  2014-03-27 18:06   ` [PATCH 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
@ 2014-03-28  8:18     ` Atsushi Kumagai
  2014-03-28  8:26       ` Petr Tesarik
                         ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Atsushi Kumagai @ 2014-03-28  8:18 UTC (permalink / raw)
  To: ptesarik; +Cc: kexec

Hello Petr,

>Xen dumps fail, because the p2m mapping is initialized too late.
>The dependency goes like this:
>
>- Xen uses FLATMEM
>- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
>- get_dom0_mapnr() needs p2m mappings to read from a VADDR
>- the p2m list is initialized in get_machdep_info()
>
>Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
>---
> makedumpfile.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/makedumpfile.c b/makedumpfile.c
>index e91583d..d3f5237 100644
>--- a/makedumpfile.c
>+++ b/makedumpfile.c
>@@ -3128,6 +3128,12 @@ out:
> 	if (!get_max_mapnr())
> 		return FALSE;
>
>+	if (debug_info && !get_machdep_info())
>+		return FALSE;

You have to move get_machdep_info() after cache_init()
since get_machdep_info() calls readmem() on some architectures.
Otherwise, readmem() calls cache_alloc() without the cache
initialization.


Thanks
Atsushi Kumagai

>+
>+	if (is_xen_memory() && !get_dom0_mapnr())
>+		return FALSE;
>+
> 	if (info->flag_cyclic) {
> 		if (info->bufsize_cyclic == 0) {
> 			if (!calculate_cyclic_buffer_size())
>@@ -3185,9 +3191,6 @@ out:
> 		if (info->flag_sadump)
> 			(void) sadump_virt_phys_base();
>
>-		if (!get_machdep_info())
>-			return FALSE;
>-
> 		if (info->flag_sadump) {
> 			int online_cpus;
>
>@@ -3233,9 +3236,6 @@ out:
> 			return FALSE;
> 	}
>
>-	if (is_xen_memory() && !get_dom0_mapnr())
>-		return FALSE;
>-
> 	if (!get_value_for_old_linux())
> 		return FALSE;
>
>--
>1.8.4.5

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] Earlier initialization of dom0_mapnr
  2014-03-28  8:18     ` Atsushi Kumagai
@ 2014-03-28  8:26       ` Petr Tesarik
  2014-03-28  9:01         ` Atsushi Kumagai
  2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
  2014-03-28 12:09       ` Petr Tesarik
  2 siblings, 1 reply; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28  8:26 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec

On Fri, 28 Mar 2014 08:18:13 +0000
Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp> wrote:

> Hello Petr,
> 
> >Xen dumps fail, because the p2m mapping is initialized too late.
> >The dependency goes like this:
> >
> >- Xen uses FLATMEM
> >- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
> >- get_dom0_mapnr() needs p2m mappings to read from a VADDR
> >- the p2m list is initialized in get_machdep_info()
> >
> >Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> >---
> > makedumpfile.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> >diff --git a/makedumpfile.c b/makedumpfile.c
> >index e91583d..d3f5237 100644
> >--- a/makedumpfile.c
> >+++ b/makedumpfile.c
> >@@ -3128,6 +3128,12 @@ out:
> > 	if (!get_max_mapnr())
> > 		return FALSE;
> >
> >+	if (debug_info && !get_machdep_info())
> >+		return FALSE;
> 
> You have to move get_machdep_info() after cache_init()
> since get_machdep_info() calls readmem() on some architectures.
> Otherwise, readmem() calls cache_alloc() without the cache
> initialization.

*sigh*

I suspected that the dependencies may be more complex...
Out of curiosity, do you already have an overview (dependency graph or
similar)? And if not, would you appreciate it if I created one?

Petr T

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH 1/2] Earlier initialization of dom0_mapnr
  2014-03-28  8:26       ` Petr Tesarik
@ 2014-03-28  9:01         ` Atsushi Kumagai
  0 siblings, 0 replies; 16+ messages in thread
From: Atsushi Kumagai @ 2014-03-28  9:01 UTC (permalink / raw)
  To: ptesarik; +Cc: kexec

>On Fri, 28 Mar 2014 08:18:13 +0000
>Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp> wrote:
>
>> Hello Petr,
>>
>> >Xen dumps fail, because the p2m mapping is initialized too late.
>> >The dependency goes like this:
>> >
>> >- Xen uses FLATMEM
>> >- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
>> >- get_dom0_mapnr() needs p2m mappings to read from a VADDR
>> >- the p2m list is initialized in get_machdep_info()
>> >
>> >Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
>> >---
>> > makedumpfile.c | 12 ++++++------
>> > 1 file changed, 6 insertions(+), 6 deletions(-)
>> >
>> >diff --git a/makedumpfile.c b/makedumpfile.c
>> >index e91583d..d3f5237 100644
>> >--- a/makedumpfile.c
>> >+++ b/makedumpfile.c
>> >@@ -3128,6 +3128,12 @@ out:
>> > 	if (!get_max_mapnr())
>> > 		return FALSE;
>> >
>> >+	if (debug_info && !get_machdep_info())
>> >+		return FALSE;
>>
>> You have to move get_machdep_info() after cache_init()
>> since get_machdep_info() calls readmem() on some architectures.
>> Otherwise, readmem() calls cache_alloc() without the cache
>> initialization.
>
>*sigh*
>
>I suspected that the dependencies may be more complex...
>Out of curiosity, do you already have an overview (dependency graph or
>similar)? And if not, would you appreciate it if I created one?

I'm afraid that I don't have such a stuff, but it will be very helpful
for maintenance and clean-up since initial() was getting complex by
additional features. So I will appreciate your work.


Thanks
Atsushi Kumagai

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 0/2]  Allow Xen Dom0 page filtering
  2014-03-28  8:18     ` Atsushi Kumagai
  2014-03-28  8:26       ` Petr Tesarik
@ 2014-03-28 12:08       ` Petr Tesarik
  2014-03-28 12:08         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
                           ` (3 more replies)
  2014-03-28 12:09       ` Petr Tesarik
  2 siblings, 4 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:08 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, Petr Tesarik

Trying to use makedumpfile on a Xen Dom0 ELF file currently fails, but there
are in fact only a few missing pieces. With the following two patches, I was
able to produce a dump even with high dump levels (-d17 and -d31).

Needless to say, this can reduce the size of Dom0 dumps considerably.

Changes in v2:

* Call get_machdep_info() after cache_init(), so it can use readmem(VADDR, ...)

This now works for me after reverting commit ebe2fa3a.

Petr Tesarik (2):
  Earlier initialization of dom0_mapnr
  Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable

 makedumpfile.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

-- 
1.8.4.5


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 1/2] Earlier initialization of dom0_mapnr
  2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
@ 2014-03-28 12:08         ` Petr Tesarik
  2014-03-28 12:08         ` [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable Petr Tesarik
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:08 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: Petr Tesarik, Petr Tesarik, kexec

From: Petr Tesarik <petr@tesarici.cz>

Xen dumps fail, because the p2m mapping is initialized too late.
The dependency goes like this:

- Xen uses FLATMEM
- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
- get_dom0_mapnr() needs p2m mappings to read from a VADDR
- the p2m list is initialized in get_machdep_info()

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index e91583d..1117598 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3181,13 +3181,16 @@ out:
 	if (!is_xen_memory() && !cache_init())
 		return FALSE;
 
+	if (debug_info && !get_machdep_info())
+		return FALSE;
+
+	if (is_xen_memory() && !get_dom0_mapnr())
+		return FALSE;
+
 	if (debug_info) {
 		if (info->flag_sadump)
 			(void) sadump_virt_phys_base();
 
-		if (!get_machdep_info())
-			return FALSE;
-
 		if (info->flag_sadump) {
 			int online_cpus;
 
@@ -3233,9 +3236,6 @@ out:
 			return FALSE;
 	}
 
-	if (is_xen_memory() && !get_dom0_mapnr())
-		return FALSE;
-
 	if (!get_value_for_old_linux())
 		return FALSE;
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable
  2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
  2014-03-28 12:08         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
@ 2014-03-28 12:08         ` Petr Tesarik
  2014-03-28 12:08         ` [PATCH 0/2] Allow Xen Dom0 page filtering Petr Tesarik
  2014-04-03  2:38         ` [PATCH v2 " Atsushi Kumagai
  3 siblings, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:08 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: Petr Tesarik, Petr Tesarik, kexec

From: Petr Tesarik <petr@tesarici.cz>

If max_pfn symbol is not exported in the Dom0 kernel's VMCOREINFO, the
maximum PFN can be determined from the size of the mapping between PFN
and MFN.

Using this approach, filtering works for Xen kernels without debuginfo
(and even without adding more lines to VMCOREINFO).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 1117598..341fbe8 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -189,9 +189,30 @@ get_dom0_mapnr()
 		}
 
 		info->dom0_mapnr = max_pfn;
-		DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
+	} else if (info->p2m_frames) {
+		unsigned long mfns[MFNS_PER_FRAME];
+		unsigned long mfn_idx = info->p2m_frames - 1;
+		unsigned long long maddr;
+		unsigned i;
+
+		maddr = pfn_to_paddr(info->p2m_mfn_frame_list[mfn_idx]);
+		if (!readmem(MADDR_XEN, maddr, &mfns, sizeof(mfns))) {
+			ERRMSG("Can't read %ld domain-0 mfns at 0x%llu\n",
+				(long)MFNS_PER_FRAME, maddr);
+			return FALSE;
+		}
+
+		for (i = 0; i < MFNS_PER_FRAME; ++i)
+			if (!mfns[i])
+				break;
+
+		info->dom0_mapnr = mfn_idx * MFNS_PER_FRAME + i;
+	} else {
+		/* dom0_mapnr is unavailable, which may be non-critical */
+		return TRUE;
 	}
 
+	DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
 	return TRUE;
 }
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 0/2] Allow Xen Dom0 page filtering
  2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
  2014-03-28 12:08         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
  2014-03-28 12:08         ` [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable Petr Tesarik
@ 2014-03-28 12:08         ` Petr Tesarik
  2014-04-03  2:38         ` [PATCH v2 " Atsushi Kumagai
  3 siblings, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:08 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, Petr Tesarik

Trying to use makedumpfile on a Xen Dom0 ELF file currently fails, but there
are in fact only a few missing pieces. With the following two patches, I was
able to produce a dump even with high dump levels (-d17 and -d31).

Needless to say, this can reduce the size of Dom0 dumps considerably.

Petr Tesarik (2):
  Earlier initialization of dom0_mapnr
  Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable

 makedumpfile.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

-- 
1.8.4.5


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 0/2]  Allow Xen Dom0 page filtering
  2014-03-28  8:18     ` Atsushi Kumagai
  2014-03-28  8:26       ` Petr Tesarik
  2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
@ 2014-03-28 12:09       ` Petr Tesarik
  2014-03-28 12:09         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
  2014-03-28 12:09         ` [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable Petr Tesarik
  2 siblings, 2 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:09 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, Petr Tesarik

Trying to use makedumpfile on a Xen Dom0 ELF file currently fails, but there
are in fact only a few missing pieces. With the following two patches, I was
able to produce a dump even with high dump levels (-d17 and -d31).

Needless to say, this can reduce the size of Dom0 dumps considerably.

Changes in v2:

* Call get_machdep_info() after cache_init(), so it can use readmem(VADDR, ...)

This now works for me after reverting commit ebe2fa3a.

Petr Tesarik (2):
  Earlier initialization of dom0_mapnr
  Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable

 makedumpfile.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

-- 
1.8.4.5


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 1/2] Earlier initialization of dom0_mapnr
  2014-03-28 12:09       ` Petr Tesarik
@ 2014-03-28 12:09         ` Petr Tesarik
  2014-03-28 12:09         ` [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable Petr Tesarik
  1 sibling, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:09 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: Petr Tesarik, Petr Tesarik, kexec

From: Petr Tesarik <petr@tesarici.cz>

Xen dumps fail, because the p2m mapping is initialized too late.
The dependency goes like this:

- Xen uses FLATMEM
- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
- get_dom0_mapnr() needs p2m mappings to read from a VADDR
- the p2m list is initialized in get_machdep_info()

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index e91583d..1117598 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3181,13 +3181,16 @@ out:
 	if (!is_xen_memory() && !cache_init())
 		return FALSE;
 
+	if (debug_info && !get_machdep_info())
+		return FALSE;
+
+	if (is_xen_memory() && !get_dom0_mapnr())
+		return FALSE;
+
 	if (debug_info) {
 		if (info->flag_sadump)
 			(void) sadump_virt_phys_base();
 
-		if (!get_machdep_info())
-			return FALSE;
-
 		if (info->flag_sadump) {
 			int online_cpus;
 
@@ -3233,9 +3236,6 @@ out:
 			return FALSE;
 	}
 
-	if (is_xen_memory() && !get_dom0_mapnr())
-		return FALSE;
-
 	if (!get_value_for_old_linux())
 		return FALSE;
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable
  2014-03-28 12:09       ` Petr Tesarik
  2014-03-28 12:09         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
@ 2014-03-28 12:09         ` Petr Tesarik
  1 sibling, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-28 12:09 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: Petr Tesarik, Petr Tesarik, kexec

From: Petr Tesarik <petr@tesarici.cz>

If max_pfn symbol is not exported in the Dom0 kernel's VMCOREINFO, the
maximum PFN can be determined from the size of the mapping between PFN
and MFN.

Using this approach, filtering works for Xen kernels without debuginfo
(and even without adding more lines to VMCOREINFO).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 1117598..341fbe8 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -189,9 +189,30 @@ get_dom0_mapnr()
 		}
 
 		info->dom0_mapnr = max_pfn;
-		DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
+	} else if (info->p2m_frames) {
+		unsigned long mfns[MFNS_PER_FRAME];
+		unsigned long mfn_idx = info->p2m_frames - 1;
+		unsigned long long maddr;
+		unsigned i;
+
+		maddr = pfn_to_paddr(info->p2m_mfn_frame_list[mfn_idx]);
+		if (!readmem(MADDR_XEN, maddr, &mfns, sizeof(mfns))) {
+			ERRMSG("Can't read %ld domain-0 mfns at 0x%llu\n",
+				(long)MFNS_PER_FRAME, maddr);
+			return FALSE;
+		}
+
+		for (i = 0; i < MFNS_PER_FRAME; ++i)
+			if (!mfns[i])
+				break;
+
+		info->dom0_mapnr = mfn_idx * MFNS_PER_FRAME + i;
+	} else {
+		/* dom0_mapnr is unavailable, which may be non-critical */
+		return TRUE;
 	}
 
+	DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
 	return TRUE;
 }
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* RE: [PATCH v2 0/2]  Allow Xen Dom0 page filtering
  2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
                           ` (2 preceding siblings ...)
  2014-03-28 12:08         ` [PATCH 0/2] Allow Xen Dom0 page filtering Petr Tesarik
@ 2014-04-03  2:38         ` Atsushi Kumagai
  3 siblings, 0 replies; 16+ messages in thread
From: Atsushi Kumagai @ 2014-04-03  2:38 UTC (permalink / raw)
  To: ptesarik; +Cc: kexec

Hello Petr,

This looks good to me, I'll merge it into v1.5.6.


Thanks
Atsushi Kumagai

>Trying to use makedumpfile on a Xen Dom0 ELF file currently fails, but there
>are in fact only a few missing pieces. With the following two patches, I was
>able to produce a dump even with high dump levels (-d17 and -d31).
>
>Needless to say, this can reduce the size of Dom0 dumps considerably.
>
>Changes in v2:
>
>* Call get_machdep_info() after cache_init(), so it can use readmem(VADDR, ...)
>
>This now works for me after reverting commit ebe2fa3a.
>
>Petr Tesarik (2):
>  Earlier initialization of dom0_mapnr
>  Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable
>
> makedumpfile.c | 35 ++++++++++++++++++++++++++++-------
> 1 file changed, 28 insertions(+), 7 deletions(-)
>
>--
>1.8.4.5

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/2] Earlier initialization of dom0_mapnr
@ 2014-03-27 17:40 Petr Tesarik
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Tesarik @ 2014-03-27 17:40 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec

Xen dumps fail, because the p2m mapping is initialized too late.
The dependency goes like this:

- Xen uses FLATMEM
- get_mm_flatmem() uses info->dom0_mapnr to initialize mm structures
- get_dom0_mapnr() needs p2m mappings to read from a VADDR
- the p2m list is initialized in get_machdep_info()

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 makedumpfile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index e91583d..d3f5237 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3128,6 +3128,12 @@ out:
 	if (!get_max_mapnr())
 		return FALSE;
 
+	if (debug_info && !get_machdep_info())
+		return FALSE;
+
+	if (is_xen_memory() && !get_dom0_mapnr())
+		return FALSE;
+
 	if (info->flag_cyclic) {
 		if (info->bufsize_cyclic == 0) {
 			if (!calculate_cyclic_buffer_size())
@@ -3185,9 +3191,6 @@ out:
 		if (info->flag_sadump)
 			(void) sadump_virt_phys_base();
 
-		if (!get_machdep_info())
-			return FALSE;
-
 		if (info->flag_sadump) {
 			int online_cpus;
 
@@ -3233,9 +3236,6 @@ out:
 			return FALSE;
 	}
 
-	if (is_xen_memory() && !get_dom0_mapnr())
-		return FALSE;
-
 	if (!get_value_for_old_linux())
 		return FALSE;
 
-- 
1.8.4.5


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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-04-03  2:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-27 17:49 [PATCH 0/2] Allow Xen Dom0 page filtering Petr Tesarik
2014-03-27 18:06 ` Petr Tesarik
2014-03-27 18:06   ` [PATCH 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
2014-03-28  8:18     ` Atsushi Kumagai
2014-03-28  8:26       ` Petr Tesarik
2014-03-28  9:01         ` Atsushi Kumagai
2014-03-28 12:08       ` [PATCH v2 0/2] Allow Xen Dom0 page filtering Petr Tesarik
2014-03-28 12:08         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
2014-03-28 12:08         ` [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable Petr Tesarik
2014-03-28 12:08         ` [PATCH 0/2] Allow Xen Dom0 page filtering Petr Tesarik
2014-04-03  2:38         ` [PATCH v2 " Atsushi Kumagai
2014-03-28 12:09       ` Petr Tesarik
2014-03-28 12:09         ` [PATCH v2 1/2] Earlier initialization of dom0_mapnr Petr Tesarik
2014-03-28 12:09         ` [PATCH v2 2/2] Get Dom0 max_pfn using pfn_mfn_frame_list if max_pfn unavailable Petr Tesarik
2014-03-27 18:06   ` [PATCH " Petr Tesarik
  -- strict thread matches above, loose matches on Subject: below --
2014-03-27 17:40 [PATCH 1/2] Earlier initialization of dom0_mapnr Petr Tesarik

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.