Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/21/2017 04:17 PM, Andy Lutomirski wrote: > On Tue, Nov 21, 2017 at 3:42 PM, Dave Hansen > unsigned long start = (unsigned long)get_cpu_entry_area(cpu); > for (unsigned long addr = start; addr < start + sizeof(struct > cpu_entry_area); addr += PAGE_SIZE) { > pte_t pte = *pte_offset_k(addr);

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/21/2017 04:17 PM, Andy Lutomirski wrote: > On Tue, Nov 21, 2017 at 3:42 PM, Dave Hansen > unsigned long start = (unsigned long)get_cpu_entry_area(cpu); > for (unsigned long addr = start; addr < start + sizeof(struct > cpu_entry_area); addr += PAGE_SIZE) { > pte_t pte = *pte_offset_k(addr);

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Andy Lutomirski
On Tue, Nov 21, 2017 at 3:42 PM, Dave Hansen wrote: > On 11/21/2017 03:32 PM, Andy Lutomirski wrote: >>> To do this, we need to special-case the kernel page table walker to deal >>> with PTEs only since we can't just grab PMD or PUD flags and stick them >>> in a PTE.

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Andy Lutomirski
On Tue, Nov 21, 2017 at 3:42 PM, Dave Hansen wrote: > On 11/21/2017 03:32 PM, Andy Lutomirski wrote: >>> To do this, we need to special-case the kernel page table walker to deal >>> with PTEs only since we can't just grab PMD or PUD flags and stick them >>> in a PTE. We would only be able to use

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/21/2017 03:32 PM, Andy Lutomirski wrote: >> To do this, we need to special-case the kernel page table walker to deal >> with PTEs only since we can't just grab PMD or PUD flags and stick them >> in a PTE. We would only be able to use this path when populating things >> that we know are

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/21/2017 03:32 PM, Andy Lutomirski wrote: >> To do this, we need to special-case the kernel page table walker to deal >> with PTEs only since we can't just grab PMD or PUD flags and stick them >> in a PTE. We would only be able to use this path when populating things >> that we know are

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Andy Lutomirski
On Tue, Nov 21, 2017 at 3:17 PM, Dave Hansen wrote: > On 11/21/2017 02:46 PM, Andy Lutomirski wrote: >>> GDT: R/O TSS: R/W at least because of trampoline stack entry code: >>> EXEC+R/O exception stacks: R/W >> Can you avoid code duplication by adding some logic right

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Andy Lutomirski
On Tue, Nov 21, 2017 at 3:17 PM, Dave Hansen wrote: > On 11/21/2017 02:46 PM, Andy Lutomirski wrote: >>> GDT: R/O TSS: R/W at least because of trampoline stack entry code: >>> EXEC+R/O exception stacks: R/W >> Can you avoid code duplication by adding some logic right after the >> kernel

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/21/2017 02:46 PM, Andy Lutomirski wrote: >> GDT: R/O TSS: R/W at least because of trampoline stack entry code: >> EXEC+R/O exception stacks: R/W > Can you avoid code duplication by adding some logic right after the > kernel cpu_entry_area is set up to iterate page by page over the PTEs > in

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/21/2017 02:46 PM, Andy Lutomirski wrote: >> GDT: R/O TSS: R/W at least because of trampoline stack entry code: >> EXEC+R/O exception stacks: R/W > Can you avoid code duplication by adding some logic right after the > kernel cpu_entry_area is set up to iterate page by page over the PTEs > in

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Andy Lutomirski
> On Nov 21, 2017, at 2:19 PM, Dave Hansen wrote: > > On 11/20/2017 12:46 PM, Andy Lutomirski wrote: + /* + * We could theoretically do this in setup_fixmap_gdt(). + * But, we would need to rewrite the above page table + *

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Andy Lutomirski
> On Nov 21, 2017, at 2:19 PM, Dave Hansen wrote: > > On 11/20/2017 12:46 PM, Andy Lutomirski wrote: + /* + * We could theoretically do this in setup_fixmap_gdt(). + * But, we would need to rewrite the above page table + * allocation code to use the

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/20/2017 12:22 PM, Thomas Gleixner wrote: > On Fri, 10 Nov 2017, Dave Hansen wrote: >> __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot); >> + >> +/* CPU 0's mapping is done in kaiser_init() */ >> +if (cpu) { >> +int ret; >> + >> +ret =

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/20/2017 12:22 PM, Thomas Gleixner wrote: > On Fri, 10 Nov 2017, Dave Hansen wrote: >> __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot); >> + >> +/* CPU 0's mapping is done in kaiser_init() */ >> +if (cpu) { >> +int ret; >> + >> +ret =

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/20/2017 12:46 PM, Andy Lutomirski wrote: >>> + /* >>> + * We could theoretically do this in setup_fixmap_gdt(). >>> + * But, we would need to rewrite the above page table >>> + * allocation code to use the bootmem allocator. The >>> + * buddy allocator is not

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-21 Thread Dave Hansen
On 11/20/2017 12:46 PM, Andy Lutomirski wrote: >>> + /* >>> + * We could theoretically do this in setup_fixmap_gdt(). >>> + * But, we would need to rewrite the above page table >>> + * allocation code to use the bootmem allocator. The >>> + * buddy allocator is not

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-20 Thread Thomas Gleixner
On Mon, 20 Nov 2017, Andy Lutomirski wrote: > On Mon, Nov 20, 2017 at 12:22 PM, Thomas Gleixner wrote: > > On Fri, 10 Nov 2017, Dave Hansen wrote: > >> __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), > >> prot); > >> + > >> + /* CPU 0's mapping is

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-20 Thread Thomas Gleixner
On Mon, 20 Nov 2017, Andy Lutomirski wrote: > On Mon, Nov 20, 2017 at 12:22 PM, Thomas Gleixner wrote: > > On Fri, 10 Nov 2017, Dave Hansen wrote: > >> __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), > >> prot); > >> + > >> + /* CPU 0's mapping is done in kaiser_init()

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-20 Thread Andy Lutomirski
On Mon, Nov 20, 2017 at 12:22 PM, Thomas Gleixner wrote: > On Fri, 10 Nov 2017, Dave Hansen wrote: >> __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot); >> + >> + /* CPU 0's mapping is done in kaiser_init() */ >> + if (cpu) { >> +

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-20 Thread Andy Lutomirski
On Mon, Nov 20, 2017 at 12:22 PM, Thomas Gleixner wrote: > On Fri, 10 Nov 2017, Dave Hansen wrote: >> __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot); >> + >> + /* CPU 0's mapping is done in kaiser_init() */ >> + if (cpu) { >> + int ret; >> + >> +

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-20 Thread Thomas Gleixner
On Fri, 10 Nov 2017, Dave Hansen wrote: > __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot); > + > + /* CPU 0's mapping is done in kaiser_init() */ > + if (cpu) { > + int ret; > + > + ret = kaiser_add_mapping((unsigned long)

Re: [PATCH 12/30] x86, kaiser: map GDT into user page tables

2017-11-20 Thread Thomas Gleixner
On Fri, 10 Nov 2017, Dave Hansen wrote: > __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot); > + > + /* CPU 0's mapping is done in kaiser_init() */ > + if (cpu) { > + int ret; > + > + ret = kaiser_add_mapping((unsigned long)