From patchwork Wed Dec 10 10:34:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 419553 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 D26FE14009B for ; Wed, 10 Dec 2014 21:54:01 +1100 (AEDT) Received: from localhost ([::1]:44617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyeu7-0006my-Qq for incoming@patchwork.ozlabs.org; Wed, 10 Dec 2014 05:53:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyecK-0000k6-WB for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyecE-0008ES-3d for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyecD-0008EF-SZ for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBAAZTV1005283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Dec 2014 05:35:29 -0500 Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBAAYeSU016328; Wed, 10 Dec 2014 05:35:28 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 10 Dec 2014 11:34:15 +0100 Message-Id: <1418207679-32260-50-git-send-email-kwolf@redhat.com> In-Reply-To: <1418207679-32260-1-git-send-email-kwolf@redhat.com> References: <1418207679-32260-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PULL 49/73] ide: Check validity of logical block size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Our IDE emulation can't handle logical block sizes other than 512. Check for it. The original assumption was that other values would silently be ignored (which is bad enough), but it's not quite true: The physical block size is exposed in IDENTIFY DEVICE as a multiple of the logical block size. Setting a logical block size therefore also corrupts the physical block size (4096/4096 doesn't silently downgrade to 4096/512, but 512/512). Signed-off-by: Kevin Wolf Reviewed-by: Markus Armbruster Reviewed-by: John Snow --- hw/ide/qdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index b4f096e..1ebb58d 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -163,6 +163,11 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) return -1; } + if (dev->conf.logical_block_size != 512) { + error_report("logical_block_size must be 512 for IDE"); + return -1; + } + blkconf_serial(&dev->conf, &dev->serial); if (kind != IDE_CD) { blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err);