Skip to content

Commit 5aa4c31

Browse files
committed
Merge remote-tracking branch 'stable/linux-4.9.y' into rpi-4.9.y
2 parents da6ff85 + 7bbc6ca commit 5aa4c31

File tree

30 files changed

+187
-48
lines changed

30 files changed

+187
-48
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION = 4
22
PATCHLEVEL = 9
3-
SUBLEVEL = 75
3+
SUBLEVEL = 76
44
EXTRAVERSION =
55
NAME = Roaring Lionus
66

arch/arc/include/asm/uaccess.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ __arc_strncpy_from_user(char *dst, const char __user *src, long count)
673673
return 0;
674674

675675
__asm__ __volatile__(
676+
" mov lp_count, %5 \n"
676677
" lp 3f \n"
677678
"1: ldb.ab %3, [%2, 1] \n"
678679
" breq.d %3, 0, 3f \n"
@@ -689,8 +690,8 @@ __arc_strncpy_from_user(char *dst, const char __user *src, long count)
689690
" .word 1b, 4b \n"
690691
" .previous \n"
691692
: "+r"(res), "+r"(dst), "+r"(src), "=r"(val)
692-
: "g"(-EFAULT), "l"(count)
693-
: "memory");
693+
: "g"(-EFAULT), "r"(count)
694+
: "lp_count", "lp_start", "lp_end", "memory");
694695

695696
return res;
696697
}

arch/parisc/include/asm/ldcw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
for the semaphore. */
1212

1313
#define __PA_LDCW_ALIGNMENT 16
14+
#define __PA_LDCW_ALIGN_ORDER 4
1415
#define __ldcw_align(a) ({ \
1516
unsigned long __ret = (unsigned long) &(a)->lock[0]; \
1617
__ret = (__ret + __PA_LDCW_ALIGNMENT - 1) \
@@ -28,6 +29,7 @@
2829
ldcd). */
2930

3031
#define __PA_LDCW_ALIGNMENT 4
32+
#define __PA_LDCW_ALIGN_ORDER 2
3133
#define __ldcw_align(a) (&(a)->slock)
3234
#define __LDCW "ldcw,co"
3335

arch/parisc/kernel/entry.S

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <asm/pgtable.h>
3636
#include <asm/signal.h>
3737
#include <asm/unistd.h>
38+
#include <asm/ldcw.h>
3839
#include <asm/thread_info.h>
3940

4041
#include <linux/linkage.h>
@@ -46,6 +47,14 @@
4647
#endif
4748

4849
.import pa_tlb_lock,data
50+
.macro load_pa_tlb_lock reg
51+
#if __PA_LDCW_ALIGNMENT > 4
52+
load32 PA(pa_tlb_lock) + __PA_LDCW_ALIGNMENT-1, \reg
53+
depi 0,31,__PA_LDCW_ALIGN_ORDER, \reg
54+
#else
55+
load32 PA(pa_tlb_lock), \reg
56+
#endif
57+
.endm
4958

5059
/* space_to_prot macro creates a prot id from a space id */
5160

@@ -457,7 +466,7 @@
457466
.macro tlb_lock spc,ptp,pte,tmp,tmp1,fault
458467
#ifdef CONFIG_SMP
459468
cmpib,COND(=),n 0,\spc,2f
460-
load32 PA(pa_tlb_lock),\tmp
469+
load_pa_tlb_lock \tmp
461470
1: LDCW 0(\tmp),\tmp1
462471
cmpib,COND(=) 0,\tmp1,1b
463472
nop
@@ -480,7 +489,7 @@
480489
/* Release pa_tlb_lock lock. */
481490
.macro tlb_unlock1 spc,tmp
482491
#ifdef CONFIG_SMP
483-
load32 PA(pa_tlb_lock),\tmp
492+
load_pa_tlb_lock \tmp
484493
tlb_unlock0 \spc,\tmp
485494
#endif
486495
.endm

arch/parisc/kernel/pacache.S

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <asm/assembly.h>
3737
#include <asm/pgtable.h>
3838
#include <asm/cache.h>
39+
#include <asm/ldcw.h>
3940
#include <linux/linkage.h>
4041

4142
.text
@@ -333,8 +334,12 @@ ENDPROC_CFI(flush_data_cache_local)
333334

334335
.macro tlb_lock la,flags,tmp
335336
#ifdef CONFIG_SMP
336-
ldil L%pa_tlb_lock,%r1
337-
ldo R%pa_tlb_lock(%r1),\la
337+
#if __PA_LDCW_ALIGNMENT > 4
338+
load32 pa_tlb_lock + __PA_LDCW_ALIGNMENT-1, \la
339+
depi 0,31,__PA_LDCW_ALIGN_ORDER, \la
340+
#else
341+
load32 pa_tlb_lock, \la
342+
#endif
338343
rsm PSW_SM_I,\flags
339344
1: LDCW 0(\la),\tmp
340345
cmpib,<>,n 0,\tmp,3f

arch/parisc/kernel/process.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/kernel.h>
4040
#include <linux/mm.h>
4141
#include <linux/fs.h>
42+
#include <linux/cpu.h>
4243
#include <linux/module.h>
4344
#include <linux/personality.h>
4445
#include <linux/ptrace.h>
@@ -180,6 +181,44 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r)
180181
return 1;
181182
}
182183

184+
/*
185+
* Idle thread support
186+
*
187+
* Detect when running on QEMU with SeaBIOS PDC Firmware and let
188+
* QEMU idle the host too.
189+
*/
190+
191+
int running_on_qemu __read_mostly;
192+
193+
void __cpuidle arch_cpu_idle_dead(void)
194+
{
195+
/* nop on real hardware, qemu will offline CPU. */
196+
asm volatile("or %%r31,%%r31,%%r31\n":::);
197+
}
198+
199+
void __cpuidle arch_cpu_idle(void)
200+
{
201+
local_irq_enable();
202+
203+
/* nop on real hardware, qemu will idle sleep. */
204+
asm volatile("or %%r10,%%r10,%%r10\n":::);
205+
}
206+
207+
static int __init parisc_idle_init(void)
208+
{
209+
const char *marker;
210+
211+
/* check QEMU/SeaBIOS marker in PAGE0 */
212+
marker = (char *) &PAGE0->pad0;
213+
running_on_qemu = (memcmp(marker, "SeaBIOS", 8) == 0);
214+
215+
if (!running_on_qemu)
216+
cpu_idle_poll_ctrl(1);
217+
218+
return 0;
219+
}
220+
arch_initcall(parisc_idle_init);
221+
183222
/*
184223
* Copy architecture-specific thread state
185224
*/

arch/s390/kernel/compat_linux.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setgroups16, int, gidsetsize, u16 __user *, grouplis
263263
return retval;
264264
}
265265

266+
groups_sort(group_info);
266267
retval = set_current_groups(group_info);
267268
put_group_info(group_info);
268269

arch/x86/entry/vsyscall/vsyscall_64.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ static int __init vsyscall_setup(char *str)
6666
}
6767
early_param("vsyscall", vsyscall_setup);
6868

69+
bool vsyscall_enabled(void)
70+
{
71+
return vsyscall_mode != NONE;
72+
}
73+
6974
static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
7075
const char *message)
7176
{

arch/x86/include/asm/vsyscall.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ extern void map_vsyscall(void);
1212
* Returns true if handled.
1313
*/
1414
extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address);
15+
extern bool vsyscall_enabled(void);
1516
#else
1617
static inline void map_vsyscall(void) {}
1718
static inline bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
1819
{
1920
return false;
2021
}
22+
static inline bool vsyscall_enabled(void) { return false; }
2123
#endif
2224

2325
#endif /* _ASM_X86_VSYSCALL_H */

arch/x86/kernel/cpu/microcode/amd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ static unsigned int verify_patch_size(u8 family, u32 patch_size,
592592
#define F14H_MPB_MAX_SIZE 1824
593593
#define F15H_MPB_MAX_SIZE 4096
594594
#define F16H_MPB_MAX_SIZE 3458
595+
#define F17H_MPB_MAX_SIZE 3200
595596

596597
switch (family) {
597598
case 0x14:
@@ -603,6 +604,9 @@ static unsigned int verify_patch_size(u8 family, u32 patch_size,
603604
case 0x16:
604605
max_size = F16H_MPB_MAX_SIZE;
605606
break;
607+
case 0x17:
608+
max_size = F17H_MPB_MAX_SIZE;
609+
break;
606610
default:
607611
max_size = F1XH_MPB_MAX_SIZE;
608612
break;

arch/x86/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = {
768768
.state = 0,
769769
.cr4 = ~0UL, /* fail hard if we screw up cr4 shadow initialization */
770770
};
771-
EXPORT_SYMBOL_GPL(cpu_tlbstate);
771+
EXPORT_PER_CPU_SYMBOL(cpu_tlbstate);
772772

773773
void update_cache_mode_entry(unsigned entry, enum page_cache_mode cache)
774774
{

arch/x86/mm/kaiser.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <asm/pgalloc.h>
2020
#include <asm/desc.h>
2121
#include <asm/cmdline.h>
22+
#include <asm/vsyscall.h>
2223

2324
int kaiser_enabled __read_mostly = 1;
2425
EXPORT_SYMBOL(kaiser_enabled); /* for inlined TLB flush functions */
@@ -110,19 +111,31 @@ static inline unsigned long get_pa_from_mapping(unsigned long vaddr)
110111
*
111112
* Returns a pointer to a PTE on success, or NULL on failure.
112113
*/
113-
static pte_t *kaiser_pagetable_walk(unsigned long address)
114+
static pte_t *kaiser_pagetable_walk(unsigned long address, bool user)
114115
{
115116
pmd_t *pmd;
116117
pud_t *pud;
117118
pgd_t *pgd = native_get_shadow_pgd(pgd_offset_k(address));
118119
gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO);
120+
unsigned long prot = _KERNPG_TABLE;
119121

120122
if (pgd_none(*pgd)) {
121123
WARN_ONCE(1, "All shadow pgds should have been populated");
122124
return NULL;
123125
}
124126
BUILD_BUG_ON(pgd_large(*pgd) != 0);
125127

128+
if (user) {
129+
/*
130+
* The vsyscall page is the only page that will have
131+
* _PAGE_USER set. Catch everything else.
132+
*/
133+
BUG_ON(address != VSYSCALL_ADDR);
134+
135+
set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER));
136+
prot = _PAGE_TABLE;
137+
}
138+
126139
pud = pud_offset(pgd, address);
127140
/* The shadow page tables do not use large mappings: */
128141
if (pud_large(*pud)) {
@@ -135,7 +148,7 @@ static pte_t *kaiser_pagetable_walk(unsigned long address)
135148
return NULL;
136149
spin_lock(&shadow_table_allocation_lock);
137150
if (pud_none(*pud)) {
138-
set_pud(pud, __pud(_KERNPG_TABLE | __pa(new_pmd_page)));
151+
set_pud(pud, __pud(prot | __pa(new_pmd_page)));
139152
__inc_zone_page_state(virt_to_page((void *)
140153
new_pmd_page), NR_KAISERTABLE);
141154
} else
@@ -155,7 +168,7 @@ static pte_t *kaiser_pagetable_walk(unsigned long address)
155168
return NULL;
156169
spin_lock(&shadow_table_allocation_lock);
157170
if (pmd_none(*pmd)) {
158-
set_pmd(pmd, __pmd(_KERNPG_TABLE | __pa(new_pte_page)));
171+
set_pmd(pmd, __pmd(prot | __pa(new_pte_page)));
159172
__inc_zone_page_state(virt_to_page((void *)
160173
new_pte_page), NR_KAISERTABLE);
161174
} else
@@ -191,7 +204,7 @@ static int kaiser_add_user_map(const void *__start_addr, unsigned long size,
191204
ret = -EIO;
192205
break;
193206
}
194-
pte = kaiser_pagetable_walk(address);
207+
pte = kaiser_pagetable_walk(address, flags & _PAGE_USER);
195208
if (!pte) {
196209
ret = -ENOMEM;
197210
break;
@@ -318,6 +331,19 @@ void __init kaiser_init(void)
318331

319332
kaiser_init_all_pgds();
320333

334+
/*
335+
* Note that this sets _PAGE_USER and it needs to happen when the
336+
* pagetable hierarchy gets created, i.e., early. Otherwise
337+
* kaiser_pagetable_walk() will encounter initialized PTEs in the
338+
* hierarchy and not set the proper permissions, leading to the
339+
* pagefaults with page-protection violations when trying to read the
340+
* vsyscall page. For example.
341+
*/
342+
if (vsyscall_enabled())
343+
kaiser_add_user_map_early((void *)VSYSCALL_ADDR,
344+
PAGE_SIZE,
345+
__PAGE_KERNEL_VSYSCALL);
346+
321347
for_each_possible_cpu(cpu) {
322348
void *percpu_vaddr = __per_cpu_user_mapped_start +
323349
per_cpu_offset(cpu);

crypto/chacha20poly1305.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ static int chachapoly_create(struct crypto_template *tmpl, struct rtattr **tb,
610610
algt->mask));
611611
if (IS_ERR(poly))
612612
return PTR_ERR(poly);
613+
poly_hash = __crypto_hash_alg_common(poly);
614+
615+
err = -EINVAL;
616+
if (poly_hash->digestsize != POLY1305_DIGEST_SIZE)
617+
goto out_put_poly;
613618

614619
err = -ENOMEM;
615620
inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
@@ -618,7 +623,6 @@ static int chachapoly_create(struct crypto_template *tmpl, struct rtattr **tb,
618623

619624
ctx = aead_instance_ctx(inst);
620625
ctx->saltlen = CHACHAPOLY_IV_SIZE - ivsize;
621-
poly_hash = __crypto_hash_alg_common(poly);
622626
err = crypto_init_ahash_spawn(&ctx->poly, poly_hash,
623627
aead_crypto_instance(inst));
624628
if (err)

crypto/pcrypt.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ static void pcrypt_aead_exit_tfm(struct crypto_aead *tfm)
254254
crypto_free_aead(ctx->child);
255255
}
256256

257+
static void pcrypt_free(struct aead_instance *inst)
258+
{
259+
struct pcrypt_instance_ctx *ctx = aead_instance_ctx(inst);
260+
261+
crypto_drop_aead(&ctx->spawn);
262+
kfree(inst);
263+
}
264+
257265
static int pcrypt_init_instance(struct crypto_instance *inst,
258266
struct crypto_alg *alg)
259267
{
@@ -319,6 +327,8 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb,
319327
inst->alg.encrypt = pcrypt_aead_encrypt;
320328
inst->alg.decrypt = pcrypt_aead_decrypt;
321329

330+
inst->free = pcrypt_free;
331+
322332
err = aead_register_instance(tmpl, inst);
323333
if (err)
324334
goto out_drop_aead;
@@ -349,14 +359,6 @@ static int pcrypt_create(struct crypto_template *tmpl, struct rtattr **tb)
349359
return -EINVAL;
350360
}
351361

352-
static void pcrypt_free(struct crypto_instance *inst)
353-
{
354-
struct pcrypt_instance_ctx *ctx = crypto_instance_ctx(inst);
355-
356-
crypto_drop_aead(&ctx->spawn);
357-
kfree(inst);
358-
}
359-
360362
static int pcrypt_cpumask_change_notify(struct notifier_block *self,
361363
unsigned long val, void *data)
362364
{
@@ -469,7 +471,6 @@ static void pcrypt_fini_padata(struct padata_pcrypt *pcrypt)
469471
static struct crypto_template pcrypt_tmpl = {
470472
.name = "pcrypt",
471473
.create = pcrypt_create,
472-
.free = pcrypt_free,
473474
.module = THIS_MODULE,
474475
};
475476

0 commit comments

Comments
 (0)