From patchwork Mon Nov 13 17:53:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13454282 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1C420C4167B for ; Mon, 13 Nov 2023 17:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RmdAXSQGF+bvJMiy5Wa72Gs1VWIKg3+2l2L5oE6oD7Y=; b=1uAkrneNGPsyFA ilgGRfEy28N9hjtdpk2eFLKfcAwOerZOiHg/IsyKmFohCPWg2tumD4zyJlifRlP1rnYTc8w5D7y2P xrddR+gx5Zzdy0siSBVhogmQ5T4g3B4mO+1NWnUP1WvwuFU+ibRQYj4niyCMMLELpD2ftp/X7KxZI eDTjLCek/ylTEhipOidfxtb82wIJHgrW2+KytMEXXvn1e3urgQq3YE9hW0br4G+lgaG7Y0Jg7JeZF xicHOosmAIv38zMsnCi7nSxN2gjMWw7QQOmvHpvdP/2x082shlxhTYduN87NHb7QdS4UDXrC/nE8u grBshSSJ1IZedDZeHjjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r2b86-00ERX9-1D; Mon, 13 Nov 2023 17:53:46 +0000 Received: from mail-mw2nam12on2061e.outbound.protection.outlook.com ([2a01:111:f400:fe5a::61e] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r2b81-00ERTJ-0B for linux-arm-kernel@lists.infradead.org; Mon, 13 Nov 2023 17:53:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CrNEuqbtTMRyTkBzDIMtguVivZt2sHp2NLaGx6g5lk7A2+zYIgsz0v5SOLOsMOA3VPXBUj/COZ7lqBpnL6s1+XjeeSw/31n6CeTtLZyC0Ay87do7pNhsv/8I6VFS9qjeMixMkTfv//T1SNw67N6iqX726qor+zKcSDNZCf9nWXYIKt+gg0iEr6gyv8ZGE5aQYbVtuJarmUpCsbFqU30cNuG/DkWOz8pQDGsQKk/Nio1WwG4WmXgQVA6Y2541WaqB5EOGo/w2uNQEYj8bHul0TFb9VCh2ZN4ndw31PsPgmts2bGhW7YXsfelr0f84NXzDxDNTo+bVlhqFRUuJzghihw== 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=OlTqW+hx4z/JEPgi8ufSSNgBDqkQhsRDOmQ0a6Td5FE=; b=mBPZ4YFNfnLNFNqCo8aKylP3o/1EiBboGfKfBTfcNFKlELgSPrR56z005QDn8bRgBzo6vdjXieiNBa4d0dW35JnDjpbF++Loy8ZNNYZPjneR3QoyCXZ0FNdSlQC00+aBpiB1U/Cc3/XewEFzTKlJfIK/11BT52kzIgvRH1j52qKiq+/+u+dZUYktGb2ts8sNZg0/R9eRCdqjPEV+lLwhOk1z1wUS05EGYqDmc5tkJENKRkBlIXBUj+7AS90LWq4LmZrw63q6ajhOezJlGKtKJSKV75LXiZ6RuhF4noWxOBwf+RPQZVmXyQZ4Mu4TXzw15GHHvkIltLoJGqa03rFSjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OlTqW+hx4z/JEPgi8ufSSNgBDqkQhsRDOmQ0a6Td5FE=; b=CqVwMNNn++fgoA59P/k5ut58drjcpHVdIZ9RQ/o9+a03P9j8Jw5Qi449ghxgY5x9GfGRn0SulccELC/TznLcyYzkjYolGph+bztaoqeORmu+TRqVymJ4NQD9dEOfkoFG3wCxIGr3QW/aqnx3eHmOpUYQZknAB0/IhALDYQ8PDCT67X7P0ROrdwY0EzF/W+jm8j0bWvNs9Lbp52cRDryO1F9T0oVeYzr7FLe/6ZK3hFG1eA8NkPmLiEUEwPeuRjx2L19YTNdYGbNr+h3A1TIuP7ktn4M1gGtuUgRfwS/ndfDMy8TSeRTC4vf9w/p7gmrDeBi0eQMjc8cvZsbHvRPA0w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by DM4PR12MB6038.namprd12.prod.outlook.com (2603:10b6:8:ab::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 17:53:29 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.6977.029; Mon, 13 Nov 2023 17:53:29 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Michael Shavit , Nicolin Chen , Shameerali Kolothum Thodi Subject: [PATCH v2 16/19] iommu/arm-smmu-v3: Add a global static BLOCKED domain Date: Mon, 13 Nov 2023 13:53:23 -0400 Message-ID: <16-v2-de8b10590bf5+400-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v2-de8b10590bf5+400-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR0102CA0039.prod.exchangelabs.com (2603:10b6:208:25::16) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB6038:EE_ X-MS-Office365-Filtering-Correlation-Id: f82426df-8b93-4dc7-6862-08dbe4717053 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F8VMBpsNJwE/WPRDlv+/AwQgb3fGXoKI6jl9KRgtg0kAIKlaY8zYqUtjDCIjDyB6kxGCrnHhgDOrZsRMNBiiSEB5D2JgQN9EIWuxtMFG1FzZFrW4IexN++gq926KBonHhDWrXMdq95EK5H5tdUOKL/7lp9DqRSNQeMH+ouc9G/K/2DBg994t9H+nvQULu4cPKrjY5zHDTkdLipz4wPUhTSy9l26JF4ehTbTCow4sO+I9TVyWicyvbYkf5qDgyO7ohmYfiF/H62inkCMk29R7e/QqcXII+MfNrvLJBF3xPrTbAvh5Xp6i2gp5h8pzgqiQat8Z7zm/uSmyjQ14kQMdZPwWpzRuhFbnlu8o9hYHPaXhS5Ulrom/35JFyiQ2mKJ5x1g4JXLXnSSWNVkDspNWd+FG7IQSwySEMvewLyzOkzRMXrJVQ33g5QZnGw8yZCwWXy7TSXtaF4gR2MzBupUYm2yKuY840zPC9TPJxj+NGFi/w6IvwcYLOn5fbP/hMQJBqFBDBP1WHeQ1pW8+HJ4tPvLwuUCeN58ulAbDPEsyaWoE8tYXJ0pQvtL/AfSmSskF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(396003)(346002)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(36756003)(26005)(478600001)(6666004)(6486002)(6506007)(316002)(2616005)(6512007)(66556008)(66946007)(110136005)(38100700002)(66476007)(54906003)(5660300002)(8676002)(8936002)(4326008)(15650500001)(2906002)(83380400001)(86362001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FfqDA1/hW3RpUxgLi2M4/VOFMYvhSV1ozS3lk+/CX61SdG+lIuDrjUloe33L9VaHez9Dxac9ynpsCWdHbwWM8YDRZD6nJ0RZb8G+CN/8imBdnq8BVhi4xYKusdnuLkDzhbTlNBjVDnHtGM59usA0KmG7s1AYJjtlbSSxynBIMA1k96ruaFjgiEIHO9JzBWMoI4VSPJXSAeUFyZu7j3QKKT9lW3PEQUW/UvVhG9m0UK2dOZ509IVsngkzVCnmh9/NqPXopZp04tyzARliDbPqvDAllPc0N1BinP0FXWuOz079r2F72n436GO43BIObgSDBjdRB6FpakfYY+x6x8Rc+0khgmPjV6/lxAhPoZKSpBBDrKiAZt0UpyBRM2Z1Mv/okZOoqFgySIGzGWeKx1u7ZLqgSBEsyC/YgUi+of1lCmZZ/KEQDooIVxMljtOhBu3frkmT3eV63lkxnq/I636HpDSDPQ/V8xX/7oJNnBptkgnO46UIw5YUO5Z862g0GQf0FP5Y3DO7b9TeuYaZnLAJaW/8+AG3sHMm86RL+J2Bicj6Xikl8pj50s5AaK5z0gl8DCjtKhkxy+wgnPfutiBaWRvbZhOXo+o8t0HBIeEayA5GXRGfHfT1mP0e1HJuvpWgmFT957jyA100ar86lhfO+wO45QaRdQZg7v0uU7KrVYz6uagfs0cnqjli/1e2A2Y83BXAtnclBPRZSavyWxLermm4ASxa85v01S11p/gTOECH+CoRFiDDhbOZEduGfSplfh+5D+LIj8kwK9gG/S4umolYeernPSV/DufGc2wXql1eA9FWUV0g/jodOLo2Q3IHM1b0h+BB2T0q/m4gRr5XCg28A/5fsPn8m6S2qrLEAPahoQ+CQSJpQqFVFUvaDENHMKQegQh8LIW7bTKa9DSB4jUJQYp/dlL23IASL6lvRW5BISHgNzf/9xozcRK707hDGN/D3CaLUCTUWuyybItEMIetQahyHs/wyeu5Wp3/hPkMPn9cNqSIBfZ3sKYhPolspy0taUCKlVscd+SDkB/ZA6D8E8Gf8GVVELwKqH8mDn2OlTBGyJtTQjl1k9hR7FV3DsiV4nVSQ+ePg7vVDu7vhsO5vINM6vQgECl7CvnuuFcuoA8MQXM8S+Q363JGbG/j85pcjEouYqotSbyLBxC0HXAJ1wqK8tX1IaEShJlamyo3ZZCwbV6S0GcfuBnj2+8fKwEriEqySuthnNNOsSRVAHbFK4hg4E/bUbQm0kRh65CabaozVwVFRxKd2bqiV05jnsJb2un1m+VbjQaP3tUEMUuP1zEF2avgYc2zBJfZQ0NvQ0n5o5EK87fAS05XE0BoRzGwFr+TacGvcorex+yg41funm5UR7qNVpAwlvxc5akbHH+tCeEqLRDKP0GOivw/FH21iNtvARMpfoNQRveiSrHzrgt1aTG9zG0s0YUk0P8wUkCweWERKbfO6q2szHlRmATGps67i/lAYCCdGsc6NG/RoNAYBbJs6C9mZ/ogLpn+XUHuZZ4zG+5UgxVrGZZ43DQn8EDGQT65oFgNszsacX/+Pv9AISCtZWCg+t45EVM= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f82426df-8b93-4dc7-6862-08dbe4717053 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 17:53:27.1101 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AlPDZphv1WbR7vbVo5XoIoDabL5I4xrQ99NXw6Df27AynLg6dQ5BQHOWCdC4j8Wm X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6038 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231113_095341_114945_6118F404 X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Using the same design as the IDENTITY domain install an STRTAB_STE_0_CFG_ABORT STE. Signed-off-by: Jason Gunthorpe Reviewed-by: Michael Shavit Reviewed-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index d6f68a6187d290..48981c2ff7a746 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2647,6 +2647,24 @@ static struct iommu_domain arm_smmu_identity_domain = { .ops = &arm_smmu_identity_ops, }; +static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain, + struct device *dev) +{ + struct arm_smmu_ste ste; + + arm_smmu_make_abort_ste(&ste); + return arm_smmu_attach_dev_ste(dev, &ste); +} + +static const struct iommu_domain_ops arm_smmu_blocked_ops = { + .attach_dev = arm_smmu_attach_dev_blocked, +}; + +static struct iommu_domain arm_smmu_blocked_domain = { + .type = IOMMU_DOMAIN_BLOCKED, + .ops = &arm_smmu_blocked_ops, +}; + static int arm_smmu_map_pages(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t pgsize, size_t pgcount, int prot, gfp_t gfp, size_t *mapped) @@ -3040,6 +3058,7 @@ static void arm_smmu_remove_dev_pasid(struct device *dev, ioasid_t pasid) static struct iommu_ops arm_smmu_ops = { .identity_domain = &arm_smmu_identity_domain, + .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable, .domain_alloc = arm_smmu_domain_alloc, .probe_device = arm_smmu_probe_device,