From patchwork Tue Feb 27 22:56:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 86489 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 4F0433858293 for ; Tue, 27 Feb 2024 22:58:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id DC0643858402 for ; Tue, 27 Feb 2024 22:57:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC0643858402 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 DC0643858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709074623; cv=none; b=GVHDeyB6PFbn/5Aq3CmOrDxKMoybi+PDRZe8ozNWo4zCX0lLCwzgZV3eF1lkwxr+wulecMtDlGn8ob/N69CRE+nJywv+G+ZmmKFW7NB7c/UVKQ4yJq76MvLhuc/9byS+80DSPWYfY8PxRJtkNcK6bqYZ3pYidiRYQZ4f2371XN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709074623; c=relaxed/simple; bh=mB2uCA7GFf8IcHf8n94d1wmGmYoiXZHMQQ84vEGbFaw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rOrQmDnO0VuWp8tUuNiV6Ku5Jp0j174Px6OrDbTSxowRdynsoiusoFQXJ4RyfSXlmkK2mH1Tk2jIciRVaUqgBFYaZFNCcMhak5rZNUjzPYD0GKpJt+QXIjYKKMtmM7tuotr2gHPmldLt+6urJQzOIG3cTyeDc/dbXNCsFuEsH7E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d7232dcb3eso35157385ad.2 for ; Tue, 27 Feb 2024 14:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709074620; x=1709679420; 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=N3idKZzOv0gJ2EL0bSki58RkN41BRlAo5gY4kORw7kQ=; b=NALCA1jSCFaoSDhB6/NA7kiQ+kKAun/UnyCcUT2+PoseHuoFn4iKp2S3Ou6ysR6v3U 7WHKMAr0LNzL5oudgJqV6bvxPxoV8oaE7mzKwADnWnA/g0E9x+BsBQFDfhNGDlbsRrFn Qja4EApUPXi/db3MITCcAGBixli4Kpk41Bgp6jE1rxxos9VOdpr/GjumMS3MFZx05Z/u jFeWGew/RKEYn70mCdMvJCTEsrBrJCarDYbdgNj5tTrEzQRCbNpJsATJSTKcKvV9QXHW eI6YL/Z+8swigqaz/Enpr0sZfT4x8e5WOhgs1SEpiRi+1CY7SDzfQLa5QkDvgcrlw/gN yhew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709074620; x=1709679420; 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=N3idKZzOv0gJ2EL0bSki58RkN41BRlAo5gY4kORw7kQ=; b=ouM10hXpFZy0jAu3pPHClfwb9kZ5bNGUqLQW589ALoAkfSQCig4CLye7EjsxgIr07f 7mkgjPCSo6WrAULb8EX8DQHCkIjJvrj+dXSEaIoQ6ckxDJlGeKJNNLkUJRLXkjq+h2Xt A3Y4gI9BX7nnKX8mjo5K51pZstbcUMPTQbTC6DA6HIZrT7Da2tX010K5Ch1SJj+ILsji mLzKvJAcswU4Cn2b6mtE9PO2hV1wRcCNN3VpL8TIN/wzYfk70BHsfH4EsEQPOObHet+9 0FrJ77gWmkuwXMYR/uUkwj5zzAQd3i9kynsCmuLioh/kHVDrHzzc8c2n2qJ+Y4jlOSQw UmEg== X-Gm-Message-State: AOJu0YyWZxmkUppNiL0Dved95Wis2GcRfCTg0ED8W8lkYAIrSIDcYF6k 9s3EzvOoY002rGTl197Mt3siNBzHJPI6s5L0fRmx0RltvBRZjFD8YRR5drSse45unZ5tc6joAXq x X-Google-Smtp-Source: AGHT+IHvj6ig/+mstIgH7vuuQ5qLRAum+4g5nNMQ76w4saDpwbQ4YnVW/eMY1L0fs92/JrEqoLzU5A== X-Received: by 2002:a17:903:22cb:b0:1dc:4a90:b87d with SMTP id y11-20020a17090322cb00b001dc4a90b87dmr12431954plg.66.1709074620006; Tue, 27 Feb 2024 14:57:00 -0800 (PST) Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id li3-20020a170903294300b001dc90ac1cecsm2029225plb.284.2024.02.27.14.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 14:56:59 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: vineetg@rivosinc.com, slewis@rivosinc.com, Florian Weimer , palmer@rivosinc.com, Evan Green Subject: [PATCH v13 3/7] riscv: Add hwprobe vdso call support Date: Tue, 27 Feb 2024 14:56:39 -0800 Message-Id: <20240227225644.724901-4-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227225644.724901-1-evan@rivosinc.com> References: <20240227225644.724901-1-evan@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 --- (no changes since v10) 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 5dd7ed9d12..3a44944dbb 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 e87d886940..8aee5a8212 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 28a448175b..e64c159eb3 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