You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge: KVM: arm64: Map GPU device memory as cacheable
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1185
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.
KVM: arm64: Rename the device variable to s2_force_noncacheable
KVM: arm64: Update the check to detect device memory
KVM: arm64: Block cacheable PFNMAP mapping
KVM: arm64: Allow cacheable stage 2 mapping using VMA flags
KVM: arm64: Expose new KVM cap for cacheable PFNMAP
Documentation/virt/kvm/api.rst | 10 +++
arch/arm64/kvm/arm.c | 7 ++
arch/arm64/kvm/mmu.c | 118 ++++++++++++++++++++++++++-------
include/linux/kvm_host.h | 2 +
include/uapi/linux/kvm.h | 1 +
virt/kvm/kvm_main.c | 5 ++
NOTE:
This patch series is a backport from kvm-arm's next branch, as this functionality isn't slated for upstream inclusion until v6.17-rc1, which is too late to create an MR for RHEL-10.1 inclusion. This functionality is need in a RHEL-10.1 host in order for a device-assigned Hopper GPU to not hange a guest when basic nvida-smi commands are executed to provide functional information about the (assigned) GPU (in a guest VM).
The nvdia-vgpu vfio-pci-variant driver was merged to RHEL-10.1 in an earlier kernel, that enabled the Hopper/Blackwell device-assignment to a VM; this patch set completes the functionality by making the device usable in the VM.
This series has been in upstream development for over a year, and has had significant review by ARM, KVM, and mm maintainers, per the upstream posting:
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.
The commit-id's used in this backport from the kvm-arm -next branch are expected to be the same when eventually pulled into Linus's tree for v6.17-rc1 merge (famous last words).
JIRA: https://issues.redhat.com/browse/RHEL-73607
Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git
Signed-off-by: Donald Dutile <ddutile@redhat.com>
Approved-by: David Hildenbrand <david@redhat.com>
Approved-by: Gavin Shan <gshan@redhat.com>
Approved-by: Sebastian Ott <sebott@redhat.com>
Approved-by: Cornelia Huck <cohuck@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>
Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
0 commit comments