Skip to content

Commit 2572da4

Browse files
committed
Merge tag 'for-5.17/parisc-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
Pull parisc architecture fixes from Helge Deller: - Fix miscompilations when function calls are made from inside a put_user() call - Drop __init from map_pages() declaration to avoid random boot crashes - Added #error messages if a 64-bit compiler was used to build a 32-bit kernel (and vice versa) - Fix out-of-bound data TLB miss faults in sba_iommu and ccio-dma drivers - Add ioread64_lo_hi() and iowrite64_lo_hi() functions to avoid kernel test robot errors - Fix link failure when 8250_gsc driver is built without CONFIG_IOSAPIC * tag 'for-5.17/parisc-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: serial: parisc: GSC: fix build when IOSAPIC is not set parisc: Fix some apparent put_user() failures parisc: Show error if wrong 32/64-bit compiler is being used parisc: Add ioread64_lo_hi() and iowrite64_lo_hi() parisc: Fix sglist access in ccio-dma.c parisc: Fix data TLB miss in sba_unmap_sg parisc: Drop __init from map_pages declaration
2 parents c24449b + 6e87936 commit 2572da4

File tree

7 files changed

+50
-22
lines changed

7 files changed

+50
-22
lines changed

arch/parisc/include/asm/bitops.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
#include <asm/barrier.h>
1313
#include <linux/atomic.h>
1414

15+
/* compiler build environment sanity checks: */
16+
#if !defined(CONFIG_64BIT) && defined(__LP64__)
17+
#error "Please use 'ARCH=parisc' to build the 32-bit kernel."
18+
#endif
19+
#if defined(CONFIG_64BIT) && !defined(__LP64__)
20+
#error "Please use 'ARCH=parisc64' to build the 64-bit kernel."
21+
#endif
22+
1523
/* See http://marc.theaimsgroup.com/?t=108826637900003 for discussion
1624
* on use of volatile and __*_bit() (set/clear/change):
1725
* *_bit() want use of volatile.

arch/parisc/include/asm/uaccess.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ struct exception_table_entry {
8989
__asm__("1: " ldx " 0(" sr "%2),%0\n" \
9090
"9:\n" \
9191
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
92-
: "=r"(__gu_val), "=r"(__gu_err) \
93-
: "r"(ptr), "1"(__gu_err)); \
92+
: "=r"(__gu_val), "+r"(__gu_err) \
93+
: "r"(ptr)); \
9494
\
9595
(val) = (__force __typeof__(*(ptr))) __gu_val; \
9696
}
@@ -123,8 +123,8 @@ struct exception_table_entry {
123123
"9:\n" \
124124
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
125125
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
126-
: "=&r"(__gu_tmp.l), "=r"(__gu_err) \
127-
: "r"(ptr), "1"(__gu_err)); \
126+
: "=&r"(__gu_tmp.l), "+r"(__gu_err) \
127+
: "r"(ptr)); \
128128
\
129129
(val) = __gu_tmp.t; \
130130
}
@@ -135,13 +135,12 @@ struct exception_table_entry {
135135
#define __put_user_internal(sr, x, ptr) \
136136
({ \
137137
ASM_EXCEPTIONTABLE_VAR(__pu_err); \
138-
__typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \
139138
\
140139
switch (sizeof(*(ptr))) { \
141-
case 1: __put_user_asm(sr, "stb", __x, ptr); break; \
142-
case 2: __put_user_asm(sr, "sth", __x, ptr); break; \
143-
case 4: __put_user_asm(sr, "stw", __x, ptr); break; \
144-
case 8: STD_USER(sr, __x, ptr); break; \
140+
case 1: __put_user_asm(sr, "stb", x, ptr); break; \
141+
case 2: __put_user_asm(sr, "sth", x, ptr); break; \
142+
case 4: __put_user_asm(sr, "stw", x, ptr); break; \
143+
case 8: STD_USER(sr, x, ptr); break; \
145144
default: BUILD_BUG(); \
146145
} \
147146
\
@@ -150,7 +149,9 @@ struct exception_table_entry {
150149

151150
#define __put_user(x, ptr) \
152151
({ \
153-
__put_user_internal("%%sr3,", x, ptr); \
152+
__typeof__(&*(ptr)) __ptr = ptr; \
153+
__typeof__(*(__ptr)) __x = (__typeof__(*(__ptr)))(x); \
154+
__put_user_internal("%%sr3,", __x, __ptr); \
154155
})
155156

156157
#define __put_kernel_nofault(dst, src, type, err_label) \
@@ -180,8 +181,8 @@ struct exception_table_entry {
180181
"1: " stx " %2,0(" sr "%1)\n" \
181182
"9:\n" \
182183
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
183-
: "=r"(__pu_err) \
184-
: "r"(ptr), "r"(x), "0"(__pu_err))
184+
: "+r"(__pu_err) \
185+
: "r"(ptr), "r"(x))
185186

186187

187188
#if !defined(CONFIG_64BIT)
@@ -193,8 +194,8 @@ struct exception_table_entry {
193194
"9:\n" \
194195
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
195196
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
196-
: "=r"(__pu_err) \
197-
: "r"(ptr), "r"(__val), "0"(__pu_err)); \
197+
: "+r"(__pu_err) \
198+
: "r"(ptr), "r"(__val)); \
198199
} while (0)
199200

200201
#endif /* !defined(CONFIG_64BIT) */

arch/parisc/lib/iomap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,16 @@ u64 ioread64be(const void __iomem *addr)
346346
return *((u64 *)addr);
347347
}
348348

349+
u64 ioread64_lo_hi(const void __iomem *addr)
350+
{
351+
u32 low, high;
352+
353+
low = ioread32(addr);
354+
high = ioread32(addr + sizeof(u32));
355+
356+
return low + ((u64)high << 32);
357+
}
358+
349359
u64 ioread64_hi_lo(const void __iomem *addr)
350360
{
351361
u32 low, high;
@@ -419,6 +429,12 @@ void iowrite64be(u64 datum, void __iomem *addr)
419429
}
420430
}
421431

432+
void iowrite64_lo_hi(u64 val, void __iomem *addr)
433+
{
434+
iowrite32(val, addr);
435+
iowrite32(val >> 32, addr + sizeof(u32));
436+
}
437+
422438
void iowrite64_hi_lo(u64 val, void __iomem *addr)
423439
{
424440
iowrite32(val >> 32, addr + sizeof(u32));
@@ -530,6 +546,7 @@ EXPORT_SYMBOL(ioread32);
530546
EXPORT_SYMBOL(ioread32be);
531547
EXPORT_SYMBOL(ioread64);
532548
EXPORT_SYMBOL(ioread64be);
549+
EXPORT_SYMBOL(ioread64_lo_hi);
533550
EXPORT_SYMBOL(ioread64_hi_lo);
534551
EXPORT_SYMBOL(iowrite8);
535552
EXPORT_SYMBOL(iowrite16);
@@ -538,6 +555,7 @@ EXPORT_SYMBOL(iowrite32);
538555
EXPORT_SYMBOL(iowrite32be);
539556
EXPORT_SYMBOL(iowrite64);
540557
EXPORT_SYMBOL(iowrite64be);
558+
EXPORT_SYMBOL(iowrite64_lo_hi);
541559
EXPORT_SYMBOL(iowrite64_hi_lo);
542560
EXPORT_SYMBOL(ioread8_rep);
543561
EXPORT_SYMBOL(ioread16_rep);

arch/parisc/mm/init.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ static void __init setup_bootmem(void)
337337

338338
static bool kernel_set_to_readonly;
339339

340-
static void __init map_pages(unsigned long start_vaddr,
341-
unsigned long start_paddr, unsigned long size,
342-
pgprot_t pgprot, int force)
340+
static void __ref map_pages(unsigned long start_vaddr,
341+
unsigned long start_paddr, unsigned long size,
342+
pgprot_t pgprot, int force)
343343
{
344344
pmd_t *pmd;
345345
pte_t *pg_table;
@@ -449,7 +449,7 @@ void __init set_kernel_text_rw(int enable_read_write)
449449
flush_tlb_all();
450450
}
451451

452-
void __ref free_initmem(void)
452+
void free_initmem(void)
453453
{
454454
unsigned long init_begin = (unsigned long)__init_begin;
455455
unsigned long init_end = (unsigned long)__init_end;
@@ -463,7 +463,6 @@ void __ref free_initmem(void)
463463
/* The init text pages are marked R-X. We have to
464464
* flush the icache and mark them RW-
465465
*
466-
* This is tricky, because map_pages is in the init section.
467466
* Do a dummy remap of the data section first (the data
468467
* section is already PAGE_KERNEL) to pull in the TLB entries
469468
* for map_kernel */

drivers/parisc/ccio-dma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,14 +1003,15 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
10031003
ioc->usg_calls++;
10041004
#endif
10051005

1006-
while(sg_dma_len(sglist) && nents--) {
1006+
while (nents && sg_dma_len(sglist)) {
10071007

10081008
#ifdef CCIO_COLLECT_STATS
10091009
ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT;
10101010
#endif
10111011
ccio_unmap_page(dev, sg_dma_address(sglist),
10121012
sg_dma_len(sglist), direction, 0);
10131013
++sglist;
1014+
nents--;
10141015
}
10151016

10161017
DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);

drivers/parisc/sba_iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
10471047
spin_unlock_irqrestore(&ioc->res_lock, flags);
10481048
#endif
10491049

1050-
while (sg_dma_len(sglist) && nents--) {
1050+
while (nents && sg_dma_len(sglist)) {
10511051

10521052
sba_unmap_page(dev, sg_dma_address(sglist), sg_dma_len(sglist),
10531053
direction, 0);
@@ -1056,6 +1056,7 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
10561056
ioc->usingle_calls--; /* kluge since call is unmap_sg() */
10571057
#endif
10581058
++sglist;
1059+
nents--;
10591060
}
10601061

10611062
DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);

drivers/tty/serial/8250/8250_gsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int __init serial_init_chip(struct parisc_device *dev)
2626
unsigned long address;
2727
int err;
2828

29-
#ifdef CONFIG_64BIT
29+
#if defined(CONFIG_64BIT) && defined(CONFIG_IOSAPIC)
3030
if (!dev->irq && (dev->id.sversion == 0xad))
3131
dev->irq = iosapic_serial_irq(dev);
3232
#endif

0 commit comments

Comments
 (0)