linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] x86/cpu: Enable cpuid on Cyrix 6x86/6x86L processors
@ 2018-09-21 21:20 Matthew Whitehead
  2018-09-21 21:20 ` [PATCH v2 1/2] x86/cpu: Use correct macros for Cyrix calls Matthew Whitehead
  2018-09-21 21:20 ` [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing Matthew Whitehead
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Whitehead @ 2018-09-21 21:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, tglx, peterz, luto, bp, hpa, Matthew Whitehead

On power up, the cpuid instruction is disabled on Cyrix 6x86 and 6x86L
processors and needs to be enabled. This patchset enables it.

Matthew Whitehead (2):
  x86/cpu: Use correct macros for Cyrix calls
  x86/cpu: Change query logic so cpuid is enabled before testing

 arch/x86/kernel/cpu/common.c | 4 +++-
 arch/x86/kernel/cpu/cyrix.c  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.16.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] x86/cpu: Use correct macros for Cyrix calls
  2018-09-21 21:20 [PATCH v2 0/2] x86/cpu: Enable cpuid on Cyrix 6x86/6x86L processors Matthew Whitehead
@ 2018-09-21 21:20 ` Matthew Whitehead
  2018-09-22  9:57   ` [tip:x86/cpu] x86/CPU: " tip-bot for Matthew Whitehead
  2018-09-21 21:20 ` [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing Matthew Whitehead
  1 sibling, 1 reply; 6+ messages in thread
From: Matthew Whitehead @ 2018-09-21 21:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, tglx, peterz, luto, bp, hpa, Matthew Whitehead

There are comments in processor-cyrix.h advising you to _not_ make calls
using the deprecated macros in this style:

  setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);

This is because it expands the macro into a non-functioning calling
sequence. The calling order must be:

  outb(CX86_CCR2, 0x22);
  inb(0x23);

From the comments:

 * When using the old macros a line like
 *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
 * gets expanded to:
 *  do {
 *    outb((CX86_CCR2), 0x22);
 *    outb((({
 *        outb((CX86_CCR2), 0x22);
 *        inb(0x23);
 *    }) | 0x88), 0x23);
 *  } while (0);

The new macros fix this problem, so we use them instead.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
---
 arch/x86/kernel/cpu/cyrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index 8949b7ae6d92..d12226f60168 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -437,7 +437,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c)
 			/* enable MAPEN  */
 			setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);
 			/* enable cpuid  */
-			setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
+			setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x80);
 			/* disable MAPEN */
 			setCx86(CX86_CCR3, ccr3);
 			local_irq_restore(flags);
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing
  2018-09-21 21:20 [PATCH v2 0/2] x86/cpu: Enable cpuid on Cyrix 6x86/6x86L processors Matthew Whitehead
  2018-09-21 21:20 ` [PATCH v2 1/2] x86/cpu: Use correct macros for Cyrix calls Matthew Whitehead
@ 2018-09-21 21:20 ` Matthew Whitehead
  2018-09-21 21:54   ` Andy Lutomirski
  2018-09-22  9:58   ` [tip:x86/cpu] x86/CPU: Change query logic so CPUID " tip-bot for Matthew Whitehead
  1 sibling, 2 replies; 6+ messages in thread
From: Matthew Whitehead @ 2018-09-21 21:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, tglx, peterz, luto, bp, hpa, Matthew Whitehead

Presently we check for cpuid to be enabled first. If it is not already
enabled, then we next call identify_cpu_without_cpuid() and clear
X86_FEATURE_CPUID.

Unfortunately, identify_cpu_without_cpuid() is the function where cpuid
becomes _enabled_ on Cyrix 6x86/6x86L cpus. So we must reverse the
calling sequence so that cpuid is first enabled, and then check a second
time to see if the feature has now been activated.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
---
 arch/x86/kernel/cpu/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index eb4cb3efd20e..60c7c5ce7e55 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1040,6 +1040,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 	memset(&c->x86_capability, 0, sizeof c->x86_capability);
 	c->extended_cpuid_level = 0;
 
+	if (!have_cpuid_p())
+		identify_cpu_without_cpuid(c);
+	
 	/* cyrix could have cpuid enabled via c_identify()*/
 	if (have_cpuid_p()) {
 		cpu_detect(c);
@@ -1057,7 +1060,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 		if (this_cpu->c_bsp_init)
 			this_cpu->c_bsp_init(c);
 	} else {
-		identify_cpu_without_cpuid(c);
 		setup_clear_cpu_cap(X86_FEATURE_CPUID);
 	}
 
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing
  2018-09-21 21:20 ` [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing Matthew Whitehead
@ 2018-09-21 21:54   ` Andy Lutomirski
  2018-09-22  9:58   ` [tip:x86/cpu] x86/CPU: Change query logic so CPUID " tip-bot for Matthew Whitehead
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Lutomirski @ 2018-09-21 21:54 UTC (permalink / raw)
  To: Matthew Whitehead
  Cc: LKML, Ingo Molnar, Thomas Gleixner, Peter Zijlstra,
	Borislav Petkov, H. Peter Anvin

On Fri, Sep 21, 2018 at 2:21 PM Matthew Whitehead <tedheadster@gmail.com> wrote:
>
> Presently we check for cpuid to be enabled first. If it is not already
> enabled, then we next call identify_cpu_without_cpuid() and clear
> X86_FEATURE_CPUID.
>
> Unfortunately, identify_cpu_without_cpuid() is the function where cpuid
> becomes _enabled_ on Cyrix 6x86/6x86L cpus. So we must reverse the
> calling sequence so that cpuid is first enabled, and then check a second
> time to see if the feature has now been activated.
>
> Reviewed-by: Andy Lutomirski <luto@amacapital.net>

How about Suggested-and-reviewed-by: Andy Lutomirski <luto@kernel.org> instead?

(No need to resubmit for just that.  Ingo or Thomas, if you like
these, can you just make that substitution?)

> Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
> ---
>  arch/x86/kernel/cpu/common.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index eb4cb3efd20e..60c7c5ce7e55 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -1040,6 +1040,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
>         memset(&c->x86_capability, 0, sizeof c->x86_capability);
>         c->extended_cpuid_level = 0;
>
> +       if (!have_cpuid_p())
> +               identify_cpu_without_cpuid(c);
> +
>         /* cyrix could have cpuid enabled via c_identify()*/
>         if (have_cpuid_p()) {
>                 cpu_detect(c);
> @@ -1057,7 +1060,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
>                 if (this_cpu->c_bsp_init)
>                         this_cpu->c_bsp_init(c);
>         } else {
> -               identify_cpu_without_cpuid(c);
>                 setup_clear_cpu_cap(X86_FEATURE_CPUID);
>         }
>
> --
> 2.16.4
>


-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:x86/cpu] x86/CPU: Use correct macros for Cyrix calls
  2018-09-21 21:20 ` [PATCH v2 1/2] x86/cpu: Use correct macros for Cyrix calls Matthew Whitehead
@ 2018-09-22  9:57   ` tip-bot for Matthew Whitehead
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Matthew Whitehead @ 2018-09-22  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: qianyue.zj, mingo, tglx, luto, hpa, linux-kernel, gregkh, bp,
	pombredanne, peterz, tedheadster

Commit-ID:  03b099bdcdf7125d4a63dc9ddeefdd454e05123d
Gitweb:     https://git.kernel.org/tip/03b099bdcdf7125d4a63dc9ddeefdd454e05123d
Author:     Matthew Whitehead <tedheadster@gmail.com>
AuthorDate: Fri, 21 Sep 2018 17:20:40 -0400
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Sat, 22 Sep 2018 11:46:56 +0200

x86/CPU: Use correct macros for Cyrix calls

There are comments in processor-cyrix.h advising you to _not_ make calls
using the deprecated macros in this style:

  setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);

This is because it expands the macro into a non-functioning calling
sequence. The calling order must be:

  outb(CX86_CCR2, 0x22);
  inb(0x23);

From the comments:

 * When using the old macros a line like
 *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
 * gets expanded to:
 *  do {
 *    outb((CX86_CCR2), 0x22);
 *    outb((({
 *        outb((CX86_CCR2), 0x22);
 *        inb(0x23);
 *    }) | 0x88), 0x23);
 *  } while (0);

The new macros fix this problem, so use them instead.

Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jia Zhang <qianyue.zj@alibaba-inc.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180921212041.13096-2-tedheadster@gmail.com
---
 arch/x86/kernel/cpu/cyrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index 8949b7ae6d92..d12226f60168 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -437,7 +437,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c)
 			/* enable MAPEN  */
 			setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);
 			/* enable cpuid  */
-			setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
+			setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x80);
 			/* disable MAPEN */
 			setCx86(CX86_CCR3, ccr3);
 			local_irq_restore(flags);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:x86/cpu] x86/CPU: Change query logic so CPUID is enabled before testing
  2018-09-21 21:20 ` [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing Matthew Whitehead
  2018-09-21 21:54   ` Andy Lutomirski
@ 2018-09-22  9:58   ` tip-bot for Matthew Whitehead
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Matthew Whitehead @ 2018-09-22  9:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: konrad.wilk, hpa, tedheadster, bp, linux-kernel, mingo, luto,
	dwmw, peterz, tglx

Commit-ID:  2893cc8ff892fa74972d8dc0e1d0dc65116daaa3
Gitweb:     https://git.kernel.org/tip/2893cc8ff892fa74972d8dc0e1d0dc65116daaa3
Author:     Matthew Whitehead <tedheadster@gmail.com>
AuthorDate: Fri, 21 Sep 2018 17:20:41 -0400
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Sat, 22 Sep 2018 11:47:39 +0200

x86/CPU: Change query logic so CPUID is enabled before testing

Presently we check first if CPUID is enabled. If it is not already
enabled, then we next call identify_cpu_without_cpuid() and clear
X86_FEATURE_CPUID.

Unfortunately, identify_cpu_without_cpuid() is the function where CPUID
becomes _enabled_ on Cyrix 6x86/6x86L CPUs.

Reverse the calling sequence so that CPUID is first enabled, and then
check a second time to see if the feature has now been activated.

[ bp: Massage commit message and remove trailing whitespace. ]

Suggested-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180921212041.13096-3-tedheadster@gmail.com
---
 arch/x86/kernel/cpu/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 44c4ef3d989b..658c85d16a9b 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1076,6 +1076,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 	memset(&c->x86_capability, 0, sizeof c->x86_capability);
 	c->extended_cpuid_level = 0;
 
+	if (!have_cpuid_p())
+		identify_cpu_without_cpuid(c);
+
 	/* cyrix could have cpuid enabled via c_identify()*/
 	if (have_cpuid_p()) {
 		cpu_detect(c);
@@ -1093,7 +1096,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 		if (this_cpu->c_bsp_init)
 			this_cpu->c_bsp_init(c);
 	} else {
-		identify_cpu_without_cpuid(c);
 		setup_clear_cpu_cap(X86_FEATURE_CPUID);
 	}
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-22  9:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21 21:20 [PATCH v2 0/2] x86/cpu: Enable cpuid on Cyrix 6x86/6x86L processors Matthew Whitehead
2018-09-21 21:20 ` [PATCH v2 1/2] x86/cpu: Use correct macros for Cyrix calls Matthew Whitehead
2018-09-22  9:57   ` [tip:x86/cpu] x86/CPU: " tip-bot for Matthew Whitehead
2018-09-21 21:20 ` [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing Matthew Whitehead
2018-09-21 21:54   ` Andy Lutomirski
2018-09-22  9:58   ` [tip:x86/cpu] x86/CPU: Change query logic so CPUID " tip-bot for Matthew Whitehead

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).