[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] SMMU permission fault on Dom0 when init vpu_decoder


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Date: Mon, 30 May 2022 15:21:03 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eK9WCHv2vArtOO0GW0SO/fwPV4IVBTjAHIutp6+unPo=; b=a5xxtfWJwWhZHUgNIZOgEY6NUleduD7iTnVchWfbQbKa2ahmbtuN1Niro/vRPWsRCP+MxMbJbGt2bXdZfTZ+UXk6pyhGU0zFtQttRJJD7kVqjmOoN4Uw7TjC4k58isSeOGepqjBFKl2W8khXgJfoY6Zq3Xtc4zmDLrIxbuTNjR5mks5V1csDqz7sgulI8mrWmqlCKYEC99EPSt2F3GODkj+F0dDpCYhv1Po4USPE8yKu4MnuPc2WK48cglKYj8Vwu0/tEIE4yDAVfCogmQX4jzzij2ZFnK4OTAs9TY8s2+pPMkfki9IqkgYez07bmOfXuanwjfXJf9xOBLWWLOlXPA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V2CltKxWZkCNhVnxjNdqtO7Pz9X9fo1tq75UJ9Nd8PCmkPFFTVo+zKdHfuzDePkE9XtP9xfLQuXwSr6x8WuLjR6mUtdkgji3FT3RpJy741EyfVKM9Yow15OG5KVi5t7VTy8q6btfz4wxaciPTp+HQ4m6MJypTr1jZIk44gH/m0/ut2GSEBD35YDrLm2984rDWML3QafYJxmKALdWd0ZRRAQy5OlBMOFc8wREQEMUZQSlncguPJaU/DJE2LMVOxXoCI4ZFbgQgBPH7dZd8CqVdDMgQ7FMlrduixqQqAgIzGPttHjpr/YoJlJxvE0dCIJD94amqjw9IGoJSZs9rP1/Yw==
  • Cc: Julien Grall <julien@xxxxxxx>, Peng Fan <peng.fan@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Delivery-date: Mon, 30 May 2022 15:21:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYdDjfc3Z/1SeAUE+eDUzXC1OEPQ==
  • Thread-topic: [Xen-devel] SMMU permission fault on Dom0 when init vpu_decoder

Hello,

I'm getting permission fault from SMMU when trying to init VPU_Encoder/Decoder
in Dom0 on IMX8QM board:
(XEN) smmu: /iommu@51400000: Unhandled context fault: fsr=0x408, 
iova=0x86000a60, fsynr=0x1c0062, cb=0
This error appears when vpu_encoder/decoder tries to memcpy firmware image to
0x86000000 address, which is defined in reserved-memory node in xen device-tree
as encoder_boot/decoder_boot region.

I'm using xen from branch xen-project/staging-4.16 + imx related patches, which 
were
taken from https://source.codeaurora.org/external/imx/imx-xen.

After some investigation I found that this issue was fixed by Peng Fan in
commit: 46b3dd3718144ca6ac2c12a3b106e57fb7156554 (Hash from codeaurora), but 
only for
the Guest domains.
It introduces new p2m_type p2m_mmio_direct_nc_x, which differs from
p2m_mmio_direct_nc by XN = 0. This type is set to the reserved memory region in
map_mmio_regions function.

I was able to fix issue in Dom0 by setting p2m_mmio_direct_nc_x type for the
reserved memory in map_regions_p2mt, which is used to map memory during Dom0 
creation.
Patch can be found below.

Based on initial discussions on IRC channel - XN bit did the trick because looks
like vpu decoder is executing some code from this memory.

The purpose of this email is to discuss this issue and probably produce generic
solution for it.

Best regards,
Oleksii.

---
arm: Set p2m_type to p2m_mmio_direct_nc_x for reserved memory
regions

This is the enhancement of the 46b3dd3718144ca6ac2c12a3b106e57fb7156554.
Those patch introduces p2m_mmio_direct_nc_x p2m type which sets the
e->p2m.xn = 0 for the reserved-memory, such as vpu encoder/decoder.

Set p2m_mmio_direct_nc_x in map_regions_p2mt for reserved-memory the
same way it does in map_mmio_regions. This change is for the case
when vpu encoder/decoder works in DomO and not passed-through to the
Guest Domains.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
---
 xen/arch/arm/p2m.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index e9568dab88..bb1f681b71 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1333,6 +1333,13 @@ int map_regions_p2mt(struct domain *d,
                      mfn_t mfn,
                      p2m_type_t p2mt)
 {
+    if (((long)gfn_x(gfn) >= (GUEST_RAM0_BASE >> PAGE_SHIFT)) &&
+        (((long)gfn_x(gfn) + nr) <=
+        ((GUEST_RAM0_BASE + GUEST_RAM0_SIZE)>> PAGE_SHIFT)))
+    {
+        p2m_remove_mapping(d, gfn, nr, mfn);
+        return p2m_insert_mapping(d, gfn, nr, mfn, p2m_mmio_direct_nc_x);
+    }
     return p2m_insert_mapping(d, gfn, nr, mfn, p2mt);
 }
 
-- 
2.27.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.