Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1314108 > unrolled thread
| Started by | Huaitong Han <huaitong.han@intel.com> |
|---|---|
| First post | 2016-01-21 12:10 +0100 |
| Last post | 2016-01-21 22:10 +0100 |
| Articles | 10 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH V2] x86: use enum cpuid_leafs instead of magic numbers Huaitong Han <huaitong.han@intel.com> - 2016-01-21 12:10 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers Borislav Petkov <bp@alien8.de> - 2016-01-21 12:50 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers "H. Peter Anvin" <hpa@zytor.com> - 2016-01-21 22:10 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers Borislav Petkov <bp@alien8.de> - 2016-01-21 22:30 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers "H. Peter Anvin" <hpa@zytor.com> - 2016-01-21 22:30 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers "H. Peter Anvin" <hpa@zytor.com> - 2016-01-21 22:40 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers Borislav Petkov <bp@alien8.de> - 2016-01-21 22:50 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers "H. Peter Anvin" <hpa@zytor.com> - 2016-01-21 23:00 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers Borislav Petkov <bp@alien8.de> - 2016-01-21 22:40 +0100
Re: [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers "H. Peter Anvin" <hpa@zytor.com> - 2016-01-21 22:10 +0100
| From | Huaitong Han <huaitong.han@intel.com> |
|---|---|
| Date | 2016-01-21 12:10 +0100 |
| Subject | [PATCH V2] x86: use enum cpuid_leafs instead of magic numbers |
| Message-ID | <qTlhM-4qv-7@gated-at.bofh.it> |
v2:add a commit message.
Most of magic numbers of x86_capability have been converted to enum
cpuid_leafs, and this patch does update the remaining part.
Signed-off-by: Huaitong Han <huaitong.han@intel.com>
---
arch/x86/include/asm/elf.h | 2 +-
arch/x86/kernel/mpparse.c | 2 +-
arch/x86/lguest/boot.c | 2 +-
arch/x86/xen/enlighten.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 1514753..15340e3 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -256,7 +256,7 @@ extern int force_personality32;
instruction set this CPU supports. This could be done in user space,
but it's not easy, and we've already done it here. */
-#define ELF_HWCAP (boot_cpu_data.x86_capability[0])
+#define ELF_HWCAP (boot_cpu_data.x86_capability[CPUID_1_EDX])
/* This yields a string that ld.so will use to load implementation
specific libraries for optimization. This is more specific in
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index 30ca760..97340f2 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -408,7 +408,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
processor.cpuflag = CPU_ENABLED;
processor.cpufeature = (boot_cpu_data.x86 << 8) |
(boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
- processor.featureflag = boot_cpu_data.x86_capability[0];
+ processor.featureflag = boot_cpu_data.x86_capability[CPUID_1_EDX];
processor.reserved[0] = 0;
processor.reserved[1] = 0;
for (i = 0; i < 2; i++) {
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 4ba229a..a9033ae 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -1535,7 +1535,7 @@ __init void lguest_init(void)
*/
cpu_detect(&new_cpu_data);
/* head.S usually sets up the first capability word, so do it here. */
- new_cpu_data.x86_capability[0] = cpuid_edx(1);
+ new_cpu_data.x86_capability[CPUID_1_EDX] = cpuid_edx(1);
/* Math is always hard! */
set_cpu_cap(&new_cpu_data, X86_FEATURE_FPU);
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index d09e4c9..2c26108 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1654,7 +1654,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
cpu_detect(&new_cpu_data);
set_cpu_cap(&new_cpu_data, X86_FEATURE_FPU);
new_cpu_data.wp_works_ok = 1;
- new_cpu_data.x86_capability[0] = cpuid_edx(1);
+ new_cpu_data.x86_capability[CPUID_1_EDX] = cpuid_edx(1);
#endif
if (xen_start_info->mod_start) {
--
2.4.3
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-21 12:50 +0100 |
| Message-ID | <qTlUt-4G5-7@gated-at.bofh.it> |
| In reply to | #1314108 |
On Thu, Jan 21, 2016 at 07:02:40PM +0800, Huaitong Han wrote:
> v2:add a commit message.
>
> Most of magic numbers of x86_capability have been converted to enum
> cpuid_leafs, and this patch does update the remaining part.
>
> Signed-off-by: Huaitong Han <huaitong.han@intel.com>
> ---
> arch/x86/include/asm/elf.h | 2 +-
> arch/x86/kernel/mpparse.c | 2 +-
> arch/x86/lguest/boot.c | 2 +-
> arch/x86/xen/enlighten.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
Applied, thanks.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-01-21 22:10 +0100 |
| Message-ID | <qTuEq-2ry-19@gated-at.bofh.it> |
| In reply to | #1314129 |
On 01/21/16 03:42, Borislav Petkov wrote: > On Thu, Jan 21, 2016 at 07:02:40PM +0800, Huaitong Han wrote: >> v2:add a commit message. >> >> Most of magic numbers of x86_capability have been converted to enum >> cpuid_leafs, and this patch does update the remaining part. >> >> Signed-off-by: Huaitong Han <huaitong.han@intel.com> >> --- >> arch/x86/include/asm/elf.h | 2 +- >> arch/x86/kernel/mpparse.c | 2 +- >> arch/x86/lguest/boot.c | 2 +- >> arch/x86/xen/enlighten.c | 2 +- >> 4 files changed, 4 insertions(+), 4 deletions(-) > I'm wondering, though, if it wouldn't be better to turn these into macros so that they can be used in assembly code. That way the definitions can be interspersed with the X86_FEATURE_ definitions, too. -hpa
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-21 22:30 +0100 |
| Message-ID | <qTuXL-2zU-1@gated-at.bofh.it> |
| In reply to | #1314529 |
On Thu, Jan 21, 2016 at 01:04:57PM -0800, H. Peter Anvin wrote:
> I'm wondering, though, if it wouldn't be better to turn these into
> macros so that they can be used in assembly code. That way the
> definitions can be interspersed with the X86_FEATURE_ definitions,
> too.
What concrete use case do you have in mind, i.e., example?
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-01-21 22:30 +0100 |
| Message-ID | <qTuXM-2zU-11@gated-at.bofh.it> |
| In reply to | #1314537 |
On 01/21/16 13:21, Borislav Petkov wrote: > On Thu, Jan 21, 2016 at 01:04:57PM -0800, H. Peter Anvin wrote: >> I'm wondering, though, if it wouldn't be better to turn these into >> macros so that they can be used in assembly code. That way the >> definitions can be interspersed with the X86_FEATURE_ definitions, >> too. > > What concrete use case do you have in mind, i.e., example? > See X86_CAPABILITY in head_32.S for example. -hpa
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-01-21 22:40 +0100 |
| Message-ID | <qTv7r-2E4-11@gated-at.bofh.it> |
| In reply to | #1314542 |
On 01/21/16 13:33, Borislav Petkov wrote: > On Thu, Jan 21, 2016 at 01:25:22PM -0800, H. Peter Anvin wrote: >> See X86_CAPABILITY in head_32.S for example. > > ... so that you can get rid of the offset games at least for > CPUINFO_x86_capability in asm-offsets_32.c? > No, you still need to be able to find the beginning of the capability array, but the point is that right now it is implicit in that code that CPUID_1_EDX == 0. -hpa
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-21 22:50 +0100 |
| Message-ID | <qTvh7-2He-9@gated-at.bofh.it> |
| In reply to | #1314548 |
On Thu, Jan 21, 2016 at 01:37:36PM -0800, H. Peter Anvin wrote:
> No, you still need to be able to find the beginning of the capability
> array, but the point is that right now it is implicit in that code that
> CPUID_1_EDX == 0.
Ah, you wanna be able to do:
---
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index af1112980dd4..143646f0add1 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -441,7 +443,7 @@ enable_paging:
movb %al,X86_MODEL
andb $0x0f,%cl # mask mask revision
movb %cl,X86_MASK
- movl %edx,X86_CAPABILITY
+ movl %edx,X86_CAPABILITY + CPUID_1_EDX*4
is486:
movl $0x50022,%ecx # set AM, WP, NE and MP
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-01-21 23:00 +0100 |
| Message-ID | <qTvqO-2KT-7@gated-at.bofh.it> |
| In reply to | #1314555 |
On January 21, 2016 1:47:32 PM PST, Borislav Petkov <bp@alien8.de> wrote: >On Thu, Jan 21, 2016 at 01:37:36PM -0800, H. Peter Anvin wrote: >> No, you still need to be able to find the beginning of the capability >> array, but the point is that right now it is implicit in that code >that >> CPUID_1_EDX == 0. > >Ah, you wanna be able to do: > >--- >diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S >index af1112980dd4..143646f0add1 100644 >--- a/arch/x86/kernel/head_32.S >+++ b/arch/x86/kernel/head_32.S >@@ -441,7 +443,7 @@ enable_paging: > movb %al,X86_MODEL > andb $0x0f,%cl # mask mask revision > movb %cl,X86_MASK >- movl %edx,X86_CAPABILITY >+ movl %edx,X86_CAPABILITY + CPUID_1_EDX*4 > > is486: > movl $0x50022,%ecx # set AM, WP, NE and MP Basically, yes. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-21 22:40 +0100 |
| Message-ID | <qTv7r-2E4-13@gated-at.bofh.it> |
| In reply to | #1314542 |
On Thu, Jan 21, 2016 at 01:25:22PM -0800, H. Peter Anvin wrote:
> See X86_CAPABILITY in head_32.S for example.
... so that you can get rid of the offset games at least for
CPUINFO_x86_capability in asm-offsets_32.c?
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-01-21 22:10 +0100 |
| Message-ID | <qTuEq-2ry-7@gated-at.bofh.it> |
| In reply to | #1314108 |
On 01/21/16 03:02, Huaitong Han wrote: > v2:add a commit message. > > Most of magic numbers of x86_capability have been converted to enum > cpuid_leafs, and this patch does update the remaining part. > > Signed-off-by: Huaitong Han <huaitong.han@intel.com> Also, the plural of leaf is "leaves". -hpa
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web