{"id":2225617,"url":"http://patchwork.ozlabs.org/api/covers/2225617/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/cover/20260421093715.2995067-1-frank.chang@sifive.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421093715.2995067-1-frank.chang@sifive.com>","list_archive_url":null,"date":"2026-04-21T09:37:09","name":"[v4,0/6] Fix Zjpm implementation","submitter":{"id":79604,"url":"http://patchwork.ozlabs.org/api/people/79604/?format=json","name":"Frank Chang","email":"frank.chang@sifive.com"},"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/cover/20260421093715.2995067-1-frank.chang@sifive.com/mbox/","series":[{"id":500769,"url":"http://patchwork.ozlabs.org/api/series/500769/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500769","date":"2026-04-21T09:37:09","name":"Fix Zjpm implementation","version":4,"mbox":"http://patchwork.ozlabs.org/series/500769/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/2225617/comments/","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256\n header.s=google header.b=XVZ/RDs5;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0HMZ66HLz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 19:37:45 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wF7Xu-0008WO-Ag; Tue, 21 Apr 2026 05:37:30 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <frank.chang@sifive.com>)\n id 1wF7Xq-0008VQ-9A\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 05:37:26 -0400","from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <frank.chang@sifive.com>)\n id 1wF7Xo-0007qF-KH\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 05:37:26 -0400","by mail-pf1-x42b.google.com with SMTP id\n d2e1a72fcca58-827270d50d4so3758201b3a.3\n for <qemu-devel@nongnu.org>; Tue, 21 Apr 2026 02:37:23 -0700 (PDT)","from hsinchu16.internal.sifive.com ([210.176.154.34])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82f8e981be6sm15904589b3a.9.2026.04.21.02.37.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 02:37:21 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=sifive.com; s=google; t=1776764242; x=1777369042; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=+2Z9FaiCk46VlVG9ywRB+kf8xp8oDbDRE+mOXIB+O20=;\n b=XVZ/RDs5K/56ZeeJjGkSDd2PgQe9xOG8BxcrXKHOv68YTFZ4w4Mseo4X/Aa/F4sO7A\n 3ceJFL7V2Kx0fgOcudhn93YuysByMxW/i7asvRHtnhbIasIhI06oAEmwOdIuvoKCfW3c\n k31OhMZAHg/nDSn8gPhLO7joUBWCrTFmW67OuIzA7d7Jm4lDXv2n6zuJ5eO4bshsaUR+\n xuibnA75Fv+SecmVziTuPVPB45N3haoTRM/eYKgn73rkkLS27S1xgvbaLgSnkdsYNwfb\n CTqRxsBUEHncjS3drGZrtMbuU7nklw2U7i5ZhOlLS1i3f4UH3HnGSU/nxlrmHX07HCwz\n wG3g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776764242; x=1777369042;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=+2Z9FaiCk46VlVG9ywRB+kf8xp8oDbDRE+mOXIB+O20=;\n b=UpeBQq8lCKT9hJnIeO4rajMeCO8zUDlQ/17hORxMKhAeFduzp9KC7MoaDaHLqO7slH\n 9vN4SnVy73P/ywJqWQSxMBkBHeLBvR9uyiZ9v1qj/61Kft6aIcYpTxfpzwY3VpqmbNdQ\n 6JrkTgfNSM7t90AU7ZW/ZTTOBIau+iejLvq3E+BLbX2fd32+scL51HINXR+dBK/ig1JM\n sNUeYvLiSNiEcnBolZFIhAqSOUwqKFbqJDW0IbtiVlyFUefCQNJ16IHo/cMgjc9TFd2c\n 9Cuw2uYiV/rsT8hnsDvAsfLZELIY5xNXRwSE5UVyVig4sOfCnpBUC+OrWBMPOPoGTHPn\n C/Tw==","X-Gm-Message-State":"AOJu0Yw2TTRbRx98cRjFz9UlfPg6VwpkUjm8atcN5mDzTflLEu7rB0zv\n ab3DVPQL+wBpUm6oOK+F+JGCwVG52aOOC1v4p2KLbPBFqklToNKhJFUn8ysuTy4n6Y+n4A9q3q7\n vfBFpdMhHdoLrVtY+fikl2ocqxFg4X9ky1NMxkSyEEfU8OWFExqD+v+GCqGTaaN6arKSWPWTyUk\n G1R3wZmPx0FoLmXW4OKbtWEA/677KeHnvSQKlj24C/8Msz+8Aj","X-Gm-Gg":"AeBDietJk86pirlgB5enJ/7U9is5q6PulkhC7dF+/j4fU0dMyJNd5WPhv/PqGstXzuy\n mJb0ep8+QHNA48U1KLX9+NNYo0LDinzd1W/EOV++oQTyZ5aEN0jjozfL73hYF4DxuyRPB3G1WXE\n dN7AF7lDp6M1ix7xkI+TFsKillhDqE8gfyVhQ1n+ApFcijXjEDgeNc4yoADtZVmNBKUj97jc6As\n hmMEsg/yyeA4vyjQgXOIlcsqZ1gxmXC/Kx8n9Edfg1Vo2zGDkbgLm7tOlKTgNTfmbOPraLPrOgy\n C9lI+Nlshe/i7bIvAH6cHJDyw96Y5U4cmsRh/8+d5M4RKioaSsUUTxhjFcKiNvInE86inVZ8p6m\n R5XCbWkBoizGOWNPLxoIMkJD7l3PYU71f0SKwEIkFPSSSe25WWjcdYlnYufxGCUeyN8eIrwrxqM\n 6kD4sLaOLdHD2bkm9CGo8M4QJAm1QfgtQUc/Z+zp5mqCUCxh7xR+TKnDEYCltU","X-Received":"by 2002:a05:6a00:3028:b0:82a:6461:6d15 with SMTP id\n d2e1a72fcca58-82f8c94c5fbmr18841416b3a.46.1776764242088;\n Tue, 21 Apr 2026 02:37:22 -0700 (PDT)","From":"frank.chang@sifive.com","To":"qemu-devel@nongnu.org","Cc":"Palmer Dabbelt <palmer@dabbelt.com>,\n Alistair Francis <alistair.francis@wdc.com>,\n Weiwei Li <liwei1518@gmail.com>,\n Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>,\n Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,\n Chao Liu <chao.liu.zevorn@gmail.com>,\n qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs),\n Frank Chang <frank.chang@sifive.com>","Subject":"[PATCH v4 0/6] Fix Zjpm implementation","Date":"Tue, 21 Apr 2026 17:37:09 +0800","Message-ID":"<20260421093715.2995067-1-frank.chang@sifive.com>","X-Mailer":"git-send-email 2.43.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::42b;\n envelope-from=frank.chang@sifive.com; helo=mail-pf1-x42b.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 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":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Frank Chang <frank.chang@sifive.com>\n\nThe current Zjpm implementation has the following issues:\n\n1. The address is shifted before obtaining the correct PMLEN value.\n2. riscv_pm_get_pmm() does not handle effective privilege mode correctly.\n3. mstatus.MPRV does not affect virtual-machine load/store instructions.\n4. Sign extension for virtual-machine load/store instructions (HLV.* and\n   HSV.*) must be performed when vsatp.MODE != Bare.\n\nThis patchset fixes the above issues and also renames\nriscv_pm_get_virt_pmm() to riscv_pm_get_vm_ldst_pmm(), as the helper\nis only used when checking the PMM configuration for virtual-machine\nload/store instructions, rather than for VS/VU modes.\n\nChangelog:\n\nv4:\n  * Rebase to the latest to-apply.next branch.\n\nv3:\n  * Move riscv_cpu_eff_priv() to the header file and declare it as a\n    static inline function.\n  * Fix the MXR check bugs pointed out by Radim Krčmář.\n\nv2:\n  * Check effective privilege mode in riscv_pm_get_pmm().\n  * Fix pointer masking for virtual-machine load/store instructions\n    (HLV.* and HSV.*).\n  * Rename riscv_pm_get_virt_pmm() to riscv_pm_get_vm_ldst_pmm().\n\nFrank Chang (5):\n  target/riscv: Add a helper to return the current effective priv mode\n  target/riscv: Fix pointer masking PMM field selection logic\n  target/riscv: Fix pointer masking for virtual-machine load/store insns\n  target/riscv: Rename riscv_pm_get_virt_pmm() to\n    riscv_pm_get_vm_ldst_pmm()\n  target/riscv: Fix pointer masking translation mode check bug\n\nYong-Xuan Wang (1):\n  target/riscv: fix address masking\n\n target/riscv/cpu.h         |  41 +++++++++++++-\n target/riscv/cpu_helper.c  | 110 +++++++++++++++++++++++++++----------\n target/riscv/internals.h   |   8 +--\n target/riscv/tcg/tcg-cpu.c |   4 +-\n 4 files changed, 124 insertions(+), 39 deletions(-)\n\n--\n2.43.0"}