Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6679070ybi; Wed, 31 Jul 2019 19:20:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfuHAfFyx1b6tSSOQRWfJipMv/Ba6prPMx+HihPT+kpuECG7ihRUUlz1GOW1BA4VElfHwN X-Received: by 2002:a63:29c4:: with SMTP id p187mr65225458pgp.330.1564626020474; Wed, 31 Jul 2019 19:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564626020; cv=none; d=google.com; s=arc-20160816; b=qMczcLn8PUoczSHqvIQcodHBZrzunUgv/FVMls4T8hcN7x1wYolJKqef8dVdDT+MFG PgUF0FkNBDzKa7+OABSMrLnUSjklgv2PvyAkvnxV8NmnYGxWcZliNyNwNI2wGdM2inxa TwuEFnIOgZJO5TmVfx9ZDkHFpgLmJ32pCRE0ohkC92uPJmABLb49yGGFhk72cLK+AW4p QKHBMIlxxUo+++nJG2ON8o3sbtNsM8dUIalJ/+sHCS9HWwsFo8DoIeHN7tjZ+7/elsj3 lCALvO8kLV7RRniTTctWRszCZZyzvvGaOuJjro2T4KMaXsQb64MnMRH9D0wjPDIIPNOY NejA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr:ironport-sdr:dkim-signature; bh=Qc91V627WXBfZC7DDP1F5mIq96z4qVswWLYGaIP73D0=; b=uHTR8We+9oIR1j9hhLjpbsIESTEM88BGtCeNIxA+INIljuDiroZXjRquhZRgFh1B5j Prlq3LJpv6THQ5/IpiwyiDXD6U1SYOLmMZ1YqMRkAyyN/WAzLmBDdfY2BUerAoVOegYC HJiGqvkOqyLv0d/srMzXbQ9pLahhb6e5f1BgRI+Z/4pnVHdr+HtJ/MRw4o/ptmAwdYrA euyTBBxgbjKw0FjbrGckhiIFS/SseoH4vp/yta143uW12J1FBwmM2YBVk0aUD7g8elPP 55Dxs3aYnYgzV519PvolWzQ2rNdBovw+ZGAIfQ4W4pVj0xpRE0saTF7sCv6Yl+NOGyiP rkFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=jXMGTNLn; 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 s62si2741386pjc.75.2019.07.31.19.20.05; Wed, 31 Jul 2019 19:20:20 -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=jXMGTNLn; 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 S1728544AbfHAA6l (ORCPT + 99 others); Wed, 31 Jul 2019 20:58:41 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:61763 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbfHAA6j (ORCPT ); Wed, 31 Jul 2019 20:58:39 -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=1564621120; x=1596157120; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+zY9hAEVm58gSXJfAJQWINzIbb639f01AsOcw7UEO4w=; b=jXMGTNLn+NPfbHeKgEns6pGPNR2TumrTXoO3L2v2cyTMQyyWY3dM5f7a hHe2KAGgq0kpSCsbsmDMIVcezxFWInjGmh3Dp31t/pn+VPHXTTSamIbu6 mCP0i9/egnf3ht+x6pfPi02c0L6YOLRv4rINaGDSFAhKpaPOICPF7ymH2 Cz0UipjxCBTWg1Psf0UfhBOPaiEMKTC/DEHZWejIZx0YqgbpiRPEIwUY7 KG4OWCtITdxz4RZQtKO7BwazXGb93Ps6IfF6OD0jlkiT60IcmPn65VZbj 5MS/8ZGW0y2zdd3rma9B6hJ8eiVVrxAv2xOd8D4h85FHmmkPjTpMXRoEj w==; IronPort-SDR: 8Xte4gZn8SizZ51vGiL2gS9nCy3RGWwGUXAwbsfSWKUPkSRZR+BEXWeIeQV/rNbg+Y5WBafBCd xUwXSddt+ywP2SpQHVTsj5ErI1lUFvGM+6oKtTxl+J/BYsiOOb1hEA84iC2su0676KyBNp/aRQ mlBZ+0VJK1GoKBzJnsaLevthB83J5XWDu7/vY5Ski3c2y74fIK7kEHEuvkwJFlMVU15wS0ozbD dMvmtEfP1x6j5zrod7acW7tVTkjomFs57YZS9x8cPV+VbvMfEAQd1hf6aH8d2h4rLuQ92TCc++ yfU= X-IronPort-AV: E=Sophos;i="5.64,332,1559491200"; d="scan'208";a="116247214" 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; 01 Aug 2019 08:58:40 +0800 IronPort-SDR: J+ZG+bRmNQpySioU3qugfOU6n7N6Lgb/umSfSmC9EzbKPztV7oGqPrbmRIb8Xj5OdsmG+ZNmdQ 5dRUTZt9Y78htchK4Vw0XlIgzZPMYJClinQPoANQ012otwxfNwWn0173fFYpLRxg+4OXCp1Uvw 5guuSoB/sPjexN4bYtNmcJcmGLYONFXkFwxF3wrgvZgEyHqtEK4/709aJa0QrqwGijuXcG4kFR iDGX8dV3yrLJv0WJDaB1iZblhY/rl0U4ruGN7aHdBr+fztifGPILEgzG0RxXz+8Hb6K0g8uS21 aCZWXjxdchSrZNrCCfDwoWYB 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; 31 Jul 2019 17:56:39 -0700 IronPort-SDR: WfNKScKCSJLOm+bwKSqkTZLs6UXGdvplnSR2K1aC1Owz28W0cyBACGtINOxzf6kNaFOakw5sU7 Jcht1d31lDGLyK+JEgOCCYQAOTkV34oz7QFcR85kYxv0LpE+vY8D/faTuV7lk2cA0SBtM5ZY7V 35dWVcunseKb27my3S42oddaIwPm2914UrNA4j2jDFOsOE/cYvnXWvVGcuK/0iIVu8SNzuF9IV 0SVjuBKV/swMjN+zDDrglszNuSuNk6LZ0vy5zlyoOX7QqD7Hd1PnpSBCueejD8PO/yAl7ZJIkt Aww= 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; 31 Jul 2019 17:58:38 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Allison Randal , Anup Patel , Daniel Lezcano , devicetree@vger.kernel.org, Enrico Weigelt , Gary Guo , Greg Kroah-Hartman , Johan Hovold , linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Rob Herring , Thomas Gleixner , Yangtao Li Subject: [PATCH v3 3/5] RISC-V: Fix unsupported isa string info. Date: Wed, 31 Jul 2019 17:58:41 -0700 Message-Id: <20190801005843.10343-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801005843.10343-1-atish.patra@wdc.com> References: <20190801005843.10343-1-atish.patra@wdc.com> 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. This is not entirely correct as Linux can boot with "f or d" extensions if kernel is configured accordingly. Moreover, it will continue to print the info string for future extensions such as hypervisor as well which is misleading. /proc/cpuinfo also doesn't print any other extensions except "mafdcsu". Make 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 (except 'S') are printed via /proc/cpuinfo always. Signed-off-by: Atish Patra --- arch/riscv/kernel/cpu.c | 47 ++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 7da3c6a93abd..9b1d4550fbe6 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 = "mafdcsu"; 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,50 @@ 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 + * RISC-V ISA strings define an order, so we only print all the * extension bits when they're in order. Hide the supervisor (S) * extension from userspace as it's not accessible from there. + * 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]) { + for (e = mandatory_ext; *e != '\0'; ++e) { + if (isa[0] != e[0]) { +#if defined(CONFIG_ISA_RISCV_C) + if (isa[0] == 'c') + continue; +#endif +#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') { if (isa[0] != 's') 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 +161,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