Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1656210

Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste

From Christian Borntraeger <borntraeger@de.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste
Date 2017-06-02 15:30 +0200
Message-ID <tNUOl-1EU-7@gated-at.bofh.it> (permalink)
References (1 earlier) <tNvPY-1sb-15@gated-at.bofh.it> <tNOSC-698-9@gated-at.bofh.it> <tNRns-7G9-27@gated-at.bofh.it> <tNRQu-87W-13@gated-at.bofh.it> <tNStc-8qp-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 06/02/2017 12:53 PM, Martin Schwidefsky wrote:
> On Fri, 2 Jun 2017 12:19:19 +0200
> Christian Borntraeger <borntraeger@de.ibm.com> wrote:
> 
>> On 06/02/2017 11:46 AM, Martin Schwidefsky wrote:
>>> On Fri, 2 Jun 2017 09:02:10 +0200
>>> Heiko Carstens <heiko.carstens@de.ibm.com> wrote:
>>>   
>>>> On Thu, Jun 01, 2017 at 12:46:51PM +0200, Martin Schwidefsky wrote:  
>>>>>> Unfortunately, converting all page tables to 4k pgste page tables is
>>>>>> not possible without provoking various race conditions.    
>>>>>
>>>>> That is one approach we tried and was found to be buggy. The point is that
>>>>> you are not allowed to reallocate a page table while a VMA exists that is
>>>>> in the address range of that page table.
>>>>>
>>>>> Another approach we tried is to use an ELF flag on the qemu executable.
>>>>> That does not work either because fs/exec.c allocates and populates the
>>>>> new mm struct for the argument pages before fs/binfmt_elf.c comes into
>>>>> play.    
>>>>
>>>> How about if you would fail the system call within arch_check_elf() if you
>>>> detect that the binary requires pgstes (as indicated by elf flags) and then
>>>> restart the system call?
>>>>
>>>> That is: arch_check_elf() e.g. would set a thread flag that future mm's
>>>> should be allocated with pgstes. Then do_execve() would cleanup everything
>>>> and return to entry.S. Upon return to userspace we detect this condition
>>>> and simply restart the system call, similar to signals vs -ERESTARTSYS.
>>>>
>>>> That would make do_execve() cleanup everything and upon reentering it would
>>>> allocate an mm with the pgste flag set.
>>>>
>>>> Maybe this is a bit over-simplified, but might work.  
>>>
>>> This is not over-simplified at all, that does work:  
>>
>>
>> Nice. Next question is how to integrate that elf flag into the qemu
>> build environment.
> 
> So far I use a small C program to set the flag:
> 
> #include <elf.h>
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> 
> #define ERREXIT(...)                    \
> do {                                    \
>         fprintf(stderr, __VA_ARGS__);   \
>         exit(-1);                       \
> } while (0)
> 
> int main(int argc, char *argv[])
> {
>         Elf64_Ehdr ehdr;
>         int fd, rc;
> 
>         if (argc != 2)
>                 ERREXIT("Usage: %s <elf-file>\n", argv[0]);
> 
>         fd = open(argv[1], O_RDWR);
>         if (fd < 0)
>                 ERREXIT("Unable to open file %s\n", argv[1]);
> 
>         if (pread(fd, &ehdr, sizeof(ehdr), 0) != sizeof(ehdr) ||
>             memcmp(&ehdr.e_ident, ELFMAG, SELFMAG) != 0 ||
>                 ehdr.e_ident[EI_CLASS] != ELFCLASS64 ||
>             ehdr.e_machine != EM_S390)
>                 ERREXIT("Invalid ELF file %s\n", argv[1]);
> 
>         ehdr.e_flags |= 0x00000002;
> 
>         if (pwrite(fd, &ehdr, sizeof(ehdr), 0) != sizeof(ehdr))
>                 ERREXIT("Write to of file %s failed\n", argv[1]);
> 
>         close(fd);
>         return 0;
> }
> 

Thanks for that. I assume this is mostly for testing and we want to have 
toolchain support for that. Otherwise things like  build-id (the sha variant) 
might be wrong, no?

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste David Hildenbrand <david@redhat.com> - 2017-05-29 18:40 +0200
  [PATCH RFC 2/2] KVM: s390: Introduce KVM_VM_S390_LATE_MMAP David Hildenbrand <david@redhat.com> - 2017-05-29 18:40 +0200
  [PATCH RFC 1/2] s390x: mm: allow mixed page table types (2k and 4k) David Hildenbrand <david@redhat.com> - 2017-05-29 18:40 +0200
    Re: [PATCH RFC 1/2] s390x: mm: allow mixed page table types (2k and  4k) Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-01 13:40 +0200
      Re: [PATCH RFC 1/2] s390x: mm: allow mixed page table types (2k and  4k) David Hildenbrand <david@redhat.com> - 2017-06-01 14:50 +0200
    Re: [PATCH RFC 1/2] s390x: mm: allow mixed page table types (2k and  4k) David Hildenbrand <david@redhat.com> - 2017-06-01 15:00 +0200
      Re: [PATCH RFC 1/2] s390x: mm: allow mixed page table types (2k and  4k) Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-02 09:20 +0200
  Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-01 12:50 +0200
    Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-01 13:30 +0200
    Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste David Hildenbrand <david@redhat.com> - 2017-06-01 13:30 +0200
      Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-06-02 09:10 +0200
    Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-06-02 09:10 +0200
      Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-02 09:20 +0200
        Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-02 09:30 +0200
          Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-02 10:20 +0200
        Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-02 09:30 +0200
      Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-02 09:20 +0200
      Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-02 11:50 +0200
        Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-02 12:20 +0200
          Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-02 13:00 +0200
            Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Christian Borntraeger <borntraeger@de.ibm.com> - 2017-06-02 15:30 +0200
              Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-07 14:40 +0200
        Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-06-02 12:30 +0200
          Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable  vm.alloc_pgste Martin Schwidefsky <schwidefsky@de.ibm.com> - 2017-06-02 12:50 +0200
      Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste David Hildenbrand <david@redhat.com> - 2017-06-02 13:00 +0200

csiph-web