From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 727561F463 for ; Fri, 20 Dec 2019 22:35:11 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :cc:content-type; q=dns; s=default; b=kupfBRG1OAUTRLKnmxk0fa2zQC JLwkMWDWLKfdOuNq7xV5pPZsCrIc0CIdjgSjEAYuZ53FUN6zQGlpG9ThSLEC7yKx J/SX8GWr8sjNiie/X9+BTXQPKj1hQe1swaJYF1WTWrnRAFyjU3+xQB4BrSmCypr2 i+TWkmaeUGysInSsU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :cc:content-type; s=default; bh=MusVELAbr79D36Wm1azY8GqDkXg=; b= H88MeT6hg91DagrrbZ+zAHP9z1LA5N30DETsUMVmU/+TOK9jLByUBWPGRQVgkS/B uq+QguMIqiRrLOKAdlSc5VZonJHicWzmi1JkwijJmfe8S5bgeo08xhOdrZK2ndSa CgP8Iy3aNQbMaHfF5JO3LQlb9nnOv63x4emiV5VuFIw= Received: (qmail 50480 invoked by alias); 20 Dec 2019 22:35:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 50471 invoked by uid 89); 20 Dec 2019 22:35:08 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-lj1-f178.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=GKvH4Brk+aSNFEOGOYCuw+f1uaw8Bi15MjR401IG+Ow=; b=koS431D8sX9Rknkdso/0qK5sD0Jn7war076y0PnjEvEbidWO0ivGi9+4yKUWSxWIU1 pO+ECKa8OxQJU0GOrQlQiJjE3gRnWlF3jFNTGKvdjwT41R68UPW6ieSoLblljnNn5ovY x4TKutMS2TN37AfTN85ya12MPBPp0b9hN9LySrzMtKhcP1s/uths+HK3ReJrdkPRE+uT u4i8t/7jQMRdR0kXBy1ZcucMZ9KzNsc1kE8+JIhHfFYCOselzgavCx1VEu/YcRYxwaLJ xlTFUwKGp9k8FeVI6o5+Apq/P3RKrI3d4BV5dsCFVU/U3i+cfxChVADHuH5MPWo9Qzga USrQ== MIME-Version: 1.0 From: Alistair Francis Date: Fri, 20 Dec 2019 14:28:46 -0800 Message-ID: Subject: 32-bit time_t inside itimerval To: Arnd Bergmann , GNU C Library Cc: Alistair Francis , Lukasz Majewski Content-Type: text/plain; charset="UTF-8" Hey, I just noticed something strange. The setitimer syscall is not different for 32/64-bit time_t. So we use this syscall for both 32/64 time_t [1] SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, struct itimerval __user *, ovalue) Where struct itimerval __user *, value looks like this [2]: struct itimerval { struct timeval it_interval; /* timer interval */ struct timeval it_value; /* current value */ }; Which then uses this structure for timeval [3]: struct timeval { __kernel_old_time_t tv_sec; /* seconds */ __kernel_suseconds_t tv_usec; /* microseconds */ }; And __kernel_old_time_t is defined [4] as: typedef __kernel_long_t __kernel_old_time_t; typedef __kernel_long_t __kernel_time_t; So __kernel_old_time_t and __kernel_time_t are both 32-bit values inside the kernel. and the setiimer syscall expects a 32-bit time_t for the values inside it. This is different to the current glibc implementation where all time_t values are treated as 64-bit for RISC-V [5]. What should we do here? 1. Change glibc to use a 32-bit time_t for some structures, such as the timeval inside itimerval? 2. Convert the kernel time_t to be 64-bit for RV32? Alistair 1: https://github.com/torvalds/linux/blob/ceb307474506f888e8f16dab183405ff01dffa08/kernel/time/itimer.c#L336 2: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/linux/time.h#L39 3: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/linux/time.h#L16 4: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/asm-generic/posix_types.h#L89 5: https://github.com/alistair23/glibc/commit/71faeb322c4f4a163d138893b6855920dad45e07