From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSnLi-0001AB-HK for qemu-devel@nongnu.org; Sat, 13 Sep 2014 09:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSnLZ-00010D-FR for qemu-devel@nongnu.org; Sat, 13 Sep 2014 09:26:46 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:50128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSnLZ-000105-94 for qemu-devel@nongnu.org; Sat, 13 Sep 2014 09:26:37 -0400 Received: by mail-wi0-f177.google.com with SMTP id em10so1989797wid.16 for ; Sat, 13 Sep 2014 06:26:36 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <54144608.1010906@redhat.com> Date: Sat, 13 Sep 2014 15:26:32 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1410582855-21870-1-git-send-email-jsnow@redhat.com> <1410582855-21870-9-git-send-email-jsnow@redhat.com> In-Reply-To: <1410582855-21870-9-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 08/10] ahci: Check cmd_fis[1] more explicitly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-devel@nongnu.org Cc: stefanha@redhat.com, mst@redhat.com Il 13/09/2014 06:34, John Snow ha scritto: > 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 1153ce9..e4eae0c 100644 > --- a/hw/ide/ahci.c > +++ b/hw/ide/ahci.c > @@ -993,17 +993,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)) { > Reviewed-by: Paolo Bonzini