Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: lijiang <lijiang@redhat.com>
Cc: jgross@suse.com, Thomas.Lendacky@amd.com, bhe@redhat.com,
	x86@kernel.org, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org, dhowells@redhat.com,
	mingo@redhat.com, bp@alien8.de, hpa@zytor.com,
	tglx@linutronix.de, Dave Young <dyoung@redhat.com>,
	vgoyal@redhat.com
Subject: Re: [PATCH 3/3 v3] x86/kdump: clean up all the code related to the backup region
Date: Tue, 15 Oct 2019 06:11:21 -0500	[thread overview]
Message-ID: <87tv8az2jq.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <f3fc12b9-be39-d430-52f5-d1b76b2599a3@redhat.com> (lijiang's message of "Mon, 14 Oct 2019 18:02:22 +0800")

lijiang <lijiang@redhat.com> writes:

> 在 2019年10月12日 20:16, Dave Young 写道:
>> Hi Eric,
>> 
>> On 10/12/19 at 06:26am, Eric W. Biederman wrote:
>>> Lianbo Jiang <lijiang@redhat.com> writes:
>>>
>>>> When the crashkernel kernel command line option is specified, the
>>>> low 1MiB memory will always be reserved, which makes that the memory
>>>> allocated later won't fall into the low 1MiB area, thereby, it's not
>>>> necessary to create a backup region and also no need to copy the first
>>>> 640k content to a backup region.
>>>>
>>>> Currently, the code related to the backup region can be safely removed,
>>>> so lets clean up.
>>>>
>>>> Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
>>>> ---
>>>
>>>> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
>>>> index eb651fbde92a..cc5774fc84c0 100644
>>>> --- a/arch/x86/kernel/crash.c
>>>> +++ b/arch/x86/kernel/crash.c
>>>> @@ -173,8 +173,6 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
>>>>  
>>>>  #ifdef CONFIG_KEXEC_FILE
>>>>  
>>>> -static unsigned long crash_zero_bytes;
>>>> -
>>>>  static int get_nr_ram_ranges_callback(struct resource *res, void *arg)
>>>>  {
>>>>  	unsigned int *nr_ranges = arg;
>>>> @@ -234,9 +232,15 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg)
>>>>  {
>>>>  	struct crash_mem *cmem = arg;
>>>>  
>>>> -	cmem->ranges[cmem->nr_ranges].start = res->start;
>>>> -	cmem->ranges[cmem->nr_ranges].end = res->end;
>>>> -	cmem->nr_ranges++;
>>>> +	if (res->start >= SZ_1M) {
>>>> +		cmem->ranges[cmem->nr_ranges].start = res->start;
>>>> +		cmem->ranges[cmem->nr_ranges].end = res->end;
>>>> +		cmem->nr_ranges++;
>>>> +	} else if (res->end > SZ_1M) {
>>>> +		cmem->ranges[cmem->nr_ranges].start = SZ_1M;
>>>> +		cmem->ranges[cmem->nr_ranges].end = res->end;
>>>> +		cmem->nr_ranges++;
>>>> +	}
>>>
>>> What is going on with this chunk?  I can guess but this needs a clear
>>> comment.
>> 
>> Indeed it needs some code comment, this is based on some offline
>> discussion.  cat /proc/vmcore will give a warning because ioremap is
>> mapping the system ram.
>> 
>> We pass the first 1M to kdump kernel in e820 as system ram so that 2nd
>> kernel can use the low 1M memory because for example the trampoline
>> code.
>> 
> Thank you, Eric and Dave. I will add the code comment as below if it would be OK.
>
> @@ -234,9 +232,20 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg)
>  {
>         struct crash_mem *cmem = arg;
>  
> -       cmem->ranges[cmem->nr_ranges].start = res->start;
> -       cmem->ranges[cmem->nr_ranges].end = res->end;
> -       cmem->nr_ranges++;
> +       /*
> +        * Currently, pass the low 1MiB range to kdump kernel in e820
> +        * as system ram so that kdump kernel can also use the low 1MiB
> +        * memory due to the real mode trampoline code.
> +        * And later, the low 1MiB range will be exclued from elf header,
> +        * which will avoid remapping the 1MiB system ram when dumping
> +        * vmcore.
> +        */
> +       if (res->start >= SZ_1M) {
> +               cmem->ranges[cmem->nr_ranges].start = res->start;
> +               cmem->ranges[cmem->nr_ranges].end = res->end;
> +               cmem->nr_ranges++;
> +       } else if (res->end > SZ_1M) {
> +               cmem->ranges[cmem->nr_ranges].start = SZ_1M;
> +               cmem->ranges[cmem->nr_ranges].end = res->end;
> +               cmem->nr_ranges++;
> +       }
>  
>         return 0;
>  }

I just read through the appropriate section of crash.c and the way
things are structured doing this work in
prepare_elf64_ram_headers_callback is wrong.

This can be done in a simpler manner in elf_header_exclude_ranges.
Something like:

	/* The low 1MiB is always reserved */
	ret = crash_exclude_mem_range(cmem, 0, 1024*1024);
	if (ret)
		return ret;

Eric

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

  reply	other threads:[~2019-10-15 11:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-12  2:21 [PATCH 0/3 v3] x86/kdump: Fix 'kmem -s' reported an invalid freepointer when SME was active Lianbo Jiang
2019-10-12  2:21 ` [PATCH 1/3 " Lianbo Jiang
2019-10-12  2:21 ` [PATCH 2/3 v3] x86/kdump cleanup: remove the unused crash_copy_backup_region() Lianbo Jiang
2019-10-12  2:21 ` [PATCH 3/3 v3] x86/kdump: clean up all the code related to the backup region Lianbo Jiang
2019-10-12 11:26   ` Eric W. Biederman
2019-10-12 12:16     ` Dave Young
2019-10-13  3:54       ` Eric W. Biederman
2019-10-13  9:36         ` lijiang
2019-10-15 11:04           ` Eric W. Biederman
2019-10-16  8:40             ` lijiang
2019-10-16 14:30             ` lijiang
2019-10-16 16:51               ` Eric W. Biederman
2019-10-13 10:20         ` Dave Young
2019-10-14 10:02       ` lijiang
2019-10-15 11:11         ` Eric W. Biederman [this message]
2019-10-16  3:24           ` lijiang

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=87tv8az2jq.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dhowells@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=kexec@lists.infradead.org \
    --cc=lijiang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.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