From patchwork Wed Feb 14 14:31:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 1898962 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=W9X01W48; 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 4TZgfh1cfjz23hM for ; Thu, 15 Feb 2024 01:33:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 26D10385E458 for ; Wed, 14 Feb 2024 14:33:30 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 6386D385E457 for ; Wed, 14 Feb 2024 14:32:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6386D385E457 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 6386D385E457 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707921172; cv=none; b=WK3L3YGsaSBaU/aPzZ0hq9HZJw++O/n4SoiahCXpdyhqUo+94EqVrEisDUJId2rH8ryLtWGZ0Lf+rUf9LjePHBXCLtNZFauTpV+nemUNwL+535DTPuN9bNCKZ6uuuLMg9r80Gs/Axo7ljSziu6Ep1YwiwK5yWnvEtjMXK1sK6qc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707921172; c=relaxed/simple; bh=mB2uCA7GFf8IcHf8n94d1wmGmYoiXZHMQQ84vEGbFaw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hl4qZRbNCQcNc8p0+SbHmaW5Z4geM402ubcoQCUWok6UC4NJw/lEGNtlmryAGQHprgQRDo47lVrou8baB6TNxNJLwJuMaTM+JnZsLOaT285L5u4mpAcYTzrFaS16B8zcPypnXyRtIHHR+v50hHx4lTbbgpkm0tVQzXP1if/WDEM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e09ea155c5so3168725b3a.2 for ; Wed, 14 Feb 2024 06:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1707921168; x=1708525968; 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=W9X01W48t0p+zZWLEXu4bglEoR8+zGAbcT5xoGqdjznLhnAb8WBv/b0KQ98ZaAIIs4 zBzDMI/Y3OQfqFsv3EHB+sxyegEeWM2xpIXNZwgesFXIRpjOOhtJ+VFyGpSNY+60C6og n/43KC1oD10rNuS3qnYMbkjNPf5tJxyNZAxSY5oTUmKH+HuYwXxiyyYp+XMsJFWdkOEc d0A02sePPcOnUpwqPpwlDsXMtavu0KTCPnvbL7TeGff+OyMQ5vPVqXMCvwsFrIulAFUn xMB2nWJugMpXsJXmMMwW0MnI/sLeVe6dERzTzFkOLIlFAigA92tnw3/NbABXcLeKYUiC qlxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707921168; x=1708525968; 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=UocbnzxW/WJneuN07oPuWmlQlDmB/561302xVOrhNJPpAR9vF8vr5s4wqD/UopVGPr B75Cz2Q2VY8dFprksYrjWk6nBqUoQcxHI9QbwLt9WvlE2YfW51Kn8/xJuJMjl7M1PRZo EIE/QNju07U9H65j8E/jzff/B+/mV593zOSZ9Cj/UfhSQ31hvws5hU0P7nl0A39Y/mth 7yN6VjxvgToLbVB6ekMUUAYob+B1601YVMKaz2z2DAHnPm42kwXg7jazbX2BAzwb4CwK Xc6wLDtEBE0E+e0vCE5Pf5cghdINy1wLfWSYPcJaFeYi+X/4NsKsgBRtJ8iDiF+sZQrE 1izw== X-Gm-Message-State: AOJu0Yy6ql8vudjylVmajDbWVvKoi6wKBeMN8VSyn5bu3WUAblBWTiDM 2HKdAaIqhKVPOpgY9meL0JKjYwvM0nj737HHjZe3CiZjMy5XZ4aLuR20Z1rRzLxe/yaLB9rvtHN L X-Google-Smtp-Source: AGHT+IHU6rrsIGYd99HnaAnpuRpCsC/Vt0/hBA1GijcibnbqNv+p9tOkpR2JGzMH2KNXa2eeedyIrQ== X-Received: by 2002:a05:6a20:9f45:b0:19e:a1b5:e765 with SMTP id ml5-20020a056a209f4500b0019ea1b5e765mr3336116pzb.9.1707921168476; Wed, 14 Feb 2024 06:32:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXi062y4h3p8j/LPpb3BpJzFxgWi1BX2WpouLlzGDobMtY4nxYLNLn7gFFtMWbMFYQPT+ZpVLsQTHuCC3VPqPJRKzQMjazN1lWyeQXiFFF8/otES0C2ILGsnMXrPUJGMC9S1FOMPwTekyL4IVYmWLZBwjizVRT3siUqDSoCJ70V Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id k21-20020a635a55000000b005dc98d9114bsm1140255pgm.43.2024.02.14.06.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:32:48 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: vineetg@rivosinc.com, Florian Weimer , slewis@rivosinc.com, palmer@rivosinc.com, Evan Green Subject: [PATCH v12 3/7] riscv: Add hwprobe vdso call support Date: Wed, 14 Feb 2024 06:31:54 -0800 Message-Id: <20240214143159.2951158-4-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214143159.2951158-1-evan@rivosinc.com> References: <20240214143159.2951158-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+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 --- (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