Re: arm64: virtio broken in upstream kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 13, 2014 at 10:09:51AM +0800, Wang, Yalin wrote:
> > Sent: Thursday, October 23, 2014 5:47 AM
> > To: kvmarm@xxxxxxxxxxxxxxxxxxxxx
> > Cc: Wang, Yalin; peter.maydell@xxxxxxxxxx
> > Subject: arm64: virtio broken in upstream kernel
> > 
> > Initially I thought this was a qemu bug, so I was tracking it here.
> > 
> > https://bugs.launchpad.net/qemu/+bug/1383857
> > 
> > In brief, virtio devices don't show up in the guest when using kernel
> > 3.18.0+rc1.  I'm also using 64k pages, but I don't know if that is related.
> > 
> > I did a bisect and it pointed at:
> > 
> >   421520ba98290a73b35b7644e877a48f18e06004 is the first bad commit
> >   commit 421520ba98290a73b35b7644e877a48f18e06004
> >   Author: Yalin Wang <Yalin.Wang@xxxxxxxxxxxxxx>
> >   Date: Fri Sep 26 03:07:09 2014 +0100
> > 
> >     ARM: 8167/1: extend the reserved memory for initrd to be page aligned
> > 
> >     This patch extends the start and end address of initrd to be page
> > aligned,
> >     so that we can free all memory including the un-page aligned head or
> > tail
> >     page of initrd, if the start or end address of initrd are not page
> >     aligned, the page can't be freed by free_initrd_mem() function.
> > 
> >     Signed-off-by: Yalin Wang <yalin.wang@xxxxxxxxxxxxxx>
> >     Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx>
> >     Signed-off-by: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>
> > 
> >   :040000 040000 23bd54d302533c173a4ae592969dd2868794e9ed
> > f1833b44ee7a389902f6f9d2fb55f4b89ba0de16 M arch
> > 
> > I also reverted this patch on top of the 3.18.0+rc1 kernel, and I see:
> > 
> >   supermin: internal insmod virtio.ko
> >   supermin: internal insmod virtio_ring.ko
> >   supermin: internal insmod virtio_blk.ko
> >   supermin: internal insmod virtio-rng.ko
> >   supermin: internal insmod virtio_console.ko
> >   supermin: internal insmod virtio_net.ko
> >   supermin: internal insmod scsi_transport_spi.ko
> >   supermin: internal insmod virtio_scsi.ko
> >   supermin: internal insmod virtio_balloon.ko
> >   supermin: internal insmod virtio_mmio.ko
> >   [    2.765223] BUG: failure at
> > include/linux/virtio_config.h:125/virtio_device_ready()!
> >   [    2.765932] Kernel panic - not syncing: BUG!
> >   [    2.766792] CPU: 0 PID: 18 Comm: kworker/0:1 Not tainted 3.18.0-rc1+
> > #46
> >   [    2.767532] Workqueue: events control_work_handler [virtio_console]
> >   [    2.768194] Call trace:
> >   [    2.768779] [<fffffe0000096cc8>] dump_backtrace+0x0/0x164
> >   [    2.769252] [<fffffe0000096e48>] show_stack+0x1c/0x28
> >   [    2.769618] [<fffffe0000726ff4>] dump_stack+0x74/0x94
> >   [    2.769947] [<fffffe00007264a4>] panic+0xe8/0x228
> >   [    2.770434] [<fffffdfffc14252c>] add_port+0x378/0x37c [virtio_console]
> >   [    2.770983] [<fffffdfffc142fb4>] control_work_handler+0x374/0x390
> > [virtio_console]
> >   [    2.771552] [<fffffe00000cf8cc>] process_one_work+0x148/0x3a4
> >   [    2.772067] [<fffffe00000d0358>] worker_thread+0x13c/0x488
> >   [    2.772758] [<fffffe00000d53fc>] kthread+0xe0/0xf8
> >   [    2.773801] Rebooting in 1 seconds..Reboot failed -- System halted
> > 
> > So I guess this patch really is to blame.
> > 
> > Not sure I understand exactly why aligning the initrd affects virtio
> > however ...
> > 
> > Rich.
> > 
> > --
> > Richard Jones, Virtualization Group, Red Hat
> > http://people.redhat.com/~rjones Read my programming and virtualization
> > blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from
> > scratch http://libguestfs.org/virt-builder.1.html
> 
> 
> Could you try this patch? If my patch is suspicious .
> 
> ---
> this patch extend the start and end address of initrd to be page aligned,
> so that we can free all memory including the un-page aligned
> head or tail page of initrd, if the start or end address of initrd are
> not page aligned, the page can't be freed by free_initrd_mem() function.
> 
> Signed-off-by: Yalin Wang <yalin.wang@xxxxxxxxxxxxxx>
> ---
>  arch/arm/mm/init.c   | 19 +++++++++++++++++--
>  arch/arm64/mm/init.c | 37 +++++++++++++++++++++++++++++++++----
>  2 files changed, 50 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 659c75d..8490b70 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -277,6 +277,8 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)  void __init arm_memblock_init(const struct machine_desc *mdesc)  {
>  	/* Register the kernel text, kernel data and initrd with memblock. */
> +	phys_addr_t phys_initrd_start_orig __maybe_unused;
> +	phys_addr_t phys_initrd_size_orig __maybe_unused;
>  #ifdef CONFIG_XIP_KERNEL
>  	memblock_reserve(__pa(_sdata), _end - _sdata);  #else @@ -289,6 +291,13 @@ void __init arm_memblock_init(const struct machine_desc *mdesc)
>  		phys_initrd_size = initrd_end - initrd_start;
>  	}
>  	initrd_start = initrd_end = 0;
> +	phys_initrd_start_orig = phys_initrd_start;
> +	phys_initrd_size_orig = phys_initrd_size;
> +	/* make sure the start and end address are page aligned */
> +	phys_initrd_size = round_up(phys_initrd_start + phys_initrd_size, PAGE_SIZE);
> +	phys_initrd_start = round_down(phys_initrd_start, PAGE_SIZE);
> +	phys_initrd_size -= phys_initrd_start;
> +
>  	if (phys_initrd_size &&
>  	    !memblock_is_region_memory(phys_initrd_start, phys_initrd_size)) {
>  		pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling initrd\n", @@ -305,9 +314,10 @@ void __init arm_memblock_init(const struct machine_desc *mdesc)
>  		memblock_reserve(phys_initrd_start, phys_initrd_size);
>  
>  		/* Now convert initrd to virtual addresses */
> -		initrd_start = __phys_to_virt(phys_initrd_start);
> -		initrd_end = initrd_start + phys_initrd_size;
> +		initrd_start = __phys_to_virt(phys_initrd_start_orig);
> +		initrd_end = initrd_start + phys_initrd_size_orig;
>  	}
> +
>  #endif
>  
>  	arm_mm_memblock_reserve();
> @@ -636,6 +646,11 @@ static int keep_initrd;  void free_initrd_mem(unsigned long start, unsigned long end)  {
>  	if (!keep_initrd) {
> +		if (start == initrd_start)
> +			start = round_down(start, PAGE_SIZE);
> +		if (end == initrd_end)
> +			end = round_up(end, PAGE_SIZE);
> +
>  		poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
>  		free_reserved_area((void *)start, (void *)end, -1, "initrd");
>  	}
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 5472c24..9dfd9a6 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -138,15 +138,38 @@ static void arm64_memory_present(void)  void __init arm64_memblock_init(void)  {
>  	phys_addr_t dma_phys_limit = 0;
> -
> +	phys_addr_t phys_initrd_start;
> +	phys_addr_t phys_initrd_size;
>  	/*
>  	 * Register the kernel text, kernel data, initrd, and initial
>  	 * pagetables with memblock.
>  	 */
>  	memblock_reserve(__pa(_text), _end - _text);  #ifdef CONFIG_BLK_DEV_INITRD
> -	if (initrd_start)
> -		memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
> +	if (initrd_start) {
> +		phys_initrd_start = __virt_to_phys(initrd_start);
> +		phys_initrd_size = initrd_end - initrd_start;
> +		/* make sure the start and end address are page aligned */
> +		phys_initrd_size = round_up(phys_initrd_start + phys_initrd_size, PAGE_SIZE);
> +		phys_initrd_start = round_down(phys_initrd_start, PAGE_SIZE);
> +		phys_initrd_size -= phys_initrd_start;
> +		if (phys_initrd_size &&
> +				!memblock_is_region_memory(phys_initrd_start, phys_initrd_size)) {
> +			pr_err("INITRD: %pa+%pa is not a memory region - disabling initrd\n",
> +					&phys_initrd_start, &phys_initrd_size);
> +			phys_initrd_start = phys_initrd_size = 0;
> +		}
> +		if (phys_initrd_size &&
> +				memblock_is_region_reserved(phys_initrd_start, phys_initrd_size)) {
> +			pr_err("INITRD: %pa+%pa overlaps in-use memory region - disabling initrd\n",
> +					&phys_initrd_start, &phys_initrd_size);
> +			phys_initrd_start = phys_initrd_size = 0;
> +		}
> +		if (phys_initrd_size)
> +			memblock_reserve(phys_initrd_start, phys_initrd_size);
> +		else
> +			initrd_start = initrd_end = 0;
> +	}
>  #endif
>  
>  	if (!efi_enabled(EFI_MEMMAP))
> @@ -334,8 +357,14 @@ static int keep_initrd;
>  
>  void free_initrd_mem(unsigned long start, unsigned long end)  {
> -	if (!keep_initrd)
> +	if (!keep_initrd) {
> +		if (start == initrd_start)
> +			start = round_down(start, PAGE_SIZE);
> +		if (end == initrd_end)
> +			end = round_up(end, PAGE_SIZE);
> +
>  		free_reserved_area((void *)start, (void *)end, 0, "initrd");
> +	}
>  }
>  
>  static int __init keepinitrd_setup(char *__unused)
> --
> 2.1.0

No, this patch doesn't seem to make any difference I'm afraid.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux