Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96916
b: refs/heads/master
c: 5ca9fd5
h: refs/heads/master
v: v3
  • Loading branch information
Heiko Carstens authored and Avi Kivity committed May 18, 2008
1 parent 79b641a commit 7abecb7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 107d6d2efa9eb8c48d050936d8019230ac6b24cd
refs/heads/master: 5ca9fd54e3d75489ff9c70d7af6e0b9a390dd656
40 changes: 23 additions & 17 deletions trunk/drivers/s390/kvm/kvm_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,32 @@ static unsigned desc_size(const struct kvm_device_desc *desc)
+ desc->config_len;
}

/*
* This tests (and acknowleges) a feature bit.
*/
static bool kvm_feature(struct virtio_device *vdev, unsigned fbit)
/* This gets the device's feature bits. */
static u32 kvm_get_features(struct virtio_device *vdev)
{
unsigned int i;
u32 features = 0;
struct kvm_device_desc *desc = to_kvmdev(vdev)->desc;
u8 *features;
u8 *in_features = kvm_vq_features(desc);

if (fbit / 8 > desc->feature_len)
return false;
for (i = 0; i < min(desc->feature_len * 8, 32); i++)
if (in_features[i / 8] & (1 << (i % 8)))
features |= (1 << i);
return features;
}

features = kvm_vq_features(desc);
if (!(features[fbit / 8] & (1 << (fbit % 8))))
return false;
static void kvm_set_features(struct virtio_device *vdev, u32 features)
{
unsigned int i;
struct kvm_device_desc *desc = to_kvmdev(vdev)->desc;
/* Second half of bitmap is features we accept. */
u8 *out_features = kvm_vq_features(desc) + desc->feature_len;

/*
* We set the matching bit in the other half of the bitmap to tell the
* Host we want to use this feature.
*/
features[desc->feature_len + fbit / 8] |= (1 << (fbit % 8));
return true;
memset(out_features, 0, desc->feature_len);
for (i = 0; i < min(desc->feature_len * 8, 32); i++) {
if (features & (1 << i))
out_features[i / 8] |= (1 << (i % 8));
}
}

/*
Expand Down Expand Up @@ -221,7 +226,8 @@ static void kvm_del_vq(struct virtqueue *vq)
* The config ops structure as defined by virtio config
*/
static struct virtio_config_ops kvm_vq_configspace_ops = {
.feature = kvm_feature,
.get_features = kvm_get_features,
.set_features = kvm_set_features,
.get = kvm_get,
.set = kvm_set,
.get_status = kvm_get_status,
Expand Down

0 comments on commit 7abecb7

Please sign in to comment.