Re: [PATCH v2 7/9] get the random phy addr according to slot_area info

From: Baoquan He
Date: Tue Mar 03 2015 - 06:44:31 EST


On 03/03/15 at 12:45am, Yinghai Lu wrote:
> On Mon, Mar 2, 2015 at 6:58 AM, Baoquan He <bhe@xxxxxxxxxx> wrote:
> > Now random value can be used to get related slot info stored in
> > slot_area, mainly use slot_area.num to position which slot is target.
> > With this slot its starting address is returned as the physical
> > address where kernel will put.
> >
> > @@ -362,7 +364,7 @@ repeat:
> > goto repeat;
> > }
> >
> > -static unsigned long find_random_addr(unsigned long minimum,
> > +static unsigned long find_random_phy_addr(unsigned long minimum,
> > unsigned long size)
>

Hi Yinghai,

Thanks for testing and reviewing.

Yes, I forgot to change calling name. Must be dizzy during making patch.
Will change.

> You forgot to change calling name.
>
> got:
>
> arch/x86/boot/compressed/aslr.o: In function `choose_kernel_location':
> aslr.c:(.text+0x163): undefined reference to `find_random_addr'
> make[2]: *** [arch/x86/boot/compressed/vmlinux] Error 1
> make[1]: *** [arch/x86/boot/compressed/vmlinux] Error 2
>
> Please make the patch set bisect-able.

Ok, will rearrange patches.
>
> after fixing that, on the system with 4G ram: i got:
>
> early console in decompress_kernel
> KASLR using RDTSC...
> decompress_kernel:
> input: [0x13f5ed3b4-0x13ff6a64b], output: 0x153000000, heap:

Here input means the region where kernel was linked to load?

In normal kernel the linked address is 0x1000000. In your input region
the result of ALIGN(0x13f5ed3b4, CONFIG_PHYSICAL_ALIGN) is 0x140000000.
And size of this region is smaller than 16M. It should return in
process_e820_entry() with two checks.

I guess you use kexec or a special bootloader to put kernel in this
load address.

I will check code again it doesn't handle this case correctly.

> [0x13ff76000-0x13ff7dfff]
>
> Decompressing Linux... xz...
>
> XZ-compressed data is corrupt
>
>
> without the patch, I have:
>
> early console in decompress_kernel
> KASLR could not find suitable E820 region...
> decompress_kernel:
> input: [0x13f5ee3b4-0x13ff6b64b], output: 0x13cc00000, heap:
> [0x13ff76000-0x13ff7dfff]
>
> Decompressing Linux... xz... Parsing ELF... done.
> ...
> [ 0.016848] e820: BIOS-provided physical RAM map (sanitized by setup):
> [ 0.018854] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
> [ 0.020982] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
> [ 0.023166] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
> [ 0.025783] BIOS-e820: [mem 0x0000000000100000-0x00000000bffdffff] usable
> [ 0.027901] BIOS-e820: [mem 0x00000000bffe0000-0x00000000bfffffff] reserved
> [ 0.030079] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
> [ 0.032252] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
> [ 0.034437] BIOS-e820: [mem 0x0000000100000000-0x000000013fffffff] usable
>
> so you code now select range that is out of boundary to non ram area.
>
> Thanks
>
> Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/