Received: by 10.213.65.68 with SMTP id h4csp739631imn; Thu, 22 Mar 2018 07:35:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELugD4NvNljLkyoWIcIfqLPU5lIkRqsjUOk8BtBO6jEcbmrpzjx+8Z613fQd4qp/ReRJ6cjP X-Received: by 10.99.109.203 with SMTP id i194mr18561232pgc.314.1521729302054; Thu, 22 Mar 2018 07:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729302; cv=none; d=google.com; s=arc-20160816; b=L00fKy3xZOJEm+0Dhi2ptxCLb7ZiKmwzu+s/HHNVXPLaULMC7FaTaQYcYQLRgUvPcr xd3JK1yXz9xoioKsZyvNQ5I3OpLVnXLzGfxlqR9UJW8QepbbFjONWRyIJM9rnpKeDlOg tAarTc41m0yZBT0JimH4GxT0pwtGMq4N3xO3nO3FSbei9nYQEQt65AY8wjgsFprr3yDb Mcn5K4DPD216zqw3v0jMOZxzC3Lwuonoo6e0oiTREtUvKJ10oivHvV22VEvMx7i3fLzP ThH6ITCcLmhFVUmf/52gV0Puz8wBip1mGle+n2yaUW/3NZrcSDmClBarynNpKKvqlLgm ZkVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=jZaVDcHQyTtcGThgp3tpmn12GTGUMcUouHcWoX9q99g=; b=ItreENnTCDOJb7us87rZSfyx6Ys6VsTDP0JM1Bp1/xIV4ofYaylmScyFCyX+Do0ctn Cnn94XNACC3RppPfO7dG0I06RL5dbJOrty/YLoM/JMqhQf4Q/9xztlDcqckeFVfUl2r0 r5Se2GldTCEJnMIkEsVjeiXnT1jyag6YbKvkOUTSSlLQIG5INb9Q9PZ5rtnY/TmTgHZh SO/SwV8aT6LnYSVOqV729SRSzZyNXGurAD6P+7F/MmX2GV+7soCjNOorSufjBK6adaas Ev49IgGn4TWC0TJfWMwlWwJpFjX0l+BYphU1WBoI8W3TLzAy9gQbmRlebcr6dyc+3SJg 9FSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=baxK7Obr; dkim=pass header.i=@flygoat.com header.s=mail header.b=n2YgRVIP; 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 67-v6si6423676ple.311.2018.03.22.07.34.47; Thu, 22 Mar 2018 07:35:02 -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=baxK7Obr; dkim=pass header.i=@flygoat.com header.s=mail header.b=n2YgRVIP; 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 S932489AbeCVOWj (ORCPT + 99 others); Thu, 22 Mar 2018 10:22:39 -0400 Received: from forward106p.mail.yandex.net ([77.88.28.109]:56167 "EHLO forward106p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932482AbeCVOWf (ORCPT ); Thu, 22 Mar 2018 10:22:35 -0400 Received: from mxback1g.mail.yandex.net (mxback1g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:162]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 6EB132D84021; Thu, 22 Mar 2018 17:22:33 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Scdfi7f1g3-MW7C4MR1; Thu, 22 Mar 2018 17:22:33 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; s=mail; t=1521728553; bh=jZaVDcHQyTtcGThgp3tpmn12GTGUMcUouHcWoX9q99g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=baxK7ObrTyvXumtpFZDQmfFvz3I5j0YxunW0JSgDHuJcYVZg/TAsFdrDEAbN5AwK7 R56LhJVFSv9smbokSLcw3dZczTu6xSgvFE9X9cCSR1YYiN761S7fiYk9Ixjk/W3QFM 2IpGUdzIIwFKyuqjYcBQg56MvU2uC+gk1GOIfTJo= Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id xanZbOtqWb-MSvaRxMc; Thu, 22 Mar 2018 17:22:30 +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=1521728551; bh=jZaVDcHQyTtcGThgp3tpmn12GTGUMcUouHcWoX9q99g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=n2YgRVIP3NT79wgJXBB0XZoXzG6J+qTTzRTS7ZWddtXimwNnbpyNooZYwXuLgaGI8 VPEd1LIdSmqLTKQe/GuxzrPS+d/Uug1A0dciXD3jO3bMwyjgl1QNqlD83+qfmICPEK meDDV6EBL+z5bJn6D7gvWKmQqY4Y8ApIel/UDPds= Authentication-Results: smtp2j.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 v2 1/2] MIPS: Introduce has_cpu_mips*_user in cpu-features.h Date: Thu, 22 Mar 2018 22:22:14 +0800 Message-Id: <20180322142215.7705-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180321145304.4639-1-jiaxun.yang@flygoat.com> References: <20180321145304.4639-1-jiaxun.yang@flygoat.com> 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 which 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 which 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 which 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