From patchwork Wed Dec 13 21:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 1875882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=fXzJAsCC; dkim-atps=neutral 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=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sr7Ty6q0tz23nF for ; Thu, 14 Dec 2023 08:12:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01794385C303 for ; Wed, 13 Dec 2023 21:12:21 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id E00A8385DC29 for ; Wed, 13 Dec 2023 21:12:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E00A8385DC29 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 E00A8385DC29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702501925; cv=none; b=d/vHbpDA8TWpyrZyfF4cwEi6EjC9Tz1d7tjh0LR8mx8Ne3ciJ5XVinBq41sas8v+rYTiDeJxMX6yqjfZy4IjZtg4upNTreMxORETOyK6h0LpuKMmF82QYVLlNOmD99o4nevpMqzy84v0xvSvTd0Jbq7le87B0W6uH6vPeF7stKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702501925; c=relaxed/simple; bh=si3nlXVmqsJIVSt66LWuQDsPtKZt7WHlxnFipwumVcU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fV89sPnlJnOFtsg67+n2/HC3XzDYN9JTgHO2hRbzVafdTkHRnZuo64/CN10DaFbUj9C9VtGc0bfBmoRLDEeC2fLTP25pwAOELzbOcjSuLWtxL17pYznD3Tz8ZTQ0R74qjBMK0A6ylhdByscCIKhCU7ffazoMzCuLKgWjZ+W4Nes= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-59067ccb090so4749849eaf.1 for ; Wed, 13 Dec 2023 13:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702501920; x=1703106720; 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=6R2nKdRh8JjcImBZ02Cmdtc7yAtNLzNCryFyVjwVl5A=; b=fXzJAsCCArKLc3ZUXbPx7tebb4IoWg7/DBDAz1mLP9rh0glKgU91ysIS1DACWL5JQq 4+owC/k7ZX1IbAqiY1qHsRHZFY/0l/8zpk4evNTC4/F2rJbwbpFmJ5XIy8IGUR++nwQh zYuvTXg4Hj+GXqW45/0B9bhyzj8ioFFA0pkIh6DpLmfuMnsmc69LOrD//RxKWhtvCvCd NhcOMWSsLwF18f1bx7fB77w93JSkogPlbi5JsM1nez/drJyjlI27MSI/PNUV2DbV4+qm Hf0loVE8V9Xx0x25bsy6QU51KNgTmud2kxNQ0sj9i4C8XhKbg0UXf70YhdARf6SKaqG8 RtjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702501920; x=1703106720; 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=6R2nKdRh8JjcImBZ02Cmdtc7yAtNLzNCryFyVjwVl5A=; b=UzS4wLlzfeEllzF2gTnrYtNMJSqrqDORJLNjNOtsiU2QNxZ07TCN1wEFZYPJzMlgZK 1mAfkFkVREEIsZdih9O7VCXd6bfJjfShX2aRic8OQUKE98llhp0uv+cBYb71sedxms5b LSPNzJTYIC80KqQHktVcnWHwX1E3IOKO/bX1bAmzOGe81hEWWkcfhUrnideHcC8COJV/ bEShu7rXXZNW9G7eVRZt+sSysYNiEyplOxXa+DtU+nu9IU8Z0eDG0tfTsCn1LBpyME67 xc5MjqVKDs8XZRXUNTy3Wxghw+lzAuWjHi4xnpUhNDIYOOej6Qqur1aLoFBqqSQGehEL n3Iw== X-Gm-Message-State: AOJu0YyypMrvVV3uS7VmVV4AoiRye7NNue+j7BB19tt2nwZYDhgCix0K sAqIGDUVNRj1F8UJtndfYxONGlrmqMDztteOw9o= X-Google-Smtp-Source: AGHT+IEJ5oELA25zqUNKTBco+SyWKO8pILiIxZw19MWvZDZB4HMZvQnU5PsvMuz3XdY92JghQ+VFqA== X-Received: by 2002:a4a:a9cd:0:b0:590:7041:ba13 with SMTP id h13-20020a4aa9cd000000b005907041ba13mr5305029oon.0.1702501920326; Wed, 13 Dec 2023 13:12:00 -0800 (PST) Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id c15-20020a4a380f000000b0058d1de21893sm3223109ooa.24.2023.12.13.13.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 13:12:00 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: vineetg@rivosinc.com, slewis@rivosinc.com, palmer@rivosinc.com, Florian Weimer , Evan Green Subject: [PATCH v10 3/7] riscv: Add hwprobe vdso call support Date: Wed, 13 Dec 2023 13:11:38 -0800 Message-Id: <20231213211142.1543025-4-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213211142.1543025-1-evan@rivosinc.com> References: <20231213211142.1543025-1-evan@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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+incoming=patchwork.ozlabs.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 --- Changes in v10: - Remove leading underscores in definition (Adhemerval) - Remove spurious 5 from INTERNAL_SYSCALL_CALL (Adhemerval) - Use new INTERNAL_VSYSCALL macro instead (Adhemerval) 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 | 4 ++-- sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + 4 files changed, 16 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 af84eb4a7f..441a44eafc 100644 --- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c +++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c @@ -28,8 +28,8 @@ int __riscv_hwprobe (struct riscv_hwprobe *pairs, size_t pair_count, { int r; - r = INTERNAL_SYSCALL_CALL (riscv_hwprobe, pairs, pair_count, - cpu_count, cpus, flags); + r = INTERNAL_VSYSCALL (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