From: xieming <xieming@kylinos.cn>
To: christoffer.dall@arm.com, marc.zyngier@arm.com
Cc: linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org,
xieming@kylinos.cn
Subject: [PATCH] kvm: fix gpu passthrough into vm on arm64
Date: Wed, 23 Mar 2022 09:25:19 +0800 [thread overview]
Message-ID: <20220323012519.521058-1-xieming@kylinos.cn> (raw)
1) when passthrough some pcie device, such as AMD gpus,
kvm will report:"Unsupported FSC:" err.
2) the main reason is kvm setting memory type to
PAGE_S2_DEVICE(DEVICE_nGnRE), but in guestos, all of device io memory
type when ioremapping (including gpu driver TTM memory type) is
setting to MT_NORMAL_NC.
3) according to ARM64 stage1&stage2 conbining rules.
memory type attributes combining rules:
Normal-WB < Normal-WT < NormalNC < Device-GRE < Device-nGRE <
DevicenGnRE < Device-nGnRnE
Normal-WB is weakest,Device-nGnRnE is strongest.
refferring to 'Arm Architecture Reference Manual Armv8,
for Armv8-A architecture profile' pdf, chapter B2.8
refferring to 'ARM System Memory Management Unit Architecture
Specification SMMU architecture version 3.0 and version 3.1' pdf,
chapter 13.1.5
4) therefore, the I/O memory attribute of the VM is setting to
DevicenGnRE is a big mistake. it causes all device memory accessing in
the virtual machine must be aligned.
To summarize: stage2 memory type cannot be stronger than stage1 in
arm64 archtechture.
Signed-off-by: xieming <xieming@kylinos.cn>
---
virt/kvm/arm/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index 11103b75c596..9b7fb13f4546 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -1209,7 +1209,7 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
pfn = __phys_to_pfn(pa);
for (addr = guest_ipa; addr < end; addr += PAGE_SIZE) {
- pte_t pte = pfn_pte(pfn, PAGE_S2_DEVICE);
+ pte_t pte = pfn_pte(pfn, PAGE_S2);
if (writable)
pte = kvm_s2pte_mkwrite(pte);
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-03-23 1:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-23 1:25 xieming [this message]
2022-03-23 10:12 ` [PATCH] kvm: fix gpu passthrough into vm on arm64 Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220323012519.521058-1-xieming@kylinos.cn \
--to=xieming@kylinos.cn \
--cc=christoffer.dall@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).