On 06/15/2015 05:44 PM, John Snow wrote: >> Note that while this returns the desired 16 or 32 bits in the low >> order side of the result, it does not guarantee that the remaining >> upper bytes are all 0. I don't know if it matters to callers, or >> even what real hardware does, but you may want to mask things at >> both return statements, to guarantee a stable result limited to >> size bytes of information rather than leaking nearby bytes from the >> rest of the registers being read. > > > I believe the masking is handled by the memory system in general, see > memory_region_read_accessor, which masks the returned uint64_t with an > appropriate value set earlier by access_with_adjusted_size: > > access_mask = -1ULL >> (64 - access_size * 8);
Good, the caller takes care of it. > > So we're probably OK here, but I can leave a comment if you think it's > too hand-wavey. Yeah, always nicer to state our assumption that we rely on the caller to truncate the result to the desired access size. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature