From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47342 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oog9l-0000CZ-LX for qemu-devel@nongnu.org; Thu, 26 Aug 2010 13:22:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oog9i-0004p9-Rc for qemu-devel@nongnu.org; Thu, 26 Aug 2010 13:22:29 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:43909) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oog9h-0004p0-NE for qemu-devel@nongnu.org; Thu, 26 Aug 2010 13:22:26 -0400 Received: by qwh5 with SMTP id 5so1905245qwh.4 for ; Thu, 26 Aug 2010 10:22:24 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1282753982-1761-1-git-send-email-andreas.niederl@iaik.tugraz.at> From: Blue Swirl Date: Thu, 26 Aug 2010 17:22:04 +0000 Message-ID: Subject: Re: [Qemu-devel] [PATCH 1/3] Add TPM 1.2 host device passthrough interface Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc Cc: Andreas Niederl , qemu-devel@nongnu.org On Wed, Aug 25, 2010 at 8:46 PM, malc wrote: > On Wed, 25 Aug 2010, Blue Swirl wrote: > >> On Wed, Aug 25, 2010 at 4:33 PM, Andreas Niederl >> wrote: >> > This implementation is based on the TPM 1.2 interface for virtualized = TPM >> > devices from the Xen-4.0.0 ioemu-qemu-xen fork. >> > >> > A separate thread is used for I/O to the host TPM device because the L= inux TPM >> > driver does not allow for non-blocking I/O. >> > >> > Signed-off-by: Andreas Niederl >> >> In general, please read CODING_STYLE. >> >> Ideally, the host and guest devices should be decoupled so that the >> guest visible device should still be functional without host TPM >> support. >> >> > --- > > [..snip..] > >> > +static inline uint32_t tpm_get_size_from_buffer(const uint8_t *buffer= ) >> > +{ >> > + =C2=A0 =C2=A0uint32_t len =3D (buffer[4] << 8) + buffer[5]; >> > + =C2=A0 =C2=A0return len; >> > +} >> > + >> > +static inline uint8_t locality_from_addr(target_phys_addr_t addr) >> > +{ >> > + =C2=A0 =C2=A0return (uint8_t)((addr >> 12) & 0x7); >> > +} >> > + >> > + >> > +static void die2(int err, const char *what) >> > +{ >> > + =C2=A0 =C2=A0fprintf(stderr, "%s failed: %s\n", what, strerror(err))= ; >> > + =C2=A0 =C2=A0abort(); >> > +} >> > + >> > +static void die(const char *what) >> > +{ >> > + =C2=A0 =C2=A0die2(errno, what); >> > +} >> >> There's hw_error() and errx(), no need to reinvent the wheel. > > Since it looks as if this code was based on mine, i take issues with > your analysis. > > Firstly hw_error is for hardware errors and does not print message > corresponding to errno code Right, the correct function should be error_report(). > and lastly there is no errx[1] > > [..snip..] > > [1] err(3): > =C2=A0 =C2=A0CONFORMING TO > =C2=A0 =C2=A0 =C2=A0 These functions are non-standard BSD extensions. err() and errx() are already used somewhere. But these should be converted to error_report etc., like other printf based local functions.