lkml.org 
[lkml]   [2007]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] virtio config_ops refactoring
Date
On Friday 09 November 2007 09:33:04 Anthony Liguori wrote:
> I really want to make sure that if a guest tries
> to read a 4-byte PCI config field, that it does so using an "outl"
> instruction so that in my QEMU backend

So you want to enforce PCI requirements onto virtio config accesses. This
doesn't seem very nice: the fact that PCI accesses use different namespaces
for different sizes makes sense from a primitive hardware point of view, but
sucks for software. Fortunately, if you insist on byte-at-a-time they're the
same.

> switch (addr) {
> case VIRTIO_BLK_CONFIG_MAX_SEG:
> return vdev->max_seg & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SEG + 1:
> return (vdev->max_seg >> 8) & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SEG + 2:
> return (vdev->max_seg >> 16) & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SEG + 3:
> return (vdev->max_seg >> 24) & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SIZE:
> return vdev->max_size & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SIZE + 1:
> return (vdev->max_size >> 8) & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SIZE + 2:
> return (vdev->max_size >> 16) & 0xFF;
> case VIRTIO_BLK_CONFIG_MAX_SIZE + 3:
> return (vdev->max_size >> 24) & 0xFF;
> ...

struct virtio_blk_config
{
uint32_t max_seg, max_size;
};

...
struct virtio_blk_config conf = { vdev->max_seg, vdev->max_size };

return ((unsigned char *)&conf)[addr];

(Which strongly implies our headers should expose that nominal struct, rather
than numerical constants).

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

\
 
 \ /
  Last update: 2007-11-09 12:57    [W:0.052 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site