From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2F17C433E1 for ; Tue, 25 Aug 2020 14:23:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D19E20665 for ; Tue, 25 Aug 2020 14:23:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D19E20665 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAZrd-0000HT-Qr for qemu-devel@archiver.kernel.org; Tue, 25 Aug 2020 10:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAZr2-0007sp-9K for qemu-devel@nongnu.org; Tue, 25 Aug 2020 10:23:16 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:38155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAZqz-0003fB-Rr for qemu-devel@nongnu.org; Tue, 25 Aug 2020 10:23:15 -0400 Received: from [192.168.100.1] ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.103]) with ESMTPSA (Nemesis) id 1MJEMt-1jvVo40jRD-00KenN; Tue, 25 Aug 2020 16:23:11 +0200 Subject: Re: [PATCH v2 2/2] linux-user: Add support for utimensat_time64() and semtimedop_time64() From: Laurent Vivier To: Filip Bozuta , qemu-devel@nongnu.org References: <20200824223050.92032-1-Filip.Bozuta@syrmia.com> <20200824223050.92032-3-Filip.Bozuta@syrmia.com> Autocrypt: addr=laurent@vivier.eu; prefer-encrypt=mutual; keydata= mQINBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgVGVLYthYSfTtN0Y60OgNkWCMtFwKxRaXt1WFA5ceqinN/XkgA+vf2Ch72zBkJL RBIhfOPFv5f2Hkkj0MvsUXpOWaOjatiu0fpPo6Hw14UEpywke1zN4NKubApQOlNKZZC4hu6/ 8pv2t4HRi7s0K88jQYBRPObjrN5+owtI51xMaYzvPitHQ2053LmgsOdN9EKOqZeHAYG2SmRW LOxYWKX14YkZI5j/TXfKlTpwSMvXho+efN4kgFvFm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wHeJOxGKCGIyeKORsteIqgnkINW9fnKJw2pgk8qHkwVc3Vu+wGS ZiJK0xFusPQehjWTHn9WjMG1zvQ5TQQHxau/2FkP45+nRPco6vVFQe8JmgtRF8WFJA== Message-ID: <626ac58f-cd0f-0e64-07d7-c5de1d009b47@vivier.eu> Date: Tue, 25 Aug 2020 16:23:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:EWkwRb6LFQThVf1hQgdwb7oo/Ywj6dXFG6K2iPPsQbRGODvUIyR GQqTAYVhZi+tg8bKdXXBv3M8btRoZSK8ZKGVc1mJfXvw/Sd+bUnJa/ldHrBevYLYUNI0nBW Cyqx14eTvth0+jx4DBiDH3EXkpTyFo7iN/SgQxaWf/dm5Y2/Ntr1Vbo1x0l2zkMfE7JkZc6 Sw044PSnHhEudy7h/ZFeg== X-UI-Out-Filterresults: notjunk:1;V03:K0:SyH7Hjs6c2I=:KdF+JGoqvkUrIYcXgAq6xP e9jIAYsqAJjv3/NuTMEp35tnQEp3SQwrGBgMgu7FhrBPzx7B+TZPc87WxNO23mk/tw5DvPzjY yXkjTu+Zw9GXIqHXBN+IYwL9cMISc58HfPcnZX5eXIgDwxJbMAb8xA8O9dyA9yaGUf1KWoKTg BV1vDuoN8iQWXAC00vkrV5pT1UhfRV/sKfI4Kk33GbF5A0K0IQybrp4YRLhtg5y7KjopY4MYK OAaOrmIRrfQYkcXSoB+UAdWbZoEVuruPRuv1uqzFdfY3G3oVJikwYuv7wKRBR7/lkaJQhohTj 4I8thYw9H/tJk3xvGeW15IP/SDTp7W9vwCZF7c/eYlcKibpLCOSV+BUtbFjRdp8nZNM7EFeEO MVrdu+BBziynykTOIwma8P/q1no/unOckdy7vpz7oUhGADU7WDCk6Q45gkM7uiyvl+CHgBxvt l61gp98SxohfKpOzh/LdMwujNEh/9iE64DRRT10qNSWICOYDcvRT5dFqaNovyxlhuOgU7roQM 5HxRI0qnfJ2j1her+l/ncx5IQNhF+kaHOqfi2HD8n4r/cXHBz7a0xgOMTUbHZXm0jo5aKlgeJ DWjPheWtRHchql7bkF1qV9an+YbiLxc5ntaJKVKnyd466LDglyjI/c9pC9bmPBXT2+4IKLYSV Pi79NJa+Gmg4VZkrq3pfIr4J7ZsUCRh18DcybGrKdLNu7kdItajBYMvCn2eSwA/KxDpVdjMTd Hgruplo5J3Ksw21dUBKjgj/i8NmrUlhyTMzut0awEXjZyL2gpunSZVaQF04+ppULKUPy6G0dR j4tWn3YV2MJHN+iFcktL1Bp5md6sZfcoZlImteo6zh8qbtRbKS17rP4NVRq76xEcXw9+ujW Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/25 10:23:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-2.602, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Le 25/08/2020 à 09:18, Laurent Vivier a écrit : > Le 25/08/2020 à 00:30, Filip Bozuta a écrit : >> This patch introduces functionality for following time64 syscalls: >> >> *utimensat_time64() >> >> int utimensat(int dirfd, const char *pathname, >> const struct timespec times[2], int flags); >> -- change file timestamps with nanosecond precision -- >> man page: https://man7.org/linux/man-pages/man2/utimensat.2.html >> >> *semtimedop_time64() >> >> int semtimedop(int semid, struct sembuf *sops, size_t nsops, >> const struct timespec *timeout); >> -- System V semaphore operations -- >> man page: https://www.man7.org/linux/man-pages/man2/semtimedop.2.html >> >> Implementation notes: >> >> Syscall 'utimensat_time64()' is implemented in similar way as its >> regular variants only difference being that time64 converting function >> is used to convert values of 'struct timespec' between host and target >> ('target_to_host_timespec64()'). >> >> For syscall 'semtimedop_time64()' and additional argument is added >> in function 'do_semtimedop()' through which the aproppriate 'struct timespec' >> converting function is called (false for regular target_to_host_timespec() >> and true for target_to_host_timespec64()). For 'do_ipc()' a >> check was added as that additional argument: 'TARGET_ABI_BITS == 64'. >> >> Signed-off-by: Filip Bozuta >> Reviewed-by: Laurent Vivier >> --- >> linux-user/syscall.c | 60 ++++++++++++++++++++++++++++++++++++-------- >> 1 file changed, 50 insertions(+), 10 deletions(-) >> >> diff --git a/linux-user/syscall.c b/linux-user/syscall.c >> index fc6a6e32e4..4d460af744 100644 >> --- a/linux-user/syscall.c >> +++ b/linux-user/syscall.c >> @@ -1253,7 +1253,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts, >> #endif >> >> #if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) || \ >> - defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64) >> + defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64) || \ >> + defined(TARGET_NR_utimensat_time64) || defined(TARGET_NR_semtimedop_time64) >> static inline abi_long target_to_host_timespec64(struct timespec *host_ts, >> abi_ulong target_addr) >> { >> @@ -4117,7 +4118,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf, >> } >> >> #if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) || \ >> - defined(TARGET_NR_semtimedop) >> + defined(TARGET_NR_semtimedop) || defined(TARGET_NR_semtimedop_time64) >> >> /* >> * This macro is required to handle the s390 variants, which passes the >> @@ -4134,7 +4135,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf, >> static inline abi_long do_semtimedop(int semid, >> abi_long ptr, >> unsigned nsops, >> - abi_long timeout) >> + abi_long timeout, bool time64) >> { >> struct sembuf sops[nsops]; >> struct timespec ts, *pts = NULL; >> @@ -4142,8 +4143,14 @@ static inline abi_long do_semtimedop(int semid, >> >> if (timeout) { >> pts = &ts; >> - if (target_to_host_timespec(pts, timeout)) { >> - return -TARGET_EFAULT; >> + if (time64) { >> + if (target_to_host_timespec64(pts, timeout)) { >> + return -TARGET_EFAULT; >> + } >> + } else { >> + if (target_to_host_timespec(pts, timeout)) { >> + return -TARGET_EFAULT; >> + } >> } >> } >> >> @@ -4657,7 +4664,7 @@ static abi_long do_ipc(CPUArchState *cpu_env, >> >> switch (call) { >> case IPCOP_semop: >> - ret = do_semtimedop(first, ptr, second, 0); >> + ret = do_semtimedop(first, ptr, second, 0, false); >> break; >> case IPCOP_semtimedop: >> /* >> @@ -4667,9 +4674,9 @@ static abi_long do_ipc(CPUArchState *cpu_env, >> * to a struct timespec where the generic variant uses fifth parameter. >> */ >> #if defined(TARGET_S390X) >> - ret = do_semtimedop(first, ptr, second, third); >> + ret = do_semtimedop(first, ptr, second, third, TARGET_ABI_BITS == 64); >> #else >> - ret = do_semtimedop(first, ptr, second, fifth); >> + ret = do_semtimedop(first, ptr, second, fifth, TARGET_ABI_BITS == 64); >> #endif >> break; >> >> @@ -9887,11 +9894,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, >> #endif >> #ifdef TARGET_NR_semop >> case TARGET_NR_semop: >> - return do_semtimedop(arg1, arg2, arg3, 0); >> + return do_semtimedop(arg1, arg2, arg3, 0, false); >> #endif >> #ifdef TARGET_NR_semtimedop >> case TARGET_NR_semtimedop: >> - return do_semtimedop(arg1, arg2, arg3, arg4); >> + return do_semtimedop(arg1, arg2, arg3, arg4, false); >> +#endif >> +#ifdef TARGET_NR_semtimedop_time64 >> + case TARGET_NR_semtimedop_time64: >> + return do_semtimedop(arg1, arg2, arg3, arg4, true); >> #endif >> #ifdef TARGET_NR_semctl >> case TARGET_NR_semctl: >> @@ -11938,6 +11949,35 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, >> } >> return ret; >> #endif >> +#ifdef TARGET_NR_utimensat_time64 >> + case TARGET_NR_utimensat_time64: >> + { >> + struct timespec *tsp, ts[2]; >> + if (!arg3) { >> + tsp = NULL; >> + } else { >> + if (target_to_host_timespec64(ts, arg3)) { >> + return -TARGET_EFAULT; >> + } >> + if (target_to_host_timespec64(ts + 1, arg3 + >> + sizeof(struct target__kernel_timespec))) { >> + return -TARGET_EFAULT; >> + } >> + tsp = ts; >> + } >> + if (!arg2) >> + ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); >> + else { >> + p = lock_user_string(arg2); >> + if (!p) { >> + return -TARGET_EFAULT; >> + } >> + ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); >> + unlock_user(p, arg2, 0); >> + } >> + } >> + return ret; >> +#endif >> #ifdef TARGET_NR_futex >> case TARGET_NR_futex: >> return do_futex(arg1, arg2, arg3, arg4, arg5, arg6); >> > > Applied to my linux-user-for-5.2 branch. I have removed it from my queue because the "TARGET_NR_utimensat_time64" part breaks something (at least with sh4/sid on x86_64): $ touch a $ cp -p a b /usr/bin/cp: preserving times for 'b': Invalid argument Thanks, Laurent