14
14
#include <linux/spinlock.h>
15
15
#include <xen/xen.h>
16
16
17
- static bool force_used_validation = false;
18
- module_param (force_used_validation , bool , 0444 );
19
-
20
17
#ifdef DEBUG
21
18
/* For development, we want to crash whenever the ring is screwed. */
22
19
#define BAD_RING (_vq , fmt , args ...) \
@@ -185,9 +182,6 @@ struct vring_virtqueue {
185
182
} packed ;
186
183
};
187
184
188
- /* Per-descriptor in buffer length */
189
- u32 * buflen ;
190
-
191
185
/* How to notify other side. FIXME: commonalize hcalls! */
192
186
bool (* notify )(struct virtqueue * vq );
193
187
@@ -496,7 +490,6 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
496
490
unsigned int i , n , avail , descs_used , prev , err_idx ;
497
491
int head ;
498
492
bool indirect ;
499
- u32 buflen = 0 ;
500
493
501
494
START_USE (vq );
502
495
@@ -578,7 +571,6 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
578
571
VRING_DESC_F_NEXT |
579
572
VRING_DESC_F_WRITE ,
580
573
indirect );
581
- buflen += sg -> length ;
582
574
}
583
575
}
584
576
/* Last one doesn't continue. */
@@ -618,10 +610,6 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
618
610
else
619
611
vq -> split .desc_state [head ].indir_desc = ctx ;
620
612
621
- /* Store in buffer length if necessary */
622
- if (vq -> buflen )
623
- vq -> buflen [head ] = buflen ;
624
-
625
613
/* Put entry in available array (but don't update avail->idx until they
626
614
* do sync). */
627
615
avail = vq -> split .avail_idx_shadow & (vq -> split .vring .num - 1 );
@@ -796,11 +784,6 @@ static void *virtqueue_get_buf_ctx_split(struct virtqueue *_vq,
796
784
BAD_RING (vq , "id %u is not a head!\n" , i );
797
785
return NULL ;
798
786
}
799
- if (vq -> buflen && unlikely (* len > vq -> buflen [i ])) {
800
- BAD_RING (vq , "used len %d is larger than in buflen %u\n" ,
801
- * len , vq -> buflen [i ]);
802
- return NULL ;
803
- }
804
787
805
788
/* detach_buf_split clears data, so grab it now. */
806
789
ret = vq -> split .desc_state [i ].data ;
@@ -1079,7 +1062,6 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq,
1079
1062
unsigned int i , n , err_idx ;
1080
1063
u16 head , id ;
1081
1064
dma_addr_t addr ;
1082
- u32 buflen = 0 ;
1083
1065
1084
1066
head = vq -> packed .next_avail_idx ;
1085
1067
desc = alloc_indirect_packed (total_sg , gfp );
@@ -1109,8 +1091,6 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq,
1109
1091
desc [i ].addr = cpu_to_le64 (addr );
1110
1092
desc [i ].len = cpu_to_le32 (sg -> length );
1111
1093
i ++ ;
1112
- if (n >= out_sgs )
1113
- buflen += sg -> length ;
1114
1094
}
1115
1095
}
1116
1096
@@ -1164,10 +1144,6 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq,
1164
1144
vq -> packed .desc_state [id ].indir_desc = desc ;
1165
1145
vq -> packed .desc_state [id ].last = id ;
1166
1146
1167
- /* Store in buffer length if necessary */
1168
- if (vq -> buflen )
1169
- vq -> buflen [id ] = buflen ;
1170
-
1171
1147
vq -> num_added += 1 ;
1172
1148
1173
1149
pr_debug ("Added buffer head %i to %p\n" , head , vq );
@@ -1203,7 +1179,6 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
1203
1179
__le16 head_flags , flags ;
1204
1180
u16 head , id , prev , curr , avail_used_flags ;
1205
1181
int err ;
1206
- u32 buflen = 0 ;
1207
1182
1208
1183
START_USE (vq );
1209
1184
@@ -1283,8 +1258,6 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
1283
1258
1 << VRING_PACKED_DESC_F_AVAIL |
1284
1259
1 << VRING_PACKED_DESC_F_USED ;
1285
1260
}
1286
- if (n >= out_sgs )
1287
- buflen += sg -> length ;
1288
1261
}
1289
1262
}
1290
1263
@@ -1304,10 +1277,6 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
1304
1277
vq -> packed .desc_state [id ].indir_desc = ctx ;
1305
1278
vq -> packed .desc_state [id ].last = prev ;
1306
1279
1307
- /* Store in buffer length if necessary */
1308
- if (vq -> buflen )
1309
- vq -> buflen [id ] = buflen ;
1310
-
1311
1280
/*
1312
1281
* A driver MUST NOT make the first descriptor in the list
1313
1282
* available before all subsequent descriptors comprising
@@ -1494,11 +1463,6 @@ static void *virtqueue_get_buf_ctx_packed(struct virtqueue *_vq,
1494
1463
BAD_RING (vq , "id %u is not a head!\n" , id );
1495
1464
return NULL ;
1496
1465
}
1497
- if (vq -> buflen && unlikely (* len > vq -> buflen [id ])) {
1498
- BAD_RING (vq , "used len %d is larger than in buflen %u\n" ,
1499
- * len , vq -> buflen [id ]);
1500
- return NULL ;
1501
- }
1502
1466
1503
1467
/* detach_buf_packed clears data, so grab it now. */
1504
1468
ret = vq -> packed .desc_state [id ].data ;
@@ -1704,7 +1668,6 @@ static struct virtqueue *vring_create_virtqueue_packed(
1704
1668
struct vring_virtqueue * vq ;
1705
1669
struct vring_packed_desc * ring ;
1706
1670
struct vring_packed_desc_event * driver , * device ;
1707
- struct virtio_driver * drv = drv_to_virtio (vdev -> dev .driver );
1708
1671
dma_addr_t ring_dma_addr , driver_event_dma_addr , device_event_dma_addr ;
1709
1672
size_t ring_size_in_bytes , event_size_in_bytes ;
1710
1673
@@ -1794,15 +1757,6 @@ static struct virtqueue *vring_create_virtqueue_packed(
1794
1757
if (!vq -> packed .desc_extra )
1795
1758
goto err_desc_extra ;
1796
1759
1797
- if (!drv -> suppress_used_validation || force_used_validation ) {
1798
- vq -> buflen = kmalloc_array (num , sizeof (* vq -> buflen ),
1799
- GFP_KERNEL );
1800
- if (!vq -> buflen )
1801
- goto err_buflen ;
1802
- } else {
1803
- vq -> buflen = NULL ;
1804
- }
1805
-
1806
1760
/* No callback? Tell other side not to bother us. */
1807
1761
if (!callback ) {
1808
1762
vq -> packed .event_flags_shadow = VRING_PACKED_EVENT_FLAG_DISABLE ;
@@ -1815,8 +1769,6 @@ static struct virtqueue *vring_create_virtqueue_packed(
1815
1769
spin_unlock (& vdev -> vqs_list_lock );
1816
1770
return & vq -> vq ;
1817
1771
1818
- err_buflen :
1819
- kfree (vq -> packed .desc_extra );
1820
1772
err_desc_extra :
1821
1773
kfree (vq -> packed .desc_state );
1822
1774
err_desc_state :
@@ -2224,7 +2176,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
2224
2176
void (* callback )(struct virtqueue * ),
2225
2177
const char * name )
2226
2178
{
2227
- struct virtio_driver * drv = drv_to_virtio (vdev -> dev .driver );
2228
2179
struct vring_virtqueue * vq ;
2229
2180
2230
2181
if (virtio_has_feature (vdev , VIRTIO_F_RING_PACKED ))
@@ -2284,15 +2235,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
2284
2235
if (!vq -> split .desc_extra )
2285
2236
goto err_extra ;
2286
2237
2287
- if (!drv -> suppress_used_validation || force_used_validation ) {
2288
- vq -> buflen = kmalloc_array (vring .num , sizeof (* vq -> buflen ),
2289
- GFP_KERNEL );
2290
- if (!vq -> buflen )
2291
- goto err_buflen ;
2292
- } else {
2293
- vq -> buflen = NULL ;
2294
- }
2295
-
2296
2238
/* Put everything in free lists. */
2297
2239
vq -> free_head = 0 ;
2298
2240
memset (vq -> split .desc_state , 0 , vring .num *
@@ -2303,8 +2245,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
2303
2245
spin_unlock (& vdev -> vqs_list_lock );
2304
2246
return & vq -> vq ;
2305
2247
2306
- err_buflen :
2307
- kfree (vq -> split .desc_extra );
2308
2248
err_extra :
2309
2249
kfree (vq -> split .desc_state );
2310
2250
err_state :
0 commit comments