From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A05FFC54F51 for ; Wed, 29 Jul 2026 12:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HVHsThmsC1FC/RFABCzk6LOthuorTiRc4YLLaNHgASY=; b=uesoxwIJNAV8z2 nLIUvIRQbVsDzqBNq75xKS6gIwjeoJm841yyiutWvIZdJu11KgbQ80AbGEVPC/jYAf1k/emTSZ7gs I7tNWnvM8w5g5FyNVkBfC43yk2dFMQKD2FQuj4H/wKjgXPeO438BFb3wytpFhLhskd2bqvap6SxOY vW5t5F0PX8k3AUb5YEzl2kN95tYMQJBtCxLzzskAN1Nb+gscQHGCKpopbyXmp7M/Z6X6cPjgIzTJy gFwaAUd3ZKZzAGd3KaMRIj7pZZtI1F6yBklmrfa7U/sFOnHvvWqfSTDdAcwz19mryKjLLnPi3kXCV Ze23h9+K7JvEaospLfoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wp34a-00000007pOf-1JUP; Wed, 29 Jul 2026 12:07:44 +0000 Received: from mail-pz2-x00.google.com ([2607:f8b0:4864:3b::]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wp34W-00000007pN9-3Y94 for kvm-riscv@lists.infradead.org; Wed, 29 Jul 2026 12:07:43 +0000 Received: by mail-pz2-x00.google.com with SMTP id 41be03b00d2f7-ca24d39d8a4so388575a12.1 for ; Wed, 29 Jul 2026 05:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785326860; x=1785931660; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qLMnpNtLpsL2XHYkd+z33mKUcr79GQx5LDeNnSKUE6Y=; b=q1F+BVkWYnzVDeqQiC/zxrtHNKy8qwAXio8DVKRwnMjU6kpCKGvv4TJNM0k29Tq/C2 VDhiaMh+m7U1hTlXmBXwW4cjAQj/Fc5HbSdEXtydEHzsCf1VtzPTd4kRpr2kh4AXg7H2 h1Evu+PfxfprUdFRKLUzikme7BB11SufSegnYWEwjw5V0+jvNajXwR0QzjdnFUr6PnCP X+YeXX7ByDw7qGskGojV2zdqJByBUozLLcIp55NdeerqDm4Ei0GHac60fEbhrdsvruCy Ue4HGWfP+HrGa+GKaa96YOMhznKMntc6QiAX4Mn8yVp0OGWahuYpYeeUs4KcfX3NpEtI 2fTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785326860; x=1785931660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qLMnpNtLpsL2XHYkd+z33mKUcr79GQx5LDeNnSKUE6Y=; b=kiijGTgYO2z4DoOAhr6KX8WmCdDrBoX6dDy6EyJbFnpMJPzjvNuYEm66xDUd7XUiyK kBOorLtaTYl5U6cWrHNfk1heZDq5LlDggb91jdoUQL1YO+ld0gV8ra4gwLL5xb2EbM4s xBCtbYpufx9hWWaaLNl+4rE3rDFPSa+rzJ7a92UTA79pypYukHTbn5x+EOJUS4GD9tMP qEZFBEY1alh/rkGY6Wjcc8ulbXXX5+N6/cB9Ps/W7p5IVSN07eUXAk2YEXqqIsNYmOSf 4GPzvxV6gltohKeTzksfmGIxyN9pfqOKuR7kzzAkuoswihTxi1xsvuQTgET/Vb890Z75 gknA== X-Forwarded-Encrypted: i=1; AHgh+RoXj0d2YIcjIlHczA1874X3/nO6Yw8+hFF9Nf1a3dLjc6m8KIO+CpGSFZOrdsWjCsDyFRAerwc7WG8=@lists.infradead.org X-Gm-Message-State: AOJu0YzvZvnS2UO76Km4a5v2NNJXnIITf2E0qViHHjRNPsGFCDEzZUrv oBRpE1NyQOqMoWBHu81WxQrTPthD5xv8YgrQk5kBZ7fEObxo1hnR7kfl X-Gm-Gg: AR+sD101mfC1pkJK9rwENsA5MSi+wR8wqt2w1WYF1FkyWO6bALWY0MZOo4PQjTB0z4a H/kXmddSPNT3EcjJjBEhcHbg7XXpxcmVZysX5Gz0Dgw61+nD1fl8DjqpXs0dIcq7XhjNOePEFIV UST5EOx4yV2aK4K+5a7UDJXtS2dm9+LsErZW0i7Htf8ohw8/1P/lBXvdZox2fJXQ5MUzlQqMgP7 eQE2b529RsngAv7/C+rHPjuduxHFMJ8mQ54ysN4Gq9lKKxM+Ja0xxM0WkCiJeRpwJAoKMg8xW3n V8bU60X/H/qbuBWs7jGNwLU2v4s98ih8fYQSVUFCi1bfC5VmY6AGzhWqfCkbV+1hIQUa+6O50E8 LXMOThdsiU2mnItkHrxyn5uMBa2r7MIto52iv00B5mX7FqPMCQ22SOgzDGEzj+Yejk2Huy5zxWM 7PB3X2vrQBucdOvGtnttSKOZMaSra7eF/y47g/gTa6wTa+6bwEZpubEk6CmGdY1gx9UfZbkqjLO IQ0JSaJ4ny7M/4= X-Received: by 2002:a05:6a00:ab8b:b0:84e:165:da58 with SMTP id d2e1a72fcca58-84e933cefd6mr6852509b3a.52.1785326859904; Wed, 29 Jul 2026 05:07:39 -0700 (PDT) Received: from q-System-Product-Name ([129.227.183.200]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84ea0055133sm1309570b3a.18.2026.07.29.05.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 05:07:39 -0700 (PDT) From: "Bingyu.Xian" To: Anup Patel Cc: Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Quan Zhou , stable@vger.kernel.org Subject: [PATCH v3 0/3] RISC-V: KVM: G-stage fault path fix and cleanup Date: Wed, 29 Jul 2026 20:07:30 +0800 Message-ID: <20260729120733.829457-1-shanbeeyoo@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260729075230.743030-1-shanbeeyoo@gmail.com> References: <20260729075230.743030-1-shanbeeyoo@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260729_050740_878352_F6E3D8DF X-CRM114-Status: GOOD ( 11.98 ) X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+kvm-riscv=archiver.kernel.org@lists.infradead.org Three small changes to the RISC-V G-stage page fault path, sent as separate patches per review feedback. 1/3: Treat -EEXIST from kvm_riscv_gstage_map_page() as a quiet success, aligning RISC-V with x86 and arm64. Real bug fix; Fixes: 9d05c1fee837, Cc: stable. 2/3: vma_pageshift: short -> unsigned int. No-functional-change type cleanup in preparation for sharing a common struct kvm_page_fault across architectures. 3/3: Widen the G-stage fault address to gpa_t end to end -- the local in gstage_page_fault(), the (gpa_t) cast before the <<2 shift, and the fault_addr parameters of kvm_riscv_vcpu_mmio_load/ store(). This completes the RV32 34-bit GPA fix that v2 only half-addressed: v2 widened the local and cast the shift, but the address was still narrowed to 32 bits at the MMIO handler call (unsigned long parameter), aliasing accesses above 4 GB into the low 4 GB. The handlers' internal uses (run->mmio.phys_addr is __u64, kvm_io_bus_read/write() take gpa_t) are already 64-bit. Also in preparation for sharing a common struct kvm_page_fault. No functional change on RV64. Not Cc'd to stable: RV32 KVM is unsupported and this is untested at runtime. Changes since v2 [1]: - Split into separate patches per feedback. - Completed the fault_addr widening v2 left half-done: widened the kvm_riscv_vcpu_mmio_load/store() fault_addr parameters to gpa_t so the 34-bit address is not truncated at the MMIO handler call. The KVM_MEM_USERFAULT port that motivated this cleanup will follow as a separate RFC. [1] https://lore.kernel.org/kvm/20260729075230.743030-1-shanbeeyoo@gmail.com/ Bingyu.Xian (3): RISC-V: KVM: Treat -EEXIST from G-stage map as success RISC-V: KVM: Use unsigned int for vma_pageshift RISC-V: KVM: Widen G-stage fault address to gpa_t arch/riscv/include/asm/kvm_vcpu_insn.h | 4 ++-- arch/riscv/kvm/mmu.c | 8 +++++--- arch/riscv/kvm/vcpu_exit.c | 5 +++-- arch/riscv/kvm/vcpu_insn.c | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) -- 2.54.0 -- kvm-riscv mailing list kvm-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kvm-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73F4BC53200 for ; Wed, 29 Jul 2026 12:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CJNFMNhVp1h3ugzr5OAiT/+iX4hJxM71z3XRTpUBn6c=; b=qTjm2JVUhOWwrT rGrAZrGxla6vKlRc0KjFIBqDX5wQPTU9II9BvFQHStq5juq0DoVIZXNHSQ5LapmubZedB75+oSxfu pKhb5CFaY9Fzqb5y7Ba4S3Z0kSjP8H9JQMZX07ZgaDRNhImi2xrfW0GayrepVrBg9uQyJAw7cjeWS nlunoUzWa4XAMV5hjaaLgANqTSCbChaBumqKhkeHPlP/4gLCZdBAh9x8+kKxZTEhPogqKTu8WYTI2 tAWKK1Kdwk86nQlKUBD+Qt7I2ZByY9FGq99sJ0G7LYtoNAC4obysvsv1u+oxl0dxJKRYfSOi7Wmb7 MUKuEzwyfghAO0v9e/rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wp34Z-00000007pNt-0wqr; Wed, 29 Jul 2026 12:07:43 +0000 Received: from mail-pz2-x01.google.com ([2607:f8b0:4864:3b::1]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wp34W-00000007pN8-3Mgc for linux-riscv@lists.infradead.org; Wed, 29 Jul 2026 12:07:42 +0000 Received: by mail-pz2-x01.google.com with SMTP id 41be03b00d2f7-ca034c989e2so366252a12.0 for ; Wed, 29 Jul 2026 05:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785326860; x=1785931660; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qLMnpNtLpsL2XHYkd+z33mKUcr79GQx5LDeNnSKUE6Y=; b=q1F+BVkWYnzVDeqQiC/zxrtHNKy8qwAXio8DVKRwnMjU6kpCKGvv4TJNM0k29Tq/C2 VDhiaMh+m7U1hTlXmBXwW4cjAQj/Fc5HbSdEXtydEHzsCf1VtzPTd4kRpr2kh4AXg7H2 h1Evu+PfxfprUdFRKLUzikme7BB11SufSegnYWEwjw5V0+jvNajXwR0QzjdnFUr6PnCP X+YeXX7ByDw7qGskGojV2zdqJByBUozLLcIp55NdeerqDm4Ei0GHac60fEbhrdsvruCy Ue4HGWfP+HrGa+GKaa96YOMhznKMntc6QiAX4Mn8yVp0OGWahuYpYeeUs4KcfX3NpEtI 2fTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785326860; x=1785931660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qLMnpNtLpsL2XHYkd+z33mKUcr79GQx5LDeNnSKUE6Y=; b=HosfvHLxrC+Qs0IUJ2GK4hCANM5uhdJ3rlCQ8iKBLQsfLM3N3DE1tC/0YRPcor4UQi HJFJX/ws87uydRffHe/WrwsN3Xegwa0jeTbalwEMzI/3+Ow4IusUf7o7/PoZ6DdkRmEY fWtTCDEPwa8+S/0f83FQwTbyvCBTkMxxmiVaDei8Z9b86IcJID+JOswTwGRc6VEVmLZ+ aSPFlxagEavCN1qoRjQGNJRAnlts4fzvBuT9n3ir3wHWIA9HGOPPpOqjFVnW6tOcYMNJ ZlWrUHscHyjgMbXGgiwY3fXI+Xc0gjDo3Y1SieyM9O8LQOBZAfF2FJLyslV5I5+WmFcu OBWA== X-Forwarded-Encrypted: i=1; AHgh+Rqf0fxvGsWKNYEcsz2ldngBaN+MdvlIDDXhHrQIHYykqdV3t+BPdoQskFqeOj6DE4Nw/2S1O7Ke53K5YQ==@lists.infradead.org X-Gm-Message-State: AOJu0YyMM+nCevBmaSQVzd9iIf8zMnxTkNvOPC8LJgr4CJxUdfOe3w3+ EnEIXl630WBJFEybcGE3WjHFnWyGeJ0JfyycU3D46/a+nVaEFEDm7r8Q X-Gm-Gg: AR+sD11O37oXHCSBEe0PzEzEGepVWYjb3wyRDmApq58N3/mkMHeh+w52AAk/uYJ2U1w fFfqwq820ES+WQrDUtvUCmVcz2VLcK/f515VNA61A67ENgIDwrY2zh9uhU7ULi/RiEtIeTHkyxo 0mC1SRT4ofpFghC2POW8be0GcoxHuDSaA+7FHA2ZuJ54lsSLAvwcI7COyvFMrXaDjteWOBDtGEp JvO+mSgjIIk2oGOLyPFTvKOuXRqwN1CRu0WIdM2PR3d6pwAwXzXlcDNsVM6sXxUOJUOVeZqYDaI AVO8RblHKZwEZRUarxfhijihcwXtGxwGYgo4lK87FqmMNeuYqqp/s1TQ/RrtpmjjcJJEgzQScGZ i/SF1tcftQqdRWhX3ITEKkA0jwD9aZifE21V8xDbBVQO/NsrlHHpI5YJET5S1uvbq5VyG9cSeQG r9rsNrOBFc8vhrCjbFFbqNvsq8Yy6aA7t9hHeCMgJAVsuVuJqYWVYNb297tdQItgOKp6vdscYs+ bDdJLYHyuoFVKE= X-Received: by 2002:a05:6a00:ab8b:b0:84e:165:da58 with SMTP id d2e1a72fcca58-84e933cefd6mr6852509b3a.52.1785326859904; Wed, 29 Jul 2026 05:07:39 -0700 (PDT) Received: from q-System-Product-Name ([129.227.183.200]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84ea0055133sm1309570b3a.18.2026.07.29.05.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 05:07:39 -0700 (PDT) From: "Bingyu.Xian" To: Anup Patel Cc: Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Quan Zhou , stable@vger.kernel.org Subject: [PATCH v3 0/3] RISC-V: KVM: G-stage fault path fix and cleanup Date: Wed, 29 Jul 2026 20:07:30 +0800 Message-ID: <20260729120733.829457-1-shanbeeyoo@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260729075230.743030-1-shanbeeyoo@gmail.com> References: <20260729075230.743030-1-shanbeeyoo@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260729_050740_841453_1D9F25B4 X-CRM114-Status: GOOD ( 11.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Three small changes to the RISC-V G-stage page fault path, sent as separate patches per review feedback. 1/3: Treat -EEXIST from kvm_riscv_gstage_map_page() as a quiet success, aligning RISC-V with x86 and arm64. Real bug fix; Fixes: 9d05c1fee837, Cc: stable. 2/3: vma_pageshift: short -> unsigned int. No-functional-change type cleanup in preparation for sharing a common struct kvm_page_fault across architectures. 3/3: Widen the G-stage fault address to gpa_t end to end -- the local in gstage_page_fault(), the (gpa_t) cast before the <<2 shift, and the fault_addr parameters of kvm_riscv_vcpu_mmio_load/ store(). This completes the RV32 34-bit GPA fix that v2 only half-addressed: v2 widened the local and cast the shift, but the address was still narrowed to 32 bits at the MMIO handler call (unsigned long parameter), aliasing accesses above 4 GB into the low 4 GB. The handlers' internal uses (run->mmio.phys_addr is __u64, kvm_io_bus_read/write() take gpa_t) are already 64-bit. Also in preparation for sharing a common struct kvm_page_fault. No functional change on RV64. Not Cc'd to stable: RV32 KVM is unsupported and this is untested at runtime. Changes since v2 [1]: - Split into separate patches per feedback. - Completed the fault_addr widening v2 left half-done: widened the kvm_riscv_vcpu_mmio_load/store() fault_addr parameters to gpa_t so the 34-bit address is not truncated at the MMIO handler call. The KVM_MEM_USERFAULT port that motivated this cleanup will follow as a separate RFC. [1] https://lore.kernel.org/kvm/20260729075230.743030-1-shanbeeyoo@gmail.com/ Bingyu.Xian (3): RISC-V: KVM: Treat -EEXIST from G-stage map as success RISC-V: KVM: Use unsigned int for vma_pageshift RISC-V: KVM: Widen G-stage fault address to gpa_t arch/riscv/include/asm/kvm_vcpu_insn.h | 4 ++-- arch/riscv/kvm/mmu.c | 8 +++++--- arch/riscv/kvm/vcpu_exit.c | 5 +++-- arch/riscv/kvm/vcpu_insn.c | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) -- 2.54.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz2-f0.google.com (mail-pz2-f0.google.com [74.125.228.0]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A08A647CA75 for ; Wed, 29 Jul 2026 12:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.0 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785326862; cv=none; b=Lo73cny05mWmMdpehPbklt3TXj2/lepp1/L82C7bNO2WHfJEQKA7gcfIf3WXpM4QC3aN+MrBF3z93uZvb6kDzGdXlizsy3xKUkv5DB3kIjhJOos0aoT7Sj9h22qOT4AU5uzG3hm8dc/pK62W68gko4wG4brUYOd22MLNPDWcZ4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785326862; c=relaxed/simple; bh=iUKsISx97Eyt6gD0CUDPFNVPi3iaca7Phiogt4QFNmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rgLe+ayEcKThgh+TTKqbnFNjJIRFKAGwUbdF7RkLZGK56yUaMsetOGt/KCws3ig5Je0qPTrWwvaqOLEayiAulcryluVQ9rbCoxUdnqtesq1q9/AxNxXYiKkKiZ9JJexm3IVBmpOF03kSE3y51blEqJt76WiXJwOhhzvonftKVt8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NMOM4E4H; arc=none smtp.client-ip=74.125.228.0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NMOM4E4H" Received: by mail-pz2-f0.google.com with SMTP id 41be03b00d2f7-ca24d39d8a4so388571a12.1 for ; Wed, 29 Jul 2026 05:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785326860; x=1785931660; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qLMnpNtLpsL2XHYkd+z33mKUcr79GQx5LDeNnSKUE6Y=; b=NMOM4E4H/Es5UZqsV9fPFVl0rVJEPPG+A/3VXI5E+ZjCgQUp+XE4wgRo/koFtjBs4j KWuuQ2ZyVK9sC98XdVaFqiCbpyw0YyDlUa28uzlmcUkocpUMEyInSH5dLdWfLcnhSGs/ Y+rmyFOCWxwLRORacSUXNffta963yjVqvEAp21kMiKs0ATknKcDLnkEF6adQ62do3+kF sKuu6al9k/lbrowXY/FELO3SjYxZmQXFgdqjcZ2U3Bq0sX95YyHsq/SZholOzwOnlTSK uydapEO/B04YyLKlvGdg30jXX4wWfzC3lqqcYfbhm/ng+ephKzKI58hUrKB2FsOGidF4 wkkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785326860; x=1785931660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qLMnpNtLpsL2XHYkd+z33mKUcr79GQx5LDeNnSKUE6Y=; b=nDalUCwAPxnyZXbJ3t7UnW6GfvKQbPZJsL3zrPMLITjzwHeFdQ6nl7LiIc2IKLquf9 C9ydqB9iyoVAYZD+YwfiYDt/m8nGC1s23+wEVlaUmHUiC0cBpUBfn275N2LJwc3MjVIA hF0RSD9UXyNR85Fcy9QGMsMzisJxOFlQWaPGOYPW/+JQcZK+jmDfdttR5AMa/cCeqjkn iWiMJ7uRU5wqvrwjIfSO5QlKTcpYjSCJJE63fGIyel1vUoxQhAtPFgBzD/+ZPjubep8g WQ92TLG2egEvvMC6rcIzNhNCqOwNN1c2ePHR8ZJ9flWXVCE1OOs5h2z+kIaE/0h3yGsL kZDA== X-Forwarded-Encrypted: i=1; AHgh+RrNa/hSOjkbobegMltwcPlS9ag1HDZ8mDwEV0U8g4KUcBXBfxBsrwDmfbOrP1uxjJnLrww=@vger.kernel.org X-Gm-Message-State: AOJu0YyH2cWNWBIoC2fGIyKmDsXE15KQPja/FouyUI8jiUhZxnhL0cmp BKQt4fUisaqwauBZE82BlsmfoUaMMDFa+Xe6kqgTsaLM9CpMvIiOcFRDQV7kFJ9NnCUlbg== X-Gm-Gg: AR+sD10uTPU92OHX9oyT8y0YvK+NvL+MCxKPWztj1AmgnZ4nx6lgBA39ZDoqJqCSMiV DwaWnJZfCEqs6q9a3uWJVsNvMeJLipS6ujlbCQ2FsIdPwdFpwe2kJSU0vzCtVlNHEPHWXEGp+J/ gOyX+Ub1uCeU2NRMFx/d38GA/JIOfl3E9Y1SyK3CNyLooVxUzfcRRKW1eNQrTtlnOvOKzYBCIwS PQv+FQoGpTndCeTdly2aNDvyXRGiuxVlJTpeIvvpyFDN5CQ0vxM1yicfCj1U1cTmFpctOfTcrk1 BLFmaSq1T3Pw7kLDkXN5fWFapviESnKBAK5BWEXjLJNJsHyFkmSNeCBAqI23JcQvhSzKj5AVi06 opnG/VK7N+9vdjK5+6n2WANradRZ7ifaSjGO/IqYChoSJjMLoCSAwxvtm9JvQAPA4t79V+6bTN8 wXf8ShkVIWvF6nla1p1MWp51uOt0Bxd7gq/Lz5xyczRlmQ5sk5+aPui+XrkulV6KfURR8p6kJco 7vCIq4k9PIsqYA= X-Received: by 2002:a05:6a00:ab8b:b0:84e:165:da58 with SMTP id d2e1a72fcca58-84e933cefd6mr6852509b3a.52.1785326859904; Wed, 29 Jul 2026 05:07:39 -0700 (PDT) Received: from q-System-Product-Name ([129.227.183.200]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84ea0055133sm1309570b3a.18.2026.07.29.05.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 05:07:39 -0700 (PDT) From: "Bingyu.Xian" To: Anup Patel Cc: Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Quan Zhou , stable@vger.kernel.org Subject: [PATCH v3 0/3] RISC-V: KVM: G-stage fault path fix and cleanup Date: Wed, 29 Jul 2026 20:07:30 +0800 Message-ID: <20260729120733.829457-1-shanbeeyoo@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260729075230.743030-1-shanbeeyoo@gmail.com> References: <20260729075230.743030-1-shanbeeyoo@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Three small changes to the RISC-V G-stage page fault path, sent as separate patches per review feedback. 1/3: Treat -EEXIST from kvm_riscv_gstage_map_page() as a quiet success, aligning RISC-V with x86 and arm64. Real bug fix; Fixes: 9d05c1fee837, Cc: stable. 2/3: vma_pageshift: short -> unsigned int. No-functional-change type cleanup in preparation for sharing a common struct kvm_page_fault across architectures. 3/3: Widen the G-stage fault address to gpa_t end to end -- the local in gstage_page_fault(), the (gpa_t) cast before the <<2 shift, and the fault_addr parameters of kvm_riscv_vcpu_mmio_load/ store(). This completes the RV32 34-bit GPA fix that v2 only half-addressed: v2 widened the local and cast the shift, but the address was still narrowed to 32 bits at the MMIO handler call (unsigned long parameter), aliasing accesses above 4 GB into the low 4 GB. The handlers' internal uses (run->mmio.phys_addr is __u64, kvm_io_bus_read/write() take gpa_t) are already 64-bit. Also in preparation for sharing a common struct kvm_page_fault. No functional change on RV64. Not Cc'd to stable: RV32 KVM is unsupported and this is untested at runtime. Changes since v2 [1]: - Split into separate patches per feedback. - Completed the fault_addr widening v2 left half-done: widened the kvm_riscv_vcpu_mmio_load/store() fault_addr parameters to gpa_t so the 34-bit address is not truncated at the MMIO handler call. The KVM_MEM_USERFAULT port that motivated this cleanup will follow as a separate RFC. [1] https://lore.kernel.org/kvm/20260729075230.743030-1-shanbeeyoo@gmail.com/ Bingyu.Xian (3): RISC-V: KVM: Treat -EEXIST from G-stage map as success RISC-V: KVM: Use unsigned int for vma_pageshift RISC-V: KVM: Widen G-stage fault address to gpa_t arch/riscv/include/asm/kvm_vcpu_insn.h | 4 ++-- arch/riscv/kvm/mmu.c | 8 +++++--- arch/riscv/kvm/vcpu_exit.c | 5 +++-- arch/riscv/kvm/vcpu_insn.c | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) -- 2.54.0