From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXIdt-0004Ac-DA for qemu-devel@nongnu.org; Tue, 09 Aug 2016 21:49:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXIdn-0006q4-Hy for qemu-devel@nongnu.org; Tue, 09 Aug 2016 21:49:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXIdn-0006q0-CP for qemu-devel@nongnu.org; Tue, 09 Aug 2016 21:49:07 -0400 Date: Wed, 10 Aug 2016 09:49:02 +0800 From: Peter Xu Message-ID: <20160810014902.GC4201@pxdev.xzpeter.org> References: <1470127147-12442-1-git-send-email-davidkiarie4@gmail.com> <1470127147-12442-4-git-send-email-davidkiarie4@gmail.com> <20160809054434.GA3979@pxdev.xzpeter.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [V15 3/4] hw/i386: Introduce AMD IOMMU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Kiarie Cc: QEMU Developers , rkrcmar@redhat.com, Jan Kiszka , Valentine Sinitsyn , Eduardo Habkost , "Michael S. Tsirkin" On Tue, Aug 09, 2016 at 08:46:09PM +0300, David Kiarie wrote: > On Tue, Aug 9, 2016 at 8:44 AM, Peter Xu wrote: > > > On Tue, Aug 02, 2016 at 11:39:06AM +0300, David Kiarie wrote: > > > > [...] > > > > > +/* external write */ > > > +static void amdvi_writew(AMDVIState *s, hwaddr addr, uint16_t val) > > > +{ > > > + uint16_t romask = lduw_le_p(&s->romask[addr]); > > > + uint16_t w1cmask = lduw_le_p(&s->w1cmask[addr]); > > > + uint16_t oldval = lduw_le_p(&s->mmior[addr]); > > > + stw_le_p(&s->mmior[addr], (val & ~(val & w1cmask)) | (romask & > > oldval)); > > > > I think the above is problematic, e.g., what if we write 1 to one of > > the romask while it's 0 originally? In that case, the RO bit will be > > written to 1. > > > > Maybe we need: > > > > stw_le_p(&s->mmior[addr], ((oldval & romask) | (val & ~romask)) & \ > > (val & w1cmask)); > > > > Same question to the below two functions. > > > > It seems to me you're not taking care of w1/c bits correctly ? > > I think: > > stw_le_p(&s->mmior[addr], ((oldval & romask) | (val & ~romask)) & \ > ~ (val & w1cmask)); > should suffice. Right. :) -- peterx