From patchwork Sun Aug 23 14:59:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 248149 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1881663ils; Sun, 23 Aug 2020 07:59:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3txVMY/qAvdSvz8jydQakobBRzY4nJjEk5uC6upHTiqew9B7vcVx1Knh63FOjPIJhuvCd X-Received: by 2002:a25:ab0d:: with SMTP id u13mr2194772ybi.248.1598194794229; Sun, 23 Aug 2020 07:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598194794; cv=none; d=google.com; s=arc-20160816; b=e/YlD58q3tC2kpeggBjmtUMe7xnycFToRTbWLqJgwpMVh1E/4c0FS/+sWRsw0OvDvb SyZi2wN+roMvWh5NAWvIUQ3qWTfD9Nqu9Lwk0oq/hOZQOC7IkX3kI+m49bqfBriZuf+b 9lcqco0qCudY2/M0z9ByDO6Bz4WgMf/IP++lvI59tQg88Q507y8nydh7ZZP6HpqhSzp3 H7PGZGIXDF9IrZ6qU5h86LCLlrPE4aU9Mb++JMqLeBbe1x3PXmcX7GqS0hFBepOkr9Nz /bIB/nwDodY7kFTpZ6E6N0avR/vC1M3atoxtE9GNdrT08Qva6dF11nQ5dOOaaQBoH958 hclQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=wur1SFGp5xDijZMn7bJkUj1KQAmzkSNHK88wQEnF7jk=; b=FdE2gModCzi9pfgGG07wWXFmC8TwKUDCTlZ9yEFDzn/1qHi0TuwrS6bN6voRkRnQj1 +kru6GxAIIKVzk4ZydfSi/ToBX+p5axTxY+sUrCE6qazgzIemTuTgev+LIDFsuQUcDNT 7PKW/rOUFuy42PuN0i2chLm27W5VPK3nHxDcLnUjYyqG87E5v4Z4Z9tRAHMI6uAT73JT aKTkuaJq9skD1rQKq++Zi8muoFXuBmOzbgHSs04cStxKFFI2m4120jcvf9Cuy6aUfRmI 8I9Z8lf9l8ftCbgeuDnnKCOzILwO0+GeYRPM4MfY+07HxLuJyvR0F9UPeFSCXslru/Vp MfEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m17si8699443ybt.300.2020.08.23.07.59.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Aug 2020 07:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:34902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9rTN-0004x5-Mc for patch@linaro.org; Sun, 23 Aug 2020 10:59:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9rSr-0004r1-HD for qemu-devel@nongnu.org; Sun, 23 Aug 2020 10:59:21 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:52415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9rSp-0006dz-PQ for qemu-devel@nongnu.org; Sun, 23 Aug 2020 10:59:21 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MrgcU-1kxGiW1FZ6-00nljk; Sun, 23 Aug 2020 16:59:16 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 3/6] linux-user: Adjust guest page protection for the host Date: Sun, 23 Aug 2020 16:59:09 +0200 Message-Id: <20200823145912.1171738-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200823145912.1171738-1-laurent@vivier.eu> References: <20200823145912.1171738-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:uVSC+BN8iffnkVovJ5et5KG/MimAMbh6ytMx2N7MYhuKxwm2lXf pm5282ABPtW5oxmMgi8dvLGg1PHoCBh7R9znGic0L6LkcjmsD7cP0i998jpvA9vM43rDp8m JWTsw1dGeO4sD83jxN9m3iJJDSDodXoDjPEv0n3TLlAWSHCNjM7JDF0NozNvdcJNDr0kOi/ oDB4YsaeOXMh4iPgQObnA== X-UI-Out-Filterresults: notjunk:1; V03:K0:+930OTmX7ew=:8+r9hGeTbX+k/Jokb28Vju 1WkyEYFeX/sgS41Z8vCpUedbsFB67c5ffe27pzM/1R21p9TlBWPE5Zw5kTgu1lbW7mnUoG0Zr QZZrazNnfOdhYj9mK6cxXClavvpJuBWinxIyhAQMvNI1FFIQq0sGQKjGJpVA/ye5oVN5ga8X3 GLU/hQ2BpfXUU9twhnGgy5g7GVJ201N/JvjDCfK+oeGiVpknnfmbjO8s3IgiavRTzd5OF83bF q522eFKL8FljtGwr/NcceQhrVflAYd/SSBVt4RKgum7Q/Gs4LG7rGpwY4SN7BExSJMKyHptcN 2h+2GYrNXeJ0l6QdOhTYikltVlk0d/ePaTqaV9iw6FRkwOvttnuO733D8+fS4mGDsN9AKSjTu RaC/iKJQl8myWOCSu587DVMX+JnCfVBeP9mZipcelC/u4ZBYqQ/X9kP4+QeEri/n3J9UkqgDI dA1dKcWqke0siqB7SsKZgLGimX90e4r32lFTMBrhaIM1s9F2iKlM5g+w7qxG2TXKn1hLDA3R1 Vl0/OkYIbSO5NN/QZAcXTw1+dpxtt1m1+xQNeez/wsAdMXnBxeC5kP3g8RkoJDoyMsnjUXvUC bxqvgs0QNSgQx+0r6GTlJh6AgFvYlHz1BKw5Ixyn/3zGtcX4KxpfJ/BBGGirbvbtzBIW9F0b8 3dals+rooEVUAS7G5rLzuvynzXkDRTCmyl7fi4KMBCkBcYSbqCVOzYfXPWG05qjCDKrqsw9ET D96FpSUc2ufv0d0Y79al93nJgsuqPybMeYBqGl1e7/IbK6pnIXCMAOC4sdSQhRNWWjyq+Zhjr eYHeeakIbNpQYj1gIesn8TcMWo4e2BJJYKxFmb5yHMtCdYOKZAhsy8kEOSCyIpqIb4pC+m6 Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/23 10:59:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Executable guest pages are never directly executed by the host, but do need to be readable for translation. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20200519185645.3915-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.26.2 diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 46c7eeba9bd2..f2615634201d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -76,8 +76,12 @@ static int validate_prot_to_pageflags(int *host_prot, int prot) * don't bother transforming guest bit to host bit. Any other * target-specific prot bits will not be understood by the host * and will need to be encoded into page_flags for qemu emulation. + * + * Pages that are executable by the guest will never be executed + * by the host, but the host will need to be able to read them. */ - *host_prot = prot & (PROT_READ | PROT_WRITE | PROT_EXEC); + *host_prot = (prot & (PROT_READ | PROT_WRITE)) + | (prot & PROT_EXEC ? PROT_READ : 0); return prot & ~valid ? 0 : page_flags; }