From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id D3FE83858D37 for ; Fri, 1 Sep 2023 23:52:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3FE83858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c1f8aaab9aso20151535ad.1 for ; Fri, 01 Sep 2023 16:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1693612353; x=1694217153; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aAhWPSgvktYgj2fzRCxEswRwk7DllMq47Tg6ba8f3Mc=; b=Ip4JYdA4cgVy888LWgU1JrSRY3sE7NGsGizI2QntHqwKA2DS6vEu63xVkAk3FySg6/ 7JPccvS4mjwKgVG5DuVdjHNBV/hqGS7nNAJUMNHWUCoZYOBWVZpOCtRHIrtxSMbYS6Ui popTALHrkzYxj7pa1vBjZ97f4SHwZS1+yRM54ik3xRKTgpq2zM0xmlTcTMmjS++4GGg5 QpanvObBChFPsIeDSvGFdAM2DSMFWVbZ4x9V50q63yMHvTzfkjCHX2ZuFaodRbVidpQ4 OA1eBnm/QAPpqNlP1pMCWRM4M3hF8f46HCMIAtPNvRDMFVXoLUL2zODJ+YcyhXHJuy+t 9PJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693612353; x=1694217153; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aAhWPSgvktYgj2fzRCxEswRwk7DllMq47Tg6ba8f3Mc=; b=DAHESlTob+pNUCE0BaDQKoIilkXFTxYByqzsMwPwMKGxMYQIcDMGSPd5Xndj0g8pub vpwLqArxwxFO5RjtuWb0sBr3RVEgimRynpjGk0pji5ZtxCJzfkP3wKUewsL/O6yBZhtn cYA8R6wghpsh3a3IOQ9veyuY0IXNaz6/nV1Dn2Uz+ouyvjAyhpG5joQ5nk/4E1/vWF0e HQfebZD2f1i3gaal7qKKBkXspQ3CeloH0KOSKvIoR438BayuQ0kzDyfzmvSZyZ2Q/7QT xOIMho5cn3S4w0qKl3JAtGNeCD6AWhCTlNWYscAvLxWMOklfc488JfSdv26D87czsiul xu8A== X-Gm-Message-State: AOJu0YwGQ1toH0AGZDVfppL9RTXsE3RTGybNlc5mXmImD9WcqrSX8ekK Oc5m+9cmzeLc8giK2GVhsB+hibjeeOx3kfy4Ru4= X-Google-Smtp-Source: AGHT+IHaUWpm1HDuE+hZGTtGE5RVoA/t+U6Mc6UQ4xahBZwSIxS/c81NIL6haoKPW8SNZKuidxRMWA== X-Received: by 2002:a17:902:9893:b0:1c0:6dcd:453d with SMTP id s19-20020a170902989300b001c06dcd453dmr4037020plp.20.1693612353427; Fri, 01 Sep 2023 16:52:33 -0700 (PDT) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001bee782a1desm3499551plg.181.2023.09.01.16.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:52:33 -0700 (PDT) From: Evan Green To: libc-alpha@sourceware.org Cc: slewis@rivosinc.com, Florian Weimer , vineetg@rivosinc.com, palmer@rivosinc.com, Evan Green Subject: [PATCH v8 2/6] riscv: Add hwprobe vdso call support Date: Fri, 1 Sep 2023 16:52:20 -0700 Message-Id: <20230901235224.3304592-3-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901235224.3304592-1-evan@rivosinc.com> References: <20230901235224.3304592-1-evan@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The new riscv_hwprobe syscall also comes with a vDSO for faster answers to your most common questions. Call in today to speak with a kernel representative near you! Signed-off-by: Evan Green Reviewed-by: Palmer Dabbelt --- (no changes since v7) Changes in v7: - Use INTERNAL_VSYSCALL_CALL (Florian) Changes in v3: - Add the "return" to the vsyscall - Fix up vdso arg types to match kernel v4 version - Remove ifdef around INLINE_VSYSCALL (Adhemerval) Changes in v2: - Add vDSO interface sysdeps/unix/sysv/linux/dl-vdso-setup.c | 10 ++++++++++ sysdeps/unix/sysv/linux/dl-vdso-setup.h | 3 +++ sysdeps/unix/sysv/linux/riscv/hwprobe.c | 17 ++++++++++++++--- sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c index 97eaaeac37..ed8b1ef426 100644 --- a/sysdeps/unix/sysv/linux/dl-vdso-setup.c +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.c @@ -71,6 +71,16 @@ PROCINFO_CLASS int (*_dl_vdso_clock_getres_time64) (clockid_t, # ifdef HAVE_GET_TBFREQ PROCINFO_CLASS uint64_t (*_dl_vdso_get_tbfreq)(void) RELRO; # endif + +/* RISC-V specific ones. */ +# ifdef HAVE_RISCV_HWPROBE +PROCINFO_CLASS int (*_dl_vdso_riscv_hwprobe)(void *, + size_t, + size_t, + unsigned long *, + unsigned int) RELRO; +# endif + #endif #undef RELRO diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.h b/sysdeps/unix/sysv/linux/dl-vdso-setup.h index 867072b897..39eafd5316 100644 --- a/sysdeps/unix/sysv/linux/dl-vdso-setup.h +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.h @@ -47,6 +47,9 @@ setup_vdso_pointers (void) #ifdef HAVE_GET_TBFREQ GLRO(dl_vdso_get_tbfreq) = dl_vdso_vsym (HAVE_GET_TBFREQ); #endif +#ifdef HAVE_RISCV_HWPROBE + GLRO(dl_vdso_riscv_hwprobe) = dl_vdso_vsym (HAVE_RISCV_HWPROBE); +#endif } #endif diff --git a/sysdeps/unix/sysv/linux/riscv/hwprobe.c b/sysdeps/unix/sysv/linux/riscv/hwprobe.c index e28194e344..6a9a44657f 100644 --- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c +++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c @@ -27,9 +27,20 @@ int __riscv_hwprobe (struct riscv_hwprobe *__pairs, size_t __pair_count, unsigned int __flags) { int r; - - r = INTERNAL_SYSCALL_CALL (riscv_hwprobe, 5, __pairs, __pair_count, - __cpu_count, __cpus, __flags); + __riscv_hwprobe_t vdso_hwprobe = + (__riscv_hwprobe_t)GLRO(dl_vdso_riscv_hwprobe); + + if (vdso_hwprobe != NULL) + { + r = INTERNAL_VSYSCALL_CALL (vdso_hwprobe, 5, __pairs, __pair_count, + __cpu_count, __cpus, __flags); + } + else + { + r = INTERNAL_SYSCALL_CALL (riscv_hwprobe, 5, __pairs, __pair_count, + __cpu_count, __cpus, __flags); + + } /* Negate negative errno values to match pthreads API. */ return -r; diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h index 5583b96d23..ee015dfeb6 100644 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h @@ -156,6 +156,7 @@ /* List of system calls which are supported as vsyscalls (for RV32 and RV64). */ # define HAVE_GETCPU_VSYSCALL "__vdso_getcpu" +# define HAVE_RISCV_HWPROBE "__vdso_riscv_hwprobe" # undef HAVE_INTERNAL_BRK_ADDR_SYMBOL # define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1 -- 2.34.1