From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
David Hildenbrand <david@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste
Date: Fri, 2 Jun 2017 15:20:33 +0200 [thread overview]
Message-ID: <63b5c762-fbbb-b6dc-0f2d-6837dac5bb04@de.ibm.com> (raw)
In-Reply-To: <20170602125345.5ac9e12e@mschwideX1>
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?
next prev parent reply other threads:[~2017-06-02 13:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 16:32 [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste David Hildenbrand
2017-05-29 16:32 ` [PATCH RFC 1/2] s390x: mm: allow mixed page table types (2k and 4k) David Hildenbrand
2017-06-01 11:39 ` Christian Borntraeger
2017-06-01 12:44 ` David Hildenbrand
2017-06-01 12:59 ` David Hildenbrand
2017-06-02 7:11 ` Christian Borntraeger
2017-05-29 16:32 ` [PATCH RFC 2/2] KVM: s390: Introduce KVM_VM_S390_LATE_MMAP David Hildenbrand
2017-06-01 10:46 ` [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Martin Schwidefsky
2017-06-01 11:24 ` Christian Borntraeger
2017-06-01 11:27 ` David Hildenbrand
2017-06-02 7:06 ` Heiko Carstens
2017-06-02 7:02 ` Heiko Carstens
2017-06-02 7:13 ` Christian Borntraeger
2017-06-02 7:16 ` Martin Schwidefsky
2017-06-02 7:18 ` Christian Borntraeger
2017-06-02 7:25 ` Christian Borntraeger
2017-06-02 8:11 ` Martin Schwidefsky
2017-06-02 9:46 ` Martin Schwidefsky
2017-06-02 10:19 ` Christian Borntraeger
2017-06-02 10:53 ` Martin Schwidefsky
2017-06-02 13:20 ` Christian Borntraeger [this message]
2017-06-07 12:34 ` Martin Schwidefsky
2017-06-07 20:47 ` Heiko Carstens
2017-06-08 5:35 ` Martin Schwidefsky
2017-06-08 6:25 ` Heiko Carstens
2017-06-08 11:24 ` Martin Schwidefsky
2017-06-08 13:17 ` Heiko Carstens
2017-06-02 10:28 ` Heiko Carstens
2017-06-02 10:48 ` Martin Schwidefsky
2017-06-02 10:54 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63b5c762-fbbb-b6dc-0f2d-6837dac5bb04@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=heiko.carstens@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).