From patchwork Wed Jun 22 11:48:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9192541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6E1EE6075A for ; Wed, 22 Jun 2016 11:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E2DA283FA for ; Wed, 22 Jun 2016 11:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50624283FC; Wed, 22 Jun 2016 11:50:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC68A28364 for ; Wed, 22 Jun 2016 11:50:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFgeM-0000O1-TU; Wed, 22 Jun 2016 11:48:54 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFgeL-0000NI-C6 for xen-devel@lists.xen.org; Wed, 22 Jun 2016 11:48:53 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id C5/25-04210-42B7A675; Wed, 22 Jun 2016 11:48:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsVybKJsh65KdVa 4wadf7BZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bmjZ+YCm5LVax7MI+lgfG7cBcjF4eQwFRG iSO9O9kgnF4midcT7jJ2MXJysAkYSvx9sokNxBYRkJHovLSIEaSIWaCLUWLD+xesIAlhAW+Jp dv+MYHYLAKqEtf2L2UBsXkF3CRePdjMDmJLCMhJnDw2GayeU8BdYv3c7UwQ29oYJZac62GEKM qQmNczhxXC9pJYdOMSlK0mcfXcJuYJjHwLGBlWMaoXpxaVpRbpGuolFWWmZ5TkJmbm6BoamOr lphYXJ6an5iQmFesl5+duYgSGSj0DA+MOxqZe50OMkhxMSqK88spZ4UJ8SfkplRmJxRnxRaU5 qcWHGGU4OJQkeN+UA+UEi1LTUyvSMnOAQQuTluDgURLhfQGS5i0uSMwtzkyHSJ1iVJQS530Pk hAASWSU5sG1wSLlEqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVh3p8gU3gy80rgpr8CWswEtH hZfzrI4pJEhJRUA6N55c0bTFf7F/RuvrzvfuqeyBx59nsqEYlxj59uuufKZ8ggsc3RREz93fv Iy3Yl7zsjz7QkiLOLFEnIOew/9+DgnvPt9dvZdyxvZ1xdIbX2UsUFR9nLwftC+m9vsmJvfM+d +6X8xz2/XOe70uc/PuJ/6iBWcPLp6U/lmT8VrGe17PQ3MPLrvaHEUpyRaKjFXFScCACde5OFj wIAAA== X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-16.tower-206.messagelabs.com!1466596130!30222756!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43174 invoked from network); 22 Jun 2016 11:48:51 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Jun 2016 11:48:51 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C906120142; Wed, 22 Jun 2016 11:48:49 +0000 (UTC) Received: from localhost.localdomain (60.99.208.46.dyn.plus.net [46.208.99.60]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 972D220148; Wed, 22 Jun 2016 11:48:47 +0000 (UTC) From: Stefano Stabellini To: peter.maydell@linaro.org Date: Wed, 22 Jun 2016 12:48:39 +0100 Message-Id: <1466596120-28350-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466596120-28350-1-git-send-email-sstabellini@kernel.org> References: <1466596120-28350-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: anthony.perard@citrix.com, Juergen Gross , sstabellini@kernel.org, qemu-devel@nongnu.org, xen-devel@lists.xen.org Subject: [Xen-devel] [PULL 2/3] xen: fix qdisk BLKIF_OP_DISCARD for 32/64 word size mix X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Juergen Gross In case the word size of the domU and qemu running the qdisk backend differ BLKIF_OP_DISCARD will not work reliably, as the request structure in the ring have different layouts for different word size. Correct this by copying the request structure in case of different word size element by element in the BLKIF_OP_DISCARD case, too. Signed-off-by: Juergen Gross Acked-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- hw/block/xen_blkif.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/hw/block/xen_blkif.h b/hw/block/xen_blkif.h index 7ccf92e..0738684 100644 --- a/hw/block/xen_blkif.h +++ b/hw/block/xen_blkif.h @@ -28,6 +28,14 @@ struct blkif_x86_32_request { blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; }; +struct blkif_x86_32_request_discard { + uint8_t operation; /* BLKIF_OP_DISCARD */ + uint8_t flag; /* nr_segments in request struct */ + blkif_vdev_t handle; /* only for read/write requests */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */ + uint64_t nr_sectors; /* # of contiguous sectors to discard */ +}; struct blkif_x86_32_response { uint64_t id; /* copied from request */ uint8_t operation; /* copied from request */ @@ -46,6 +54,14 @@ struct blkif_x86_64_request { blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; }; +struct blkif_x86_64_request_discard { + uint8_t operation; /* BLKIF_OP_DISCARD */ + uint8_t flag; /* nr_segments in request struct */ + blkif_vdev_t handle; /* only for read/write requests */ + uint64_t __attribute__((__aligned__(8))) id; + blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */ + uint64_t nr_sectors; /* # of contiguous sectors to discard */ +}; struct blkif_x86_64_response { uint64_t __attribute__((__aligned__(8))) id; uint8_t operation; /* copied from request */ @@ -88,7 +104,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, /* Prevent the compiler from using src->... instead. */ barrier(); if (dst->operation == BLKIF_OP_DISCARD) { - struct blkif_request_discard *s = (void *)src; + struct blkif_x86_32_request_discard *s = (void *)src; struct blkif_request_discard *d = (void *)dst; d->nr_sectors = s->nr_sectors; return; @@ -114,7 +130,7 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, /* Prevent the compiler from using src->... instead. */ barrier(); if (dst->operation == BLKIF_OP_DISCARD) { - struct blkif_request_discard *s = (void *)src; + struct blkif_x86_64_request_discard *s = (void *)src; struct blkif_request_discard *d = (void *)dst; d->nr_sectors = s->nr_sectors; return;