2020-01-15 12:20:31

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH vdsotest] Use vdso wrapper for gettimeofday()

To properly handle errors returned by gettimeofday(), the
DO_VDSO_CALL() macro has to be used, otherwise vdsotest
misinterpret VDSO function return on error.

This has gone unnoticed until now because the powerpc VDSO
gettimeofday() always succeed, but while porting powerpc to
generic C VDSO, the following has been encountered:

gettimeofday(valid, UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(valid, UINTPTR_MAX) (VDSO): exited with status 1, expected 0
gettimeofday(valid, page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(valid, page (PROT_NONE)) (VDSO): exited with status 1, expected 0
gettimeofday(valid, page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(valid, page (PROT_READ)) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, valid) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, valid) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, NULL) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, NULL) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, UINTPTR_MAX) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, page (PROT_NONE)) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, page (PROT_READ)) (VDSO): exited with status 1, expected 0
gettimeofday(page (PROT_NONE), valid) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), valid) (VDSO): exited with status 1, expected 0
gettimeofday(page (PROT_NONE), NULL) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), NULL) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_NONE), UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), UINTPTR_MAX) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_NONE), page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), page (PROT_NONE)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_NONE), page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), page (PROT_READ)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), valid) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), valid) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), NULL) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), NULL) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), UINTPTR_MAX) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), page (PROT_NONE)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), page (PROT_READ)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday/abi: 18 failures/inconsistencies encountered

Signed-off-by: Christophe Leroy <[email protected]>
---
src/gettimeofday.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gettimeofday.c b/src/gettimeofday.c
index c50ecea..472f372 100644
--- a/src/gettimeofday.c
+++ b/src/gettimeofday.c
@@ -54,11 +54,16 @@ static void gettimeofday_syscall_nofail(struct timeval *tv, struct timezone *tz)
error(EXIT_FAILURE, errno, "SYS_gettimeofday");
}

+static int gettimeofday_vdso_wrapper(struct timeval *tv, struct timezone *tz)
+{
+ return DO_VDSO_CALL(gettimeofday_vdso, int, 2, tv, tz);
+}
+
static void gettimeofday_vdso_nofail(struct timeval *tv, struct timezone *tz)
{
int err;

- err = gettimeofday_vdso(tv, tz);
+ err = gettimeofday_vdso_wrapper(tv, tz);
if (err)
error(EXIT_FAILURE, errno, "gettimeofday");
}
@@ -153,7 +158,7 @@ static void gettimeofday_bench(struct ctx *ctx, struct bench_results *res)
struct timeval tv;

if (vdso_has_gettimeofday()) {
- BENCH(ctx, gettimeofday_vdso(&tv, NULL),
+ BENCH(ctx, gettimeofday_vdso_wrapper(&tv, NULL),
&res->vdso_interval);
}

@@ -196,7 +201,7 @@ static void do_gettimeofday(void *arg, struct syscall_result *res)
if (args->force_syscall)
err = gettimeofday_syscall_wrapper(args->tv, args->tz);
else
- err = gettimeofday_vdso(args->tv, args->tz);
+ err = gettimeofday_vdso_wrapper(args->tv, args->tz);
record_syscall_result(res, err, errno);
}

--
2.13.3


2020-01-16 16:59:48

by Nathan Lynch

[permalink] [raw]
Subject: Re: [PATCH vdsotest] Use vdso wrapper for gettimeofday()

Hi Christophe,

Christophe Leroy <[email protected]> writes:
> To properly handle errors returned by gettimeofday(), the
> DO_VDSO_CALL() macro has to be used, otherwise vdsotest
> misinterpret VDSO function return on error.
>
> This has gone unnoticed until now because the powerpc VDSO
> gettimeofday() always succeed, but while porting powerpc to
> generic C VDSO, the following has been encountered:

Thanks for this, I'll review it soon.

Can you point me to patches for the powerpc generic vdso work?

2020-01-16 22:31:27

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH vdsotest] Use vdso wrapper for gettimeofday()



Le 16/01/2020 à 17:56, Nathan Lynch a écrit :
> Hi Christophe,
>
> Christophe Leroy <[email protected]> writes:
>> To properly handle errors returned by gettimeofday(), the
>> DO_VDSO_CALL() macro has to be used, otherwise vdsotest
>> misinterpret VDSO function return on error.
>>
>> This has gone unnoticed until now because the powerpc VDSO
>> gettimeofday() always succeed, but while porting powerpc to
>> generic C VDSO, the following has been encountered:
>
> Thanks for this, I'll review it soon.
>
> Can you point me to patches for the powerpc generic vdso work?
>

Sure.

v3 is at
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=152867

I added you in v4 destinees.

Christophe

2020-04-07 16:14:09

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH vdsotest] Use vdso wrapper for gettimeofday()

Hi Nathan,

Le 16/01/2020 à 17:56, Nathan Lynch a écrit :
> Hi Christophe,
>
> Christophe Leroy <[email protected]> writes:
>> To properly handle errors returned by gettimeofday(), the
>> DO_VDSO_CALL() macro has to be used, otherwise vdsotest
>> misinterpret VDSO function return on error.
>>
>> This has gone unnoticed until now because the powerpc VDSO
>> gettimeofday() always succeed, but while porting powerpc to
>> generic C VDSO, the following has been encountered:
>
> Thanks for this, I'll review it soon.
>
> Can you point me to patches for the powerpc generic vdso work?
>

I have not seen any update on the vdsotest repository, have you been
able to have a look at the patch ?

Thanks
Christophe

2020-04-14 19:30:40

by Nathan Lynch

[permalink] [raw]
Subject: Re: [PATCH vdsotest] Use vdso wrapper for gettimeofday()

Christophe Leroy <[email protected]> writes:
> Hi Nathan,
>
> Le 16/01/2020 à 17:56, Nathan Lynch a écrit :
>> Hi Christophe,
>>
>> Christophe Leroy <[email protected]> writes:
>>> To properly handle errors returned by gettimeofday(), the
>>> DO_VDSO_CALL() macro has to be used, otherwise vdsotest
>>> misinterpret VDSO function return on error.
>>>
>>> This has gone unnoticed until now because the powerpc VDSO
>>> gettimeofday() always succeed, but while porting powerpc to
>>> generic C VDSO, the following has been encountered:
>>
>> Thanks for this, I'll review it soon.
>>
>> Can you point me to patches for the powerpc generic vdso work?
>>
>
> I have not seen any update on the vdsotest repository, have you been
> able to have a look at the patch ?

Thanks for the reminder. I've applied this now.