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: 639121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rZNNG586fz9sdQ for ; Wed, 22 Jun 2016 21:56:14 +1000 (AEST) Received: from localhost ([::1]:57459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFglQ-0002Gw-Nb for incoming@patchwork.ozlabs.org; Wed, 22 Jun 2016 07:56:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFgeQ-0003Id-Bl for qemu-devel@nongnu.org; Wed, 22 Jun 2016 07:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFgeJ-0001vU-8O for qemu-devel@nongnu.org; Wed, 22 Jun 2016 07:48:57 -0400 Received: from mail.kernel.org ([198.145.29.136]:57942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFgeI-0001vA-UJ for qemu-devel@nongnu.org; Wed, 22 Jun 2016 07:48:51 -0400 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 198.145.29.136 Subject: [Qemu-devel] [PULL 2/3] xen: fix qdisk BLKIF_OP_DISCARD for 32/64 word size mix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: anthony.perard@citrix.com, Juergen Gross , sstabellini@kernel.org, qemu-devel@nongnu.org, xen-devel@lists.xen.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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;