From patchwork Wed Aug 2 15:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 73490 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F29F385EC55 for ; Wed, 2 Aug 2023 15:59:56 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 035783857C48 for ; Wed, 2 Aug 2023 15:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 035783857C48 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-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686f090310dso6961026b3a.0 for ; Wed, 02 Aug 2023 08:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690991955; x=1691596755; 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=kgIlVLgcpwisLpKOdSF47rExv2PhcF7fzRtifvTXV+k=; b=rlpPATh72P9PiKnktBaS9N9OyMCvKZ8+U4yEYDEL/MR159CEsZzn3GIFogje4nV7Lx cDCoRm3rhEV5oZUS1IonLIVp7OB/AZOUNoCQaXZTMvr07gHwDI2H0tTllEbOkbS315wN kfu+kkm8D/8idjxXkpzzveahsxsnbtGXL7gGAM5dDFPWHFLXBDDSOiYEpiRTkyWoUxr0 K7jfI21RdBn3aKcwZ/Gejavg6htz3L6bQhObOIf9xegWEbH88sYBsV06X1xlLU/IDiR8 EpgnykJur9zbgMXAzX3QtioD4Z4cYsqehcs6aY2vF+Y9MPsbcPOesxP4vVmRYBfz99LB PP6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690991955; x=1691596755; 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=kgIlVLgcpwisLpKOdSF47rExv2PhcF7fzRtifvTXV+k=; b=WkPQVq+tKWQfNIs0F0oy4PUpgs04JlJTYeQbWeU+OPeajIgDVw88zG9Az8jRgOiaV4 23ha5DPxMKxv2csaaXwUnNSSsI9yLO5wT5/vZoVdZxPvi00fWO8Td2KI5pcMZbwzALhV 36fY1bJyYSpwVX9TEb6oERR6Hv2BtI/81LHTJET6p9eW+lYA+a7nNcyGDrjO6OiD7+cE DIpM5UB8PCQdMbk0Z3H7tMgMbsdF12q+dYrCmpnKPPqIiN9bq+qbyQjeJ8xiaq6vpO3k Ooy/5WnSuzW1dKGDTjME7EqMGUz5gGolG5oD07sDixHCfVrAPg97guQBi9nTK/BBKyUs 7+sg== X-Gm-Message-State: ABy/qLZ13AFaOBSzAvKJHJCDvHic2d1hiwzSyQEPiU0iSJ0r1u8p+7KL qhx94/Ty5cBmRt/1d04uEPhbV2rZG4O5sslRQZI= X-Google-Smtp-Source: APBJJlHpishuTUBgaTv+Pm/y7c9HjW762bR5hHOU220zagcCw+blDKetZLUvZ3iURY5JNa1+tek9zg== X-Received: by 2002:a05:6a00:124d:b0:687:7d09:c0f with SMTP id u13-20020a056a00124d00b006877d090c0fmr1641328pfi.12.1690991955448; Wed, 02 Aug 2023 08:59:15 -0700 (PDT) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id i5-20020aa787c5000000b00682936d04ccsm11200091pfo.180.2023.08.02.08.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:59:15 -0700 (PDT) From: Evan Green To: libc-alpha@sourceware.org Cc: slewis@rivosinc.com, Florian Weimer , palmer@rivosinc.com, vineetg@rivosinc.com, Evan Green Subject: [PATCH v6 2/5] riscv: Add hwprobe vdso call support Date: Wed, 2 Aug 2023 08:59:00 -0700 Message-Id: <20230802155903.2552780-3-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802155903.2552780-1-evan@rivosinc.com> References: <20230802155903.2552780-1-evan@rivosinc.com> MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 v3) 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 | 6 ++++-- sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + 4 files changed, 18 insertions(+), 2 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 81f24dbc19..57b06c22a5 100644 --- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c +++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c @@ -20,11 +20,13 @@ #include #include #include +#include int __riscv_hwprobe (struct riscv_hwprobe *__pairs, size_t __pair_count, size_t __cpu_count, unsigned long int *__cpus, unsigned int __flags) { - return INLINE_SYSCALL_CALL (riscv_hwprobe, __pairs, __pair_count, - __cpu_count, __cpus, __flags); + /* The vDSO may be able to provide the answer without a syscall. */ + return INLINE_VSYSCALL(riscv_hwprobe, 5, __pairs, __pair_count, + __cpu_count, __cpus, __flags); } 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