From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlRUA-0000Nb-2Y for qemu-devel@nongnu.org; Mon, 03 Nov 2014 18:56:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlRU3-0003Eq-5p for qemu-devel@nongnu.org; Mon, 03 Nov 2014 18:56:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlRU2-0003Em-Tj for qemu-devel@nongnu.org; Mon, 03 Nov 2014 18:56:27 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA3NuQdI005760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 3 Nov 2014 18:56:26 -0500 From: John Snow Date: Mon, 3 Nov 2014 18:56:18 -0500 Message-Id: <1415058979-16604-5-git-send-email-jsnow@redhat.com> In-Reply-To: <1415058979-16604-1-git-send-email-jsnow@redhat.com> References: <1415058979-16604-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 4/5] ahci: Check cmd_fis[1] more explicitly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, 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 --- 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 3671be1..536b455 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)) { -- 1.9.3