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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75412C77B7C for ; Wed, 2 Jul 2025 16:53:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2DAC6B00BC; Wed, 2 Jul 2025 12:53:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDE5B6B00CE; Wed, 2 Jul 2025 12:53:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCDD66B00CF; Wed, 2 Jul 2025 12:53:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BA6206B00BC for ; Wed, 2 Jul 2025 12:53:02 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 47ADF106221 for ; Wed, 2 Jul 2025 16:53:02 +0000 (UTC) X-FDA: 83619919404.28.0FDF7ED Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id D723EC000F for ; Wed, 2 Jul 2025 16:52:59 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EDwtMXNI; spf=pass (imf22.hostedemail.com: domain of ddutile@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=ddutile@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751475180; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BYPE9kAm4n5JaaAj3WmzYSVaYGMobSZ1mvZBnXOb9Jo=; b=cr7McVWlPqGzeYyIrjRFN0ivdOZwa77YxzWXOv4m7F1u8nmtMlUa894+keGU0kLhuAWI8C i89DyMzGYluNVl1GwWa7sEnk5I6f3NpTK/C8m0ubA5f2dysQ1meSyCi7VPHhb6Z6XABktG ai9KZMF12IyC7ybLSvJhT6rcboA1uOg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EDwtMXNI; spf=pass (imf22.hostedemail.com: domain of ddutile@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=ddutile@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751475180; a=rsa-sha256; cv=none; b=rH2sfDi/ZL/ztiRJMptVzCyLjsMoQ4tSYcsvullxdSFdDRxtX9iI66u4o3buDdQlf0cICI VV3NAhgRXND3R38ohJnUazkOdmhF5mTPN2099Z2zjIZTXqOZh30aSmbe6eivvH+nLtQPcU AFXRaJXpfb85NsMt8Q8J6p9foN4sJiA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751475179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BYPE9kAm4n5JaaAj3WmzYSVaYGMobSZ1mvZBnXOb9Jo=; b=EDwtMXNI3vV+7orAlA9+Wq/KtFXqzMNgKGA7CdZM+KspZA09Jw6I34feWgjJagvWtE2gIV +20aDYTE4kBxP7lMunxSB2WRZy5UXvOjHHy+GDR5yyqVo+YKJDI6zoBh0UTGJGSQ3HeaDv 9tADzCRAVY3p7h5zGktFn2gRcz4LTJk= Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-mc0tKs_lOsKai5Qx_OUu-A-1; Wed, 02 Jul 2025 12:52:58 -0400 X-MC-Unique: mc0tKs_lOsKai5Qx_OUu-A-1 X-Mimecast-MFC-AGG-ID: mc0tKs_lOsKai5Qx_OUu-A_1751475177 Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-2eae95dfae3so4980107fac.1 for ; Wed, 02 Jul 2025 09:52:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751475177; x=1752079977; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BYPE9kAm4n5JaaAj3WmzYSVaYGMobSZ1mvZBnXOb9Jo=; b=POXuyW9D825k47NyES0VqdiRFd+iGJVlIlqdfAFqjqaiW8ejl0wHnLMUuv7gGuMLi9 S8AFGuhEtrOpNxJKhq00KjeAPYPndbIceHwXCdNdv3G/FC9Wejik9dpP+lSuIwLcx5Sy x8UVelY+CG4rNFNVgEJAPVuSrm2YRCnMUncIZpRqU4kN9nw5LvBLc+JOl3uVBAFe9Wvd TASxy2uODLRH3z2JPfzVRSQjowMgdUDuqgTfFfAvwraD2MSOhn3OCQ1bDVv8Y4qPBlt7 0uSU9GzSaghI5YM2RSAyBLfbQMEziyPHE16vHzjDZVyiY7CEuj/jCN0LP99BBtwBQxm2 1WCg== X-Forwarded-Encrypted: i=1; AJvYcCW19on/5WlYjRm2wfx6HT/qTQ10IXr0YNYTy+27vcN7AI/+ZS3bWtXDnkB1/eFVIRm0u2leuFVQAw==@kvack.org X-Gm-Message-State: AOJu0YwA64NAm8sTBybYnfU7AxkRtt2BSrdiYNciltNILC06Da6WZ6P7 4Zz8c9YxAhVN9fM96OZZDgoQDlhOQjOZan6qcuLoxrXbF4NvWtL8aIQIVMcL0yJYWTeFct9TBuU UpunjmHr5HFduQOy0yBfIiyxgUotM4HTkJMzNXaO5joA8k4vsVZD6 X-Gm-Gg: ASbGncvgazMuUyfIf+Zp+/xsPjwJA9t5kL/S6wj8A+pIdl1mMGzMzxN9/puhAWvAfA+ nH4Rs4inQObzOVCHL9WU87oYEaozvYlEWf8XvmQLjvyQ8jZHpNbkdHsud3kDjykeh1Z/4cTqnxM oJD5zVdQAz3dEx9nho8jYTk/MLOBCTWKH4P9KW1O97l+fHjO/a1+DTBxYlgvXFfwqtWka7F08Tj 5r3uYC0PjGpOFks6VCO6l0chMl5tvtMHFzbcLJd0moxHgM7skzsfrxghbL8sMm2r9NRlO5KGFqm LlCPKOj8DAuzOZ9Nk3TExWY= X-Received: by 2002:a05:6870:c18c:b0:2ea:6ec5:f182 with SMTP id 586e51a60fabf-2f76cb4ee23mr82926fac.38.1751475177345; Wed, 02 Jul 2025 09:52:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8xhPj4vbeCO6BR/7uWOvOuQ5ERydvemFdCvd/3yMMwrMEKbwcC+0fs0OrYA1xZmzNSwVtTg== X-Received: by 2002:a05:6870:c18c:b0:2ea:6ec5:f182 with SMTP id 586e51a60fabf-2f76cb4ee23mr82872fac.38.1751475176870; Wed, 02 Jul 2025 09:52:56 -0700 (PDT) Received: from [192.168.40.164] ([70.105.235.240]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73afafee51bsm2562567a34.10.2025.07.02.09.52.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Jul 2025 09:52:56 -0700 (PDT) Message-ID: <1a14ee0a-04af-407d-89a5-5222ee6da9c7@redhat.com> Date: Wed, 2 Jul 2025 12:51:06 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 0/6] KVM: arm64: Map GPU device memory as cacheable To: Ankit Agrawal , Jason Gunthorpe , "maz@kernel.org" , "oliver.upton@linux.dev" , "joey.gouly@arm.com" , "suzuki.poulose@arm.com" , "yuzenghui@huawei.com" , "catalin.marinas@arm.com" , "will@kernel.org" , "ryan.roberts@arm.com" , "shahuang@redhat.com" , "lpieralisi@kernel.org" , "david@redhat.com" , "seanjc@google.com" Cc: Aniket Agashe , Neo Jia , Kirti Wankhede , Krishnakant Jaju , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , Zhi Wang , Matt Ochs , Uday Dhoke , Dheeraj Nigam , "alex.williamson@redhat.com" , "sebastianene@google.com" , "coltonlewis@google.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "ardb@kernel.org" , "akpm@linux-foundation.org" , "gshan@redhat.com" , "linux-mm@kvack.org" , "tabba@google.com" , "qperret@google.com" , "kvmarm@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "maobibo@loongson.cn" References: <20250621042111.3992-1-ankita@nvidia.com> From: Donald Dutile In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Yr1tTz8sZmoDrqojNkVUwozluT8DKiAeOctkOq3i9QM_1751475177 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: 3godfj9baupoqj5qacbjsia3zazm54ew X-Rspamd-Queue-Id: D723EC000F X-Rspamd-Server: rspam11 X-Rspam-User: X-HE-Tag: 1751475179-83623 X-HE-Meta: U2FsdGVkX19SdeCyINyeef02m6JXeT2+PQCQxhP2dJJfT+st2OLBd4dF1rIPewB3I/nYP3CrOl/gYDy/nN0jKdpxfq/SH3kttMy01udBmNx0lZ7JB4Qlj2ggmkhaUdUgqAqYumV4bNqvPZCgbKf3jqHb0fPZfPJBResakLUnwKJ9STkNvUJrPQQHoSesFEn2mDeysJN4Bp7K2oQ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dcoxQm8aMULdT+nhmUcA5m+mHFOVATvVh2qh+WcBof0/pJS7UV5nRDH9qNG0VeAyb2YyHiAxG8ENmmfTtbhNSowRjt/QtLN0u0nYwhQZ7a8WMOGhWHoCd+ZNfMaGVT5n3wPlx1hoL6fiwSc8w90XuQQRcm5JcHpE1E9rZKoPeCLE9RddgivBD/D8jlQCVwcSve02u6SguViDIfZnPIGp15xSNyRRwkdkj6BJAE9rOLO1fgqgkNkiLCnl/DJ313BvlJcIQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 7/2/25 5:33 AM, Ankit Agrawal wrote: >> Grace based platforms such as Grace Hopper/Blackwell Superchips have >> CPU accessible cache coherent GPU memory. The GPU device memory is >> essentially a DDR memory and retains properties such as cacheability, >> unaligned accesses, atomics and handling of executable faults. This >> requires the device memory to be mapped as NORMAL in stage-2. >> >> Today KVM forces the memory to either NORMAL or DEVICE_nGnRE depending >> on whether the memory region is added to the kernel. The KVM code is >> thus restrictive and prevents device memory that is not added to the >> kernel to be marked as cacheable. The patch aims to solve this. >> >> A cachebility check is made by consulting the VMA pgprot value. If >> the pgprot mapping type is cacheable, it is considered safe to be >> mapped cacheable as the KVM S2 will have the same Normal memory type >> as the VMA has in the S1 and KVM has no additional responsibility >> for safety. >> >> Note when FWB (Force Write Back) is not enabled, the kernel expects to >> trivially do cache management by flushing the memory by linearly >> converting a kvm_pte to phys_addr to a KVA. The cache management thus >> relies on memory being mapped. Since the GPU device memory is not kernel >> mapped, exit when the FWB is not supported. Similarly, ARM64_HAS_CACHE_DIC >> allows KVM to avoid flushing the icache and turns icache_inval_pou() into >> a NOP. So the cacheable PFNMAP is made contingent on these two hardware >> features. >> >> The ability to safely do the cacheable mapping of PFNMAP is exposed >> through a KVM capability for userspace consumption. >> >> The changes are heavily influenced by the discussions among >> maintainers Marc Zyngier and Oliver Upton besides Jason Gunthorpe, >> Catalin Marinas, David Hildenbrand, Sean Christopherson [1]. Many >> thanks for their valuable suggestions. >> >> Applied over next-20250610 and tested on the Grace Blackwell >> platform by booting up VM, loading NVIDIA module [2] and running >> nvidia-smi in the VM. >> >> To run CUDA workloads, there is a dependency on the IOMMUFD and the >> Nested Page Table patches being worked on separately by Nicolin Chen. >> (nicolinc@nvidia.com). NVIDIA has provided git repositories which >> includes all the requisite kernel [3] and Qemu [4] patches in case >> one wants to try. >> >> v8 -> v9 >> 1. Included MIXEDMAP to also be considered for cacheable mapping. >> (Jason Gunthorpe). >> 2. Minor text nits (Jason Gunthorpe). > > Humble reminder for review. > Apologies for the delay, I had some issues getting a Grace-Hopper to test on, and a VM that needed to be adjusted(bigger file system) to run the 12.9.1 CUDA install script. Anyhow, able to assign a G-H GPU to a VM under qemu-kvm, and in the guest, successfully perform an 'nvidia-smi'. Previously, without this patch series in the host, the nvida-smi command would fail and hang the guest. (qemu-kvm was qemu-10.0 -based) If anyone wants more details, or want more tests run, feel free to ask; I can probably keep the system for another day or two, but I'll have to give it up by this Friday. Tested-by: Donald Dutile