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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml

Pull UML fixes from Richard Weinberger:

- Make sure to set a default console, otherwise ttynull is selected

- Revert initial ARCH_HAS_SET_MEMORY support, this needs more work

- Fix a regression due to ubd refactoring

- Various small fixes

* tag 'for-linus-5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml:
um: time: fix initialization in time-travel mode
um: fix os_idle_sleep() to not hang
Revert "um: support some of ARCH_HAS_SET_MEMORY"
Revert "um: allocate a guard page to helper threads"
um: virtio: free vu_dev only with the contained struct device
um: kmsg_dumper: always dump when not tty console
um: stdio_console: Make preferred console
um: return error from ioremap()
um: ubd: fix command line handling of ubd

+84 -99
-1
arch/um/Kconfig
··· 15 15 select HAVE_DEBUG_KMEMLEAK 16 16 select HAVE_DEBUG_BUGVERBOSE 17 17 select NO_DMA 18 - select ARCH_HAS_SET_MEMORY 19 18 select GENERIC_IRQ_SHOW 20 19 select GENERIC_CPU_DEVICES 21 20 select HAVE_GCC_PLUGINS
+3 -3
arch/um/drivers/ubd_kern.c
··· 375 375 file = NULL; 376 376 377 377 backing_file = strsep(&str, ",:"); 378 - if (*backing_file == '\0') 378 + if (backing_file && *backing_file == '\0') 379 379 backing_file = NULL; 380 380 381 381 serial = strsep(&str, ",:"); 382 - if (*serial == '\0') 382 + if (serial && *serial == '\0') 383 383 serial = NULL; 384 384 385 385 if (backing_file && ubd_dev->no_cow) { ··· 1241 1241 /* Letting ubd=sync be like using ubd#s= instead of ubd#= is 1242 1242 * enough. So use anyway the io thread. */ 1243 1243 } 1244 - stack = alloc_stack(0); 1244 + stack = alloc_stack(0, 0); 1245 1245 io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *), 1246 1246 &thread_fd); 1247 1247 if(io_pid < 0){
+2 -1
arch/um/drivers/virtio_uml.c
··· 1084 1084 } 1085 1085 1086 1086 os_close_file(vu_dev->sock); 1087 + kfree(vu_dev); 1087 1088 } 1088 1089 1089 1090 /* Platform device */ ··· 1098 1097 if (!pdata) 1099 1098 return -EINVAL; 1100 1099 1101 - vu_dev = devm_kzalloc(&pdev->dev, sizeof(*vu_dev), GFP_KERNEL); 1100 + vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL); 1102 1101 if (!vu_dev) 1103 1102 return -ENOMEM; 1104 1103
+1 -1
arch/um/include/asm/io.h
··· 5 5 #define ioremap ioremap 6 6 static inline void __iomem *ioremap(phys_addr_t offset, size_t size) 7 7 { 8 - return (void __iomem *)(unsigned long)offset; 8 + return NULL; 9 9 } 10 10 11 11 #define iounmap iounmap
-3
arch/um/include/asm/pgtable.h
··· 55 55 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 56 56 #define __PAGE_KERNEL_EXEC \ 57 57 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) 58 - #define __PAGE_KERNEL_RO \ 59 - (_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED) 60 58 #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) 61 59 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) 62 60 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) 63 61 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) 64 62 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) 65 63 #define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC) 66 - #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO) 67 64 68 65 /* 69 66 * The i386 can't do page protection for execute, and considers that the same
-1
arch/um/include/asm/set_memory.h
··· 1 - #include <asm-generic/set_memory.h>
+1 -1
arch/um/include/shared/kern_util.h
··· 19 19 #define UML_ROUND_UP(addr) \ 20 20 ((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK) 21 21 22 - extern unsigned long alloc_stack(int atomic); 22 + extern unsigned long alloc_stack(int order, int atomic); 23 23 extern void free_stack(unsigned long stack, int order); 24 24 25 25 struct pt_regs;
+7 -2
arch/um/kernel/kmsg_dump.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/kmsg_dump.h> 3 3 #include <linux/console.h> 4 + #include <linux/string.h> 4 5 #include <shared/init.h> 5 6 #include <shared/kern.h> 6 7 #include <os.h> ··· 17 16 if (!console_trylock()) 18 17 return; 19 18 20 - for_each_console(con) 21 - break; 19 + for_each_console(con) { 20 + if(strcmp(con->name, "tty") == 0 && 21 + (con->flags & (CON_ENABLED | CON_CONSDEV)) != 0) { 22 + break; 23 + } 24 + } 22 25 23 26 console_unlock(); 24 27
+4 -7
arch/um/kernel/process.c
··· 32 32 #include <os.h> 33 33 #include <skas.h> 34 34 #include <linux/time-internal.h> 35 - #include <asm/set_memory.h> 36 35 37 36 /* 38 37 * This is a per-cpu array. A processor only modifies its entry and it only ··· 62 63 free_pages(stack, order); 63 64 } 64 65 65 - unsigned long alloc_stack(int atomic) 66 + unsigned long alloc_stack(int order, int atomic) 66 67 { 67 - unsigned long addr; 68 + unsigned long page; 68 69 gfp_t flags = GFP_KERNEL; 69 70 70 71 if (atomic) 71 72 flags = GFP_ATOMIC; 72 - addr = __get_free_pages(flags, 1); 73 + page = __get_free_pages(flags, order); 73 74 74 - set_memory_ro(addr, 1); 75 - 76 - return addr + PAGE_SIZE; 75 + return page; 77 76 } 78 77 79 78 static inline void set_current(struct task_struct *task)
+31 -19
arch/um/kernel/time.c
··· 535 535 536 536 return 1; 537 537 } 538 + 539 + static void time_travel_set_start(void) 540 + { 541 + if (time_travel_start_set) 542 + return; 543 + 544 + switch (time_travel_mode) { 545 + case TT_MODE_EXTERNAL: 546 + time_travel_start = time_travel_ext_req(UM_TIMETRAVEL_GET_TOD, -1); 547 + /* controller gave us the *current* time, so adjust by that */ 548 + time_travel_ext_get_time(); 549 + time_travel_start -= time_travel_time; 550 + break; 551 + case TT_MODE_INFCPU: 552 + case TT_MODE_BASIC: 553 + if (!time_travel_start_set) 554 + time_travel_start = os_persistent_clock_emulation(); 555 + break; 556 + case TT_MODE_OFF: 557 + /* we just read the host clock with os_persistent_clock_emulation() */ 558 + break; 559 + } 560 + 561 + time_travel_start_set = true; 562 + } 538 563 #else /* CONFIG_UML_TIME_TRAVEL_SUPPORT */ 539 564 #define time_travel_start_set 0 540 565 #define time_travel_start 0 ··· 575 550 } 576 551 577 552 static void time_travel_set_interval(unsigned long long interval) 553 + { 554 + } 555 + 556 + static inline void time_travel_set_start(void) 578 557 { 579 558 } 580 559 ··· 760 731 { 761 732 long long nsecs; 762 733 734 + time_travel_set_start(); 735 + 763 736 if (time_travel_mode != TT_MODE_OFF) 764 737 nsecs = time_travel_start + time_travel_time; 765 738 else ··· 773 742 774 743 void __init time_init(void) 775 744 { 776 - #ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT 777 - switch (time_travel_mode) { 778 - case TT_MODE_EXTERNAL: 779 - time_travel_start = time_travel_ext_req(UM_TIMETRAVEL_GET_TOD, -1); 780 - /* controller gave us the *current* time, so adjust by that */ 781 - time_travel_ext_get_time(); 782 - time_travel_start -= time_travel_time; 783 - break; 784 - case TT_MODE_INFCPU: 785 - case TT_MODE_BASIC: 786 - if (!time_travel_start_set) 787 - time_travel_start = os_persistent_clock_emulation(); 788 - break; 789 - case TT_MODE_OFF: 790 - /* we just read the host clock with os_persistent_clock_emulation() */ 791 - break; 792 - } 793 - #endif 794 - 795 745 timer_set_signal_handler(); 796 746 late_time_init = um_timer_setup; 797 747 }
-54
arch/um/kernel/tlb.c
··· 608 608 vma = vma->vm_next; 609 609 } 610 610 } 611 - 612 - struct page_change_data { 613 - unsigned int set_mask, clear_mask; 614 - }; 615 - 616 - static int change_page_range(pte_t *ptep, unsigned long addr, void *data) 617 - { 618 - struct page_change_data *cdata = data; 619 - pte_t pte = READ_ONCE(*ptep); 620 - 621 - pte_clear_bits(pte, cdata->clear_mask); 622 - pte_set_bits(pte, cdata->set_mask); 623 - 624 - set_pte(ptep, pte); 625 - return 0; 626 - } 627 - 628 - static int change_memory(unsigned long start, unsigned long pages, 629 - unsigned int set_mask, unsigned int clear_mask) 630 - { 631 - unsigned long size = pages * PAGE_SIZE; 632 - struct page_change_data data; 633 - int ret; 634 - 635 - data.set_mask = set_mask; 636 - data.clear_mask = clear_mask; 637 - 638 - ret = apply_to_page_range(&init_mm, start, size, change_page_range, 639 - &data); 640 - 641 - flush_tlb_kernel_range(start, start + size); 642 - 643 - return ret; 644 - } 645 - 646 - int set_memory_ro(unsigned long addr, int numpages) 647 - { 648 - return change_memory(addr, numpages, 0, _PAGE_RW); 649 - } 650 - 651 - int set_memory_rw(unsigned long addr, int numpages) 652 - { 653 - return change_memory(addr, numpages, _PAGE_RW, 0); 654 - } 655 - 656 - int set_memory_nx(unsigned long addr, int numpages) 657 - { 658 - return -EOPNOTSUPP; 659 - } 660 - 661 - int set_memory_x(unsigned long addr, int numpages) 662 - { 663 - return -EOPNOTSUPP; 664 - }
+19 -3
arch/um/kernel/um_arch.c
··· 26 26 #include <mem_user.h> 27 27 #include <os.h> 28 28 29 - #define DEFAULT_COMMAND_LINE "root=98:0" 29 + #define DEFAULT_COMMAND_LINE_ROOT "root=98:0" 30 + #define DEFAULT_COMMAND_LINE_CONSOLE "console=tty" 30 31 31 32 /* Changed in add_arg and setup_arch, which run before SMP is started */ 32 33 static char __initdata command_line[COMMAND_LINE_SIZE] = { 0 }; ··· 110 109 int ncpus = 1; 111 110 112 111 /* Set in early boot */ 113 - static int have_root __initdata = 0; 112 + static int have_root __initdata; 113 + static int have_console __initdata; 114 114 115 115 /* Set in uml_mem_setup and modified in linux_main */ 116 116 long long physmem_size = 32 * 1024 * 1024; ··· 161 159 __uml_setup("debug", no_skas_debug_setup, 162 160 "debug\n" 163 161 " this flag is not needed to run gdb on UML in skas mode\n\n" 162 + ); 163 + 164 + static int __init uml_console_setup(char *line, int *add) 165 + { 166 + have_console = 1; 167 + return 0; 168 + } 169 + 170 + __uml_setup("console=", uml_console_setup, 171 + "console=<preferred console>\n" 172 + " Specify the preferred console output driver\n\n" 164 173 ); 165 174 166 175 static int __init Usage(char *line, int *add) ··· 277 264 add_arg(argv[i]); 278 265 } 279 266 if (have_root == 0) 280 - add_arg(DEFAULT_COMMAND_LINE); 267 + add_arg(DEFAULT_COMMAND_LINE_ROOT); 268 + 269 + if (have_console == 0) 270 + add_arg(DEFAULT_COMMAND_LINE_CONSOLE); 281 271 282 272 host_task_size = os_get_top_address(); 283 273 /*
+2 -2
arch/um/os-Linux/helper.c
··· 45 45 unsigned long stack, sp; 46 46 int pid, fds[2], ret, n; 47 47 48 - stack = alloc_stack(__cant_sleep()); 48 + stack = alloc_stack(0, __cant_sleep()); 49 49 if (stack == 0) 50 50 return -ENOMEM; 51 51 ··· 116 116 unsigned long stack, sp; 117 117 int pid, status, err; 118 118 119 - stack = alloc_stack(__cant_sleep()); 119 + stack = alloc_stack(0, __cant_sleep()); 120 120 if (stack == 0) 121 121 return -ENOMEM; 122 122
+14 -1
arch/um/os-Linux/time.c
··· 104 104 */ 105 105 void os_idle_sleep(void) 106 106 { 107 - pause(); 107 + struct itimerspec its; 108 + sigset_t set, old; 109 + 110 + /* block SIGALRM while we analyze the timer state */ 111 + sigemptyset(&set); 112 + sigaddset(&set, SIGALRM); 113 + sigprocmask(SIG_BLOCK, &set, &old); 114 + 115 + /* check the timer, and if it'll fire then wait for it */ 116 + timer_gettime(event_high_res_timer, &its); 117 + if (its.it_value.tv_sec || its.it_value.tv_nsec) 118 + sigsuspend(&old); 119 + /* either way, restore the signal mask */ 120 + sigprocmask(SIG_UNBLOCK, &set, NULL); 108 121 }