lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878vp1iqpz.fsf@rustcorp.com.au>
Date:	Tue, 04 Oct 2011 10:16:00 +1030
From:	Rusty Russell <rusty@...tcorp.com.au>
To:	Pawel Moll <pawel.moll@....com>, linux-kernel@...r.kernel.org,
	virtualization@...ts.linux-foundation.org,
	linux-arm-kernel@...ts.infradead.org
Cc:	peter.maydell@...aro.org, Pawel Moll <pawel.moll@....com>,
	Anthony Liguori <aliguori@...ibm.com>,
	"Michael S.Tsirkin" <mst@...hat.com>
Subject: Re: [PATCH] virtio: Add platform bus driver for memory mapped virtio device

On Wed, 28 Sep 2011 14:47:43 +0100, Pawel Moll <pawel.moll@....com> wrote:
> This patch, based on virtio PCI driver, adds support for memory
> mapped (platform) virtio device. This should allow environments
> like qemu to use virtio-based block & network devices even on
> platforms without PCI support.
> 
> One can define and register a platform device which resources
> will describe memory mapped control registers and "mailbox"
> interrupt. Such device can be also instantiated using the Device
> Tree node with compatible property equal "virtio,mmio".

Hi Pawel...

> +/* The alignment to use between consumer and producer parts of vring.
> + * Currently hardcoded to page size. */
> +#define VIRTIO_MMIO_VRING_ALIGN		PAGE_SIZE

Really?  Shouldn't that just be 4k?  I haven't seen the qemu side of
this, but it seems weird to depend on the kernel's idea of page size...

Note that the seabios/coreboot hackers wanted a smaller ring alignment
so they didn't have to waste two precious pages per device.  You might
want to consider making this an option in the header (perhaps express
it as log2, eg. 12 rather than 4096).


> +	/* TODO: Write requested queue size to VIRTIO_MMIO_QUEUE_NUM */
> +
> +	/* Check if queue is either not available or already active. */
> +	num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM);
> +	if (!num || readl(vm_dev->base + VIRTIO_MMIO_QUEUE_PFN)) {

Please fix this now, like so:

        /* Queue shouldn't already be set up. */        
        if (readl(vm_dev->base + VIRTIO_MMIO_QUEUE_PFN))
                ...

        /* Try for a big queue, drop down to a two-page queue. */
        num = VIRTIO_MMIO_MAX_RING;
        for (;;) {
                size = PAGE_ALIGN(vring_size(num, VIRTIO_MMIO_VRING_ALIGN));
                info->queue = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
                if (info->queue)
                        break;

                /* Already smallest possible allocation? */
                if (size == VIRTIO_MMIO_VRING_ALIGN*2) {
                        err = -ENOMEM;
                        goto error_kmalloc;
                }
                num /= 2;
        }

Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ