From: xiongweimin <[email protected]>
Hi Eugenio,
Thanks for your review!
You are right. My original patch has an issue with the `break` statement,
which skips the `v->in_batch = false` assignment when `set_map` fails.
The correct approach is to simply capture the return value without
breaking:
```c
case VHOST_IOTLB_BATCH_END:
if (v->in_batch && ops->set_map)
r = ops->set_map(vdpa, asid, iotlb);
v->in_batch = false;
break;
```
This way:
1. The return value of `set_map` is propagated to the caller
2. `v->in_batch` is always reset, regardless of success or failure
Updated patch attached below.
---
Subject: [PATCH] vhost-vdpa: propagate set_map error to caller
The return value of ops->set_map() is currently ignored when handling
VHOST_IOTLB_BATCH_END. If the backend fails to program the IOTLB,
the VMM incorrectly believes the operation succeeded and may continue
with stale or incorrect mappings.
Propagate the error from ops->set_map() to the caller.
Signed-off-by: xiongweimin <[email protected]>
---
drivers/vhost/vdpa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index bb96b1aa5..b52d8d94e 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1298,7 +1298,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev
*dev, u32 asid,
break;
case VHOST_IOTLB_BATCH_END:
if (v->in_batch && ops->set_map)
- ops->set_map(vdpa, asid, iotlb);
+ r = ops->set_map(vdpa, asid, iotlb);
v->in_batch = false;
break;
default:
--
2.39.3