From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751215AbdFBKTa (ORCPT ); Fri, 2 Jun 2017 06:19:30 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52749 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbdFBKT2 (ORCPT ); Fri, 2 Jun 2017 06:19:28 -0400 Subject: Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste To: Martin Schwidefsky , Heiko Carstens Cc: David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Huth References: <20170529163202.13077-1-david@redhat.com> <20170601124651.3e7969ab@mschwideX1> <20170602070210.GA4221@osiris> <20170602114647.35e6d30f@mschwideX1> From: Christian Borntraeger Date: Fri, 2 Jun 2017 12:19:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170602114647.35e6d30f@mschwideX1> Content-Type: text/plain; charset=utf-8 Content-Language: en-IE Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17060210-0020-0000-0000-00000C12F5D9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007158; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00869007; UDB=6.00431980; IPR=6.00648976; BA=6.00005393; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015677; XFM=3.00000015; UTC=2017-06-02 10:19:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060210-0021-0000-0000-00005C9AEACD Message-Id: <2d45c9d5-2108-7408-e7cd-44b9f6d03b0f@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-02_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706020191 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/02/2017 11:46 AM, Martin Schwidefsky wrote: > On Fri, 2 Jun 2017 09:02:10 +0200 > Heiko Carstens 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. > -- > diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig > index 69a77eecaec1..7bd182676ddd 100644 > --- a/arch/s390/Kconfig > +++ b/arch/s390/Kconfig > @@ -64,6 +64,7 @@ config ARCH_SUPPORTS_UPROBES > > config S390 > def_bool y > + select ARCH_BINFMT_ELF_STATE > select ARCH_HAS_DEVMEM_IS_ALLOWED > select ARCH_HAS_ELF_RANDOMIZE > select ARCH_HAS_GCOV_PROFILE_ALL > diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h > index e8f623041769..79911231f9e6 100644 > --- a/arch/s390/include/asm/elf.h > +++ b/arch/s390/include/asm/elf.h > @@ -151,6 +151,28 @@ extern unsigned int vdso_enabled; > && (x)->e_ident[EI_CLASS] == ELF_CLASS) > #define compat_start_thread start_thread31 > > +struct arch_elf_state { > +}; > + > +#define INIT_ARCH_ELF_STATE { } > + > +#define arch_elf_pt_proc(ehdr, phdr, elf, interp, state) (0) > +#define arch_check_elf(ehdr, interp, interp_ehdr, state) \ > +({ \ > + struct elf64_hdr *hdr = (void*) ehdr; \ > + int _rc = 0; \ > + if (hdr->e_ident[EI_CLASS] == ELFCLASS64 && \ > + (hdr->e_flags & 0x00000002) && \ shall we define some EF_S390_PGSTE flags in elf.h for this number? What is 0x00000001 by the way?