Received: by 10.213.65.68 with SMTP id h4csp1318777imn; Wed, 21 Mar 2018 07:55:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELvWj91lMR/Pl/oIDqdxjXeMAgF+iRYreJ/cwGLl3iPtR0IgTb/DKSVo+xdwuWBwvGF7wn63 X-Received: by 10.98.92.194 with SMTP id q185mr16929292pfb.63.1521644105364; Wed, 21 Mar 2018 07:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521644105; cv=none; d=google.com; s=arc-20160816; b=EQPF+I7BCp4qomk+VB1oIaeFvxMEJ4alJdX1aif7dpitx54pNDCM9RuUhwv1vsOVWW Q7Ul69TG/hHsgT4mt0jDAQRp4iEPoH0iU0bCx6lNW5IT8PV5xCNVO/+bhywyEEJ/aWhF XQYqDHM51mMXiGoL0ZpzooxY2Myq0lJv9nCNnwMqYefP2eo40uO/PRYEYs1R+ZmeycmF PuEVY9wDY0Wy5uR+0NRP5Dz4oCHea6KJhl4867dnRG26YUpornwBmvsjvddH9zeTq7Or V/H5B9ImRXliWzW2Un6hcFNYKWJjixEdCCfCE1ENtCcOVb5iKXzQz9xnbp2fRqP2szq0 d63A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature:arc-authentication-results; bh=p+WYh4nd4uWSP6vmuQ3HNDEbe3VQXFp724VO03wmSv8=; b=wqpnVFJJ8Oyv3m0kv//1xpiGP5CEExHihuPK5Lw6QhhHFrontAnQpJGxEYYfeTNt/R WAtSL10bFXygb1w9AzIumynHEEewo9XzI3hHNJladqP9J96ZWOwyggaeyVMoiUhQoIq0 EbfIgHR7D30ZnHcm9QJsbQwFDF2xDAgWSwTeFUpyKy+s5Hi2SaHLVcj8TPBf7N0BWOmm I2q/1RiOp1Rd+DD4Xdzi+36iLRsDYOTKwLFKTD67/Qe9USTLVAl9fUbHufdotLtdDkJr VuHM3uUEqMOMJLxACbbaC87OuNscyUOv8OGNJ6HUstlLxmywjyFLg27kx0c4q3PYPdt0 Eexw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=Np0+8DGS; dkim=pass header.i=@flygoat.com header.s=mail header.b=nkW0PiM/; 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=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8-v6si4473064plk.550.2018.03.21.07.54.51; Wed, 21 Mar 2018 07:55:05 -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=pass header.i=@flygoat.com header.s=mail header.b=Np0+8DGS; dkim=pass header.i=@flygoat.com header.s=mail header.b=nkW0PiM/; 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=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752407AbeCUOxf (ORCPT + 99 others); Wed, 21 Mar 2018 10:53:35 -0400 Received: from forward106j.mail.yandex.net ([5.45.198.249]:39348 "EHLO forward106j.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752064AbeCUOx1 (ORCPT ); Wed, 21 Mar 2018 10:53:27 -0400 Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 669041803FDA; Wed, 21 Mar 2018 17:53:25 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id RZ5oCZZBbK-rOBGVNMj; Wed, 21 Mar 2018 17:53:25 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; s=mail; t=1521644005; bh=p+WYh4nd4uWSP6vmuQ3HNDEbe3VQXFp724VO03wmSv8=; h=From:To:Cc:Subject:Date:Message-Id; b=Np0+8DGSOOWxDLLTdHi4FBsCK4g0ynGxYL5sc1t11F0yD0xM2FegvCp2NR8IOIc12 oTeUd6Y1RdoBnQIc72JVQTjCT/aN/YssLmIE03xe8Hd96bv0R10pW+pMCTT8sl1woF 4JrZF282gGHUR1pzBk2Zs4hkEVxciqym0gpv81lo= Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Tlo5VWq6Rp-rGi01KP4; Wed, 21 Mar 2018 17:53:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; s=mail; t=1521644002; bh=p+WYh4nd4uWSP6vmuQ3HNDEbe3VQXFp724VO03wmSv8=; h=From:To:Cc:Subject:Date:Message-Id; b=nkW0PiM/Di935OI0ySDHJ7MINHmdw0h59bIPoPOd7qqy62X+2uoGrgo2Zd3fUMhHA NrT2NP4qfo2zJVtHk25fJJJDXp9Ykc16Xw2rdyqMDij2KsFlOMb4emebk0hSjENJz+ d1tPXUcQkOPwVclWPepeP+5s3tuHaklJaVEuWZrQ= Authentication-Results: smtp3o.mail.yandex.net; dkim=pass header.i=@flygoat.com From: Jiaxun Yang To: jhogan@kernel.org Cc: chenhc@lemote.com, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Jiaxun Yang Subject: [PATCH 1/2] MIPS: Introduce has_cpu_mips*_user in cpu-features.h Date: Wed, 21 Mar 2018 22:53:03 +0800 Message-Id: <20180321145304.4639-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.16.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some processors support user mode instructions ISA level witch is different with the ISA level it should be treated in kernel, such as Loongson 3A1000 3B1000 3A1500 3B1500 support all mips64r2 user mode instructions however, they should be treated as mips64r1 in kernel. So we introduce has_cpu_mips*_user to decide witch level should be displayed in cpuinfo to prevent misleading userspace programs. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/cpu-features.h | 39 ++++++++++++++++++++++++++++++++++++ arch/mips/kernel/proc.c | 22 ++++++++++---------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 721b698bfe3c..0eff1956e229 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -251,6 +251,45 @@ # define cpu_has_mips64r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R6) #endif +/* + * For the CPU that has a user mode instructions ISA level witch is different + * from the ISA level it should be treated in kernel, this ISA level will + * be displayed in cpuinfo as a reference for userspace programs. + */ +#ifndef cpu_has_mips_1_user +# define cpu_has_mips_1_user (cpu_has_mips_1) +#endif +#ifndef cpu_has_mips_2_user +# define cpu_has_mips_2_user (cpu_has_mips_2) +#endif +#ifndef cpu_has_mips_3_user +# define cpu_has_mips_3_user (cpu_has_mips_3) +#endif +#ifndef cpu_has_mips_4_user +# define cpu_has_mips_4_user (cpu_has_mips_4) +#endif +#ifndef cpu_has_mips_5_user +# define cpu_has_mips_5_user (cpu_has_mips_5) +#endif +#ifndef cpu_has_mips32r1_user +# define cpu_has_mips32r1_user (cpu_has_mips32r1) +#endif +#ifndef cpu_has_mips32r2_user +# define cpu_has_mips32r2_user (cpu_has_mips32r2) +#endif +#ifndef cpu_has_mips32r6_user +# define cpu_has_mips32r6_user (cpu_has_mips32r6) +#endif +#ifndef cpu_has_mips64r1_user +# define cpu_has_mips64r1_user (cpu_has_mips64r1) +#endif +#ifndef cpu_has_mips64r2_user +# define cpu_has_mips64r2_user (cpu_has_mips64r2) +#endif +#ifndef cpu_has_mips64r6_user +# define cpu_has_mips64r6_user (cpu_has_mips64r6) +#endif + /* * Shortcuts ... */ diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index b2de408a259e..65a9a695af3c 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c @@ -84,27 +84,27 @@ static int show_cpuinfo(struct seq_file *m, void *v) } seq_printf(m, "isa\t\t\t:"); - if (cpu_has_mips_1) + if (cpu_has_mips_1_user) seq_printf(m, " mips1"); - if (cpu_has_mips_2) + if (cpu_has_mips_2_user) seq_printf(m, "%s", " mips2"); - if (cpu_has_mips_3) + if (cpu_has_mips_3_user) seq_printf(m, "%s", " mips3"); - if (cpu_has_mips_4) + if (cpu_has_mips_4_user) seq_printf(m, "%s", " mips4"); - if (cpu_has_mips_5) + if (cpu_has_mips_5_user) seq_printf(m, "%s", " mips5"); - if (cpu_has_mips32r1) + if (cpu_has_mips32r1_user) seq_printf(m, "%s", " mips32r1"); - if (cpu_has_mips32r2) + if (cpu_has_mips32r2_user) seq_printf(m, "%s", " mips32r2"); - if (cpu_has_mips32r6) + if (cpu_has_mips32r6_user) seq_printf(m, "%s", " mips32r6"); - if (cpu_has_mips64r1) + if (cpu_has_mips64r1_user) seq_printf(m, "%s", " mips64r1"); - if (cpu_has_mips64r2) + if (cpu_has_mips64r2_user) seq_printf(m, "%s", " mips64r2"); - if (cpu_has_mips64r6) + if (cpu_has_mips64r6_user) seq_printf(m, "%s", " mips64r6"); seq_printf(m, "\n"); -- 2.16.2