From nobody Tue Feb 10 19:17:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.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=1588185787; cv=none; d=zohomail.com; s=zohoarc; b=gBh9ZZlTmtrcETx7ZCIBV5zqGT1kOLjK/9K1QPUoW/RQxNk3FA5sUzpAr47wtejwGjnSIhTOG96eYOyMA6y8zIcYW5Dne6pzzHv1KOZuFip5Rcr/pDZGokGG6qL+bscbHXecnYFEHGWdJ/N5knoPT5mAUlMHb/wZLPghf6ZxIJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588185787; 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=zHurqTxpa2A85blyvLiS+6E1VJ8YKYX8bNvKfkd7O6w=; b=Ebcmx9h/m/s1kg3UNnHdlHq2KZQLYSranRpFQmvZbaeIZuHkfbIKD9DkMoTN/umcgvBMuU/sra9c/aJxJcWVDWw/t9uNoV2lFLdYS/pVF2fLdF8v8Ij0Wo4glrjGnpvipgMCElASS2nyufq310XCKNM8/gMiIcJOuCb4eBzLrAM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.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 1588185787895117.09734612931561; Wed, 29 Apr 2020 11:43:07 -0700 (PDT) Received: from localhost ([::1]:46144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTrfm-00014e-EB for importer@patchew.org; Wed, 29 Apr 2020 14:43:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37444) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTraD-0008OA-Ez for qemu-devel@nongnu.org; Wed, 29 Apr 2020 14:37:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTraB-0003Uy-3X for qemu-devel@nongnu.org; Wed, 29 Apr 2020 14:37:21 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:2049) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jTra5-0003Ps-8D; Wed, 29 Apr 2020 14:37:13 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 Apr 2020 02:37:06 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2020 11:27:10 -0700 Received: from cnf007834.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.55.253]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Apr 2020 11:37:04 -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=1588185434; x=1619721434; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H3Rf0GK2uIFQ8+W/s2BSGxfdGYDmRN5HO2AJN6YT9+s=; b=gLvfl+mUoF6QViAfi0TQRNW9BxVhhhwwSqTPVcl7QXNxoZNkT+Ds6MFO AHon52DbrAeS9OURcv+oHsZXBheX6BSGut2JHMZ3ocIPgSg/Cji/nlkrI V079Z/iKZ2LshAIuawMD2TGAbeVwIowSRDpx2WLWjjDvnypAK7Z0yYYpB JCtbpW46mAJv6jepSj9ycaIodfeRHWnpZJdUEJyOWX5LA2k/6oojHmhN2 lTrA23zJDsydjKcPatVZNGZiY/7ZsWTFQ3v5u0gYazizCqYLacdbKRPWq b2MQUMrdBRJue6QRQt4m4M1mgozIJLDrhie6xp7HKwKUUBguQGzZO/Kvb Q==; IronPort-SDR: Odtz9RtK4yukYFjLkl7PPCBAXAcQYRKgeiGfVWnvO4Btfsl+ZeIhicSJ3OrJfEwkFTWUtijMAP gXXY2OWGcEmrWRBN/CZbZJd8Ma0ZEekr8y4MRaCbWP99Y/QKhqaBFQolPoKetc3fpv3S5wJ+bB 8Cf2iUjk5EjRW+5OB6YGzE9IAu8fhAF8lsM9nRZd8+1Bsqqb6817T0ZgnvQVA265We2uaF20B+ tVObTrLV9m5MhAqVee5Rbjl5qYmL4FraOYxz2KsbBnuDyfpBKqOXmfOXWz6dYtUsKulyUATwJ9 qZ8= X-IronPort-AV: E=Sophos;i="5.73,332,1583164800"; d="scan'208";a="137935142" IronPort-SDR: UXb1/ASlPfPPHstv3Tk3GT+kdTbkLEcq10ZQkC4eQsFmPBN1sntJkXq0PNg9UNJ33lzVeF9Pm4 wR0F6HqOKrP4pRLB4oEJffI/oUOY96uSw= IronPort-SDR: oacbIocZ4C1rRt/d5AjOi+jHqCXiVXYBwKJrxI1Y2JpdI9i3/LTVFOhvRzjRQM8jQQvhX+Kbke MNy5oH+WvOiA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL 06/14] riscv: Fix Stage2 SV32 page table walk Date: Wed, 29 Apr 2020 11:28:48 -0700 Message-Id: <20200429182856.2588202-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429182856.2588202-1-alistair.francis@wdc.com> References: <20200429182856.2588202-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=381fbd49e=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 14:37:03 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Received-From: 216.71.154.45 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: Alistair Francis , Anup Patel , palmerdabbelt@google.com, qemu-riscv@nongnu.org, qemu-devel@nongnu.org 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" From: Anup Patel As-per RISC-V H-Extension v0.5 draft, the Stage2 SV32 page table has 12bits of VPN[1] and 10bits of VPN[0]. The additional 2bits in VPN[1] is required to handle the 34bit intermediate physical address coming from Stage1 SV32 page table. The 12bits of VPN[1] implies that Stage2 SV32 level-0 page table will be 16KB in size with total 4096 enteries where each entry maps 4MB of memory (same as Stage1 SV32 page table). The get_physical_address() function is broken for Stage2 SV32 level-0 page table because it incorrectly computes output physical address for Stage2 SV32 level-0 page table entry. The root cause of the issue is that get_physical_address() uses the "widened" variable to compute level-0 physical address mapping which changes level-0 mapping size (instead of 4MB). We should use the "widened" variable only for computing index of Stage2 SV32 level-0 page table. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Message-id: 20200330082724.120444-1-anup.patel@wdc.com Message-Id: <20200330082724.120444-1-anup.patel@wdc.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 50e13a064f..bc80aa87cf 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -559,12 +559,7 @@ restart: /* for superpage mappings, make a fake leaf PTE for the TLB's benefit. */ target_ulong vpn =3D addr >> PGSHIFT; - if (i =3D=3D 0) { - *physical =3D (ppn | (vpn & ((1L << (ptshift + widened)) -= 1))) << - PGSHIFT; - } else { - *physical =3D (ppn | (vpn & ((1L << ptshift) - 1))) << PGS= HIFT; - } + *physical =3D (ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT; =20 /* set permissions on the TLB entry */ if ((pte & PTE_R) || ((pte & PTE_X) && mxr)) { --=20 2.26.2