Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Feb 2020 19:09:57 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Ian Lepore <ian@FreeBSD.org>
Cc:        cem@freebsd.org, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r357349 - in head/sys: conf modules/tpm
Message-ID:  <C4FE2F90-5022-471B-892C-D5F014797169@FreeBSD.org>
In-Reply-To: <4a87b670557d23181c3a98bc5a65c8c1a42302d3.camel@freebsd.org>
References:  <202001311936.00VJaEDP056807@repo.freebsd.org> <CAG6CVpWy%2BA3MN47GyLoL5jvdT7pMABevg-L9w0o7HpZF9Vq5oQ@mail.gmail.com> <18BC9807-4B4C-482C-AB7E-20F9C7B68F29@FreeBSD.org> <4a87b670557d23181c3a98bc5a65c8c1a42302d3.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_3B7BCF2F-AE68-4E1C-B3D3-5C6CAAF476E5
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii

On 1 Feb 2020, at 18:48, Ian Lepore <ian@FreeBSD.org> wrote:
> 
> On Fri, 2020-01-31 at 23:36 +0100, Dimitry Andric wrote:
>> Hmm yes, you are quite right.  Other parts of the code also seem to
>> use ~TPM_XXX, and the WR4() inline function called takes a
>> uint32_t.  I'll revert my change and apply the tilde version instead!
>> 
>> -Dimitry
>> 
> 
> So you're going to switch from writing 0 to writing 0xfffffffe, and
> just assume that will work the same?  Like, without looking at the
> datasheet or TRM for the device?  Surely those other 31 bits you're
> turning on in a control register can't do anything important, can they?

Hmm, the data sheet says:

Writes (0000 0001h): Cancel a command
Writes (0000 0000h): Clears field when command has been cancelled

It seems the other bits in the register are not used for anything.

So indeed it is probably better to explicitly define these values as 0x0
and 0x1, and not use ~ or ! operators at all.


> I haven't looked at the code, but I'll bet the other places that are
> using ~SYMBOLNAME are doing so in the context of read-modify-write in a
> way that preserves existing bits, which is completely different than
> just turning on 31 bits as a side effect of turning one bit off.

There aren't many places, but they tend to use the AND4() and OR4()
inline functions, which do are more usual pattern of read-modify-write.

I'll fix up the code again...

-Dimitry


--Apple-Mail=_3B7BCF2F-AE68-4E1C-B3D3-5C6CAAF476E5
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.2

iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCXjW+9QAKCRCwXqMKLiCW
o8vlAKChYDR3Dv3pXGQLV0y1fzQB46+sewCguyLETIVjFjfRdpwcrXU2NeyTAMg=
=Zhhq
-----END PGP SIGNATURE-----

--Apple-Mail=_3B7BCF2F-AE68-4E1C-B3D3-5C6CAAF476E5--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C4FE2F90-5022-471B-892C-D5F014797169>