From nobody Mon Feb 9 19:10:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1565905276; cv=none; d=zoho.com; s=zohoarc; b=fXTc/9yEs8VcU+UHi45Zy2YSeJLQIZ+Moh0wW619THL2KYuyr0Bs+yj3HWPOaWIbp5Vf/TxftfEmMuBMCTeX1AJZyh+yVhJMhV8btflK1GBPGHty/IFQmqIw3VmmIndvkosFmeiICybW/1wEMlcDJM/6zv5cqDQRCQh+9/jHbSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565905276; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hREZfWDKtfc9hyj47wiEQ/RzURui3pAq0g2GSEOBn2w=; b=RXfrC6vq5I3Kb/LFYIIdw+JYc8GXXcOp1n1n32oBGQqytunPPxoEsM/b8l/pcxkDLDUmBrdHoi4eAUBfMbGChzPUL/V8mBzcKQfryDKqeGPWPFbCs4V5ca1NjHv8CEjkW4Rer2nC07gNYF8zfGVdXcAcDYbSVCxQ470ZIVN4+9s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565905276185617.9652338421123; Thu, 15 Aug 2019 14:41:16 -0700 (PDT) Received: from localhost ([::1]:47320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyNUb-0004le-SW for importer@patchew.org; Thu, 15 Aug 2019 17:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60263) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyNRu-0002vT-GS for qemu-devel@nongnu.org; Thu, 15 Aug 2019 17:38:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyNRt-0006BD-1p for qemu-devel@nongnu.org; Thu, 15 Aug 2019 17:38:22 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:19195) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyNRs-0006Ao-B4; Thu, 15 Aug 2019 17:38:21 -0400 Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 16 Aug 2019 05:38:15 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2019 14:35:46 -0700 Received: from risc6-mainframe.sdcorp.global.sandisk.com (HELO risc6-mainframe.int.fusionio.com) ([10.196.157.58]) by uls-op-cesaip02.wdc.com with ESMTP; 15 Aug 2019 14:38:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1565905100; x=1597441100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TzSLaqGd1ijZpKYVZGyg4YDJEHLu4T6oDeS8B/digZY=; b=lxqV9Lm9JqaSaQwn1DBg41+JUU8SEW1y7X51H9/GOkSKtDPXw5wS72Jx XkuDCKCk2bWs3tKVcVJ1GSFiQT61kLmTkNhSB6tfMV4qoU+PiRWzZT5Dd soipP5CK3e7oOM7uSzcKWY/3n50OWbmsxKvi7Wcgj0WYzf8L1RK7LYhRo N0fm++J4sNhoB+l4Vjdu3P0a+LtmS3kFgHsSqKMfm2K/UZeoPsrAYI1WT 0fjqonxlLwyV8ry7j+weupRd02uJs7XyW/uzXsJu7oHLtlNqwexuSKXWP 5wqllZMbq/K48l9JgwAu5XuzHO0XXEulkodOqnFJRjNvRkIipnibWJm97 g==; IronPort-SDR: mYbRdi8E4XMVKxMPHzK+ADyfaspQTyXRvgAsKEeSs24cg+hC0RtEerl976HzGNy4rSEzcXrXjo H3i7UIN522mti6zTC7lEBuXgYgG3VPa2JaMrLsMXmcqKaxupbRT2MLDW4MEfvSAn3SYDKKcUF1 w2ioVYGuGbEVcF8ji5zbO/Ez5W4r6mY5lRnbcTjsk66LcVwyRPmiyamquOJqUmBTbIdBUcKajx K6KcG2y4lL5yEm7X36HSJEEQoGx5i9YRVssQvW3sfDu/OqgUijv0qJm9zXNZbISGek5LxSa2ci las= X-IronPort-AV: E=Sophos;i="5.64,389,1559491200"; d="scan'208";a="222470286" IronPort-SDR: i6Xs2WQ8swew2MgH4r00Gx6v2n0XEux/6qkBo+zeZHbbEqazIB1iTdfk6V0Z1GPskD0TXUhd9s Pr9FRsH2XrzT3fghsPk6UVVAzXTQX7ZrEeGxQHAnUCOPLxTCjOWt/GBFIqph44xgUkuQxLWCc6 67t+mjOd44uqOjni1DwvJAkDtMMPvoc2g2etcgG3jJUP5cGCrci456XI+eoUcwspxN9Y9vRkcH DlnlDlnFVQwemHHdWtM3islsjNDHxgcEeO84UQR19QpVYgMpwdnmcFr3BVqAApPYyD5fQASPqE bkRplu6NWP0jpqsHSAxT9vqr IronPort-SDR: 2KPJdM7gtEa5pdPQHr3uHB4LRu983Yj0FX2sBbFmztPt3fksXMvc2Y/mmUWu8rzo9x8UgjZDy3 8WzItftpnoj1ASuYicuI4qFSna5HNTGplT1XNTOxCiV+iPUL3ZJwDlqrQwedLFpzRy+JpO9ylp dQ6q7MZPG7IPc6ohuhbEoNKnYTwqJf/FUYfnwzd4D//0G/WzCfKSQtfgrjwsPu0cTlzYbnby1n BhvsYJiXI14kpopGrjr4LVfN9DUzYq+qVZyR/XZyr6YG4HMboouBD8hiOfVpYmPqwy3oz/VK5k HYk= From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Thu, 15 Aug 2019 14:34:47 -0700 Message-Id: <1a5abeb9acb758a24daddc5ca8ecd56229a73cf1.1565904855.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [PATCH v3 1/7] target/riscv: Don't set write permissions on dirty PTEs 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: alistair23@gmail.com, palmer@sifive.com, alistair.francis@wdc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Setting write permission on dirty PTEs results in userspace inside a Hypervisor guest (VU) becoming corrupted. This appears to be because it ends up with write permission in the second stage translation in cases where we aren't doing a store. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index e32b6126af..f027be7f16 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -340,10 +340,8 @@ restart: if ((pte & PTE_X)) { *prot |=3D PAGE_EXEC; } - /* add write permission on stores or if the page is already di= rty, - so that we TLB miss on later writes to update the dirty bit= */ - if ((pte & PTE_W) && - (access_type =3D=3D MMU_DATA_STORE || (pte & PTE_D))) { + /* add write permission on stores */ + if ((pte & PTE_W) && (access_type =3D=3D MMU_DATA_STORE)) { *prot |=3D PAGE_WRITE; } return TRANSLATE_SUCCESS; --=20 2.22.0