From patchwork Mon May 30 15:21:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 12864714 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6F02C433F5 for ; Mon, 30 May 2022 15:21:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.338616.563407 (Exim 4.92) (envelope-from ) id 1nvhCh-0000rG-E8; Mon, 30 May 2022 15:21:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 338616.563407; Mon, 30 May 2022 15:21:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvhCh-0000r9-BJ; Mon, 30 May 2022 15:21:11 +0000 Received: by outflank-mailman (input) for mailman id 338616; Mon, 30 May 2022 15:21:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvhCg-0000r0-2R for xen-devel@lists.xenproject.org; Mon, 30 May 2022 15:21:10 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 20617a68-e02c-11ec-837f-e5687231ffcc; Mon, 30 May 2022 17:21:08 +0200 (CEST) Received: from pps.filterd (m0174682.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24UEFH2I029805; Mon, 30 May 2022 15:21:06 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3gct621q5d-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 May 2022 15:21:06 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by DBAPR03MB6389.eurprd03.prod.outlook.com (2603:10a6:10:195::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Mon, 30 May 2022 15:21:03 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::31b5:dfd5:2d38:c0b2]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::31b5:dfd5:2d38:c0b2%9]) with mapi id 15.20.5293.019; Mon, 30 May 2022 15:21:03 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 20617a68-e02c-11ec-837f-e5687231ffcc ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V2CltKxWZkCNhVnxjNdqtO7Pz9X9fo1tq75UJ9Nd8PCmkPFFTVo+zKdHfuzDePkE9XtP9xfLQuXwSr6x8WuLjR6mUtdkgji3FT3RpJy741EyfVKM9Yow15OG5KVi5t7VTy8q6btfz4wxaciPTp+HQ4m6MJypTr1jZIk44gH/m0/ut2GSEBD35YDrLm2984rDWML3QafYJxmKALdWd0ZRRAQy5OlBMOFc8wREQEMUZQSlncguPJaU/DJE2LMVOxXoCI4ZFbgQgBPH7dZd8CqVdDMgQ7FMlrduixqQqAgIzGPttHjpr/YoJlJxvE0dCIJD94amqjw9IGoJSZs9rP1/Yw== 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-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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eK9WCHv2vArtOO0GW0SO/fwPV4IVBTjAHIutp6+unPo=; b=I1kCmX3+u3sqMyv60e9IvIOz/+ZbB47O/bYQIdZMeWrWTqAeBlO1l7FX1dFL4SvlRifPJh5ROX+pPlqlysj1CMJULGwvob0PaDI9/OFq7okJcwy4+Iiet7bhYC5Xtrw5+W1HYu0DlooPGAOMRdA6Lop1F6JSNIuB8hcP9MXItiMbYaHG2wTBll6RQp26Fnvv8ajzUgcusDMAbe2jRE8ADoOZ7lVLvEsodT9NQB1N8pT/xlO+R4fdk86XFRxUHNeehS+juNK1gZ3nkbXIduGHgWQXBIBjMu6AMPqSlCs+fbq+VdZSymLf1TxpVmtLbVM0UNFp12hmyLwTGnveNpsQYQ== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Julien Grall , Peng Fan , Bertrand Marquis , Oleksii Moisieiev Subject: [Xen-devel] SMMU permission fault on Dom0 when init vpu_decoder Thread-Topic: [Xen-devel] SMMU permission fault on Dom0 when init vpu_decoder Thread-Index: AQHYdDjfc3Z/1SeAUE+eDUzXC1OEPQ== Date: Mon, 30 May 2022 15:21:03 +0000 Message-ID: <20220530152102.GA883104@EPUAKYIW015D> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6f4172b5-a17f-420a-b2fe-08da42500266 x-ms-traffictypediagnostic: DBAPR03MB6389:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: evJqUCON4+N8dWbtcXDtyThAzei7QJWZLURW5oXjB7aFWOPpq1QtsemeMdxYkBa8ZAzh8I//N0BSzfJuOI/vHtNbxCF3c9LOpIcNenKiq6KUQpxmxwebHE7ucTOA3RvxBKVPQkFvtYM2XBXtBSzrN9AjoOC9qMvBMFab8AZPWk11lS3qFALwqOC9NqjGpwed1Jt19WwRKu413zFUeTJ3ISDXSRzzUGK3eEZXWScUsvoW+TU915fZ4Zqng6zczr1WPtv1yDCLnne+T967h8K1E7NGap61VsoyOyYeOk6F+Wmw7O9EMSAjXSXqmCrGixGEGx1II8h4eWFzIw2RiEGzHKFm5rREjlYykNbXRs1Jg7pPC1ymDQfdsgRpuTTKgRtqONlY/l7NMjjlIl82FQFwLEB2qYJVGP6sMB1QebFmBY9JwqnAmmmnNSjDGWJkX76Vqgt9PMB+GinqMHRF0EN7QThEDA/psvi/5B8j/qHNKWUsYHpcWRPHy3svp9dYRceG/NUgK85RHhWAz+Peq1dXXfjsUVJU/DaHpWtevLWZOqqlLOr86khyCvy/FurQ2LZ7mxtthFzUCdWt//NL8L2P0YiE3KU3TgjeFAn5Uh6Uri57Ut5dtNgwbYSCd6yIWQ0L08frcgVKewykVHIRGzV3OxGUsPtiO7EAntO5CCEN97pzhGgCMPlB95MLBUBK/Jmrtl0szO0ytA+bhdDrBVQ9bWKKw47GhWrYaYLuMSNOcQMZURo2u2f1IQiDVBkmXN8rsOZcrlNgOaFjoRPPezTD9d66zWMlAcH7DRIk9gZIgas= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(7916004)(4636009)(366004)(38100700002)(186003)(1076003)(107886003)(8676002)(316002)(4326008)(54906003)(6916009)(66476007)(91956017)(76116006)(66446008)(38070700005)(71200400001)(66946007)(64756008)(8936002)(6486002)(86362001)(966005)(6506007)(508600001)(33656002)(5660300002)(33716001)(122000001)(9686003)(6512007)(26005)(66556008)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: aP/lH3G2zp/pKTv+5shiqVOPkPIfSGooajfZvUyATFtW65r0Y77Ckgu57iClV3AjHrdv74lV5qMzlysI+rtqu1GUakfiGFT7CaJUfQ8tRgfP0ARkn2iW1FBAnW70Rf42tqKqfw8M9lAvvDNm+4p+Ur/swNRgkN/YMxWiilHH0A63l2ruP/DbML6Tz2Mr9C9AV+Co72hXpvimTUcaGacCEUVOaJADCqxprjBf0yVsXr+QYkmQT/gWckphJS7qv9nLgQS79LVwloj4ESWsgUhU02MKluVU5+zCgnaCWscHnfEequm43PTLcRxguc3Mw/EkSaTriwqeEY4dr6+rOu71vRscSSUNI1p2cIAlJtrGfHzbTIEr/TYS/iJsci7h2DAdylethrN6ZYJjWANFXU5oC6vtNUr8QK3/z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AmtgzkCbYPSXwlkdQz+T6y0HIO4K8/PXOMx+Lyr0cOneT3XkrJUWTHWs0KR8Ngxjw3oaLdoCxHGF1qgrFYqpACqM9CReAaeZybkNymbceWZbnh3XpSlTsQ20W3VhsFkvWSTh5c/DlsdMAVfesH7x4YFO9vHbxIhw3gjBYrZEA2hNEa51oq3WIeJdt6b9dULLnMEOSpYqMAauJN8/4JgbdUV4ZUfU3kbQMnYZJu8kvyb9X/G+bvbNpK8/qah+DK5oEwfbvxG+V04kIn9IvCNuY3p4VkKdnkfChDuzERNcUZvRQVGk/0 Content-ID: <74D2542000AD5C4F8A93073705CB4B9D@eurprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f4172b5-a17f-420a-b2fe-08da42500266 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2022 15:21:03.0979 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W2y9A0cCUyl+nL0rl2eHo2eduWwK2hEkUeSbv4qPx661eG+QMBVNVPqiq76g3dxY+2Lncj4Rb9Fj198b19O6tKgWTAJWL3GJ1FoWU1RJKN4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR03MB6389 X-Proofpoint-GUID: sGrL-VupN3GqprkXGjatCGiXWarH4bys X-Proofpoint-ORIG-GUID: sGrL-VupN3GqprkXGjatCGiXWarH4bys X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-30_06,2022-05-30_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 adultscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 clxscore=1011 bulkscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2205300080 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 --- 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); }