From owner-svn-src-all@FreeBSD.ORG Tue Oct 22 19:55:04 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id EC58ECFF; Tue, 22 Oct 2013 19:55:04 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D86E5237A; Tue, 22 Oct 2013 19:55:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9MJt4uQ018427; Tue, 22 Oct 2013 19:55:04 GMT (envelope-from grehan@svn.freebsd.org) Received: (from grehan@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9MJt4BC018426; Tue, 22 Oct 2013 19:55:04 GMT (envelope-from grehan@svn.freebsd.org) Message-Id: <201310221955.r9MJt4BC018426@svn.freebsd.org> From: Peter Grehan Date: Tue, 22 Oct 2013 19:55:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256926 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2013 19:55:05 -0000 Author: grehan Date: Tue Oct 22 19:55:04 2013 New Revision: 256926 URL: http://svnweb.freebsd.org/changeset/base/256926 Log: Fix AHCI ATAPI emulation when backed with /dev/cd0 - remove assumption that the backing file/device had 512-byte sectors - fix incorrect iovec size variable that would result in a buffer overrun when an o/s issued an i/o request with more s/g elements than the blockif api Reviewed by: Zhixiang Yu (zxyu.core@gmail.com) MFC after: 3 days Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- head/usr.sbin/bhyve/pci_ahci.c Tue Oct 22 19:53:52 2013 (r256925) +++ head/usr.sbin/bhyve/pci_ahci.c Tue Oct 22 19:55:04 2013 (r256926) @@ -663,8 +663,7 @@ atapi_read_capacity(struct ahci_port *p, uint8_t buf[8]; uint64_t sectors; - sectors = blockif_size(p->bctx) / blockif_sectsz(p->bctx); - sectors >>= 2; + sectors = blockif_size(p->bctx) / 2048; be32enc(buf, sectors - 1); be32enc(buf + 4, 2048); cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; @@ -908,9 +907,9 @@ atapi_read(struct ahci_port *p, int slot /* * Build up the iovec based on the prdt */ - for (i = 0; i < hdr->prdtl; i++) { + for (i = 0; i < iovcnt; i++) { breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc), - prdt->dba, prdt->dbc + 1); + prdt->dba, prdt->dbc + 1); breq->br_iov[i].iov_len = prdt->dbc + 1; aior->done += (prdt->dbc + 1); prdt++;