From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH] vhost: fix segfault as handle set_mem_table message Date: Tue, 5 Dec 2017 22:19:54 +0800 Message-ID: <20171205141954.GF9111@yliu-dev> References: <1510746068-143223-1-git-send-email-jianfeng.tan@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jianfeng Tan , dev@dpdk.org, stable@dpdk.org, Yi Yang To: Maxime Coquelin Return-path: Content-Disposition: inline In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Nov 28, 2017 at 01:09:29PM +0100, Maxime Coquelin wrote: > > > On 11/15/2017 12:41 PM, Jianfeng Tan wrote: > >In a running VM, operations (like device attach/detach) will > >trigger the QEMU to resend set_mem_table to vhost-user backend. > > > >DPDK vhost-user handles this message rudely by unmap all existing > >regions and map new ones. This might lead to segfault if there > >is pmd thread just trying to touch those unmapped memory regions. > > > >But for most cases, except VM memory hotplug, QEMU still sends the > >set_mem_table message even the memory regions are not changed as > >QEMU vhost-user filters out those not backed by file (fd > 0). > > > >To fix this case, we add a check in the handler to see if the > >memory regions are really changed; if not, we just keep old memory > >regions. > > > >Fixes: 8f972312b8f4 ("vhost: support vhost-user") > > > >CC: stable@dpdk.org > > > >CC: Yuanhan Liu > >CC: Maxime Coquelin > > > >Reported-by: Yang Zhang > >Reported-by: Xin Long > >Signed-off-by: Yi Yang > >Signed-off-by: Jianfeng Tan > >--- > > lib/librte_vhost/vhost_user.c | 33 +++++++++++++++++++++++++++++++++ > > 1 file changed, 33 insertions(+) > > Reviewed-by: Maxime Coquelin Applied to dpdk-next-virtio. Thanks. --yliu