From nobody Fri Dec 19 19:18:04 2025 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=1572050240; cv=none; d=zoho.com; s=zohoarc; b=mWACxGPWS80tIvhXwAwlJQf9pvd3cyXFG9DWdHvOPSBbVeXY6Zq5+/mqcjsPNtEEqka611/A/FCWxbpBQca/1LMsWrrhd/F7V8s7aQOhpnUn5pyX0iC3F2zoZdlcoabB1OVuNmP2NMyCXl5mI3c2s0fYnvRfy37E34aojOyq7vM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572050240; 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; bh=5M3CbCVeP6EVa8oPHMNs9/UbYLg/5QpmamrpCUmvezA=; b=RTgphQr9/Jhgn2PtsyHF3QX0yl05p1VkOo4wpbMcwVecFjgTGGGmVoNHyNvGGfCT9BOyGUaMmB0nH/l2p3pwaSAFIXcuN2ef+Nmd4Z3iL+zeTPCa2AAPem5lfoJjBy4tqc/IvcmxX3ft4mPnfRxtr0u6rRa+PaiigI46ASazeNI= 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 1572050240262743.5359486955548; Fri, 25 Oct 2019 17:37:20 -0700 (PDT) Received: from localhost ([::1]:37492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOA51-00052y-82 for importer@patchew.org; Fri, 25 Oct 2019 20:37:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO903-00046d-7E for qemu-devel@nongnu.org; Fri, 25 Oct 2019 19:28:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iO902-0003s7-4P for qemu-devel@nongnu.org; Fri, 25 Oct 2019 19:28:07 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:10389) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iO901-0003r5-T1; Fri, 25 Oct 2019 19:28:06 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Oct 2019 07:28:05 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 16:23:31 -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; 25 Oct 2019 16:28:06 -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=1572046085; x=1603582085; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qq3BN6rY7UmBDtE9mG6vAdLDQL46C93+/Qlv2qhxHJg=; b=QAFmJwA9QODJRxgEycv/u0CsMvbonvFR07igO47CTAOa6aIBQoZLDzKj n7+YmkZmYUIq96/HqyjClVPj68964torxlMNP4K+GTl736ej9JnXjqDtM 1Nqbf1LpWC7zv0GuLeS3j61fFGyqW3q/1yc7R4Eq6IAjOl6A94b23+cSo mIB1SKZ97zf+hOsx7UKP1ABWTkqpTsplSJ+yPOi3WpjV55NGp9Q4pWqUL iwUlwC19sw+5+KMrPqldSvxlWFggMwKkLxktZuTun2MsUhbbCowFQxkKk gFymXE+EMZvdDYOcAiTkh4KOxhGl2nFZynEptSxW/IzBT8ragfUaBCrJA A==; IronPort-SDR: sGEVy0jQC/WDyuTxm7D3T9uQiZmWeB7Erb6Rot7BedHq/9lUKK7Kpj0iBiONil4pvgeKhZgeC7 IuPKOKGc79kMRlg618/3QJsyJ79Coue25EM37FEF+aOFJDWjQlQydtCEgeVt5TpL8Znhs6AX2D qRul50Zb7ojHAl6J0q85+P8xHtPac1Ohvw9B2jRZt7K4oG/GUE4GwVsG5vFdEXgM/H4ZTuYBpg //DpiZTlw2wLdZ4PXaD+BwruwRYS3qhP417x8mYmaRepUbxf10IZgGsnPHl2FDGsGbTQDuEFcG J5A= X-IronPort-AV: E=Sophos;i="5.68,230,1569254400"; d="scan'208";a="228520354" IronPort-SDR: kwetnRu9aD3e+ay57fbishlyAfyh3WzQPcIKso8w5KBp4DsK7KE4KqJI8EU1x95C0zkBIneSDt 5d2j9157uuNL59g/NK46T4fJPsa3OVPMIfItIOpdvY4UO0pBIJ48nvnSPfhGadunKTBPJrrs0+ VtFgEZHy/+rYXiCF1GPvaJaOoqEWqOAYUW8tMCcCvbM1ylbBDLWdciJgTlZP0CoYl/cFLzwx37 4+9hWJeIgm74MrKNlz4G3J0ZLEM0mAf6a1CDMky9l8mRve5yKlvMnBYn3AQfYlXJgCyLMLkU2z 82XJJVDFYwhRizwbQVBWJFnq IronPort-SDR: RyL78MHZk9qyGuMPRju9DLHoPADQJis7Spd8vMTWdsIHFez2A8UVQfsPI9PfufFG7bsyJ8ZWto H1JfNAIQnxtzIc8XgapqCSeKb82GIYfKYflEFinQFeA2K2JziD8FPoWvCls1C6xJZ2FUn3hxw1 1K14Bba8K8DZvi5GpFjByJ2AaRbLH4J4P/cpRtr7dO6+4IefZlcf46VfVLyNDSeYSURpWsjC9D 5bTLGIQ4j2VFmeDUNkfniP/G6RmwKhYfVlUo0BngWF9WmGa6wzpnmpRs27UaPV4PWKtDceGCk1 4QQ= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v2 01/27] target/riscv: Don't set write permissions on dirty PTEs Date: Fri, 25 Oct 2019 16:23:10 -0700 Message-Id: <092c283c3e57b668490e150e8799de28171d6972.1572045716.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.23.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 [fuzzy] X-Received-From: 68.232.141.245 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 0e1a4d91fc..31f553efb9 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -344,10 +344,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.23.0