From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCOZM-0005oH-W7 for qemu-devel@nongnu.org; Tue, 07 Jul 2015 04:49:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCOZM-0002Ce-2i for qemu-devel@nongnu.org; Tue, 07 Jul 2015 04:49:36 -0400 Date: Tue, 7 Jul 2015 09:49:29 +0100 From: Stefan Hajnoczi Message-ID: <20150707084929.GB25892@stefanha-thinkpad.redhat.com> References: <1436219392-31915-1-git-send-email-jsnow@redhat.com> <1436219392-31915-3-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="98e8jtXdkpgskNou" Content-Disposition: inline In-Reply-To: <1436219392-31915-3-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/2] ahci: fix signature generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: pbonzini@redhat.com, hare@suse.de, qemu-block@nongnu.org, qemu-devel@nongnu.org --98e8jtXdkpgskNou Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 06, 2015 at 05:49:52PM -0400, John Snow wrote: > The initial register device-to-host FIS no longer needs to specially > set certain fields, as these can be handled generically by setting those > fields explicitly with the signatures we want at port reset time. >=20 > (1) Signatures are decomposed into their four component registers and > set upon (AHCI) port reset. > (2) the signature cache register is no longer set manually per-each > device type, but instead just once during ahci_init_d2h. >=20 > Signed-off-by: John Snow > --- > hw/ide/ahci.c | 33 ++++++++++++++++++++------------- > 1 file changed, 20 insertions(+), 13 deletions(-) I see two code paths that call ahci_init_d2h(). Either ahci_reset_port() does it (if a block device is attached) or it's called when the guest writes to the PORT_CMD register. I'm not sure the latter works. The signature doesn't seem to be set anywhere. Any ideas? > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > index bb6a92f..f352dd7 100644 > --- a/hw/ide/ahci.c > +++ b/hw/ide/ahci.c > @@ -537,20 +537,31 @@ static void ahci_init_d2h(AHCIDevice *ad) > { > uint8_t init_fis[20]; > IDEState *ide_state =3D &ad->port.ifs[0]; > + AHCIPortRegs *pr =3D &ad->port_regs; > =20 > memset(init_fis, 0, sizeof(init_fis)); > =20 > - init_fis[4] =3D 1; > - init_fis[12] =3D 1; > - > - if (ide_state->drive_kind =3D=3D IDE_CD) { > - init_fis[5] =3D ide_state->lcyl; > - init_fis[6] =3D ide_state->hcyl; > - } > + /* We're emulating receiving the first Reg H2D Fis from the device; > + * Update the SIG register, but otherwise procede as normal. */ > + pr->sig =3D (ide_state->hcyl << 24) | > + (ide_state->lcyl << 16) | > + (ide_state->sector << 8) | > + (ide_state->nsector & 0xFF); > =20 > ahci_write_fis_d2h(ad, init_fis); > } > =20 > +static void ahci_set_signature(AHCIDevice *ad, uint32_t sig) > +{ > + IDEState *s =3D &ad->port.ifs[0]; > + s->hcyl =3D sig >> 24 & 0xFF; > + s->lcyl =3D sig >> 16 & 0xFF; > + s->sector =3D sig >> 8 & 0xFF; > + s->nsector =3D sig & 0xFF; > + > + DPRINTF(ad->port_no, "set hcyl:lcyl:sect:nsect =3D 0x%08x\n", sig); > +} > + > static void ahci_reset_port(AHCIState *s, int port) > { > AHCIDevice *d =3D &s->dev[port]; > @@ -600,16 +611,12 @@ static void ahci_reset_port(AHCIState *s, int port) > =20 > s->dev[port].port_state =3D STATE_RUN; > if (!ide_state->blk) { > - pr->sig =3D 0; > ide_state->status =3D SEEK_STAT | WRERR_STAT; > } else if (ide_state->drive_kind =3D=3D IDE_CD) { > - pr->sig =3D SATA_SIGNATURE_CDROM; > - ide_state->lcyl =3D 0x14; > - ide_state->hcyl =3D 0xeb; > - DPRINTF(port, "set lcyl =3D %d\n", ide_state->lcyl); > + ahci_set_signature(d, SATA_SIGNATURE_CDROM); > ide_state->status =3D SEEK_STAT | WRERR_STAT | READY_STAT; > } else { > - pr->sig =3D SATA_SIGNATURE_DISK; > + ahci_set_signature(d, SATA_SIGNATURE_DISK); > ide_state->status =3D SEEK_STAT | WRERR_STAT; > } > =20 > --=20 > 2.1.0 >=20 --98e8jtXdkpgskNou Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVm5KZAAoJEJykq7OBq3PIJJYIAJS1O7HbSkXfKHV4NeH0F0W8 B9Dr0RMXBbA6SWP5geUoVxehnZUb2O2AjIGfK7bMGAXCZ9syJoUhGvdMhmuxHlri uTRI/1GszXkhizItCj7Ez8ftRkgxzToF7uor0y3cGtfH3xhzDjKsdxQ0l2sqklzj iA11sV7yPCLqQJzlfFgVSNphyXylO/ZuERmOYmkszKxJ4qvxWvdrE3762HM9ia2j NYJ6XNDfyL4QFNBdzTJzZicNcCvpmYWBsXqzjQPicrjpNRzLzhVvZjtLs/hef5at nnfuPG13XRpu2VylNlTrTuiH83SIYu/6RYxHjkoOJsSSHozxX5udb9X+qHNhLu8= =Jcnl -----END PGP SIGNATURE----- --98e8jtXdkpgskNou--