From patchwork Fri Nov 14 11:05:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 410779 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 B50DD1400AB for ; Fri, 14 Nov 2014 22:09:25 +1100 (AEDT) Received: from localhost ([::1]:35870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpEkl-00061T-Iy for incoming@patchwork.ozlabs.org; Fri, 14 Nov 2014 06:09:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpEi4-0001B4-Nl for qemu-devel@nongnu.org; Fri, 14 Nov 2014 06:06:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XpEhx-0001oQ-8M for qemu-devel@nongnu.org; Fri, 14 Nov 2014 06:06:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpEhx-0001o2-0j for qemu-devel@nongnu.org; Fri, 14 Nov 2014 06:06:29 -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 sAEB6Re4004060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 14 Nov 2014 06:06:27 -0500 Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAEB6Pi7014695; Fri, 14 Nov 2014 06:06:26 -0500 From: Stefan Hajnoczi To: Date: Fri, 14 Nov 2014 11:05:54 +0000 Message-Id: <1415963157-30103-9-git-send-email-stefanha@redhat.com> In-Reply-To: <1415963157-30103-1-git-send-email-stefanha@redhat.com> References: <1415963157-30103-1-git-send-email-stefanha@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: Peter Maydell , John Snow , Stefan Hajnoczi Subject: [Qemu-devel] [PULL for-2.2 08/11] ahci: Check cmd_fis[1] more explicitly 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 From: John Snow Instead of checking for a known byte, inspect the fields of this byte explicitly to produce more meaningful error messages and improve the readability of this section. Signed-off-by: John Snow Reviewed-by: Paolo Bonzini Message-id: 1415058979-16604-5-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi --- hw/ide/ahci.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 578a93b..d6b012c 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1004,17 +1004,18 @@ static int handle_cmd(AHCIState *s, int port, int slot) break; } - switch (cmd_fis[1]) { - case SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER: - break; - case 0: - break; - default: - DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x " - "cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1], - cmd_fis[2]); - goto out; - break; + if (cmd_fis[1] & 0x0F) { + DPRINTF(port, "Port Multiplier not supported." + " cmd_fis[0]=%02x cmd_fis[1]=%02x cmd_fis[2]=%02x\n", + cmd_fis[0], cmd_fis[1], cmd_fis[2]); + goto out; + } + + if (cmd_fis[1] & 0x70) { + DPRINTF(port, "Reserved flags set in H2D Register FIS." + " cmd_fis[0]=%02x cmd_fis[1]=%02x cmd_fis[2]=%02x\n", + cmd_fis[0], cmd_fis[1], cmd_fis[2]); + goto out; } if (!(cmd_fis[1] & SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER)) {