From nobody Fri Apr 26 05:13:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565736924; cv=none; d=zoho.com; s=zohoarc; b=dwYazm2wSKclspY+HT54DyGTK3Dgn7g6otMt/nxUY0UKSuUxcsgvfZmNh2LaG2H8x4yiWkZnadK4nbwElt6rTTOIHzkmQZjBTm+v7XS6Z+zWgzXEbG4HoQmPHGkgchi20l7TaJKibrCptK3W+rU2soBd6/24b91DskLLqX4BEQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565736924; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=9hzQDp4ZaD0ACnDOE3HEeTilvKbeiwOSKUnAotgimJQ=; b=By5HxbENi0NlBnkqD+ArCyHNKGTNC+WlNUntoR/fXx3EH+BWwwBjD6ypHAxKI4BdocCjK7HhR1/Obm8DA1gXmHC0mYJa802XLeSy5J96dhO0B/gdpRhnuh28gaYf0pvi457UL0abapspOUDXDgd4+7GKYW0M+k6LkoFLhbEDbz0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565736924557813.3281381117295; Tue, 13 Aug 2019 15:55:24 -0700 (PDT) Received: from localhost ([::1]:56030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxfhL-0006iL-KK for importer@patchew.org; Tue, 13 Aug 2019 18:55:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56723) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxfgl-0005te-Dp for qemu-devel@nongnu.org; Tue, 13 Aug 2019 18:54:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxfgk-0006UT-Gx for qemu-devel@nongnu.org; Tue, 13 Aug 2019 18:54:47 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxfgk-0006UB-CZ for qemu-devel@nongnu.org; Tue, 13 Aug 2019 18:54:46 -0400 Received: by mail-pf1-f195.google.com with SMTP id p184so52431713pfp.7 for ; Tue, 13 Aug 2019 15:54:46 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id w10sm3258290pjv.23.2019.08.13.15.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2019 15:54:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:mime-version :content-transfer-encoding:cc:from:to; bh=9hzQDp4ZaD0ACnDOE3HEeTilvKbeiwOSKUnAotgimJQ=; b=udk6OMbyR0RLczvNKY2UdOoEsEyFyR0rHI4t/d3/qaZEI/ulcLeZzthuGm9fY107ah 75wCTVXAeq2xHiT3iFuoOyWzSaGHeNtz94QTfijGyQ0R3BZwmjrBDkwuZEEjvoc9SqP3 abp4aMzyIaFXdgv9bNTyCkdjAsxWnOJGMHLX0KLiqZLu3ZA0zeVTHvw0l0NIMQ1VF5AH mGvvrwJTwc+BJP7NQYAlP1WqCnIjjTLRX7sb5PD6uuG+MvO+FUN2m9UhrDl751yVmSQm sLW95LjAnlr3WDm4QdLKtBD4WMjzulHH27ffrPvZA3sIM5B+UjUc3QSURHt+NP0sBliO JwCQ== X-Gm-Message-State: APjAAAWb/2NH5i/UrI6INvhYFeun3f4Rh7pcbIoRZkfGc8z/DQsaSj8J LwRukEPk7Qc93Qaa/UzWu4y5WgWNhRo= X-Google-Smtp-Source: APXvYqxotfhbhfvjziG8ocdUpOtNFpDWKhIFFk8kTQRMLIb+3/PvuqOYJpTIBqfPScCSSuomLZXqUw== X-Received: by 2002:a63:e70f:: with SMTP id b15mr36374923pgi.152.1565736884691; Tue, 13 Aug 2019 15:54:44 -0700 (PDT) Date: Tue, 13 Aug 2019 15:53:07 -0700 Message-Id: <20190813225307.5792-1-palmer@sifive.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Palmer Dabbelt To: Alistair Francis , qemu-riscv@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.210.195 Subject: [Qemu-devel] [PATCH v2] RISC-V: Ignore the S and U letters when formatting ISA strings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Palmer Dabbelt , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The ISA strings we're providing from QEMU aren't actually legal RISC-V ISA strings, as both S and U cannot exist as single-letter extensions and must instead be multi-letter strings. We're still using the ISA strings inside QEMU to track the availiable extensions, so this patch just strips out the S and U extensions when formatting ISA strings. This boots Linux on top of 4.1-rc3, which no longer has the U extension in /proc/cpuinfo. Signed-off-by: Palmer Dabbelt Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f8d07bd20ad7..a67c54c738ba 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -501,7 +501,23 @@ char *riscv_isa_string(RISCVCPU *cpu) char *p =3D isa_str + snprintf(isa_str, maxlen, "rv%d", TARGET_LONG_BI= TS); for (i =3D 0; i < sizeof(riscv_exts); i++) { if (cpu->env.misa & RV(riscv_exts[i])) { - *p++ =3D qemu_tolower(riscv_exts[i]); + char lower =3D qemu_tolower(riscv_exts[i]); + switch (lower) { + case 's': + case 'u': + /* + * The 's' and 'u' letters shouldn't show up in ISA strings as + * they're not extensions, but they should show up in MISA. + * Since we use these letters interally as a pseudo ISA string + * to set MISA it's easier to just strip them out when + * formatting the ISA string. + */ + break; + + default: + *p++ =3D lower; + break; + } } } *p =3D '\0'; --=20 2.21.0