From patchwork Fri Apr 7 23:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 1766758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20210112.gappssmtp.com header.i=@rivosinc-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=F3LjIBen; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PtYtl2ZWxz1yZF for ; Sat, 8 Apr 2023 09:07:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 555783857345 for ; Fri, 7 Apr 2023 23:07:57 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 13D783858002 for ; Fri, 7 Apr 2023 23:07:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13D783858002 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-x102a.google.com with SMTP id qe8-20020a17090b4f8800b0023f07253a2cso44393307pjb.3 for ; Fri, 07 Apr 2023 16:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1680908843; x=1683500843; 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=XMG14HTGNa6uAe7w+Dfmw/9dDeb1ZA19ComYuXgl3iY=; b=F3LjIBenjGDuSCgDJmBo7pn6GaUYs9EQkiX4yU5SpfbHBNIw2K6t32ynD8sXIEGipo WXh8KU5f8laGvFrnWjwQyvVb5cWCnuXgNl1th37QEim1rfmstwPxphFzjoerfvGUM3CS irF5YW72TjiPqykxwTiYjFhDySh7W97q5a3pqkDPAnNTDEUc597ibrfyRimwNOMhCXCl 3vqLspcUSclwawR4Knqmb/65TrZjegee0DYmnM14gY+0jPIUBXPTv45yCqKSWpB+shPL LKucUaQQTze87/U65wPeEQVX4O4BCZPzAoay5PJcbyUyua6VSLrEz+09cfclikKibjtK uIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680908843; x=1683500843; 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=XMG14HTGNa6uAe7w+Dfmw/9dDeb1ZA19ComYuXgl3iY=; b=lhNuhMU6Yv0GGWcdbbRcNypAWzT7vh3t3A1VlURfuK3POHYbM3/tRAbxz9A+H/5aNQ M1WCWEbxZ762jO33ZkuNHbxquUYoVr4SKJMGEAEODg/vQZwqYXqNl9gjV2m6E4DxWKCT vt/MCK0ruW7yR9pOWMVv/NrUyOytgxEHH3pFIL3ql4Xjdz0OPt4TsyLxbiFewRZFqy4T UmkUjwggd6PAdTwfrSJvRb8rcL8r2op/PL8fQZJ6Pr3GKGJm+rkJ0jFjSRU4rmCneOWy +hZpzmE9X1hVXUAhcsY5Y8Q+gIPl/CvB3gINLWR1TffayUQ+ltvPIlH7xNPZH8K3H4gE gs+Q== X-Gm-Message-State: AAQBX9efFOzyVmKTVFXAOC9igymJMevTFMojzd0VRCyIRcC9q8YgVRDg wlBpAon9i/SY2d5BoYh+fj6NYp2tkkG6l2BA7b4= X-Google-Smtp-Source: AKy350bgYZ9YwPpLRk3rZJIB+dQx46041gnD56rT2aGNIGSF3KGG9r0P5jtCzIiUoHWO3mKDqOlDkw== X-Received: by 2002:a17:90a:e7c3:b0:233:f786:35ca with SMTP id kb3-20020a17090ae7c300b00233f78635camr418372pjb.35.1680908843694; Fri, 07 Apr 2023 16:07:23 -0700 (PDT) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id ei7-20020a17090ae54700b00240ab3c5f66sm3224691pjb.29.2023.04.07.16.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 16:07:23 -0700 (PDT) From: Evan Green To: libc-alpha@sourceware.org Cc: vineetg@rivosinc.com, palmer@rivosinc.com, slewis@rivosinc.com, Evan Green Subject: [PATCH v3 2/3] riscv: Add hwprobe vdso call support Date: Fri, 7 Apr 2023 16:07:09 -0700 Message-Id: <20230407230711.2621614-3-evan@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230407230711.2621614-1-evan@rivosinc.com> References: <20230407230711.2621614-1-evan@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 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+incoming=patchwork.ozlabs.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 --- 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 | 5 +++-- sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c index 68fa8de641..3fc558afdd 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 e9023e2fba..6bf28f574b 100644 --- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c +++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c @@ -20,11 +20,12 @@ #include #include #include +#include int __riscv_hwprobe (struct riscv_hwprobe *pairs, size_t pair_count, size_t cpu_count, unsigned long *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 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