From patchwork Tue Feb 23 16:57:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 81496 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1NH3AK4022183 for ; Tue, 23 Feb 2010 17:03:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753556Ab0BWRBm (ORCPT ); Tue, 23 Feb 2010 12:01:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1025 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753492Ab0BWRBj (ORCPT ); Tue, 23 Feb 2010 12:01:39 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1NH11A8030991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 23 Feb 2010 12:01:01 -0500 Received: from redhat.com (vpn2-11-39.ams2.redhat.com [10.36.11.39]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o1NH0s81023950; Tue, 23 Feb 2010 12:00:54 -0500 Date: Tue, 23 Feb 2010 18:57:43 +0200 From: "Michael S. Tsirkin" To: Rusty Russell , kvm@vger.kernel.org, virtualization@lists.osdl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Miller , markmc@redhat.com, gleb@redhat.com, herbert.xu@redhat.com, quintela@redhat.com, dlaor@redhat.com, avi@redhat.com Subject: [PATCH 1/3] vhost: logging math fix Message-ID: <51e0f786b06c198ab355abab19f0bd11ac6a167b.1266943453.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 23 Feb 2010 17:03:10 +0000 (UTC) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 6eb1525..c767279 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1004,10 +1004,12 @@ int vhost_add_used(struct vhost_virtqueue *vq, unsigned int head, int len) if (unlikely(vq->log_used)) { /* Make sure data is seen before log. */ smp_wmb(); - log_write(vq->log_base, vq->log_addr + sizeof *vq->used->ring * - (vq->last_used_idx % vq->num), - sizeof *vq->used->ring); - log_write(vq->log_base, vq->log_addr, sizeof *vq->used->ring); + log_write(vq->log_base, + vq->log_addr + ((void *)used - (void *)vq->used), + sizeof *used); + log_write(vq->log_base, + vq->log_addr + offsetof(struct vring_used, idx), + sizeof vq->used->idx); if (vq->log_ctx) eventfd_signal(vq->log_ctx, 1); }