Skip to content

KVM: arm64: support write combining and cachable IO memory in VMs

[email protected] kvmarm linux-arm-kernel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 52 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: determine memory type from VMAarch/arm64/include/asm/kvm_pgtable.h arch/arm64/kvm/hyp/pgtable.c arch/arm64/kvm/mmu.c+45 -513 replies
2/2KVM: arm64: allow the VM to select DEVICE_* and NORMAL_NC for IO memoryarch/arm64/include/asm/memory.h arch/arm64/kvm/hyp/pgtable.c+3 -139 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchCatalin Marinas
1/2
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 0/2] KVM: arm64: support write combining and cachable IO memory in VMs

From: Ankit Agrawal <[email protected]>

Today KVM forces all of the memory to either NORMAL or DEVICE_nGnRE largely based on pfn_is_map_memory() and ignores the per-VMA flags that indicate the memory attributes.

This means there is no way for a VM to get NORMAL_NC IO memory (what Linux calls WC memory, which is used for performance in certain NIC and GPU devices). There is also no way for a VM to get cachable IO memory (like from a CXL or pre-CXL device). In both cases the memory will be forced to be DEVICE_nGnRE and the VM's memory attributes will be ignored.

After some discussions with ARM and CPU architects we reached the conclusion there was no need for KVM to prevent the VM from selecting between DEVICE_* and NORMAL_NC for IO memory in VMs. There was a fear that NORMAL_NC could result in uncontained failures, but upon deeper analysis it turns out there are already possible cases for uncontained failures with DEVICE types too. Ultimately the platform must be implemented in a way that ensures that all DEVICE_* and NORMAL_NC accesses have no uncontained failures.

Fortunately real platforms do tend to implement this.

This is similar to x86 where various BIOS choices can result in uncontained failures (machine checks in x86 speak) on IO memory. On either architecture there is no way for KVM to know if the underlying platform is fully safe or not.

This series expands the assumption that any uncachable IO will not have any uncontained failures for DEVICE_* and NORMAL_NC and that cachable IO will not have uncontained failures for NORMAL. We hope ARM will publish information helping platform designers follow these guidelines.

Additionally have KVM drive the decision on cachable or not entirely on the VMA. If the VMA is cachable then the KVM memory is made NORMAL regardless of pfn_is_map_memory(). This closes a hole where cachable VMA mappings in a process could be accessed via an uncached alias through KVM.

Applied over next-20230906

Ankit Agrawal (2):
KVM: arm64: determine memory type from VMA
KVM: arm64: allow the VM to select DEVICE_* and NORMAL_NC for IO
memory

 arch/arm64/include/asm/kvm_pgtable.h |  8 ++++++
 arch/arm64/include/asm/memory.h      |  2 ++
 arch/arm64/kvm/hyp/pgtable.c         |  4 +--
 arch/arm64/kvm/mmu.c                 | 40 +++++++++++++++++++++++++---
 4 files changed, 48 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1