[PATCH v2 2/2] kexec: Provide arch_kexec_protect(unprotect)_crashkres()

Petr Tesarik ptesarik at suse.cz
Thu Jan 7 01:20:41 PST 2016


On Thu, 7 Jan 2016 13:08:21 +0800
Xunlei Pang <xlpang at redhat.com> wrote:

> On 01/07/2016 at 10:36 AM, Minfei Huang wrote:
> > On 01/07/16 at 10:14am, Xunlei Pang wrote:
> >>>> +static int
> >>>> +kexec_mark_range(unsigned long start, unsigned long end, bool protect)
> >>>> +{
> >>>> +	struct page *page;
> >>>> +	unsigned int nr_pages;
> >>>> +
> >>>> +	/* For physical range: [start, end] */
> >>>> +	if (!start || !end || start > end)
> >>>> +		return 0;
> >>> Hi, Xunlei.
> >>>
> >>>         if (start > end)
> >>>                 return 0;
> >> If both start and end are zero, we want to return directly, so the two
> >> more check doesn't hurt.
> > How about if the start is equal to 0, and end is larger than 0? It is
> > better to make code more robust, although it never happen in currect
> > kexec code.
> 
> Hmm, this will be better:
> 
> 	if (!end || start > end)
> 		return 0;
> 
> it handles the common case not using crash_low_res(start and end are 0).

Hm, if both start and end are 0, then what about using this condition:

 	if (start >= end)
 		return 0;

I think it's good enough, because if start is equal to end, then
there's nothing to protect anyway.

Regards,
Petr Tesarik



More information about the kexec mailing list