Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5861023ybh; Wed, 7 Aug 2019 12:42:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdt3A9W+LdN0TyfmPUMQigLpfzwgy78G2nrN9yAqnyaEq0h1tMzKY6lkvpqwRSSTMmN+If X-Received: by 2002:a17:90a:3ae8:: with SMTP id b95mr81963pjc.68.1565206956484; Wed, 07 Aug 2019 12:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565206956; cv=none; d=google.com; s=arc-20160816; b=0Fq8tsqqjg1L/SPOpAW0h6E3zQPQ6BoxwfVQKisTgf2GEP7lIbI3ZtxB5pCXe+YOvp L3J8Qgfm9CISHUvM6P/Nk0626HuSDfFov1nLUnfk6H5wKRmQZhb5hcRMPvy5Gr2H0PWz mnOlzFudtxhHds1Falu16TC3aKlZ4TwQ7YuWNO3z0Bc8Jt54byALkl9Z43cZO8aLxLzs whm6Dnq+/V7pHzigcwnW+WR6UMxsZjoDgjwnHiYUUOnPYUEQfj2/QshohB42bQc8xMn5 UxNN6U5g8wI7MBetY/0Gs+MXMehNZCy/lQSh40V3PsF88loBkzthzdzlso/7kSnPG5RE 65Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr :ironport-sdr:dkim-signature; bh=Ow6fDIKq+IloLD0fr+aiLO3eiGg+H6wlDkAqxT2zzgU=; b=xgCqkGGnT7P4Y9XwUv5AelQ2dfkEZyX+LZhJ46PNX8kz9L03HxJNB/O0f3ucBuYZm4 We8QPYddUwCOi8EZAO+btMpS08/Fc1qlscGkDnbvBWHAE0bTCMPMVd5es2UXvAr1mW/U NI1cTJJMpPE0se84dYBsRZOB6jnlEK9XnucDu0LtZ3bsUi7pojfeiNyDm9gxY2fajHfb +TWSGbqMfZl9rvutFHymKkUeFBzgTCFglgA9s2sx4s5BHm1crsZVENHAcrMNhKRNBvKQ PDYqHn5cPzDzKJ/WNKe3DW3dNKLHockFoUeTTl8/vtHFWW1Pb3cHpVZlZ7RMqtTjhl4N D16g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Un+cInh5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si49775360pgq.392.2019.08.07.12.42.21; Wed, 07 Aug 2019 12:42:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Un+cInh5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389324AbfHGSXh (ORCPT + 99 others); Wed, 7 Aug 2019 14:23:37 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:6617 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388163AbfHGSXh (ORCPT ); Wed, 7 Aug 2019 14:23:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1565202217; x=1596738217; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ICuPazclqjqPUmwAWo1Qq1t08V25XRdrKY9dRhoRIRo=; b=Un+cInh5H79gsRgn+7NFC9Bed/E11Kqd2PVy3Hy+5pBZ23I4asgEQu5/ ObsbJAtJwkEUw6IoCPDz6xhoaTydoDquWSXnIR4gwSwf/lP0sZyj/PdO7 fVTy4SNYtzXoMeC3IP7up4QO1VCEDa9BzwtIT8KNc25wgQwgwamx2DCof t2I/gccxB6fzFyKOb6v6kLj2qSrys5njqVtTmxDFAFnQgTKVnsm06SHbv c5cT02ySMvL76iOMJaLR/7Zkg2VcTTtWxpSWZvIioI5nG4og5LHCQsX/S t/LIcbTCbhGh/5uP8eiEE4rpeSN2RTj8EwPl2/Xe788cP5lICATGy0cVy w==; IronPort-SDR: DYtuRhsdf4NU9TifiHiNvAh2H4jw7bR3j5k0mNX6LlRcIlo66MIxC0gXyykCSqZtTRw+tEmkRl 97bWKuzFhir/4PzWj0YBNBaDq9/5K+yJ7movZL8M6drAqBW5jRUXloCK+//3sx3KUb9NSktv2q 36hemDDrCYYr/Neviq6wjQCF7M1hFqNQoP5VuSeDQIqIngujAfe0vmqKhUK4NpaD4L7YhVh9M2 fd+UxnNxVNNoyISeld32k0aDDYkkEnuaVnpSTG0slH6Y9O1wEEVcgY3QP2ekx38Xu3hvHJy5uu axo= X-IronPort-AV: E=Sophos;i="5.64,358,1559491200"; d="scan'208";a="221758072" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 08 Aug 2019 02:23:34 +0800 IronPort-SDR: maTJYxjmdhKQiijJ18PfkMaWkwjQR0SwLEHHEcHwVY+VHoEfy5RgRWtEJ6Uhy6kP04q14qkODu gdGlPkbM7XI8Xf+wo/UGjJgSaK2NkAqVztzn3ypdAFAemD4SPqPBzVYo7g8LNgKJZncZkGiQtG nUjdfkqPWjGOrVR9YJhuPjz5u3ljLuSqllGWEdo6ZkWL8vbc+HKrpQA1PYKDQcVbOykn7ytxFb ULLNP8rWQpoH5l/bh8iKzHJAmHdXsyGGhtUxUTfe2kxG1oqG7Gzc0Ky7vqBWWkW+lRlTI5tbfw oo19FgKTIKcGUwoBwycRRhzm Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 11:21:22 -0700 IronPort-SDR: kWXPYgAEnldKXrFkOQTNQqEhek82VjyuPfGLPZPYbZfci9wBXghJ3SstPS9IxHLBac3X5tuGV7 ykSeVxDp9buS6mdP5V2BkKYHUcMzvedf2EssHjtOxqBoDAwubtjHQPifuIZnST7hXZylOrigjF sCoIiMmX2OtkIpSTV7Jo0fLlA+NmZILpYlVMI1E0ozmsB9C9WET442pNBr2BQeww2hoVFsfnIQ RXqSJ8k4A0kvLTOBj7Kc9K1tKEpOZDzYUDpj7QZsSV/qTVgHLVb5uXzQbU8dL/m8X6msL3GMve yMw= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 07 Aug 2019 11:23:35 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Anup Patel , Johan Hovold , linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley Subject: [v5 PATCH] RISC-V: Fix unsupported isa string info. Date: Wed, 7 Aug 2019 11:23:16 -0700 Message-Id: <20190807182316.28013-1-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, kernel prints a info warning if any of the extensions from "mafdcsu" is missing in device tree. Here are few issues with this approach. 1. It is not entirely correct as Linux can boot with "f or d" extensions if kernel is configured accordingly. 2. It will continue to print the info string for future extensions such as hypervisor as well which is completely misleading. 3. As per the RISC-V user level specification, S extension can not exist in single letter extensions and must use multi-letter strings. There are no U extension defined at all. 4. /proc/cpuinfo also doesn't print any other extensions except "mafdcsu". Fix this by making sure that info log is only printed only if kernel is configured to have any mandatory extensions but device tree doesn't describe it. All the extensions present in device tree and follow the order described in the RISC-V specification are printed via /proc/cpuinfo always. Signed-off-by: Atish Patra --- arch/riscv/kernel/cpu.c | 49 +++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 7da3c6a93abd..e521142e8ac3 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -7,6 +7,7 @@ #include #include #include +#include /* * Returns the hart ID of the given device tree node, or -ENODEV if the node @@ -46,11 +47,14 @@ int riscv_of_processor_hartid(struct device_node *node) #ifdef CONFIG_PROC_FS -static void print_isa(struct seq_file *f, const char *orig_isa) +static void print_isa(struct seq_file *f, const char *orig_isa, + unsigned long cpuid) { - static const char *ext = "mafdcsu"; + static const char *mandatory_ext = "mafdc"; const char *isa = orig_isa; const char *e; + char unsupported_isa[26] = {0}; + int index = 0; /* * Linux doesn't support rv32e or rv128i, and we only support booting @@ -70,27 +74,44 @@ static void print_isa(struct seq_file *f, const char *orig_isa) isa += 5; /* - * Check the rest of the ISA string for valid extensions, printing those - * we find. RISC-V ISA strings define an order, so we only print the - * extension bits when they're in order. Hide the supervisor (S) - * extension from userspace as it's not accessible from there. + * RISC-V ISA strings define an order, so we only print all the + * extension bits when they're in order. Throw a warning only if + * any mandatory extensions are not available and kernel is + * configured to have that mandatory extensions. */ - for (e = ext; *e != '\0'; ++e) { - if (isa[0] == e[0]) { - if (isa[0] != 's') - seq_write(f, isa, 1); - + for (e = mandatory_ext; *e != '\0'; ++e) { + if (isa[0] != e[0]) { +#if defined(CONFIG_FP) + if ((isa[0] == 'f') || (isa[0] == 'd')) + continue; +#endif + unsupported_isa[index] = e[0]; + index++; + } + /* Only write if part of isa string */ + if (isa[0] != '\0') { + seq_write(f, isa, 1); isa++; } } + if (isa[0] != '\0') { + /* Add remainging isa strings */ + for (e = isa; *e != '\0'; ++e) { +#if !defined(CONFIG_VIRTUALIZATION) + if (e[0] != 'h') +#endif + seq_write(f, e, 1); + } + } seq_puts(f, "\n"); /* * If we were given an unsupported ISA in the device tree then print * a bit of info describing what went wrong. */ - if (isa[0] != '\0') - pr_info("unsupported ISA \"%s\" in device tree\n", orig_isa); + if (unsupported_isa[0]) + pr_info("unsupported ISA extensions \"%s\" in device tree for cpu [%ld]\n", + unsupported_isa, cpuid); } static void print_mmu(struct seq_file *f, const char *mmu_type) @@ -134,7 +155,7 @@ static int c_show(struct seq_file *m, void *v) seq_printf(m, "processor\t: %lu\n", cpu_id); seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); if (!of_property_read_string(node, "riscv,isa", &isa)) - print_isa(m, isa); + print_isa(m, isa, cpu_id); if (!of_property_read_string(node, "mmu-type", &mmu)) print_mmu(m, mmu); if (!of_property_read_string(node, "compatible", &compat) -- 2.21.0