From nobody Sat May 4 13:19:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149034766833456.02334605168187; Fri, 24 Mar 2017 02:27:48 -0700 (PDT) Received: from localhost ([::1]:60410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crLVa-00061E-Pw for importer@patchew.org; Fri, 24 Mar 2017 05:27:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crLUs-0005aL-Cr for qemu-devel@nongnu.org; Fri, 24 Mar 2017 05:27:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crLUp-0005St-81 for qemu-devel@nongnu.org; Fri, 24 Mar 2017 05:27:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1crLUp-0005SE-24 for qemu-devel@nongnu.org; Fri, 24 Mar 2017 05:26:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4DE180F9D; Fri, 24 Mar 2017 09:26:58 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 134CE17D23; Fri, 24 Mar 2017 09:26:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D4DE180F9D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D4DE180F9D From: Thomas Huth To: qemu-devel@nongnu.org, Cornelia Huck Date: Fri, 24 Mar 2017 10:26:55 +0100 Message-Id: <1490347615-19222-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 24 Mar 2017 09:26:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] target/s390x/kvm: Fix problem when running with SELinux under z/VM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When running QEMU with KVM under z/VM, the memory for the guest is allocated via legacy_s390_alloc() since the KVM_CAP_S390_COW extension is not supported on z/VM. legacy_s390_alloc() then uses mmap(... PROT_EXEC ...) for the guest memory - but this does not work when running with SELinux enabled, mmap() fails and QEMU aborts with the following error message: cannot set up guest memory 's390.ram': Permission denied Looking at the other allocator function qemu_anon_ram_alloc(), it seems like PROT_EXEC is normally not needed for allocating the guest RAM, and indeed, the guest also starts successfully under z/VM when we remove the PROT_EXEC from the legacy_s390_alloc() function. So let's get rid of that flag here to be able to run with SELinux under z/VM, too. Signed-off-by: Thomas Huth --- target/s390x/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index ac47154..5167436 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -678,8 +678,7 @@ static void *legacy_s390_alloc(size_t size, uint64_t *a= lign) { void *mem; =20 - mem =3D mmap((void *) 0x800000000ULL, size, - PROT_EXEC|PROT_READ|PROT_WRITE, + mem =3D mmap((void *) 0x800000000ULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, -1, 0); return mem =3D=3D MAP_FAILED ? NULL : mem; } --=20 1.8.3.1