From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Carstens Subject: Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste Date: Fri, 2 Jun 2017 09:02:10 +0200 Message-ID: <20170602070210.GA4221@osiris> References: <20170529163202.13077-1-david@redhat.com> <20170601124651.3e7969ab@mschwideX1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Huth , Christian Borntraeger To: Martin Schwidefsky Return-path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55484 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751128AbdFBHCS (ORCPT ); Fri, 2 Jun 2017 03:02:18 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v526waGi141510 for ; Fri, 2 Jun 2017 03:02:17 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2atu3cwn24-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 02 Jun 2017 03:02:17 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Jun 2017 08:02:15 +0100 Content-Disposition: inline In-Reply-To: <20170601124651.3e7969ab@mschwideX1> Sender: kvm-owner@vger.kernel.org List-ID: 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. At least I also don't like the next "hack", that is specifically designed to only work with how QEMU is currently implemented. It might break with future QEMU changes or the next user space implementation that drives the kvm interface, but is doing everything differently. Let's look for a "clean" solution that will always work. We had too many hacks for this problem and *all* of them were broken.