* [Qemu-devel] [PATCH 1/1] dump: Update correct kdump phys_base field for AArch64
@ 2018-03-09 17:03 Wei Huang
2018-03-11 17:42 ` Marc-André Lureau
0 siblings, 1 reply; 3+ messages in thread
From: Wei Huang @ 2018-03-09 17:03 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, wei
For guest kernel that supports KASLR, the load address can change every
time when guest VM runs. To find the physical base address correctly,
current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=".
However this string pattern is only available on x86_64. AArch64 uses a
different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure
QEMU dump uses the correct string on AArch64.
Signed-off-by: Wei Huang <wei@redhat.com>
---
dump.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dump.c b/dump.c
index 097e60b..6bdb0db 100644
--- a/dump.c
+++ b/dump.c
@@ -1609,10 +1609,18 @@ static void vmcoreinfo_update_phys_base(DumpState *s)
lines = g_strsplit((char *)vmci, "\n", -1);
for (i = 0; lines[i]; i++) {
- if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) {
- if (qemu_strtou64(lines[i] + 18, NULL, 16,
+ const char *prefix = NULL;
+
+ if (s->dump_info.d_machine == EM_X86_64) {
+ prefix = "NUMBER(phys_base)=";
+ } else if (s->dump_info.d_machine == EM_AARCH64) {
+ prefix = "NUMBER(PHYS_OFFSET)=";
+ }
+
+ if (prefix && g_str_has_prefix(lines[i], prefix)) {
+ if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16,
&phys_base) < 0) {
- warn_report("Failed to read NUMBER(phys_base)=");
+ warn_report("Failed to read %s", prefix);
} else {
s->dump_info.phys_base = phys_base;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] dump: Update correct kdump phys_base field for AArch64
2018-03-09 17:03 [Qemu-devel] [PATCH 1/1] dump: Update correct kdump phys_base field for AArch64 Wei Huang
@ 2018-03-11 17:42 ` Marc-André Lureau
2018-03-12 13:45 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2018-03-11 17:42 UTC (permalink / raw)
To: Wei Huang; +Cc: qemu-devel
Hi
On Fri, Mar 9, 2018 at 6:03 PM, Wei Huang <wei@redhat.com> wrote:
> For guest kernel that supports KASLR, the load address can change every
> time when guest VM runs. To find the physical base address correctly,
> current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=".
> However this string pattern is only available on x86_64. AArch64 uses a
> different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure
> QEMU dump uses the correct string on AArch64.
>
> Signed-off-by: Wei Huang <wei@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> dump.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/dump.c b/dump.c
> index 097e60b..6bdb0db 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -1609,10 +1609,18 @@ static void vmcoreinfo_update_phys_base(DumpState *s)
>
> lines = g_strsplit((char *)vmci, "\n", -1);
> for (i = 0; lines[i]; i++) {
> - if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) {
> - if (qemu_strtou64(lines[i] + 18, NULL, 16,
> + const char *prefix = NULL;
> +
> + if (s->dump_info.d_machine == EM_X86_64) {
> + prefix = "NUMBER(phys_base)=";
> + } else if (s->dump_info.d_machine == EM_AARCH64) {
> + prefix = "NUMBER(PHYS_OFFSET)=";
> + }
> +
> + if (prefix && g_str_has_prefix(lines[i], prefix)) {
> + if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16,
> &phys_base) < 0) {
> - warn_report("Failed to read NUMBER(phys_base)=");
> + warn_report("Failed to read %s", prefix);
> } else {
> s->dump_info.phys_base = phys_base;
> }
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] dump: Update correct kdump phys_base field for AArch64
2018-03-11 17:42 ` Marc-André Lureau
@ 2018-03-12 13:45 ` Peter Maydell
0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2018-03-12 13:45 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Wei Huang, qemu-devel
On 11 March 2018 at 17:42, Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
> Hi
>
> On Fri, Mar 9, 2018 at 6:03 PM, Wei Huang <wei@redhat.com> wrote:
>> For guest kernel that supports KASLR, the load address can change every
>> time when guest VM runs. To find the physical base address correctly,
>> current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=".
>> However this string pattern is only available on x86_64. AArch64 uses a
>> different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure
>> QEMU dump uses the correct string on AArch64.
>>
>> Signed-off-by: Wei Huang <wei@redhat.com>
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Thanks; applied to target-arm.next for 2.12.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-12 13:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-09 17:03 [Qemu-devel] [PATCH 1/1] dump: Update correct kdump phys_base field for AArch64 Wei Huang
2018-03-11 17:42 ` Marc-André Lureau
2018-03-12 13:45 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).