Re: [PATCH RFC v2 6/6] KVM: introduce a new API for getting dirty bitmaps

Arnd Bergmann
2010-04-23T13:12:55Z

On Friday 23 April 2010, Avi Kivity wrote:
> Ah so the 31st bit is optional as far as userspace is concerned? What
> does it mean? (just curious)

On data pointers it's ignored. When you branch to a function, this bit
determines whether the target function is run in 24 or 31 bit mode.
This allows linking to legacy code on older operating systems that
also support 24 bit libraries.

> What happens on the opposite conversion? is it restored?
>
> What about
>
> int compare_pointer(void *a, void *b)
> {
> unsigned long ai = (unsigned long)a;
> void *aia = (void *)ai;
>
> return a == b; /* true if a and b point to the same object */
> }

Some instructions set the bit, others clear it, so aia and a may not
be bitwise identical.

> Does gcc mask the big in pointer comparisons as well?

Yes. To stay in the above example:

a == aia; /* true */
(unsigned long)a == (unsigned long)aia; /* true */
*(unsigned long *)&a == *(unsigned long *)&aia; /* undefined on s390 */

Arnd