From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [RFC PATCH v3 08/18] xen/arm: vITS: Add virtual ITS driver Date: Mon, 29 Jun 2015 13:13:04 +0100 Message-ID: <1435579984.32500.296.camel@citrix.com> References: <1434974517-12136-1-git-send-email-vijay.kilari@gmail.com> <1434974517-12136-9-git-send-email-vijay.kilari@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1434974517-12136-9-git-send-email-vijay.kilari@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: vijay.kilari@gmail.com Cc: stefano.stabellini@eu.citrix.com, Prasun.Kapoor@caviumnetworks.com, vijaya.kumar@caviumnetworks.com, tim@xen.org, xen-devel@lists.xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, manish.jaggi@caviumnetworks.com List-Id: xen-devel@lists.xenproject.org On Mon, 2015-06-22 at 17:31 +0530, vijay.kilari@gmail.com wrote: > + if ( !p2m_is_ram(p2mt) ) > + { > + put_page(page); > + dprintk(XENLOG_G_ERR, "vITS:d%dv%d with wrong attributes\n", > + d->domain_id, current->vcpu_id); "d%dv%d" should be done (everywhere) with the "%pv" format code passing current as the argument. See docs/misc/printk-formats.txt. > + return -EINVAL; > + return -EINVAL; > + } > + > + p = __map_domain_page(page); > + /* Offset within the mapped page */ > + offset = dt_entry & (PAGE_SIZE - 1); This should be "& ~PAGE_MASK" please. > + > + if ( set ) > + memcpy(p + offset, entry, sizeof(struct vdevice_table)); > + else > + memcpy(entry, p + offset, sizeof(struct vdevice_table)); Personally I'd have done this with *entry = *(struct ..*)(p + offset) and vice versa and let the compiler figure out how to achieve that. > + /* dt_entry is validated when read */ The vits_get_vdevice_entry call is right above and in this implementation I don't see any checks in that function, so I don't think this comment is strictly true. Since it is very important that information living in this guest accessible memory is correctly validated before use I think these comments need to be 100% trustworthy. I think vits_get_vdevice_entry is indeed the right place for those checks as the comment suggests. If there are no actual checks needed (e.g. because everything is in terms of IPA) then there should be a comment in that function explaining exactly why nothing actually needs to be validated. > + offset = event * sizeof(struct vitt); > + if ( offset > dt_entry.vitt_size ) > + { > + dprintk(XENLOG_G_ERR, "vITS:d%dv%d ITT out of range\n", > + d->domain_id, current->vcpu_id); > + return -EINVAL;