Skip to contentSkip to conversation

x86/cpu: Do the feature test first in enable_sep_cpu()

PATCH In review Borislav Petkov 3 participants 3 messages Mar 16, 2016 – Mar 29, 2016 x86

lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/1 x86/cpu: Do the feature test first in enable_sep_cpu()

From: Borislav Petkov <[email protected]>

... before assigning local vars. Kill out label too and simplify.

No functionality change.

---
 arch/x86/kernel/cpu/common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/common.c +3 -4
index 249461f95851..63658d23d3dd 100644
@@ -1030,12 +1030,12 @@ void enable_sep_cpu(void)
 	struct tss_struct *tss;
 	int cpu;
 
+	if (!boot_cpu_has(X86_FEATURE_SEP))
+		return;
+
 	cpu = get_cpu();
 	tss = &per_cpu(cpu_tss, cpu);
 
-	if (!boot_cpu_has(X86_FEATURE_SEP))
-		goto out;
-
 	/*
 	 * We cache MSR_IA32_SYSENTER_CS's value in the TSS's ss1 field --
 	 * see the big comment in struct x86_hw_tss's definition.
@@ -1050,7 +1050,6 @@ void enable_sep_cpu(void)
 
 	wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0);
 
-out:
 	put_cpu();
 }
 #endif
Signature · 1 line
2.7.3
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

... before assigning local vars. Kill out label too and simplify.

No functionality change.

Quoted 37 lines
---
 arch/x86/kernel/cpu/common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/common.c +3 -5
index 249461f95851..63658d23d3dd 100644
@@ -1030,12 +1030,12 @@ void enable_sep_cpu(void)
        struct tss_struct *tss;
        int cpu;
 
+       if (!boot_cpu_has(X86_FEATURE_SEP))
+               return;
+
        cpu = get_cpu();
        tss = &per_cpu(cpu_tss, cpu);
 
-       if (!boot_cpu_has(X86_FEATURE_SEP))
-               goto out;
-
        /*
         * We cache MSR_IA32_SYSENTER_CS's value in the TSS's ss1 field --
         * see the big comment in struct x86_hw_tss's definition.
@@ -1050,7 +1050,6 @@ void enable_sep_cpu(void)
 
        wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0);
 
-out:
        put_cpu();
 }
 #endif
--

2.7.3

Signature · 2 lines
Andy Lutomirski
AMA Capital Management, LLC
#2 lore raw
In reply to Borislav Petkov
x86/cpu: Do the feature test first in enable_sep_cpu()
Commit-ID:  b3edfda4382ffaef5e5c1cffb25a33b3b9ef4546
Gitweb:     http://git.kernel.org/tip/b3edfda4382ffaef5e5c1cffb25a33b3b9ef4546
Author:     Borislav Petkov <[email protected]>
AuthorDate: Wed, 16 Mar 2016 13:19:29 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 29 Mar 2016 12:57:12 +0200

x86/cpu: Do the feature test first in enable_sep_cpu()

... before assigning local vars. Kill out label too and simplify.

No functionality change.

---
 arch/x86/kernel/cpu/common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/common.c +3 -4
index 8394b3d..7fea407 100644
@@ -1076,12 +1076,12 @@ void enable_sep_cpu(void)
 	struct tss_struct *tss;
 	int cpu;
 
+	if (!boot_cpu_has(X86_FEATURE_SEP))
+		return;
+
 	cpu = get_cpu();
 	tss = &per_cpu(cpu_tss, cpu);
 
-	if (!boot_cpu_has(X86_FEATURE_SEP))
-		goto out;
-
 	/*
 	 * We cache MSR_IA32_SYSENTER_CS's value in the TSS's ss1 field --
 	 * see the big comment in struct x86_hw_tss's definition.
@@ -1096,7 +1096,6 @@ void enable_sep_cpu(void)
 
 	wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0);
 
-out:
 	put_cpu();
 }
 #endif