Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp37565ybv; Wed, 19 Feb 2020 15:57:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwLi/gp9v9gz2pZIGOJeM2w+fLNueI8BtXBJ/0VDvRos5Mq+ZDzjmGDCV4QVs3ilmKNfbzW X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr20549668otp.137.1582156639903; Wed, 19 Feb 2020 15:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582156639; cv=none; d=google.com; s=arc-20160816; b=WMbRe4z10jkmyAicyNxTBwUMiuo34OGOsEQnYoTOjOkYjq4ai0s8ShbwmT4bKKsdII 0ZW2vIj7HhV2s48pvxklUqoW6LT1NPm9hwtBJc0kPafGpI5bDO5dtnd2mARVk/GI07WA 1eVS0ucz1cx6ajcb5V6tAK+s+Ua+EItFlsxTLAnUrRLspH46IFDnKaTq1r9YZXQlzAsB eVeHi8C5OEYKJPWw4AGpI2TrIQK9weBSgPlU1syxbj6Y6j5nGleNMg/8eU3WXQ2GHhFM 8wcIUKflLet7+hlo5DWgsKw8z+tToWcgaxuYAofk2RwIEcXZRxkFdoG+hNQNDmrKUi4C K9kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :mail-followup-to:reply-to:message-id:subject:to:from:date :dkim-signature; bh=gVZETO5ToPW9ORza98Ii24fKRNVEYxysJCTkt8Xpckw=; b=u2xAWRCwT3TaalYX4Yr9W2ptU/WR03kzkldapHCdaWv6qqXJScareivzGS06rPJN+S ouDg5DPiC7aL0Z2XspseAX7qeKqgOQBXPz4k1R4+2VQEKoUd6p6rLH0xHvOkdzX7NTC+ ufabPcHkn6GODQNvz2BN4Ckd50fYQDWuKyNmey25Z08F9FatlGMY6bMUY7NXbsMD/0t0 Xr0epVVDb31jnM7hVI3avUYa1vZDEb0ar0b149PehgsHhR9Gv8CeShl10EZ2TNyiPTEa Ev2QwP7vyfs6Yoxxc+wQckvWmH1mrAWDrVcSzeo2FesVvztWsEyb6YRlXCvQKXD8rPTN UqGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ei3vKDzR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si744572otq.23.2020.02.19.15.57.08; Wed, 19 Feb 2020 15:57:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ei3vKDzR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbgBSXzW (ORCPT + 99 others); Wed, 19 Feb 2020 18:55:22 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:52181 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726613AbgBSXzW (ORCPT ); Wed, 19 Feb 2020 18:55:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582156521; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=gVZETO5ToPW9ORza98Ii24fKRNVEYxysJCTkt8Xpckw=; b=Ei3vKDzRLMehLGiO7JJUoEJWFVhwfYnmfVQ57XE0oPqFYrVtD2tD/n7npYmnAmN9FCQJ8c TLQkvYrNDZ8TJHEo63yXHHtUlJPUje63C2i/brVZ7PiWoDMKCEla2WW4GUfd3iR7HUKPTU ibz7yeQAOfDCpDwpTTkQtZ8yiC4hP2Y= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-LWYBNX4MPUu7TMq7ka3Akg-1; Wed, 19 Feb 2020 18:55:19 -0500 X-MC-Unique: LWYBNX4MPUu7TMq7ka3Akg-1 Received: by mail-qt1-f197.google.com with SMTP id p12so1387489qtu.6 for ; Wed, 19 Feb 2020 15:55:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:reply-to :mail-followup-to:mime-version:content-disposition; bh=gVZETO5ToPW9ORza98Ii24fKRNVEYxysJCTkt8Xpckw=; b=UfweLVPABEmMajOuD+IX1VnsNY4e9Aln/k7eiK07CVN+F6/3Ly4vlDnPdXLTnX79zu sKDuXsdUpZHNmGC7d7l/jzEgY919ov1mobGAIaPehg2yC1m7MIZlzjE/ysSpdnokyPGi CQpZVU87WOSVSU25BAM5UNhA2Z6whcPbVmY+CmfBv3XjZrFWFXHm1dvaeclrnmWPE3kw sXVLdjcQePq7+/z5hPX6jpWl226IPiN+S3dG2RqTcgMTIVZpHa+i/nWSAKbBTqPM5ivv RIJwzJOTuucOnv3FKOhRfMMr3d2wDwrHI1jeHncYk1Cmw8Ub5hFzwJ4YlmZpJtCORIJj i0wg== X-Gm-Message-State: APjAAAWHpcDwRlbLNaDeSw+73HtnFG/UlO7KmNvFip+B4ZlAkW6lSgUm YKlb4LD6hlfHy1Mc/UcxZaNmDdA8r0P69jlm1XRtUDTmC7Gx5g6vsN9aOIyIAMUrAKY/MEVqMFo 9K5kzMtbTaU1vum4sTUXgaCD6 X-Received: by 2002:ac8:7773:: with SMTP id h19mr24151852qtu.144.1582156518743; Wed, 19 Feb 2020 15:55:18 -0800 (PST) X-Received: by 2002:ac8:7773:: with SMTP id h19mr24151842qtu.144.1582156518440; Wed, 19 Feb 2020 15:55:18 -0800 (PST) Received: from localhost (ip70-163-223-149.ph.ph.cox.net. [70.163.223.149]) by smtp.gmail.com with ESMTPSA id z6sm849662qto.86.2020.02.19.15.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 15:55:17 -0800 (PST) Date: Wed, 19 Feb 2020 16:55:16 -0700 From: Jerry Snitselaar To: Lu Baolu , Joerg Roedel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: question about iommu_need_mapping Message-ID: <20200219235516.zl44y7ydgqqja6x5@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: Lu Baolu , Joerg Roedel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Is it possible for a device to end up with dev->archdata.iommu == NULL on iommu_need_mapping in the following instance: 1. iommu_group has dma domain for default 2. device gets private identity domain in intel_iommu_add_device 3. iommu_need_mapping gets called with that device. 4. dmar_remove_one_dev_info sets dev->archdata.iommu = NULL via unlink_domain_info. 5. request_default_domain_for_dev exits after checking that group->default_domain exists, and group->default_domain->type is dma. 6. iommu_request_dma_domain_for_dev returns 0 from request_default_domain_for_dev and a private dma domain isn't created for the device. The case I was seeing went away with commit 9235cb13d7d1 ("iommu/vt-d: Allow devices with RMRRs to use identity domain"), because it changed which domain the group and devices were using, but it seems like it is still a possibility with the code. Baolu, you mentioned possibly removing the domain switch. Commit 98b2fffb5e27 ("iommu/vt-d: Handle 32bit device with identity default domain") makes it sound like the domain switch is required. Regards, Jerry