On 09/18/2012 10:21 AM, Xiao Guangrong wrote:
> On 09/16/2012 08:07 PM, Avi Kivity wrote:
> 
>> +    /*
>> +     * On a write fault, fold the dirty bit into accessed_dirty by shifting 
>> it one
>> +     * place right.
>> +     *
>> +     * On a read fault, do nothing.
>> +     */
>> +    accessed_dirty &= pte >> (write_fault >> ilog2(PFERR_WRITE_MASK));
> 
> It is too trick: it depends on DIRTY_SHIFT = ACCESSED_SHIFT + 1. How about 
> change it
> to:
>   accessed_dirty &= pte >> (!!write_fault >> (DIRTY_SHIFT - ACCESSED_SHIFT)) ?

!! forces a branch, unless gcc is really clever.  So I changed it to

        shift = write_fault >> ilog2(PFERR_WRITE_MASK);
        shift *= PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT;
        accessed_dirty &= pte >> shift;

which should result in the same code.

-- 
error compiling committee.c: too many arguments to function
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to