qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [qemu-s390x] [PATCH for-4.0 2/2] target/s390x: Implement STCK et al


From: Richard Henderson
Subject: Re: [qemu-s390x] [PATCH for-4.0 2/2] target/s390x: Implement STCK et al for CONFIG_USER_ONLY
Date: Mon, 3 Dec 2018 07:30:05 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1

On 12/3/18 4:21 AM, David Hildenbrand wrote:
> On 30.11.18 20:22, Richard Henderson wrote:
>> This is a non-privileged instruction that was only implemented
>> for system mode.  However, the stck instruction is used by glibc,
>> so this was causing SIGILL for programs run under debian stretch.
>>
>> Signed-off-by: Richard Henderson <address@hidden>
>> ---
>>  target/s390x/helper.h      |  2 +-
>>  target/s390x/misc_helper.c | 13 ++++++++++++-
>>  target/s390x/translate.c   |  2 ++
>>  target/s390x/insn-data.def | 11 ++++++-----
>>  4 files changed, 21 insertions(+), 7 deletions(-)
>>
>> diff --git a/target/s390x/helper.h b/target/s390x/helper.h
>> index 018e9dd414..6260b50496 100644
>> --- a/target/s390x/helper.h
>> +++ b/target/s390x/helper.h
>> @@ -121,13 +121,13 @@ DEF_HELPER_4(cu41, i32, env, i32, i32, i32)
>>  DEF_HELPER_4(cu42, i32, env, i32, i32, i32)
>>  DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32)
>>  DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env)
>> +DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
>>  
>>  #ifndef CONFIG_USER_ONLY
>>  DEF_HELPER_3(servc, i32, env, i64, i64)
>>  DEF_HELPER_4(diag, void, env, i32, i32, i32)
>>  DEF_HELPER_3(load_psw, noreturn, env, i64, i64)
>>  DEF_HELPER_FLAGS_2(spx, TCG_CALL_NO_RWG, void, env, i64)
>> -DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
>>  DEF_HELPER_FLAGS_2(sck, TCG_CALL_NO_RWG, i32, env, i64)
>>  DEF_HELPER_FLAGS_2(sckc, TCG_CALL_NO_RWG, void, env, i64)
>>  DEF_HELPER_FLAGS_2(sckpf, TCG_CALL_NO_RWG, void, env, i64)
>> diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
>> index 3f91579570..c2940afecb 100644
>> --- a/target/s390x/misc_helper.c
>> +++ b/target/s390x/misc_helper.c
>> @@ -76,8 +76,19 @@ uint64_t HELPER(stpt)(CPUS390XState *env)
>>  #endif
>>  }
>>  
>> -#ifndef CONFIG_USER_ONLY
>> +#ifdef CONFIG_USER_ONLY
>> +/* Store Clock */
>> +uint64_t HELPER(stck)(CPUS390XState *env)
>> +{
>> +    struct timespec ts;
>> +    uint64_t ms;
>>  
>> +    clock_gettime(CLOCK_REALTIME, &ts);
>> +    ms = (ts.tv_nsec / 1000) + (ts.tv_sec * 100000ull);
>> +
>> +    return TOD_UNIX_EPOCH + ms;
> 
> In theory, the TOD can be completely controlled by the operating system
> (e.g. set the TOD to X). So for user space, there isn't really any
> guarantee about the values returned via stck.
> 
> E.g. in the PoP 4-51:
> 
> "4. A program using the clock value as a time-of-day
> and calendar indication must be consistent with
> the programming support under which the pro-
> gram is to be executed. [...]"

Ok, but then there's the matter of the CC result.  We currently hard-code this
as 0, meaning "clock is set", meaning it does have the real TOD value.

We could set CC as 1, meaning "clock is not set", meaning the value is only
good for relative computation.

Is this perhaps a bug in our system implementation as well?

What CC value is provided to userspace on real hardware?


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]