From nobody Sun May 19 22:21:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1683035121; cv=none; d=zohomail.com; s=zohoarc; b=T2O881qiL+9Wx2BUNxtK8A7eVhLBGtDYlCJQ/Iw5GX4YVmW/TCSUsv7JTInH9kT/2xKo3QqY1v1xjf2rZXpkh7U6ClVYCrfXee7rOC4dhVDdCiOlVtAaM72LVr67liCYc+5P5BPXnzTdCJAwVvr48NT8PEtFtdT/6SM63k7fJwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683035121; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lANrWLTi+XM60+2ibqZjJzSjy4xDAX2f7nYs4FCisB8=; b=eMFCIXT19sCfaM8MJP4/tg3rvPPFOqvNV21PPvK8b0l1AkDqEkTamb+qJf//Z8Bi9roroIxbtcmdFy+S2L8oIjep9cJcK7k7MZLPWuyxs5YnAXnF18+sEuf4GSuRkb5RHNpB8JVJ0CPBE5Q7k3puMQGnjkUprdf3W08RMF1EUpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683035121714458.1027431300108; Tue, 2 May 2023 06:45:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptqIb-0004MP-Ld; Tue, 02 May 2023 09:44:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptqIZ-0004Lk-Uo for qemu-devel@nongnu.org; Tue, 02 May 2023 09:44:08 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptqIX-00087u-QZ for qemu-devel@nongnu.org; Tue, 02 May 2023 09:44:07 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id BC49821D0D; Tue, 2 May 2023 13:44:00 +0000 (UTC) Received: from hawking.suse.de (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id AB1D32C141; Tue, 2 May 2023 13:44:00 +0000 (UTC) Received: by hawking.suse.de (Postfix, from userid 17005) id 884FC4A0372; Tue, 2 May 2023 15:44:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683035040; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=lANrWLTi+XM60+2ibqZjJzSjy4xDAX2f7nYs4FCisB8=; b=QJMcON/qsIb0L6LiCu0rAqNFY29lt2/GRzUKBIIcdT1iU/mq/m2SnTlVzDW7k6uToxpjQF yDr4HU23BTJCMQ6ZSUPFJ5OcIvHoJCAYA/6OEU13STJyH4jn2FYmep07lN1r11cUfJ6H8I ML5ftr9ZbNq3GUxbWLbFIFe4YZVL6Pw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683035040; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=lANrWLTi+XM60+2ibqZjJzSjy4xDAX2f7nYs4FCisB8=; b=ENrVVb9SYIEwss3evdLLDvCMtad5gq/Ni9zUCVvixoGwIVzFMGhCDXrMcBuWpspQM+1cwR 4E79h8GOSNbpznBg== From: Andreas Schwab To: Laurent Vivier Subject: [PATCH] linux-user: Add /proc/cpuinfo handler for RISC-V CC: qemu-devel@nongnu.org X-Yow: I don't believe there really IS a GAS SHORTAGE.. I think it's all just a BIG HOAX on the part of the plastic sign salesmen-- .. to sell more numbers!! Date: Tue, 02 May 2023 15:44:00 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1c; envelope-from=schwab@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1683035124006100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Andreas Schwab --- linux-user/syscall.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 69f740ff98..c72456a34b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8231,7 +8231,8 @@ void target_exception_dump(CPUArchState *env, const c= har *fmt, int code) } =20 #if HOST_BIG_ENDIAN !=3D TARGET_BIG_ENDIAN || \ - defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA) + defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA) = || \ + defined(TARGET_RISCV) static int is_proc(const char *filename, const char *entry) { return strcmp(filename, entry) =3D=3D 0; @@ -8309,6 +8310,31 @@ static int open_cpuinfo(CPUArchState *cpu_env, int f= d) } #endif =20 +#if defined(TARGET_RISCV) +static int open_cpuinfo(CPUArchState *cpu_env, int fd) +{ + int i, num_cpus; + + num_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); + for (i =3D 0; i < num_cpus; i++) { + dprintf(fd, "processor\t: %d\n", i); + dprintf(fd, "hart\t\t: %d\n", i); +#if defined(TARGET_RISCV32) + dprintf(fd, "isa\t\t: rv32imafdc\n"); + dprintf(fd, "mmu\t\t: sv32\n"); +#endif +#if defined(TARGET_RISCV64) + dprintf(fd, "isa\t\t: rv64imafdc\n"); + dprintf(fd, "mmu\t\t: sv57\n"); +#endif + dprintf(fd, "mvendorid\t: 0x0\n"); + dprintf(fd, "marchid\t\t: 0x0\n"); + dprintf(fd, "mimpid\t\t: 0x0\n\n"); + } + return 0; +} +#endif + #if defined(TARGET_M68K) static int open_hardware(CPUArchState *cpu_env, int fd) { @@ -8333,7 +8359,7 @@ static int do_openat(CPUArchState *cpu_env, int dirfd= , const char *pathname, int #if HOST_BIG_ENDIAN !=3D TARGET_BIG_ENDIAN { "/proc/net/route", open_net_route, is_proc }, #endif -#if defined(TARGET_SPARC) || defined(TARGET_HPPA) +#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || defined(TARGET_RISCV) { "/proc/cpuinfo", open_cpuinfo, is_proc }, #endif #if defined(TARGET_M68K) --=20 2.40.1 --=20 Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint =3D 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."