Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'parisc-for-6.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux

Pull parisc updates from Helge Deller:
"Fixes:

- When we added basic vDSO support in kernel 5.18 we introduced a bug
which prevented a mmap() of graphic card memory. This is because we
used the DMB (data memory break trap bit) page flag as special-bit,
but missed to clear that bit when loading the TLB.

- Graphics card memory size was not correctly aligned

- Spelling fixes (from Colin Ian King)

Enhancements:

- PDC console (which uses firmware calls) now rewritten as early
console

- Reduced size of alternative tables"

* tag 'parisc-for-6.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
parisc: Fix spelling mistake "mis-match" -> "mismatch" in eisa driver
parisc: Fix userspace graphics card breakage due to pgtable special bit
parisc: fbdev/stifb: Align graphics memory size to 4MB
parisc: Convert PDC console to an early console
parisc: Reduce kernel size by packing alternative tables

+67 -267
+12 -9
arch/parisc/include/asm/alternative.h
··· 22 22 23 23 struct alt_instr { 24 24 s32 orig_offset; /* offset to original instructions */ 25 - s32 len; /* end of original instructions */ 26 - u32 cond; /* see ALT_COND_XXX */ 25 + s16 len; /* end of original instructions */ 26 + u16 cond; /* see ALT_COND_XXX */ 27 27 u32 replacement; /* replacement instruction or code */ 28 - }; 28 + } __packed; 29 29 30 30 void set_kernel_text_rw(int enable_read_write); 31 31 void apply_alternatives_all(void); ··· 35 35 /* Alternative SMP implementation. */ 36 36 #define ALTERNATIVE(cond, replacement) "!0:" \ 37 37 ".section .altinstructions, \"aw\" !" \ 38 - ".word (0b-4-.), 1, " __stringify(cond) "," \ 39 - __stringify(replacement) " !" \ 38 + ".word (0b-4-.) !" \ 39 + ".hword 1, " __stringify(cond) " !" \ 40 + ".word " __stringify(replacement) " !" \ 40 41 ".previous" 41 42 42 43 #else ··· 45 44 /* to replace one single instructions by a new instruction */ 46 45 #define ALTERNATIVE(from, to, cond, replacement)\ 47 46 .section .altinstructions, "aw" ! \ 48 - .word (from - .), (to - from)/4 ! \ 49 - .word cond, replacement ! \ 47 + .word (from - .) ! \ 48 + .hword (to - from)/4, cond ! \ 49 + .word replacement ! \ 50 50 .previous 51 51 52 52 /* to replace multiple instructions by new code */ 53 53 #define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\ 54 54 .section .altinstructions, "aw" ! \ 55 - .word (from - .), -num_instructions ! \ 56 - .word cond, (new_instr_ptr - .) ! \ 55 + .word (from - .) ! \ 56 + .hword -num_instructions, cond ! \ 57 + .word (new_instr_ptr - .) ! \ 57 58 .previous 58 59 59 60 #endif /* __ASSEMBLY__ */
-3
arch/parisc/include/asm/pdc.h
··· 19 19 #define PDC_TYPE_SYSTEM_MAP 1 /* 32-bit, but supports PDC_SYSTEM_MAP */ 20 20 #define PDC_TYPE_SNAKE 2 /* Doesn't support SYSTEM_MAP */ 21 21 22 - void pdc_console_init(void); /* in pdc_console.c */ 23 - void pdc_console_restart(void); 24 - 25 22 void setup_pdc(void); /* in inventory.c */ 26 23 27 24 /* wrapper-functions from pdc.c */
+6 -1
arch/parisc/include/asm/pgtable.h
··· 192 192 #define _PAGE_PRESENT_BIT 22 /* (0x200) Software: translation valid */ 193 193 #define _PAGE_HPAGE_BIT 21 /* (0x400) Software: Huge Page */ 194 194 #define _PAGE_USER_BIT 20 /* (0x800) Software: User accessible page */ 195 + #ifdef CONFIG_HUGETLB_PAGE 196 + #define _PAGE_SPECIAL_BIT _PAGE_DMB_BIT /* DMB feature is currently unused */ 197 + #else 198 + #define _PAGE_SPECIAL_BIT _PAGE_HPAGE_BIT /* use unused HUGE PAGE bit */ 199 + #endif 195 200 196 201 /* N.B. The bits are defined in terms of a 32 bit word above, so the */ 197 202 /* following macro is ok for both 32 and 64 bit. */ ··· 224 219 #define _PAGE_PRESENT (1 << xlate_pabit(_PAGE_PRESENT_BIT)) 225 220 #define _PAGE_HUGE (1 << xlate_pabit(_PAGE_HPAGE_BIT)) 226 221 #define _PAGE_USER (1 << xlate_pabit(_PAGE_USER_BIT)) 227 - #define _PAGE_SPECIAL (_PAGE_DMB) 222 + #define _PAGE_SPECIAL (1 << xlate_pabit(_PAGE_SPECIAL_BIT)) 228 223 229 224 #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | _PAGE_DIRTY | _PAGE_ACCESSED) 230 225 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_SPECIAL)
+4 -3
arch/parisc/kernel/alternative.c
··· 26 26 struct alt_instr *entry; 27 27 int index = 0, applied = 0; 28 28 int num_cpus = num_online_cpus(); 29 - u32 cond_check; 29 + u16 cond_check; 30 30 31 31 cond_check = ALT_COND_ALWAYS | 32 32 ((num_cpus == 1) ? ALT_COND_NO_SMP : 0) | ··· 45 45 46 46 for (entry = start; entry < end; entry++, index++) { 47 47 48 - u32 *from, cond, replacement; 49 - s32 len; 48 + u32 *from, replacement; 49 + u16 cond; 50 + s16 len; 50 51 51 52 from = (u32 *)((ulong)&entry->orig_offset + entry->orig_offset); 52 53 len = entry->len;
+8
arch/parisc/kernel/entry.S
··· 499 499 * Finally, _PAGE_READ goes in the top bit of PL1 (so we 500 500 * trigger an access rights trap in user space if the user 501 501 * tries to read an unreadable page */ 502 + #if _PAGE_SPECIAL_BIT == _PAGE_DMB_BIT 503 + /* need to drop DMB bit, as it's used as SPECIAL flag */ 504 + depi 0,_PAGE_SPECIAL_BIT,1,\pte 505 + #endif 502 506 depd \pte,8,7,\prot 503 507 504 508 /* PAGE_USER indicates the page can be read with user privileges, ··· 533 529 * makes the tlb entry for the differently formatted pa11 534 530 * insertion instructions */ 535 531 .macro make_insert_tlb_11 spc,pte,prot 532 + #if _PAGE_SPECIAL_BIT == _PAGE_DMB_BIT 533 + /* need to drop DMB bit, as it's used as SPECIAL flag */ 534 + depi 0,_PAGE_SPECIAL_BIT,1,\pte 535 + #endif 536 536 zdep \spc,30,15,\prot 537 537 dep \pte,8,7,\prot 538 538 extru,= \pte,_PAGE_NO_CACHE_BIT,1,%r0
+26 -214
arch/parisc/kernel/pdc_cons.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 /* 3 - * PDC Console support - ie use firmware to dump text via boot console 3 + * PDC early console support - use PDC firmware to dump text via boot console 4 4 * 5 - * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org> 6 - * Copyright (C) 2000 Martin K Petersen <mkp at mkp.net> 7 - * Copyright (C) 2000 John Marvin <jsm at parisc-linux.org> 8 - * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> 9 - * Copyright (C) 2000 Philipp Rumpf <prumpf with tux.org> 10 - * Copyright (C) 2000 Michael Ang <mang with subcarrier.org> 11 - * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org> 12 - * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org> 13 - * Copyright (C) 2001 Helge Deller <deller at parisc-linux.org> 14 - * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> 15 - * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org> 16 - * Copyright (C) 2010 Guy Martin <gmsoft at tuxicoman.be> 5 + * Copyright (C) 2001-2022 Helge Deller <deller@gmx.de> 17 6 */ 18 7 19 - /* 20 - * The PDC console is a simple console, which can be used for debugging 21 - * boot related problems on HP PA-RISC machines. It is also useful when no 22 - * other console works. 23 - * 24 - * This code uses the ROM (=PDC) based functions to read and write characters 25 - * from and to PDC's boot path. 26 - */ 27 - 28 - /* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems. 29 - * On production kernels EARLY_BOOTUP_DEBUG should be undefined. */ 30 - #define EARLY_BOOTUP_DEBUG 31 - 32 - 33 - #include <linux/kernel.h> 34 8 #include <linux/console.h> 35 - #include <linux/string.h> 36 9 #include <linux/init.h> 37 - #include <linux/major.h> 38 - #include <linux/tty.h> 10 + #include <linux/serial_core.h> 11 + #include <linux/kgdb.h> 39 12 #include <asm/page.h> /* for PAGE0 */ 40 13 #include <asm/pdc.h> /* for iodc_call() proto and friends */ 41 14 42 15 static DEFINE_SPINLOCK(pdc_console_lock); 43 - static struct console pdc_cons; 44 16 45 17 static void pdc_console_write(struct console *co, const char *s, unsigned count) 46 18 { ··· 26 54 spin_unlock_irqrestore(&pdc_console_lock, flags); 27 55 } 28 56 29 - int pdc_console_poll_key(struct console *co) 57 + #ifdef CONFIG_KGDB 58 + static int kgdb_pdc_read_char(void) 30 59 { 31 60 int c; 32 61 unsigned long flags; ··· 36 63 c = pdc_iodc_getc(); 37 64 spin_unlock_irqrestore(&pdc_console_lock, flags); 38 65 39 - return c; 66 + return (c <= 0) ? NO_POLL_CHAR : c; 40 67 } 41 68 42 - static int pdc_console_setup(struct console *co, char *options) 69 + static void kgdb_pdc_write_char(u8 chr) 43 70 { 44 - return 0; 71 + if (PAGE0->mem_cons.cl_class != CL_DUPLEX) 72 + pdc_console_write(NULL, &chr, 1); 45 73 } 46 74 47 - #if defined(CONFIG_PDC_CONSOLE) 48 - #include <linux/vt_kern.h> 49 - #include <linux/tty_flip.h> 50 - 51 - #define PDC_CONS_POLL_DELAY (30 * HZ / 1000) 52 - 53 - static void pdc_console_poll(struct timer_list *unused); 54 - static DEFINE_TIMER(pdc_console_timer, pdc_console_poll); 55 - static struct tty_port tty_port; 56 - 57 - static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp) 58 - { 59 - tty_port_tty_set(&tty_port, tty); 60 - mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); 61 - 62 - return 0; 63 - } 64 - 65 - static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp) 66 - { 67 - if (tty->count == 1) { 68 - del_timer_sync(&pdc_console_timer); 69 - tty_port_tty_set(&tty_port, NULL); 70 - } 71 - } 72 - 73 - static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) 74 - { 75 - pdc_console_write(NULL, buf, count); 76 - return count; 77 - } 78 - 79 - static unsigned int pdc_console_tty_write_room(struct tty_struct *tty) 80 - { 81 - return 32768; /* no limit, no buffer used */ 82 - } 83 - 84 - static const struct tty_operations pdc_console_tty_ops = { 85 - .open = pdc_console_tty_open, 86 - .close = pdc_console_tty_close, 87 - .write = pdc_console_tty_write, 88 - .write_room = pdc_console_tty_write_room, 75 + static struct kgdb_io kgdb_pdc_io_ops = { 76 + .name = "kgdb_pdc", 77 + .read_char = kgdb_pdc_read_char, 78 + .write_char = kgdb_pdc_write_char, 89 79 }; 90 - 91 - static void pdc_console_poll(struct timer_list *unused) 92 - { 93 - int data, count = 0; 94 - 95 - while (1) { 96 - data = pdc_console_poll_key(NULL); 97 - if (data == -1) 98 - break; 99 - tty_insert_flip_char(&tty_port, data & 0xFF, TTY_NORMAL); 100 - count ++; 101 - } 102 - 103 - if (count) 104 - tty_flip_buffer_push(&tty_port); 105 - 106 - if (pdc_cons.flags & CON_ENABLED) 107 - mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); 108 - } 109 - 110 - static struct tty_driver *pdc_console_tty_driver; 111 - 112 - static int __init pdc_console_tty_driver_init(void) 113 - { 114 - struct tty_driver *driver; 115 - int err; 116 - 117 - /* Check if the console driver is still registered. 118 - * It is unregistered if the pdc console was not selected as the 119 - * primary console. */ 120 - 121 - struct console *tmp; 122 - 123 - console_lock(); 124 - for_each_console(tmp) 125 - if (tmp == &pdc_cons) 126 - break; 127 - console_unlock(); 128 - 129 - if (!tmp) { 130 - printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name); 131 - return -ENODEV; 132 - } 133 - 134 - printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); 135 - pdc_cons.flags &= ~CON_BOOT; 136 - 137 - driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW | 138 - TTY_DRIVER_RESET_TERMIOS); 139 - if (IS_ERR(driver)) 140 - return PTR_ERR(driver); 141 - 142 - tty_port_init(&tty_port); 143 - 144 - driver->driver_name = "pdc_cons"; 145 - driver->name = "ttyB"; 146 - driver->major = MUX_MAJOR; 147 - driver->minor_start = 0; 148 - driver->type = TTY_DRIVER_TYPE_SYSTEM; 149 - driver->init_termios = tty_std_termios; 150 - tty_set_operations(driver, &pdc_console_tty_ops); 151 - tty_port_link_device(&tty_port, driver, 0); 152 - 153 - err = tty_register_driver(driver); 154 - if (err) { 155 - printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); 156 - tty_port_destroy(&tty_port); 157 - tty_driver_kref_put(driver); 158 - return err; 159 - } 160 - 161 - pdc_console_tty_driver = driver; 162 - 163 - return 0; 164 - } 165 - device_initcall(pdc_console_tty_driver_init); 166 - 167 - static struct tty_driver * pdc_console_device (struct console *c, int *index) 168 - { 169 - *index = c->index; 170 - return pdc_console_tty_driver; 171 - } 172 - #else 173 - #define pdc_console_device NULL 174 80 #endif 175 81 176 - static struct console pdc_cons = { 177 - .name = "ttyB", 178 - .write = pdc_console_write, 179 - .device = pdc_console_device, 180 - .setup = pdc_console_setup, 181 - .flags = CON_BOOT | CON_PRINTBUFFER, 182 - .index = -1, 183 - }; 184 - 185 - static int pdc_console_initialized; 186 - 187 - static void pdc_console_init_force(void) 82 + static int __init pdc_earlycon_setup(struct earlycon_device *device, 83 + const char *opt) 188 84 { 189 - if (pdc_console_initialized) 190 - return; 191 - ++pdc_console_initialized; 192 - 85 + struct console *earlycon_console; 86 + 193 87 /* If the console is duplex then copy the COUT parameters to CIN. */ 194 88 if (PAGE0->mem_cons.cl_class == CL_DUPLEX) 195 89 memcpy(&PAGE0->mem_kbd, &PAGE0->mem_cons, sizeof(PAGE0->mem_cons)); 196 90 197 - /* register the pdc console */ 198 - register_console(&pdc_cons); 199 - } 91 + earlycon_console = device->con; 92 + earlycon_console->write = pdc_console_write; 93 + device->port.iotype = UPIO_MEM32BE; 200 94 201 - void __init pdc_console_init(void) 202 - { 203 - #if defined(EARLY_BOOTUP_DEBUG) || defined(CONFIG_PDC_CONSOLE) 204 - pdc_console_init_force(); 95 + #ifdef CONFIG_KGDB 96 + kgdb_register_io_module(&kgdb_pdc_io_ops); 205 97 #endif 206 - #ifdef EARLY_BOOTUP_DEBUG 207 - printk(KERN_INFO "Initialized PDC Console for debugging.\n"); 208 - #endif 98 + 99 + return 0; 209 100 } 210 101 211 - 212 - /* 213 - * Used for emergencies. Currently only used if an HPMC occurs. If an 214 - * HPMC occurs, it is possible that the current console may not be 215 - * properly initialised after the PDC IO reset. This routine unregisters 216 - * all of the current consoles, reinitializes the pdc console and 217 - * registers it. 218 - */ 219 - 220 - void pdc_console_restart(void) 221 - { 222 - struct console *console; 223 - 224 - if (pdc_console_initialized) 225 - return; 226 - 227 - /* If we've already seen the output, don't bother to print it again */ 228 - if (console_drivers != NULL) 229 - pdc_cons.flags &= ~CON_PRINTBUFFER; 230 - 231 - while ((console = console_drivers) != NULL) 232 - unregister_console(console_drivers); 233 - 234 - /* force registering the pdc console */ 235 - pdc_console_init_force(); 236 - } 102 + EARLYCON_DECLARE(pdc, pdc_earlycon_setup);
+4 -2
arch/parisc/kernel/setup.c
··· 70 70 strlcat(p, "tty0", COMMAND_LINE_SIZE); 71 71 } 72 72 73 + /* default to use early console */ 74 + if (!strstr(p, "earlycon")) 75 + strlcat(p, " earlycon=pdc", COMMAND_LINE_SIZE); 76 + 73 77 #ifdef CONFIG_BLK_DEV_INITRD 74 78 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */ 75 79 { ··· 142 138 */ 143 139 if (__pa((unsigned long) &_end) >= KERNEL_INITIAL_SIZE) 144 140 panic("KERNEL_INITIAL_ORDER too small!"); 145 - 146 - pdc_console_init(); 147 141 148 142 #ifdef CONFIG_64BIT 149 143 if(parisc_narrow_firmware) {
+1 -14
arch/parisc/kernel/traps.c
··· 239 239 /* unlock the pdc lock if necessary */ 240 240 pdc_emergency_unlock(); 241 241 242 - /* maybe the kernel hasn't booted very far yet and hasn't been able 243 - * to initialize the serial or STI console. In that case we should 244 - * re-enable the pdc console, so that the user will be able to 245 - * identify the problem. */ 246 - if (!console_drivers) 247 - pdc_console_restart(); 248 - 249 242 if (err) 250 243 printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n", 251 244 current->comm, task_pid_nr(current), str, err); ··· 422 429 /* unlock the pdc lock if necessary */ 423 430 pdc_emergency_unlock(); 424 431 425 - /* restart pdc console if necessary */ 426 - if (!console_drivers) 427 - pdc_console_restart(); 428 - 429 432 /* Not all paths will gutter the processor... */ 430 433 switch(code){ 431 434 ··· 471 482 unsigned long fault_space = 0; 472 483 int si_code; 473 484 474 - if (code == 1) 475 - pdc_console_restart(); /* switch back to pdc if HPMC */ 476 - else if (!irqs_disabled_flags(regs->gr[0])) 485 + if (!irqs_disabled_flags(regs->gr[0])) 477 486 local_irq_enable(); 478 487 479 488 /* Security check:
+4 -4
drivers/parisc/eisa_enumerator.c
··· 393 393 } 394 394 395 395 if (p0 + function_len < pos) { 396 - printk(KERN_ERR "eisa_enumerator: function %d length mis-match " 396 + printk(KERN_ERR "eisa_enumerator: function %d length mismatch " 397 397 "got %d, expected %d\n", 398 398 num_func, pos-p0, function_len); 399 399 res=-1; ··· 407 407 } 408 408 409 409 if (pos != es->config_data_length) { 410 - printk(KERN_ERR "eisa_enumerator: config data length mis-match got %d, expected %d\n", 410 + printk(KERN_ERR "eisa_enumerator: config data length mismatch got %d, expected %d\n", 411 411 pos, es->config_data_length); 412 412 res=-1; 413 413 } 414 414 415 415 if (num_func != es->num_functions) { 416 - printk(KERN_ERR "eisa_enumerator: number of functions mis-match got %d, expected %d\n", 416 + printk(KERN_ERR "eisa_enumerator: number of functions mismatch got %d, expected %d\n", 417 417 num_func, es->num_functions); 418 418 res=-2; 419 419 } ··· 451 451 } 452 452 if (es->eisa_slot_id != id) { 453 453 print_eisa_id(id_string, id); 454 - printk(KERN_ERR "EISA slot %d id mis-match: got %s", 454 + printk(KERN_ERR "EISA slot %d id mismatch: got %s", 455 455 slot, id_string); 456 456 457 457 print_eisa_id(id_string, es->eisa_slot_id);
-15
drivers/tty/serial/Kconfig
··· 603 603 select SERIAL_CORE_CONSOLE 604 604 default y 605 605 606 - config PDC_CONSOLE 607 - bool "PDC software console support" 608 - depends on PARISC && !SERIAL_MUX && VT 609 - help 610 - Saying Y here will enable the software based PDC console to be 611 - used as the system console. This is useful for machines in 612 - which the hardware based console has not been written yet. The 613 - following steps must be completed to use the PDC console: 614 - 615 - 1. create the device entry (mknod /dev/ttyB0 c 11 0) 616 - 2. Edit the /etc/inittab to start a getty listening on /dev/ttyB0 617 - 3. Add device ttyB0 to /etc/securetty (if you want to log on as 618 - root on this console.) 619 - 4. Change the kernel command console parameter to: console=ttyB0 620 - 621 606 config SERIAL_SUNSAB 622 607 tristate "Sun Siemens SAB82532 serial support" 623 608 depends on SPARC && PCI
+1 -1
drivers/video/fbdev/stifb.c
··· 1298 1298 1299 1299 /* limit fbsize to max visible screen size */ 1300 1300 if (fix->smem_len > yres*fix->line_length) 1301 - fix->smem_len = yres*fix->line_length; 1301 + fix->smem_len = ALIGN(yres*fix->line_length, 4*1024*1024); 1302 1302 1303 1303 fix->accel = FB_ACCEL_NONE; 1304 1304
+1 -1
lib/Kconfig.kgdb
··· 121 121 122 122 config KDB_KEYBOARD 123 123 bool "KGDB_KDB: keyboard as input device" 124 - depends on VT && KGDB_KDB 124 + depends on VT && KGDB_KDB && !PARISC 125 125 default n 126 126 help 127 127 KDB can use a PS/2 type keyboard for an input device