From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753374AbdEPV6A (ORCPT ); Tue, 16 May 2017 17:58:00 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:24620 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbdEPV57 (ORCPT ); Tue, 16 May 2017 17:57:59 -0400 Subject: Re: [PATCH 08/18] xen/pvcalls: implement connect command To: Stefano Stabellini References: <1494880570-14209-1-git-send-email-sstabellini@kernel.org> <1494880570-14209-8-git-send-email-sstabellini@kernel.org> <93420127-7a12-1b8e-931f-316c73a6404e@oracle.com> Cc: xen-devel@lists.xen.org, linux-kernel@vger.kernel.org, jgross@suse.com, Stefano Stabellini From: Boris Ostrovsky Message-ID: <9515ef24-ccad-f148-bbe3-824844d01223@oracle.com> Date: Tue, 16 May 2017 17:56:43 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> + ret = xenbus_map_ring_valloc(dev, &req->u.connect.ref, 1, &page); >>> + if (ret < 0) { >>> + sock_release(map->sock); >>> + kfree(map); >>> + goto out; >>> + } >>> + map->ring = page; >>> + map->ring_order = map->ring->ring_order; >>> + /* first read the order, then map the data ring */ >>> + virt_rmb(); >> >> Not sure I understand what the barrier is for here. I don't think compiler >> will reorder ring_order access with the call. > It's to avoid using the live version of ring_order to map the data ring > pages (the other end could be changing that value at any time). We want > to be sure that the compiler doesn't optimize out map->ring_order and > use map->ring->ring_order instead. Wouldn't WRITE_ONCE(map->ring_order, map->ring->ring_order) be the right primitive then? And also: if the other side changes ring size, what are we mapping then? It's obsolete by now. -boris > > >>> + if (map->ring_order > MAX_RING_ORDER) { >>> + ret = -EFAULT; >>> + goto out; >>> + } >> If the barrier is indeed needed this check belongs before it. > I don't think so, see above. > > >> >>> + ret = xenbus_map_ring_valloc(dev, map->ring->ref, >>> + (1 << map->ring_order), &page); >>> + if (ret < 0) { >>> + sock_release(map->sock); >>> + xenbus_unmap_ring_vfree(dev, map->ring); >>> + kfree(map); >>> + goto out; >>> + } >>> + map->bytes = page; >>>