From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YINlb-0005hr-6F for qemu-devel@nongnu.org; Mon, 02 Feb 2015 15:38:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YINlX-0007v2-6G for qemu-devel@nongnu.org; Mon, 02 Feb 2015 15:38:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YINlW-0007uv-Uy for qemu-devel@nongnu.org; Mon, 02 Feb 2015 15:38:39 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t12KcaUA001796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 2 Feb 2015 15:38:37 -0500 Message-ID: <54CFE04B.8030208@redhat.com> Date: Mon, 02 Feb 2015 15:38:35 -0500 From: John Snow MIME-Version: 1.0 References: <1422643333-27926-1-git-send-email-jsnow@redhat.com> <1422643333-27926-5-git-send-email-jsnow@redhat.com> <54CF50FE.5090906@redhat.com> In-Reply-To: <54CF50FE.5090906@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 04/19] libqos/ahci: Add command header helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: famz@redhat.com, armbru@redhat.com, stefanha@redhat.com, mst@redhat.com On 02/02/2015 05:27 AM, Paolo Bonzini wrote: > > > On 30/01/2015 19:41, John Snow wrote: >> +/* Set the #cx'th command of port #px. */ >> +void ahci_set_command_header(AHCIQState *ahci, uint8_t px, >> + uint8_t cx, AHCICommandHeader *cmd) >> +{ >> + uint64_t ba = ahci->port[px].clb; >> + ba += cx * sizeof(AHCICommandHeader); >> + >> + cmd->flags = cpu_to_le16(cmd->flags); >> + cmd->prdtl = cpu_to_le16(cmd->prdtl); >> + cmd->prdbc = cpu_to_le32(cmd->prdbc); >> + cmd->ctba = cpu_to_le64(cmd->ctba); > > Modifying cmd is uglyish, and especially it might hide bugs that only > happen on big endian system. Please copy to a local AHCICommandHeader > variable before adjusting for host endianness. > > Paolo > >> + memwrite(ba, cmd, sizeof(AHCICommandHeader)); >> +} > You're right. I had just never actually thought to reference the command after committing it before, so I hadn't considered it in that light. If I intend to share goodies with other tests it would be nice if they didn't do secretly evil things :)