Skip to content

Commit 2eb5866

Browse files
committed
Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM fixes from Russell King: - quieten the spectre-bhb prints - mark flattened device tree sections as shareable - remove some obsolete CPU domain code and help text - fix thumb unaligned access abort emulation - fix amba_device_add() refcount underflow - fix literal placement * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm: ARM: 9208/1: entry: add .ltorg directive to keep literals in range ARM: 9207/1: amba: fix refcount underflow if amba_device_add() fails ARM: 9214/1: alignment: advance IT state after emulating Thumb instruction ARM: 9213/1: Print message about disabled Spectre workarounds only once ARM: 9212/1: domain: Modify Kconfig help text ARM: 9211/1: domain: drop modify_domain() ARM: 9210/1: Mark the FDT_FIXED sections as shareable ARM: 9209/1: Spectre-BHB: avoid pr_info() every time a CPU comes out of idle
2 parents 097da1a + 29589ca commit 2eb5866

10 files changed

Lines changed: 57 additions & 51 deletions

File tree

arch/arm/include/asm/domain.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,6 @@ static __always_inline void set_domain(unsigned int val)
112112
}
113113
#endif
114114

115-
#ifdef CONFIG_CPU_USE_DOMAINS
116-
#define modify_domain(dom,type) \
117-
do { \
118-
unsigned int domain = get_domain(); \
119-
domain &= ~domain_mask(dom); \
120-
domain = domain | domain_val(dom, type); \
121-
set_domain(domain); \
122-
} while (0)
123-
124-
#else
125-
static inline void modify_domain(unsigned dom, unsigned type) { }
126-
#endif
127-
128115
/*
129116
* Generate the T (user) versions of the LDR/STR and related
130117
* instructions (inline assembly)

arch/arm/include/asm/mach/map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum {
2727
MT_HIGH_VECTORS,
2828
MT_MEMORY_RWX,
2929
MT_MEMORY_RW,
30+
MT_MEMORY_RO,
3031
MT_ROM,
3132
MT_MEMORY_RWX_NONCACHED,
3233
MT_MEMORY_RW_DTCM,

arch/arm/include/asm/ptrace.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,31 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
163163
((current_stack_pointer | (THREAD_SIZE - 1)) - 7) - 1; \
164164
})
165165

166+
167+
/*
168+
* Update ITSTATE after normal execution of an IT block instruction.
169+
*
170+
* The 8 IT state bits are split into two parts in CPSR:
171+
* ITSTATE<1:0> are in CPSR<26:25>
172+
* ITSTATE<7:2> are in CPSR<15:10>
173+
*/
174+
static inline unsigned long it_advance(unsigned long cpsr)
175+
{
176+
if ((cpsr & 0x06000400) == 0) {
177+
/* ITSTATE<2:0> == 0 means end of IT block, so clear IT state */
178+
cpsr &= ~PSR_IT_MASK;
179+
} else {
180+
/* We need to shift left ITSTATE<4:0> */
181+
const unsigned long mask = 0x06001c00; /* Mask ITSTATE<4:0> */
182+
unsigned long it = cpsr & mask;
183+
it <<= 1;
184+
it |= it >> (27 - 10); /* Carry ITSTATE<2> to correct place */
185+
it &= mask;
186+
cpsr &= ~mask;
187+
cpsr |= it;
188+
}
189+
return cpsr;
190+
}
191+
166192
#endif /* __ASSEMBLY__ */
167193
#endif

arch/arm/kernel/entry-common.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ local_restart:
302302
b ret_fast_syscall
303303
#endif
304304
ENDPROC(vector_swi)
305+
.ltorg
305306

306307
/*
307308
* This is the really slow path. We're going to be doing

arch/arm/mm/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,11 @@ config CPU_USE_DOMAINS
631631
bool
632632
help
633633
This option enables or disables the use of domain switching
634-
via the set_fs() function.
634+
using the DACR (domain access control register) to protect memory
635+
domains from each other. In Linux we use three domains: kernel, user
636+
and IO. The domains are used to protect userspace from kernelspace
637+
and to handle IO-space as a special type of memory by assigning
638+
manager or client roles to running code (such as a process).
635639

636640
config CPU_V7M_NUM_IRQ
637641
int "Number of external interrupts connected to the NVIC"

arch/arm/mm/alignment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,9 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
935935
if (type == TYPE_LDST)
936936
do_alignment_finish_ldst(addr, instr, regs, offset);
937937

938+
if (thumb_mode(regs))
939+
regs->ARM_cpsr = it_advance(regs->ARM_cpsr);
940+
938941
return 0;
939942

940943
bad_or_fault:

arch/arm/mm/mmu.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ static struct mem_type mem_types[] __ro_after_init = {
296296
.prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
297297
.domain = DOMAIN_KERNEL,
298298
},
299+
[MT_MEMORY_RO] = {
300+
.prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
301+
L_PTE_XN | L_PTE_RDONLY,
302+
.prot_l1 = PMD_TYPE_TABLE,
303+
.prot_sect = PMD_TYPE_SECT,
304+
.domain = DOMAIN_KERNEL,
305+
},
299306
[MT_ROM] = {
300307
.prot_sect = PMD_TYPE_SECT,
301308
.domain = DOMAIN_KERNEL,
@@ -489,6 +496,7 @@ static void __init build_mem_type_table(void)
489496

490497
/* Also setup NX memory mapping */
491498
mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
499+
mem_types[MT_MEMORY_RO].prot_sect |= PMD_SECT_XN;
492500
}
493501
if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
494502
/*
@@ -568,6 +576,7 @@ static void __init build_mem_type_table(void)
568576
mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
569577
mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
570578
mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
579+
mem_types[MT_MEMORY_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
571580
#endif
572581

573582
/*
@@ -587,6 +596,8 @@ static void __init build_mem_type_table(void)
587596
mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
588597
mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
589598
mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
599+
mem_types[MT_MEMORY_RO].prot_sect |= PMD_SECT_S;
600+
mem_types[MT_MEMORY_RO].prot_pte |= L_PTE_SHARED;
590601
mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
591602
mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_S;
592603
mem_types[MT_MEMORY_RWX_NONCACHED].prot_pte |= L_PTE_SHARED;
@@ -647,6 +658,8 @@ static void __init build_mem_type_table(void)
647658
mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
648659
mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
649660
mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
661+
mem_types[MT_MEMORY_RO].prot_sect |= ecc_mask | cp->pmd;
662+
mem_types[MT_MEMORY_RO].prot_pte |= kern_pgprot;
650663
mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
651664
mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= ecc_mask;
652665
mem_types[MT_ROM].prot_sect |= cp->pmd;
@@ -1360,7 +1373,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
13601373
map.pfn = __phys_to_pfn(__atags_pointer & SECTION_MASK);
13611374
map.virtual = FDT_FIXED_BASE;
13621375
map.length = FDT_FIXED_SIZE;
1363-
map.type = MT_ROM;
1376+
map.type = MT_MEMORY_RO;
13641377
create_mapping(&map);
13651378
}
13661379

arch/arm/mm/proc-v7-bugs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ static unsigned int spectre_v2_install_workaround(unsigned int method)
108108
#else
109109
static unsigned int spectre_v2_install_workaround(unsigned int method)
110110
{
111-
pr_info("CPU%u: Spectre V2: workarounds disabled by configuration\n",
112-
smp_processor_id());
111+
pr_info_once("Spectre V2: workarounds disabled by configuration\n");
113112

114113
return SPECTRE_VULNERABLE;
115114
}
@@ -209,10 +208,10 @@ static int spectre_bhb_install_workaround(int method)
209208
return SPECTRE_VULNERABLE;
210209

211210
spectre_bhb_method = method;
212-
}
213211

214-
pr_info("CPU%u: Spectre BHB: using %s workaround\n",
215-
smp_processor_id(), spectre_bhb_method_name(method));
212+
pr_info("CPU%u: Spectre BHB: enabling %s workaround for all CPUs\n",
213+
smp_processor_id(), spectre_bhb_method_name(method));
214+
}
216215

217216
return SPECTRE_MITIGATED;
218217
}

arch/arm/probes/decode.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/types.h>
1515
#include <linux/stddef.h>
1616
#include <asm/probes.h>
17+
#include <asm/ptrace.h>
1718
#include <asm/kprobes.h>
1819

1920
void __init arm_probes_decode_init(void);
@@ -35,31 +36,6 @@ void __init find_str_pc_offset(void);
3536
#endif
3637

3738

38-
/*
39-
* Update ITSTATE after normal execution of an IT block instruction.
40-
*
41-
* The 8 IT state bits are split into two parts in CPSR:
42-
* ITSTATE<1:0> are in CPSR<26:25>
43-
* ITSTATE<7:2> are in CPSR<15:10>
44-
*/
45-
static inline unsigned long it_advance(unsigned long cpsr)
46-
{
47-
if ((cpsr & 0x06000400) == 0) {
48-
/* ITSTATE<2:0> == 0 means end of IT block, so clear IT state */
49-
cpsr &= ~PSR_IT_MASK;
50-
} else {
51-
/* We need to shift left ITSTATE<4:0> */
52-
const unsigned long mask = 0x06001c00; /* Mask ITSTATE<4:0> */
53-
unsigned long it = cpsr & mask;
54-
it <<= 1;
55-
it |= it >> (27 - 10); /* Carry ITSTATE<2> to correct place */
56-
it &= mask;
57-
cpsr &= ~mask;
58-
cpsr |= it;
59-
}
60-
return cpsr;
61-
}
62-
6339
static inline void __kprobes bx_write_pc(long pcv, struct pt_regs *regs)
6440
{
6541
long cpsr = regs->ARM_cpsr;

drivers/amba/bus.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,8 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
493493
goto skip_probe;
494494

495495
ret = amba_read_periphid(dev);
496-
if (ret) {
497-
if (ret != -EPROBE_DEFER) {
498-
amba_device_put(dev);
499-
goto err_out;
500-
}
496+
if (ret)
501497
goto err_release;
502-
}
503498

504499
skip_probe:
505500
ret = device_add(&dev->dev);
@@ -546,6 +541,7 @@ static int amba_deferred_retry(void)
546541
continue;
547542

548543
list_del_init(&ddev->node);
544+
amba_device_put(ddev->dev);
549545
kfree(ddev);
550546
}
551547

0 commit comments

Comments
 (0)