From patchwork Tue May 19 18:56:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186959 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp4109066ilb; Tue, 19 May 2020 11:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxspt0ZPPJeidnpmqzioQbR/FpJDIWGZe1LatVrsv45GdEdVT2URGPvfYlAs17RISCFlq3A X-Received: by 2002:a37:6857:: with SMTP id d84mr944707qkc.42.1589914631945; Tue, 19 May 2020 11:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589914631; cv=none; d=google.com; s=arc-20160816; b=DO6gKwLon8IwcGKL8j/3/1kxPOcgauzSM86worTKmwcdw7LAjvXC3V8bdxqo9ePJ7y bz/UbE4tFFu15BqBstGDfz7YwBWcs51fdsobXadUpFYxpy5LF31juLKCAiJIMiOFTLWC 8R+rdw+1g3TRWwd3GpyT1Fc/3+ZCQMkVM1DMcv3fdezUibrevZUxL6mIA3Reo5lK8kpd CspWY22ksAKl5dSr+taBLEpGJ5fHqIgI+cmsvKQsnDriwa1E4MQWgM1jYRW3LBXOEMkC pC94x39wU47CNmIzlA7jms9ZM/JWgc0RnHhyMRxBqg4rTdQ7liHm+EiTJCt//Ar0oOZU 99Ug== 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 :dkim-signature; bh=V5c+xkhtSjo8Q7kdxtbkQlkla+/4Upk1eGz1d53+Rt4=; b=RIBYAcFoBiWBK7VNjZvZ1tm7no3VZfDUJC+kKiWlS9Bauvbwt0blYok87UvUNZ//G8 yUD4s1XvizmPN9bWWRiFsf1jHsWT8xO0cCJ9tMwieIyL8ohzB6hj8tZ7CV9Inn6HbU3A PYz3CcxfcWwZR+gaJng3+yZ6iW5Z1QhOJ7K4PwCoTLqOQC5CNwLC5nT5eukdWeXRdvTu BDk5oP5DCfiJF6cJkzP8QMZsTh0fz1uKeBAh2qeOZqc+qNO8/HeqmgwoB9KunpkJmJbP tni73RtJFblO0XqFc8vEBoeWl1Xaq5t1fWPUuauh1VYaRjbNOJnHAyJg6dz84erwpXkR t5pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JvZW3FyZ; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y16si205172qto.337.2020.05.19.11.57.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 May 2020 11:57:11 -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; dkim=pass header.i=@linaro.org header.s=google header.b=JvZW3FyZ; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb7QN-0000JX-FK for patch@linaro.org; Tue, 19 May 2020 14:57:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb7Q4-0000G4-8O for qemu-devel@nongnu.org; Tue, 19 May 2020 14:56:52 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:36531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jb7Q3-0000Da-G6 for qemu-devel@nongnu.org; Tue, 19 May 2020 14:56:51 -0400 Received: by mail-pg1-x541.google.com with SMTP id c75so261334pga.3 for ; Tue, 19 May 2020 11:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V5c+xkhtSjo8Q7kdxtbkQlkla+/4Upk1eGz1d53+Rt4=; b=JvZW3FyZ3JI2A6iARUSWKdCNRF+Pwv+2xbGzaUu/ZvpR+7dXqR7sUk7IKICF5pNyoH unAyMqxlzmUPfa1/8wsyTEyi6oT0eCK02WBYCtrVCpzR7N+n7LyzjsSMttgLR1vY3DpH lrIC+tTM5SbJUWXyO0/6y21i7+FbmqM4wSiht1dj5kMvCus6/ye049Ig2ABUJbl0Iiue +AaKY306C6cUyAea9PQWSaM1eqgnTmshepmk0+p9iFnmn0MBnYhtJYd1n6CgWp+N6jKD IT71ppkFjkzV2LD4ipD+zRXH4WkWqiifkqoiNuLKy1paEiBHWdtYzYvLQ7l8rtSdNbcy 6q8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V5c+xkhtSjo8Q7kdxtbkQlkla+/4Upk1eGz1d53+Rt4=; b=FAZJ8CtPXnIFcMjllih7lovxNnTHTQ/o60EPcR2XOjWX6GhFEmfAiM3AV0D9JPZVZp TC5514wmJFuQd2eo3dT5a2XZ3miaAPdivNMUBadq8S7EpiIuMai2AeLy/AJAc2sIuk++ /Nj6vM9VsorigZGV6V4OFIvaHiW/Osba4WnH6LlzaMzMi9zJpgpdT+cIHOAumY4wJSsr dXNn0bUeaBE7OomVsQdgSqp4sAJzwBqP2VUr6rA2h27TzCefkJZr9hDjf6WxpERej7ha +89C4I17JAOSyBL8pnIwbhAyCDMgtU6PwoOoiNuHnnHoOEPPSOVSRv9COOQ8AIGAHV7N dotw== X-Gm-Message-State: AOAM533HFrMF3Z5Jtw6MHH20GCt2UdMztfnuQCgMLFlhTs4Od94C+AS+ 5H7dEEzvynoXFkHK1pzaMHbndxSO4ic= X-Received: by 2002:aa7:9515:: with SMTP id b21mr490260pfp.282.1589914609029; Tue, 19 May 2020 11:56:49 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id b5sm237658pju.50.2020.05.19.11.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 11:56:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/2] linux-user: Adjust guest page protection for the host Date: Tue, 19 May 2020 11:56:45 -0700 Message-Id: <20200519185645.3915-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519185645.3915-1-richard.henderson@linaro.org> References: <20200519185645.3915-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Executable guest pages are never directly executed by the host, but do need to be readable for translation. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 36fd1e2250..84662c3311 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; }