From patchwork Thu Sep 1 06:51:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 601805 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp262850mae; Thu, 1 Sep 2022 00:26:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7bwjfalLBh1UsL/2Q0iy4KelOgqScapWA6Yrayr3L2iU5HQADnS381VPnz9Qdq+ERNnbX7 X-Received: by 2002:a05:622a:181e:b0:343:68e6:a5a with SMTP id t30-20020a05622a181e00b0034368e60a5amr22822517qtc.236.1662017184672; Thu, 01 Sep 2022 00:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662017184; cv=none; d=google.com; s=arc-20160816; b=L0pD8SsESrb+2TDwWQJG8qzkszAPscp3SETF4CQaDDHBpk64lvEoZ8RohKVJruV7t/ zxbG7N5R49aYdsJzI1tGNB+7VHtG8ZO0J5GEZyf/3I/jmE3wJ3j3IV5FTYy886x0WHbc UEipfOR0Sr+MbgfX2Ryvsk98E93JBuvFToqkfgJ3FQyr7n9QKfejUdC/zn8sfyQ32Xpf dYH2rYWUk6n3McfgHLsw7CaKvooCfrOG3RzpPRo7N/oB0FIdb7n5CyKwvCaFVUjrxYz8 RbZJjJMfG9fx0FFpX/Rqc++E7npKToeQGNuIUBSTvm9xWTRprT+fuR7fyTW9/V/bR77p 708w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=SHzx12Rsu42Ye71toTN4bWIrkmgQVEH0DPBud2OqwOk=; b=NCbo0za59RNwjVYCTWiEl1WJf9fxuGWExHxYOgGYxqB960dFMC9Rpft1MZJ7NycR95 XIMSOtSi+LAZx2p6L2a9ZLux67NXsipAFeT2DzR1yAcpaND774HtFBejN4E9lAVP02NV m4BG3kcOwQjQR+2+l8QZ0fUWXyDX6tLV1ga/k+LknvZ5GoMyV2LW0ITLc6S7s20omxXg 1u9vGa77fC9o9LL3q4lCuIvdwccrFzRqU9m23rr16KvnHdq0eHYis0TBqRdCVz41a+yT xFZHWTuiNiZC6X5GwVSoQIZV7PV7JFawbOotTDEMbrHQzgXlRP7mwV5nqcFcwy4LyTay 7Q0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wbzy/ksN"; 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 dv1-20020a05620a1b8100b006b99020ec71si9130912qkb.71.2022.09.01.00.26.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Sep 2022 00:26:24 -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="wbzy/ksN"; 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]:46834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTeam-0001cC-5u for patch@linaro.org; Thu, 01 Sep 2022 03:26:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTe4I-0005vk-AG for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:52:52 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:35439) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTe4A-0003Hi-Jn for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:52:45 -0400 Received: by mail-wm1-x333.google.com with SMTP id m17-20020a7bce11000000b003a5bedec07bso802567wmc.0 for ; Wed, 31 Aug 2022 23:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=SHzx12Rsu42Ye71toTN4bWIrkmgQVEH0DPBud2OqwOk=; b=wbzy/ksNA0SlkUV1s8PhRlgkyUksszXHWERNT9qmG1ysVn+FPq/H5cqzO8g15LpgOt T7Aj/wy+TYP4W3IqIOr/0KYvUjRUWMevR3R7AYhWMmVw5I1QcGVSyhGjrw9fpEA4l8FS oUy9BWBK0cNfV88Qu3bRSnonAbl6fuXn2+SYuFbMFI5NaoRbZzAJnyvLmMGh+orfImXi N9Kn8u+sUcrbTLt/sy4n627hBKkUEpTeGsSOJse/YORzWj2xIswUZbIhvffa75VxnKE6 I3aVp8mi+gw4OTQPDNQL9PPl10nJCOjXHp9Jzy13bXXug6nhQ4hAb3qMm/Eeyz0S0Tyl Auag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=SHzx12Rsu42Ye71toTN4bWIrkmgQVEH0DPBud2OqwOk=; b=FlXSCFBeV1d5lbZXp4Pk5qOHLNYslhKzLv/HlBgzMetUhFQez2T0/LwxzjISbst5zr 85jPEuxDam6E1EPYO5bCgvOKTVBlefDqJ4Q7uWYL2I8aYkBgWnBSXIzI8UVTyvHmkSmG 5QZYfdtcx5C/YR3270TslhJp/24gfFzyksWAREFtOcjGj7KFVM3U1QTTdE3fanxO6fJj S1o9LfD8Zlu0rPL3rHxMsL1zIGn/vHxbJAM3OI+qED9DQ5ilQzVuHEp9YfYZiE+XYQjo 0orUB1mgENXURznwQo1+xUcw6QK+knnxDFQIPXmi8/8GaYFfSaUEOPO2JvIkZo4N/btP fkjQ== X-Gm-Message-State: ACgBeo2/a95zavOH9TMKY4GGsZNth6GEOaX0FjzOnC3y57JGngSkKBHx F60GFZJ+JT/Je83PQOd4Iqf1ekb/cdX+VNaP X-Received: by 2002:a05:600c:25ce:b0:3a5:a3b7:bbfe with SMTP id 14-20020a05600c25ce00b003a5a3b7bbfemr4249120wml.115.1662015161030; Wed, 31 Aug 2022 23:52:41 -0700 (PDT) Received: from stoup.. ([87.192.221.83]) by smtp.gmail.com with ESMTPSA id a6-20020a5d4d46000000b00226dedf1ab7sm8308153wru.76.2022.08.31.23.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 23:52:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 05/20] linux-user: Clear translations on mprotect() Date: Thu, 1 Sep 2022 07:51:55 +0100 Message-Id: <20220901065210.117081-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901065210.117081-1-richard.henderson@linaro.org> References: <20220901065210.117081-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x333.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Ilya Leoshkevich Currently it's possible to execute pages that do not have PAGE_EXEC if there is an existing translation block. Fix by invalidating TBs that touch the affected pages. Signed-off-by: Ilya Leoshkevich Message-Id: <20220817150506.592862-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- linux-user/mmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 048c4135af..6a828e8418 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -177,9 +177,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) goto error; } } + page_set_flags(start, start + len, page_flags); - mmap_unlock(); - return 0; + tb_invalidate_phys_range(start, start + len); + ret = 0; + error: mmap_unlock(); return ret;