[{"id":3680092,"web_url":"http://patchwork.ozlabs.org/comment/3680092/","msgid":"<005262c8-7ac4-4bbe-9b69-39ebd8fca2f5@linaro.org>","list_archive_url":null,"date":"2026-04-21T22:22:44","subject":"Re: [PATCH v2 0/5] Defer the IOMMU translation and support\n access_type","submitter":{"id":85046,"url":"http://patchwork.ozlabs.org/api/people/85046/","name":"Philippe Mathieu-Daudé","email":"philmd@linaro.org"},"content":"Cc'ing Pierrick & Mark\n\nOn 21/4/26 18:29, Jim Shu wrote:\n> Note: v1 title is \"accel/tcg: Pass the access_type to IOMMUMemoryRegion\"\n> \n> Incoming security protection devices feature more complex IOMMUMemoryRegion\n> implementation in the CPU path than ARM MPC device. For example,\n> RISC-V wgChecker [1] may permit the access with only RO/WO permissions.\n> Consequently, the IOMMUMemoryRegion could return different sections for\n> read & write access.\n> \n> To support such IOMMUMemoryRegion behavior in the CPU path, the design\n> of IOMMU translation must be updated:\n> \n> 1. address_space_translate*() must now pass the access_type to\n>     IOMMUMemoryRegion.\n> 2. Since IOMMU translation results are too complex to be fully stored\n>     in the CPU TLB. we will defer the translation until the actual access\n>     occurs. Also, TLB is allowed to store the untranslated IOMMU region.\n> \n> To implement deferred IOMMU translation, this patchset introduces the\n> following changes:\n> \n> 1. tlb_set_page_full() no longer translates the IOMMU region\n>     immediately. Instead, it stores the untranslated region directly in\n>     the TLB. A new slow-path flag, TLB_IOMMU, is introduced to force\n>     access into the slow path when a region has not yet been translated\n>     in the TLB entry.\n> \n> 2. When the CPU utilizes a TLB entry in the slow path, it should perform\n>     the lazy IOMMU translation of the access_type first. The resulting\n>     translated region and access type are stored in CPUTLBEntryFull.\n>     Since the slow path always performs lazy translation first, we can\n>     switch the CPUTLBEntryFull content to the correct access type before\n>     use.\n> \n> 3. To accelerate memory access in the fast path, lazy translation can\n>     update the addend of the CPUTLBEntry when translating the region to a\n>     host memory region. We restrict the IOMMU region to have a single\n>     non-zero 'addend' across all permissions. If a second 'addend' is\n>     present for a CPUTLBEntry, QEMU will trigger an assertion. This\n>     limitation is sufficient for security devices, as their \"secondary\"\n>     region is typically an IO region used to emulate device error\n>     handling when access is rejected.\n> \n> 4. To support non-slow TLB flags, lazy translation can update the TLB\n>     flags in the 'addr_idx' of the CPUTLBEntry. Lazy translation only\n>     updates the flags for the permissions specified in @prot. This\n>     ensures that each access_type of a translated region to maintains\n>     independent TLB flags. For example, TLB_DIRTY of memory region will\n>     not be \"polluted\" from other permission that translated to different\n>     region.\n> \n> Both RISC-V wgChecker [1] and RISC-V IOPMP [2] devices require this\n> feature.\n> \n> [1] RISC-V WG:\n> https://patchew.org/QEMU/20251021155548.584543-1-jim.shu@sifive.com/\n> [2] RISC-V IOPMP:\n> https://patchew.org/QEMU/20250312093735.1517740-1-ethan84@andestech.com/\n> \n> Changed since v1:\n> - Remove the ping-pong TLB entry behavior. Instead, defer the IOMMU\n>    translation until actual access in the CPU path. Provide a IOMMU\n>    lazy translation function with the special handling of 'addend'\n>    and 'addr_idx' fields of CPUTLBEntry.\n> - Fix the checkpatch warning.\n> \n> \n> Jim Shu (5):\n>    accel/tcg: Pass access_type as an argument of tlb_set_page*()\n>    accel/tcg: address_space_translate*() will pass the correct\n>      iommu_flags\n>    accel/tcg: Provide early AS translate function\n>    accel/tcg: Add IOMMU lazy translation function\n>    accel/tcg: Support IOMMU lazy translation in CPU TLB","headers":{"Return-Path":"<qemu-ppc-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=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=xVBU3rf3;\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-ppc-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 4g0cLc5TKDz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 08:23:04 +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-ppc-bounces@nongnu.org>)\n\tid 1wFJUc-0004AI-I4; Tue, 21 Apr 2026 18:22:54 -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 <philmd@linaro.org>) id 1wFJUb-00049b-Es\n for qemu-ppc@nongnu.org; Tue, 21 Apr 2026 18:22:53 -0400","from mail-wm1-x333.google.com ([2a00:1450:4864:20::333])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1wFJUY-0007Y7-68\n for qemu-ppc@nongnu.org; Tue, 21 Apr 2026 18:22:53 -0400","by mail-wm1-x333.google.com with SMTP id\n 5b1f17b1804b1-48896199cbaso48586735e9.1\n for <qemu-ppc@nongnu.org>; Tue, 21 Apr 2026 15:22:49 -0700 (PDT)","from [192.168.69.210] (88-187-86-199.subs.proxad.net.\n [88.187.86.199]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48a525a0b1asm64647405e9.2.2026.04.21.15.22.45\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Tue, 21 Apr 2026 15:22:47 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1776810168; x=1777414968; darn=nongnu.org;\n h=content-transfer-encoding:in-reply-to:from:references:cc:to\n :content-language:subject:user-agent:mime-version:date:message-id\n :from:to:cc:subject:date:message-id:reply-to;\n bh=BAq2gyUqg3Ed/iVfZisi5D1so/0DHxlWPok1Kar9AII=;\n b=xVBU3rf3skbJSwU7ZsYJjhKvi4rUwOLIzYGmO8XFbQTBje7TnKkCrpMAZZyg1kKOMh\n xtg7PNvb2HZFU6548O1CyM7R8CbfDbsNYP1SOQn5s3dteTIDo7lNXY+OLTw/mIoBljhq\n APy+kSCPDYO+sXmJz1nJwOTBWo4J8n4duQcvalfl9x3O1MSIsMziVZ77MwPYUsUYL2fH\n ztU7uO09/MNDW60u1xM9l0Mze7Qo/KtXUWaxwuYZGM7a0ktJih94zgJOc/R6vqAvMk3N\n sc31wea3xIlTVLqv/nNCDR1dLHO1xfdQoCkr0ggFKI2GaM1V0DFuFJX+3AQ5ccUOHswd\n npDw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776810168; x=1777414968;\n h=content-transfer-encoding:in-reply-to:from:references:cc:to\n :content-language:subject:user-agent:mime-version:date:message-id\n :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=BAq2gyUqg3Ed/iVfZisi5D1so/0DHxlWPok1Kar9AII=;\n b=OtzJXsOGj+mn+7xRvLCsh9v+3LOBSWVj2h+wdmO1vOBSFjN8le2Ws0h135HfOhYT+q\n FcuTBnRBhDOyUPMmkJQEpThxvm1ug6GarKObjUxMQDxqgFwqOgLiUE93p03OgfEdq5V1\n xIUAfxnCeNRCBqug8NweBAC9DhKbxLdX/2a70MK0Oa9CfMabgJou5bGFBIiYg4fUbJzJ\n Z4u/z+r/oThr8bSG1QyGjtpMMPgGwjN6l4r+v79JAAs4bb4w1j5bv6APu/ClblwCsMpI\n /D9t6kEhDmvhCx6PS09o4+KOCno+hJkHH6Xr8/W/UDSjFaS0kuBhI5JdQPvz6ZwkTRr6\n 7hnw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ8O76C2zRlwt/6iQJdkqUkCC7CN0ghMbhIOd/NyqEgwteR6ZTe9+JDKAs7OZUpJrvw/2xlhzianQA==@nongnu.org","X-Gm-Message-State":"AOJu0Yxp0Stekrb/BfmxZ0Vg1ksZzM2oAjnhQvnYEIJyW068ZcbzXQT/\n 8kObAKB+DIrnH/4pxL4tjOu0bhq29axBG37DN6lo36EgE2u4dhDlDVtOYJarfqGY1Mk=","X-Gm-Gg":"AeBDietAMmCKskifH+Vf7LoJZQiubuvb26cZ8FvmyCJm26mv85uyavoweErEt5DQlhH\n 2dFKAXK7OEe7ceEFO1+t7cuHjjnbEO9/Cz0qVc8fO2S/2k7rVaZCNKzrsQz4zL+pEvP1eqjfVmp\n G9z+BG0ox6pHXRzZGkeULWFzkfY1rU1of7ztkQii2fD57qPoUTRude5MOki+N5ZDbTe9xNEEfg3\n QFwUhIJkJJ0/KC6zKdxuVjUESdRItwSfyNEP+FXfsyM+0iWvH+MCeWWKgZc5G03ZkdAhDcEj3hX\n AM4RoImppzBABdETdZieO8Nb6mDvnVaCUIT0SOD9JI4PTaYH8rE7cTy/nZLhRbo61AJr32vhsPX\n PA1WgbdPkK63Ty4hc1Ru5QDCGWtnSTfjwz6clZuUJmZYVwz8ADJz7p7qA780ZRidZIFWHFyIbh2\n +o7DU2LG+81MfXpdDHAfQrs5KnkhyYOKwz3iNLYsVO5uP6U3WuB62Ymx4GKVOcXobJt3dUt4CkY\n qTj","X-Received":"by 2002:a05:600c:154e:b0:488:9ed3:1492 with SMTP id\n 5b1f17b1804b1-488fb74fc02mr280369975e9.10.1776810168158;\n Tue, 21 Apr 2026 15:22:48 -0700 (PDT)","Message-ID":"<005262c8-7ac4-4bbe-9b69-39ebd8fca2f5@linaro.org>","Date":"Wed, 22 Apr 2026 00:22:44 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 0/5] Defer the IOMMU translation and support\n access_type","Content-Language":"en-US","To":"Jim Shu <jim.shu@sifive.com>, qemu-devel@nongnu.org,\n qemu-riscv@nongnu.org, Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>","Cc":"Richard Henderson <richard.henderson@linaro.org>,\n Paolo Bonzini <pbonzini@redhat.com>,\n Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,\n Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>,\n Peter Xu <peterx@redhat.com>, Michael Rolnik <mrolnik@gmail.com>,\n Helge Deller <deller@gmx.de>, Song Gao <gaosong@loongson.cn>,\n Laurent Vivier <laurent@vivier.eu>,\n \"Edgar E. Iglesias\" <edgar.iglesias@gmail.com>,\n Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang\n <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>,\n Stafford Horne <shorne@gmail.com>, Nicholas Piggin <npiggin@gmail.com>,\n Chinmay Rath <rathc@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>,\n Palmer Dabbelt <palmer@dabbelt.com>,\n Alistair Francis <alistair.francis@wdc.com>, Weiwei Li\n <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 Yoshinori Sato <yoshinori.sato@nifty.com>,\n Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>,\n Cornelia Huck <cohuck@redhat.com>, Eric Farman <farman@linux.ibm.com>,\n Matthew Rosato <mjrosato@linux.ibm.com>,\n Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,\n Artyom Tarasenko <atar4qemu@gmail.com>,\n Bastian Koppelmann <kbastian@rumtueddeln.de>,\n Max Filippov <jcmvbkbc@gmail.com>,\n \"open list:PowerPC TCG CPUs\" <qemu-ppc@nongnu.org>,\n \"open list:S390 TCG CPUs\" <qemu-s390x@nongnu.org>,\n Mark Burton <mburton@qti.qualcomm.com>","References":"<20260421162912.3295598-1-jim.shu@sifive.com>","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>","In-Reply-To":"<20260421162912.3295598-1-jim.shu@sifive.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Received-SPF":"pass client-ip=2a00:1450:4864:20::333;\n envelope-from=philmd@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,\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=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-ppc@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<qemu-ppc.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-ppc>,\n <mailto:qemu-ppc-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-ppc>","List-Post":"<mailto:qemu-ppc@nongnu.org>","List-Help":"<mailto:qemu-ppc-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-ppc>,\n <mailto:qemu-ppc-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org"}}]