From patchwork Tue Feb 21 19:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 65426 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 9B68F3844770 for ; Tue, 21 Feb 2023 19:16:12 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 1BE88384E40C for ; Tue, 21 Feb 2023 19:15:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BE88384E40C 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-pj1-x1036.google.com with SMTP id pt11so6820955pjb.1 for ; Tue, 21 Feb 2023 11:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; 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=wJQ5ZiVe6iadFMTMH6U6IPvmSSxldcjtQwO3SaIQLvI=; b=X0CME7fB89oTBA/y5pXqcfTBrnhRALHvK4VF0KbzlKXOWiJy9B5StPWCmuTeyI5U+y 0O22kokSaDVw4vt6Ck5NFOjpeuJsHB4aIKCX7qOjazo/rxDooYS5pdd9KqEin/Bxd2mM rmSY1QCsJAoMhq9MUI8/aT1eZpkIibxdE6HjUp4i0KP27DvbQjGU/stom3pDQZAQnU7G X4aoy/g3zHo+CSt20ry8IJJoN37+noKUJwd05vHKMRbonL5XgBcqORTe8QeOg01bVlVd doKWEADfj9WEFYMhpBRHNLUXNDOnwznxOqcOpsAABh0orOBHPq7UaNMB7T/U9nzPJNZ9 ZF9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wJQ5ZiVe6iadFMTMH6U6IPvmSSxldcjtQwO3SaIQLvI=; b=IW2kqUkonIbXpEDqIS9ds4rAXIV4qMZ090cF4nhokJsWM5BW5HKiYwZqFNRmiCimLt 5Awl2E7j95InwfOc56N7IPScHFPUH1J56bGg2XB4mu4ckIWaNFaMA0uCdg2mlaas/yOg GyoTvbT/9Ry2EJStmXP/Ku4rWcoc3FWxpJXJuQrpQeIV1NUkVvNSP/ekz2ytgqStrktL B8mEwfiB3MNok9mywm/KJtJhnaGe4ru9glLCdkdR25jfWRBh7F6q6FGJmKe+R5ir3pwX OW0/Ug6NYlEWoZ5N6HoMSBr679BV1kMXNfPZqxbopORSXJb0sXvc6rjEb7u9eR8NsbcM 70ug== X-Gm-Message-State: AO0yUKXtUFgMZ3qV1gil6XyP+/RpKPe4ZbO9Vz3XsdlopxzqoEMd3j8I iq+bvmCQXuMqwkVaZZ5B7tEqrryTwOUn1iEx X-Google-Smtp-Source: AK7set+Hml6Oz2CtY/ada9JTHu0H1LxO05BX66VGZObyH6IIjht6m07vOH863sX0dZpYWbE0ASpIgA== X-Received: by 2002:a17:902:dac1:b0:19a:9055:6658 with SMTP id q1-20020a170902dac100b0019a90556658mr8433171plx.18.1677006954635; Tue, 21 Feb 2023 11:15:54 -0800 (PST) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id iy17-20020a170903131100b00198fb25d09bsm3007283plb.237.2023.02.21.11.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 11:15:54 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: palmer@rivosinc.com, slewis@rivosinc.com, vineetg@rivosinc.com, Evan Green Subject: [PATCH v2 2/3] riscv: Add hwprobe vdso call support Date: Tue, 21 Feb 2023 11:15:36 -0800 Message-Id: <20230221191537.3159966-3-evan@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230221191537.3159966-1-evan@rivosinc.com> References: <20230221191537.3159966-1-evan@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 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 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 --- 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, 20 insertions(+) diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c index 68fa8de641..3fe304a0c7 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 *, + long, + long, + unsigned long *, + long) 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 74f68889ca..2c61a67db7 100644 --- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c +++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c @@ -20,11 +20,17 @@ #include #include #include +#include int __riscv_hwprobe (struct riscv_hwprobe *pairs, long pair_count, long cpu_count, unsigned long *cpus, unsigned long flags) { + /* The vDSO may be able to provide the answer without a syscall. */ +#ifdef HAVE_RISCV_HWPROBE + INLINE_VSYSCALL(riscv_hwprobe, 5, pairs, pair_count, cpu_count, cpus, flags); +#else return INLINE_SYSCALL_CALL (riscv_hwprobe, pairs, pair_count, cpu_count, cpus, flags); +#endif } diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h index 4af5fe5dbc..ba17aaaff2 100644 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h @@ -155,6 +155,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