Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp726483pxj; Thu, 13 May 2021 15:40:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjyYUUAaOyZl6KrnEfjRWInpQ6Q69J94k+d5Z7tosQ72zFwsHR0rRQNqHsP5YnjHjCNDjW X-Received: by 2002:a92:d184:: with SMTP id z4mr21582150ilz.261.1620945623998; Thu, 13 May 2021 15:40:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620945623; cv=pass; d=google.com; s=arc-20160816; b=yVwbt3MeonHdTNaDscA3yUnsVE4+9lP4RScwAlCiWzupkzwBAUYlaNiMMJ4V/r+rSq wOppm7pBANymulzB+5Mh8HgHTdvJm0shftlUvp9R9D2MTL3cYesO2opSPRMJ0jZcK4vS QkwmHCe9gR2yzYEEbWjwDheOFlV9TXOrEe0vh/tZmgOtmevYAgcsUkQBJi2lUJChklV6 kmlkh0Hevb2y/qWdqRstXjWY6oA5TZVv5vwKvi31dXYPf0ihJAtMf2nPasMBSq9f9fm1 /qttjl630TDPnH9SsHbjqetgtGKED9oUM8fIskuAW9KW9LN8fx2JBg3MizpbyJBb8T8U zQUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R6gk7OCnWs1PR9hN4AhqkKefxyKid2l90DXeruNiw1Q=; b=rcS+Mz41vum1TtPy3WmL1k3pUxxx+2MxwfY+wnScnJYba82f6pXN52DmEVpbmVdeQG MyoPlxJ652REY8iuXbF0K1sZu0P2F0jXAvmERU7FLA61z+5xQfuoTQZ+yBWBrsKIsuKb q7EufTob4JBmzEaTZBXOJqWU81QB7mU5oC1rUymuoGEM2wVjeDePN0TQmLyidLmV39m/ 1Wj0a+qpXIXgyZ3EDOUCcfW145GpGdZoo/tcJTizib8Rt5uVmEd+wuuRrGYnPaYVj3Gy 0W8nZrx1lUOy/O8KfU7pEONJV5kBenKqJ3vnzZRAarXL5BoSqGktSjdKnnv1njPfP/Fe bEjw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=DcSrnvaV; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si5114243ila.129.2021.05.13.15.40.10; Thu, 13 May 2021 15:40:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=DcSrnvaV; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbhEMReR (ORCPT + 99 others); Thu, 13 May 2021 13:34:17 -0400 Received: from mail-mw2nam12on2061.outbound.protection.outlook.com ([40.107.244.61]:29921 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229964AbhEMReR (ORCPT ); Thu, 13 May 2021 13:34:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bOPzJo5r4PM1qwLqANUfd7lK0GSHiHB+ermwEfHO7zKJLH7eY/2kuQFHm5rY7EpYhw0FpYPKz9dkru7tzcTT+BkW9owfR35SuXprCzsHdyJ4rw3E2p7f5WTWTtY0kBChsisdpr/zByauwYFTD4v/rBC7k9bq/UHsv/MDsvVzQKM/CFLVlFDFdAiomDEcw/QoQRpnmQYnqbSJDWpkQjxfSSY5Cv9JfQlXGMEsvimAZdaI+yRDbwz/OyaR9d56Uym69MwEnIpBgLJp3x1Q4veU5/d+F4NYcJqhmo3qkcs7KQJ66dClBWRHqvTVfxQytw4t/Gmr1uBh/5YGrqpn27RrzA== 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-SenderADCheck; bh=R6gk7OCnWs1PR9hN4AhqkKefxyKid2l90DXeruNiw1Q=; b=FBpPNz9n73I5a0ZTIRgxlYP1kT9LeOYBUbvuRtQA7XBpu+47pbfxzCrAn2/KyUY/r4vtW7Yx6FBmz01Hhwmh/m5YS2TjJHE35NdocxgGmKVCKYUqjRwfQf5OtrAwl3RXMtW0V2UdqPErHyLxyZv95/rD6Qk4U5p3RYk+igVGpPO0/2/NlRjvtwe0+xafyiHWFjh4d6vg9/TdCpMrFXAL+YfzHclsM+VBLiYvfCnVuSaXkCZdW14LBs1cUpWL/GUPN/lUvu7W2rW+Kby7yBUWbrFDZJP1bJ86sQV9W+fupaXprucPMI5okzIAtC+FuBxtjZoa/TZ+kw+0W34y3n1txQ== 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=R6gk7OCnWs1PR9hN4AhqkKefxyKid2l90DXeruNiw1Q=; b=DcSrnvaV8TThVxuMns8sNDUfRK591NdYgCxAKxQX9ApcDQ76Jmmn/YHcfpo61d+koGABE0R9VVNPmLI6Gv2SGpwN53aTt7E4k+M+BPjBRZzvAL/3C0S8Ej4Q6hNLPANlU532RiVSyDnJoStlkzneH6WjL5mGJa7y/1CjUJ7NkFL+lT0gMea3ulcFE0YuAc7chAkWSePSbGxiVhMn4xVPxHv++9I8H8eFCwMs76BG/242ObJ2c/Z7AJrQtnnkVjug4HNVdd5aVpG6e2KHdPh3xBeUBWQ3J4RpQwpjuCPeUCP0rkIXzqCEvHET2iuDQ1Cy5H3vJcpkzVkU6aAoXc07sQ== Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM5PR12MB1433.namprd12.prod.outlook.com (2603:10b6:3:73::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Thu, 13 May 2021 17:33:05 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::ddb4:2cbb:4589:f039]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::ddb4:2cbb:4589:f039%4]) with mapi id 15.20.4129.026; Thu, 13 May 2021 17:33:05 +0000 Date: Thu, 13 May 2021 14:33:03 -0300 From: Jason Gunthorpe To: "Luck, Tony" Cc: Jacob Pan , Christoph Hellwig , LKML , "iommu@lists.linux-foundation.org" , Joerg Roedel , Lu Baolu , Jean-Philippe Brucker , "Liu, Yi L" , "Raj, Ashok" , "Tian, Kevin" , "Jiang, Dave" , "wangzhou1@hisilicon.com" , "zhangfei.gao@linaro.org" , "vkoul@kernel.org" , David Woodhouse Subject: Re: [PATCH v4 1/2] iommu/sva: Tighten SVA bind API with explicit flags Message-ID: <20210513173303.GL1002214@nvidia.com> References: <20210511114848.GK1002214@nvidia.com> <20210511091452.721e9a03@jacob-builder> <20210511163521.GN1002214@nvidia.com> <20210511110550.477a434f@jacob-builder> <20210511194726.GP1002214@nvidia.com> <20210513060012.0fcc7653@jacob-builder> <20210513133834.GC1002214@nvidia.com> <20210513081050.5cf6a6ed@jacob-builder> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: BL0PR0102CA0072.prod.exchangelabs.com (2603:10b6:208:25::49) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (47.55.113.94) by BL0PR0102CA0072.prod.exchangelabs.com (2603:10b6:208:25::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Thu, 13 May 2021 17:33:05 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lhFCp-0077qy-OJ; Thu, 13 May 2021 14:33:03 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3ad7715-8bb8-41b8-c357-08d916352a7f X-MS-TrafficTypeDiagnostic: DM5PR12MB1433: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G63U4ALDWK0xusXqJ/ZiINCrcnxOPZ6GUMROVWo610dE618300PzzpTfcFWiHSkTGVTLIyPzZW+kv1MGmm3XJzjZB1BeDKrxy5T499HmoIbrRWmx9Z18LPfm/k1HMeyedglS4jkZ+eZkrNXKCQHZsuE9n0s/tUkX7r+pHmP/rJYHLuqamQgws5uAfb2ur4JSZ7zjqTiOKfwvT5jPh4XQJBESx+RPYo3Acp3bQuxZJyHpF2DD8Mriq9Xqf9lshtFDPjGTF14g9bVRkh1PFApCytOHe29slkU1MUfB1kjZrJgE+1g6LUBTH9/cxv1ftODZUg/g9hjsxf/aPhoxFqQpos93cUSYKA+ymhP7Vb0bEMan7X5hFaWqhxb4f2B/UCPGO2XwRqPPAwU0npNttk/26Ta+5drBlHwvtF2IZa4rHtDWuqgGPoqSH74TRNhsoQhlJR9BUhs239t7ue83pw3H0cEZyuND7VlK805Ngt7l3f7HwJyV4/FYu6+VXHVqXfcAElO6r5zPsWrEY3IHk0nmaB17dM77ILeTeUUYOhZ8jS2ukuvMYKPmJReqPqLGvvxNbDB8mEMmXIbVpAQOrzA8AuznitF374+rGzxdmn+wCEo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3834.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(136003)(376002)(396003)(39850400004)(36756003)(86362001)(33656002)(38100700002)(7416002)(83380400001)(26005)(66556008)(66946007)(1076003)(2616005)(2906002)(4326008)(316002)(54906003)(6916009)(8676002)(478600001)(426003)(186003)(8936002)(9786002)(9746002)(66476007)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?SrAzC7yBRRsjRDwQOOI0lqKnPsRh6o5eZz/a/E5H22KqzGD/aYDdaxpoPn5E?= =?us-ascii?Q?f94eoAl+Gqm7ux8xU0LrZ05n6YflcFNro11BG9c0Yvj6ORTW3PFgsamlwaRJ?= =?us-ascii?Q?x9G7IiuE7scr6uCMF6OcfCEM/oLdnojTTozxdqepMr9spRZqkWe08x1WwTjw?= =?us-ascii?Q?a5FYVIm+8oznrMxuJcKgHj8FzKnx+OlBjPOdp8OpQRXjxxu2B0outbpy145F?= =?us-ascii?Q?58s+mBxeURia1l3BkTfCXAd6zbBpwPpq8O6h2lR8RaMfqBBKHyYDj2KXNBOl?= =?us-ascii?Q?fZ4G63OycAajiOQ65EC4OQey6B8bH5iVtmVn/NWo+ZBOjqGpPbs3Qwbm2AaN?= =?us-ascii?Q?yuGzFdFAOoC1ptgClzA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?LAajJELpMPpULorTo0Q3xtpLm87mzHNaqJdcecob7ZzWyFlHVR5DFlJKVFFN?= =?us-ascii?Q?DQd/W99XKxamN8nZ2RBmTQ5k?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3ad7715-8bb8-41b8-c357-08d916352a7f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2021 17:33:05.3938 (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: AjX/WMHlmCA0MpiB8BORFY+SrVtyz8djgraqKyvEYGmJFvcC1YFoE0UtevFflKtK X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1433 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 13, 2021 at 04:44:14PM +0000, Luck, Tony wrote: > > For shared workqueue, it can only generate DMA request with PASID. The > > submission is done by ENQCMDS (S for supervisor) instruction. > > > > If we were not to share page tables with init_mm, we need a system PASID > > that doing the same direct mapping in IOMMU page tables. > > Note that for the currently envisioned kernel use cases for accelerators it > would be OK for this system PASID to just provide either: > > 1) A 1:1 mapping for physical addresses. Kernel users of the accelerators > would provide physical addresses in descriptors. > 2) The same mapping that the kernel uses for its "1:1" map of all physical > memory. Users would use kernel virtual addresses in that "1:1" range > (e.g. those obtained from page_to_virt(struct page *p);) Well, no, neither of those are OK. The page table under the kernel PASID should behave the same way that the kernel would operate the page table assigned to a kernel RID. If the kernel has security off then the PASID should map to all physical memory, just like the RID does. If security is on then every DMA map needs to be loaded into the PASID's io page table no different than a RID page table. "kernel SVA" is, IMHO, not a desirable thing, it completely destroys the kernel's DMA security model. > If people want to use an accelerator on memory allocated by vmalloc() > things will get more complicated. But maybe we can delay solving that > problem until someone comes up with a real use case that needs to > do this? If you have a HW limitation that the device can only issue TLPs with a PASID, even for kernel users, then I think the proper thing is to tell the IOMMU layer than a certain 'struct device' enters PASID-only mode and the IOMMU layer should construct an appropriate PASID and flow the dma operations through it. Pretending the DMA layer doesn't exist and that PASID gets a free pass is not OK in the kernel. Jason