From patchwork Thu Nov 30 18:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 81047 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 1392B385C335 for ; Thu, 30 Nov 2023 18:33:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 23D3A385C41D for ; Thu, 30 Nov 2023 18:32:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23D3A385C41D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 23D3A385C41D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701369174; cv=none; b=xKynnQ72ZpcNsf2lhz54f9+yeSkIrf1ADM+lpVq4QOvI7/ySB7pTh8j1C1Q1YdrqxEWy3Q1nNaCahClpbEGeE4cfKtcJNTEZSBiSVNdY2uNuUU+3u5DAHvhuBqgNvO9EfNKf6CN84/EGC2ZR58zON9b0qay4StHDrHF/g/b2DuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701369174; c=relaxed/simple; bh=2CQCiFKGehRU5q8X4tM1luxvwAjjrXZaL8ntousGfWM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=b5Y3PESdI51GnY4e2B5595nT5BAyNGcva+SsmTUOrU/6zFOBHtLzw/bOCoVVJYw4PfZyivLRg3Xlsb/mpW5imaim6gbZ0rybm2oARHhA83fekIG2/Z7TiPph2+h6MnQahf/z+rCrdcL+29hS7A7P3Us3rnt9GkJwKbF2kBDz8gE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6cb55001124so1900438b3a.0 for ; Thu, 30 Nov 2023 10:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701369171; x=1701973971; 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=ozQO+ldTHzYe0vXloMlnMeBIeDOhk27GhgJradnIY9WKah9O9aEWac5Y5MXLEAQzqq EIf0vYG+4XsinmB9uCna00izo0XBFrquWgCk/3WCNHQsfkEjW7pzId1Y8pesd5r+W8PP FO4wIL5iucxvztCUYPiXA4+xO7VCITNxfxbReuRaDwLZwZTd4CP+cMckABOpUCazEy9r dMo06aMg9HvU5rCPVCUr3sNTrNRaIpiBELTkEfGBD/g3adJaIXjBoM1s5koV98+eAMxa 0YoH0dSkgcQ4OFJhUzw67+WRCVdBOro38TKGYxUIymC/seJlHsoDV3BYLsKtMWk1wNZ0 roow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701369171; x=1701973971; 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=RWr02N9jCQcHJGDSYHX1RF4OPiZZUY4gw9bpwPp60066SOmEpqjtvvRVWUY/CGZ7tN UvGwAUnGOERbe6UIVwqbUa2bY5JUj9z1rLeu7prR96jDkn1MOS6QcVZgS+NYL1VZEfHN 1HgM5zNnx/6h90ZP141vewqOw9aLlIVkiyg+GnrUOVkiFYVw+d7pVwTRqVAJPWMJ2b0Q bNG6kd2KJ6+lO4w7xFUclejGcVU+5/KfQZcOy5KpRuFWL/eHreHSFW5rKXbtD3cOnc5N ZfAxl8os7s3DOcsSBULkhn/eLEX3NG0xvO63uvrWa4BoiL9k8N/XPtNzrfAGE8Uh+Gqc VUmA== X-Gm-Message-State: AOJu0YzsuJZtfsavNC9CT8axi/br3H7P1W7Glg7j8niPXN6G4aaeih9H xcoe4IIft0srT8lv+PZGaki5DDoFqgR464kEfXw= X-Google-Smtp-Source: AGHT+IFxkwEqnPAsuhpZqfxqX/w2icAX9foOUC9ykZhSNUYaMPAVZy5dXUzrwGP9FfkYPoogd6llrg== X-Received: by 2002:a05:6a20:4401:b0:18a:d4ea:1678 with SMTP id ce1-20020a056a20440100b0018ad4ea1678mr33741954pzb.15.1701369171182; Thu, 30 Nov 2023 10:32:51 -0800 (PST) Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id p3-20020a62ab03000000b0068fd026b496sm1512939pff.46.2023.11.30.10.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 10:32:50 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: Florian Weimer , palmer@rivosinc.com, vineetg@rivosinc.com, slewis@rivosinc.com, Evan Green Subject: [PATCH v9 2/6] riscv: Add hwprobe vdso call support Date: Thu, 30 Nov 2023 10:32:35 -0800 Message-Id: <20231130183239.598100-3-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130183239.598100-1-evan@rivosinc.com> References: <20231130183239.598100-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.30 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 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