Skip to content

Commit 368f899

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner: "This contains the following fixes and improvements: - Avoid dereferencing an unprotected VMA pointer in the fault signal generation code - Fix inline asm call constraints for GCC 4.4 - Use existing register variable to retrieve the stack pointer instead of forcing the compiler to create another indirect access which results in excessive extra 'mov %rsp, %<dst>' instructions - Disable branch profiling for the memory encryption code to prevent an early boot crash - Fix a sparse warning caused by casting the __user annotation in __get_user_asm_u64() away - Fix an off by one error in the loop termination of the error patch in the x86 sysfs init code - Add missing CPU IDs to various Intel specific drivers to enable the functionality on recent hardware - More (init) constification in the numachip code" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/asm: Use register variable to get stack pointer value x86/mm: Disable branch profiling in mem_encrypt.c x86/asm: Fix inline asm call constraints for GCC 4.4 perf/x86/intel/uncore: Correct num_boxes for IIO and IRP perf/x86/intel/rapl: Add missing CPU IDs perf/x86/msr: Add missing CPU IDs perf/x86/intel/cstate: Add missing CPU IDs x86: Don't cast away the __user in __get_user_asm_u64() x86/sysfs: Fix off-by-one error in loop termination x86/mm: Fix fault error path using unsafe vma pointer x86/numachip: Add const and __initconst to numachip2_clockevent
2 parents c42ed9f + 196bd48 commit 368f899

File tree

14 files changed

+56
-47
lines changed

14 files changed

+56
-47
lines changed

arch/x86/events/intel/cstate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = {
552552

553553
X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_MOBILE, snb_cstates),
554554
X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_DESKTOP, snb_cstates),
555+
X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_X, snb_cstates),
555556

556557
X86_CSTATES_MODEL(INTEL_FAM6_KABYLAKE_MOBILE, snb_cstates),
557558
X86_CSTATES_MODEL(INTEL_FAM6_KABYLAKE_DESKTOP, snb_cstates),
@@ -560,6 +561,9 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = {
560561
X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNM, knl_cstates),
561562

562563
X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GOLDMONT, glm_cstates),
564+
X86_CSTATES_MODEL(INTEL_FAM6_ATOM_DENVERTON, glm_cstates),
565+
566+
X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GEMINI_LAKE, glm_cstates),
563567
{ },
564568
};
565569
MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match);

arch/x86/events/intel/rapl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,9 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
775775
X86_RAPL_MODEL_MATCH(INTEL_FAM6_KABYLAKE_DESKTOP, skl_rapl_init),
776776

777777
X86_RAPL_MODEL_MATCH(INTEL_FAM6_ATOM_GOLDMONT, hsw_rapl_init),
778+
X86_RAPL_MODEL_MATCH(INTEL_FAM6_ATOM_DENVERTON, hsw_rapl_init),
779+
780+
X86_RAPL_MODEL_MATCH(INTEL_FAM6_ATOM_GEMINI_LAKE, hsw_rapl_init),
778781
{},
779782
};
780783

arch/x86/events/intel/uncore_snbep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,7 @@ static struct intel_uncore_ops skx_uncore_iio_ops = {
34623462
static struct intel_uncore_type skx_uncore_iio = {
34633463
.name = "iio",
34643464
.num_counters = 4,
3465-
.num_boxes = 5,
3465+
.num_boxes = 6,
34663466
.perf_ctr_bits = 48,
34673467
.event_ctl = SKX_IIO0_MSR_PMON_CTL0,
34683468
.perf_ctr = SKX_IIO0_MSR_PMON_CTR0,
@@ -3492,7 +3492,7 @@ static const struct attribute_group skx_uncore_format_group = {
34923492
static struct intel_uncore_type skx_uncore_irp = {
34933493
.name = "irp",
34943494
.num_counters = 2,
3495-
.num_boxes = 5,
3495+
.num_boxes = 6,
34963496
.perf_ctr_bits = 48,
34973497
.event_ctl = SKX_IRP0_MSR_PMON_CTL0,
34983498
.perf_ctr = SKX_IRP0_MSR_PMON_CTR0,

arch/x86/events/msr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ static bool test_intel(int idx)
6363
case INTEL_FAM6_ATOM_SILVERMONT1:
6464
case INTEL_FAM6_ATOM_SILVERMONT2:
6565
case INTEL_FAM6_ATOM_AIRMONT:
66+
67+
case INTEL_FAM6_ATOM_GOLDMONT:
68+
case INTEL_FAM6_ATOM_DENVERTON:
69+
70+
case INTEL_FAM6_ATOM_GEMINI_LAKE:
71+
72+
case INTEL_FAM6_XEON_PHI_KNL:
73+
case INTEL_FAM6_XEON_PHI_KNM:
6674
if (idx == PERF_MSR_SMI)
6775
return true;
6876
break;

arch/x86/include/asm/asm.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
# define __ASM_FORM_COMMA(x) " " #x ","
1212
#endif
1313

14-
#ifdef CONFIG_X86_32
14+
#ifndef __x86_64__
15+
/* 32 bit */
1516
# define __ASM_SEL(a,b) __ASM_FORM(a)
1617
# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a)
1718
#else
19+
/* 64 bit */
1820
# define __ASM_SEL(a,b) __ASM_FORM(b)
1921
# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b)
2022
#endif
@@ -139,8 +141,8 @@
139141
* gets set up by the containing function. If you forget to do this, objtool
140142
* may print a "call without frame pointer save/setup" warning.
141143
*/
142-
register unsigned int __asm_call_sp asm("esp");
143-
#define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp)
144+
register unsigned long current_stack_pointer asm(_ASM_SP);
145+
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
144146
#endif
145147

146148
#endif /* _ASM_X86_ASM_H */

arch/x86/include/asm/thread_info.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,6 @@ struct thread_info {
158158
*/
159159
#ifndef __ASSEMBLY__
160160

161-
static inline unsigned long current_stack_pointer(void)
162-
{
163-
unsigned long sp;
164-
#ifdef CONFIG_X86_64
165-
asm("mov %%rsp,%0" : "=g" (sp));
166-
#else
167-
asm("mov %%esp,%0" : "=g" (sp));
168-
#endif
169-
return sp;
170-
}
171-
172161
/*
173162
* Walks up the stack frames to make sure that the specified object is
174163
* entirely contained by a single stack frame.

arch/x86/include/asm/uaccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ do { \
337337
_ASM_EXTABLE(1b, 4b) \
338338
_ASM_EXTABLE(2b, 4b) \
339339
: "=r" (retval), "=&A"(x) \
340-
: "m" (__m(__ptr)), "m" __m(((u32 *)(__ptr)) + 1), \
340+
: "m" (__m(__ptr)), "m" __m(((u32 __user *)(__ptr)) + 1), \
341341
"i" (errret), "0" (retval)); \
342342
})
343343

arch/x86/kernel/irq_32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void call_on_stack(void *func, void *stack)
6464

6565
static inline void *current_stack(void)
6666
{
67-
return (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));
67+
return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1));
6868
}
6969

7070
static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)
@@ -88,7 +88,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)
8888

8989
/* Save the next esp at the bottom of the stack */
9090
prev_esp = (u32 *)irqstk;
91-
*prev_esp = current_stack_pointer();
91+
*prev_esp = current_stack_pointer;
9292

9393
if (unlikely(overflow))
9494
call_on_stack(print_stack_overflow, isp);
@@ -139,7 +139,7 @@ void do_softirq_own_stack(void)
139139

140140
/* Push the previous esp onto the stack */
141141
prev_esp = (u32 *)irqstk;
142-
*prev_esp = current_stack_pointer();
142+
*prev_esp = current_stack_pointer;
143143

144144
call_on_stack(__do_softirq, isp);
145145
}

arch/x86/kernel/ksysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
299299
return 0;
300300

301301
out_clean_nodes:
302-
for (j = i - 1; j > 0; j--)
302+
for (j = i - 1; j >= 0; j--)
303303
cleanup_setup_data_node(*(kobjp + j));
304304
kfree(kobjp);
305305
out_setup_data_kobj:

arch/x86/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
142142
* from double_fault.
143143
*/
144144
BUG_ON((unsigned long)(current_top_of_stack() -
145-
current_stack_pointer()) >= THREAD_SIZE);
145+
current_stack_pointer) >= THREAD_SIZE);
146146

147147
preempt_enable_no_resched();
148148
}

arch/x86/mm/fault.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
192192
* 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really
193193
* faulted on a pte with its pkey=4.
194194
*/
195-
static void fill_sig_info_pkey(int si_code, siginfo_t *info,
196-
struct vm_area_struct *vma)
195+
static void fill_sig_info_pkey(int si_code, siginfo_t *info, u32 *pkey)
197196
{
198197
/* This is effectively an #ifdef */
199198
if (!boot_cpu_has(X86_FEATURE_OSPKE))
@@ -209,7 +208,7 @@ static void fill_sig_info_pkey(int si_code, siginfo_t *info,
209208
* valid VMA, so we should never reach this without a
210209
* valid VMA.
211210
*/
212-
if (!vma) {
211+
if (!pkey) {
213212
WARN_ONCE(1, "PKU fault with no VMA passed in");
214213
info->si_pkey = 0;
215214
return;
@@ -219,13 +218,12 @@ static void fill_sig_info_pkey(int si_code, siginfo_t *info,
219218
* absolutely guranteed to be 100% accurate because of
220219
* the race explained above.
221220
*/
222-
info->si_pkey = vma_pkey(vma);
221+
info->si_pkey = *pkey;
223222
}
224223

225224
static void
226225
force_sig_info_fault(int si_signo, int si_code, unsigned long address,
227-
struct task_struct *tsk, struct vm_area_struct *vma,
228-
int fault)
226+
struct task_struct *tsk, u32 *pkey, int fault)
229227
{
230228
unsigned lsb = 0;
231229
siginfo_t info;
@@ -240,7 +238,7 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
240238
lsb = PAGE_SHIFT;
241239
info.si_addr_lsb = lsb;
242240

243-
fill_sig_info_pkey(si_code, &info, vma);
241+
fill_sig_info_pkey(si_code, &info, pkey);
244242

245243
force_sig_info(si_signo, &info, tsk);
246244
}
@@ -762,8 +760,6 @@ no_context(struct pt_regs *regs, unsigned long error_code,
762760
struct task_struct *tsk = current;
763761
unsigned long flags;
764762
int sig;
765-
/* No context means no VMA to pass down */
766-
struct vm_area_struct *vma = NULL;
767763

768764
/* Are we prepared to handle this kernel fault? */
769765
if (fixup_exception(regs, X86_TRAP_PF)) {
@@ -788,7 +784,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,
788784

789785
/* XXX: hwpoison faults will set the wrong code. */
790786
force_sig_info_fault(signal, si_code, address,
791-
tsk, vma, 0);
787+
tsk, NULL, 0);
792788
}
793789

794790
/*
@@ -896,8 +892,7 @@ show_signal_msg(struct pt_regs *regs, unsigned long error_code,
896892

897893
static void
898894
__bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
899-
unsigned long address, struct vm_area_struct *vma,
900-
int si_code)
895+
unsigned long address, u32 *pkey, int si_code)
901896
{
902897
struct task_struct *tsk = current;
903898

@@ -945,7 +940,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
945940
tsk->thread.error_code = error_code;
946941
tsk->thread.trap_nr = X86_TRAP_PF;
947942

948-
force_sig_info_fault(SIGSEGV, si_code, address, tsk, vma, 0);
943+
force_sig_info_fault(SIGSEGV, si_code, address, tsk, pkey, 0);
949944

950945
return;
951946
}
@@ -958,24 +953,29 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
958953

959954
static noinline void
960955
bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
961-
unsigned long address, struct vm_area_struct *vma)
956+
unsigned long address, u32 *pkey)
962957
{
963-
__bad_area_nosemaphore(regs, error_code, address, vma, SEGV_MAPERR);
958+
__bad_area_nosemaphore(regs, error_code, address, pkey, SEGV_MAPERR);
964959
}
965960

966961
static void
967962
__bad_area(struct pt_regs *regs, unsigned long error_code,
968963
unsigned long address, struct vm_area_struct *vma, int si_code)
969964
{
970965
struct mm_struct *mm = current->mm;
966+
u32 pkey;
967+
968+
if (vma)
969+
pkey = vma_pkey(vma);
971970

972971
/*
973972
* Something tried to access memory that isn't in our memory map..
974973
* Fix it, but check if it's kernel or user first..
975974
*/
976975
up_read(&mm->mmap_sem);
977976

978-
__bad_area_nosemaphore(regs, error_code, address, vma, si_code);
977+
__bad_area_nosemaphore(regs, error_code, address,
978+
(vma) ? &pkey : NULL, si_code);
979979
}
980980

981981
static noinline void
@@ -1018,7 +1018,7 @@ bad_area_access_error(struct pt_regs *regs, unsigned long error_code,
10181018

10191019
static void
10201020
do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
1021-
struct vm_area_struct *vma, unsigned int fault)
1021+
u32 *pkey, unsigned int fault)
10221022
{
10231023
struct task_struct *tsk = current;
10241024
int code = BUS_ADRERR;
@@ -1045,13 +1045,12 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
10451045
code = BUS_MCEERR_AR;
10461046
}
10471047
#endif
1048-
force_sig_info_fault(SIGBUS, code, address, tsk, vma, fault);
1048+
force_sig_info_fault(SIGBUS, code, address, tsk, pkey, fault);
10491049
}
10501050

10511051
static noinline void
10521052
mm_fault_error(struct pt_regs *regs, unsigned long error_code,
1053-
unsigned long address, struct vm_area_struct *vma,
1054-
unsigned int fault)
1053+
unsigned long address, u32 *pkey, unsigned int fault)
10551054
{
10561055
if (fatal_signal_pending(current) && !(error_code & PF_USER)) {
10571056
no_context(regs, error_code, address, 0, 0);
@@ -1075,9 +1074,9 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
10751074
} else {
10761075
if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|
10771076
VM_FAULT_HWPOISON_LARGE))
1078-
do_sigbus(regs, error_code, address, vma, fault);
1077+
do_sigbus(regs, error_code, address, pkey, fault);
10791078
else if (fault & VM_FAULT_SIGSEGV)
1080-
bad_area_nosemaphore(regs, error_code, address, vma);
1079+
bad_area_nosemaphore(regs, error_code, address, pkey);
10811080
else
10821081
BUG();
10831082
}
@@ -1267,6 +1266,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
12671266
struct mm_struct *mm;
12681267
int fault, major = 0;
12691268
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
1269+
u32 pkey;
12701270

12711271
tsk = current;
12721272
mm = tsk->mm;
@@ -1467,9 +1467,10 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
14671467
return;
14681468
}
14691469

1470+
pkey = vma_pkey(vma);
14701471
up_read(&mm->mmap_sem);
14711472
if (unlikely(fault & VM_FAULT_ERROR)) {
1472-
mm_fault_error(regs, error_code, address, vma, fault);
1473+
mm_fault_error(regs, error_code, address, &pkey, fault);
14731474
return;
14741475
}
14751476

arch/x86/mm/mem_encrypt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* published by the Free Software Foundation.
1111
*/
1212

13+
#define DISABLE_BRANCH_PROFILING
14+
1315
#include <linux/linkage.h>
1416
#include <linux/init.h>
1517
#include <linux/mm.h>

arch/x86/mm/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
191191
* mapped in the new pgd, we'll double-fault. Forcibly
192192
* map it.
193193
*/
194-
unsigned int index = pgd_index(current_stack_pointer());
194+
unsigned int index = pgd_index(current_stack_pointer);
195195
pgd_t *pgd = next->pgd + index;
196196

197197
if (unlikely(pgd_none(*pgd)))

drivers/clocksource/numachip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int numachip2_set_next_event(unsigned long delta, struct clock_event_devi
4343
return 0;
4444
}
4545

46-
static struct clock_event_device numachip2_clockevent = {
46+
static const struct clock_event_device numachip2_clockevent __initconst = {
4747
.name = "numachip2",
4848
.rating = 400,
4949
.set_next_event = numachip2_set_next_event,

0 commit comments

Comments
 (0)