From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH RFC v2 6/6] KVM: introduce a new API for getting dirty bitmaps Date: Fri, 23 Apr 2010 14:57:17 +0300 Message-ID: <4BD18B1D.1080604@redhat.com> References: <20100420195349.dab60b1d.yoshikawa.takuya@oss.ntt.co.jp> <20100420200353.2d2a6dec.yoshikawa.takuya@oss.ntt.co.jp> <4BCEB777.6040505@oss.ntt.co.jp> <264937F8-98E4-4A73-9C7A-837793E1DAC8@suse.de> <4BCFB862.7010509@oss.ntt.co.jp> <4BCFE805.5040500@oss.ntt.co.jp> <4790E0BF-88C0-4D3E-9A32-110AB7AA84D4@suse.de> <4BD173C4.6060004@oss.ntt.co.jp> <9B7714E9-7244-4569-B8DB-B3E31E680CAF@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: =?UTF-8?B?RmVybmFuZG8gTHVpcyBWw6F6cXVleiBDYW8=?= , Takuya Yoshikawa , mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Arnd Bergmann To: Alexander Graf Return-path: In-Reply-To: <9B7714E9-7244-4569-B8DB-B3E31E680CAF-l3A5Bk7waGM@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: kvm.vger.kernel.org On 04/23/2010 01:20 PM, Alexander Graf wrote: > >> I would say the reason is that if we did not convert the user-space pointer to >> a "void *" kvm_get_dirty_log() would end up copying the dirty log to >> >> (log->dirty_bitmap<< 32) | 0x00000000 >> > Well yes, that was the problem. If we always set the __u64 value to the pointer we're safe though. > > union { > void *p; > __u64 q; > } > > void x(void *r) > { > // breaks: > p = r; > > // works: > q = (ulong)r; > } > In that case it's better to avoid p altogether, since users will naturally assign to the pointer. Using a 64-bit integer avoids the problem (though perhaps not sufficient for s390, Arnd?) -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.