On 6/11/19 5:07 PM, Jan Kiszka wrote:
> On 11.06.19 01:03, Ralf Ramsauer wrote:
>> If we should ever compile timing.c for 32 bit inmates, then unsigned
>> long is
>> the wrong type. A 32 bit type (aka unsigned long on 32 bit) is too
>> small to
>> hold the result.
>>
>> This ensures that we won't hit a bug when enabling on 32 bit. Once we
>> will
>> enable timing.c on 32 bit, we will have to implement 64 bit division
>> intrinsics.
>>
>> Signed-off-by: Ralf Ramsauer <[email protected]>
>> ---
>>   inmates/lib/x86/include/inmate.h | 2 +-
>>   inmates/lib/x86/timing.c         | 8 ++++----
>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/inmates/lib/x86/include/inmate.h
>> b/inmates/lib/x86/include/inmate.h
>> index 7664570d..e4f75206 100644
>> --- a/inmates/lib/x86/include/inmate.h
>> +++ b/inmates/lib/x86/include/inmate.h
>> @@ -241,7 +241,7 @@ void ioapic_pin_set_vector(unsigned int pin,
>>                  enum ioapic_trigger_mode trigger_mode,
>>                  unsigned int vector);
>>
>> -unsigned long pm_timer_read(void);
>> +unsigned long long pm_timer_read(void);
>>
>>   unsigned long tsc_read_ns(void);
>>   unsigned long tsc_init(void);
>> diff --git a/inmates/lib/x86/timing.c b/inmates/lib/x86/timing.c
>> index de41fc35..d179da0f 100644
>> --- a/inmates/lib/x86/timing.c
>> +++ b/inmates/lib/x86/timing.c
>> @@ -92,13 +92,13 @@ unsigned long tsc_init(void)
>>       return tsc_freq;
>>   }
>>
>> -unsigned long pm_timer_read(void)
>> +unsigned long long pm_timer_read(void)
>>   {
>>       unsigned int cpu = cpu_id();
>> -    unsigned long tmr;
>> +    unsigned long long tmr;
>>
>> -    tmr = ((inl(comm_region->pm_timer_address) & 0x00ffffff) *
>> NS_PER_SEC)
>> -        / PM_TIMER_HZ;
>> +    tmr = ((unsigned long long)(inl(comm_region->pm_timer_address)
>> +        & 0x00ffffff) * NS_PER_SEC) / PM_TIMER_HZ;
>>       if (tmr < pm_timer_last[cpu])
>>           pm_timer_overflows[cpu] += PM_TIMER_OVERFLOW;
>>       pm_timer_last[cpu] = tmr;
>>
> 
> This is not yet consistent: pm_timer_last is still unsigned long.
> 
> Do we need the conversion in this series already?

Nope. It's just a 'reminder' that sth. is odd there. But we can ignore
it. Same for 2/10.

Just some assorted stuff that I hit when (unsuccessfully) trying to
enable SMP on 32 bit.

  Ralf

> 
> Jan

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/2a46268d-4f8a-2b23-2ad0-2f7ccfa8d5a6%40oth-regensburg.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to