From patchwork Tue Jan 13 14:25:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43001 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9D79F20DE8 for ; Tue, 13 Jan 2015 14:28:06 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id t10sf1300234eei.2 for ; Tue, 13 Jan 2015 06:28:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=/UEo+f8ovTJJbAUdTJga64jHZGx9ly0i9w35Ad9uWtM=; b=jdGfaihZZyO6VGfVCdsisDcwgLS6n+ealwwCAQvcB/r3/g1ZPSGceJWqwEnQ1N7CBQ YjQVQ8Ptr3KKpxrOMh1H8PHp9tm93wUp2y1rrLAiVCIzp5GEmptgKmqPJE3xmwTaO61l QquK++/rLAobTMH2jxO+RRG9rq87fKDnu7c5kYufCZQCu7FLVvDEkO9GRineVR+wU7sc 5PhgdUWb5F771DXWQn5CcoiVmXZV0WPpY57JFg6YM1flCX4b05D1bOiKReXwck/USPYI xdKpV7FJB7cKJ6HAObRTwJ5MMfRJ+X1QeErgImoorS/eHuuoBUBkqSOxOXBbtnbdGMH5 6FfA== X-Gm-Message-State: ALoCoQmeI/AU/PyFhims1cgoUwCiIWPB7HzeimEJgEow/XffCAs4YjSt6GX8PqH4pMlbw9sRS/tc X-Received: by 10.152.6.202 with SMTP id d10mr4423laa.10.1421159285798; Tue, 13 Jan 2015 06:28:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.99 with SMTP id bf3ls3036lab.13.gmail; Tue, 13 Jan 2015 06:28:05 -0800 (PST) X-Received: by 10.152.7.206 with SMTP id l14mr42667881laa.1.1421159285457; Tue, 13 Jan 2015 06:28:05 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id fb6si24351586lbc.117.2015.01.13.06.28.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 06:28:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so2862213lab.8 for ; Tue, 13 Jan 2015 06:28:05 -0800 (PST) X-Received: by 10.112.26.135 with SMTP id l7mr33355963lbg.56.1421159285329; Tue, 13 Jan 2015 06:28:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1398810lbb; Tue, 13 Jan 2015 06:28:04 -0800 (PST) X-Received: by 10.224.13.65 with SMTP id b1mr49618372qaa.12.1421159277250; Tue, 13 Jan 2015 06:27:57 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id f8si26998042qcg.0.2015.01.13.06.27.56 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 Jan 2015 06:27:57 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YB2Qq-0001eQ-Bh; Tue, 13 Jan 2015 14:26:56 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YB2Qm-0001W3-B8 for xen-devel@lists.xenproject.org; Tue, 13 Jan 2015 14:26:52 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id B9/22-09842-B2B25B45; Tue, 13 Jan 2015 14:26:51 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1421159211!21169930!1 X-Originating-IP: [74.125.82.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21730 invoked from network); 13 Jan 2015 14:26:51 -0000 Received: from mail-we0-f173.google.com (HELO mail-we0-f173.google.com) (74.125.82.173) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jan 2015 14:26:51 -0000 Received: by mail-we0-f173.google.com with SMTP id q58so3218393wes.4 for ; Tue, 13 Jan 2015 06:26:51 -0800 (PST) X-Received: by 10.180.108.148 with SMTP id hk20mr8072246wib.5.1421159211006; Tue, 13 Jan 2015 06:26:51 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id ni15sm14513482wic.18.2015.01.13.06.26.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jan 2015 06:26:50 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 13 Jan 2015 14:25:27 +0000 Message-Id: <1421159133-31526-19-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> References: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com, Jan Beulich Subject: [Xen-devel] [PATCH v3 18/24] xen/passthrough: iommu_deassign_device_dt: By default reassign device to nobody X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Currently, when the device is deassigned from a domain, we directly reassign to DOM0. As the device may not have been correctly reset, this may lead to corruption or expose some part of DOM0 memory. Also, we may have no way to reset some platform devices. If Xen reassigns the device to "nobody", it may receive some global/context fault because the transaction has failed (indeed the context has been marked invalid). Unfortunately there is no simple way to quiesce a buggy hardware. I think we could live with that for a first version of platform device passthrough. DOM0 will have to issue an hypercall to assign the device to itself if it wants to use it. Signed-off-by: Julien Grall Cc: Jan Beulich --- Changes in v3: - Use the coding style of the new SMMU drivers Changes in v2: - Fix typoes in the commit message - Update commit message --- xen/drivers/passthrough/arm/smmu.c | 8 +++++++- xen/drivers/passthrough/device_tree.c | 9 +++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 3cf1773..45a2db8 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2774,7 +2774,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, int ret = 0; /* Don't allow remapping on other domain than hwdom */ - if (t != hardware_domain) + if (t && t != hardware_domain) return -EPERM; if (t == s) @@ -2784,6 +2784,12 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, if (ret) return ret; + if (t) { + ret = arm_smmu_assign_dev(t, devfn, dev); + if (ret) + return ret; + } + return 0; } diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index e7eb34f..d9b486e 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -72,15 +72,12 @@ int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev) spin_lock(&dtdevs_lock); - rc = hd->platform_ops->reassign_device(d, hardware_domain, - 0, dt_to_dev(dev)); + rc = hd->platform_ops->reassign_device(d, NULL, 0, dt_to_dev(dev)); if ( rc ) goto fail; - list_del(&dev->domain_list); - - dt_device_set_used_by(dev, hardware_domain->domain_id); - list_add(&dev->domain_list, &domain_hvm_iommu(hardware_domain)->dt_devices); + list_del_init(&dev->domain_list); + dt_device_set_used_by(dev, DOMID_IO); fail: spin_unlock(&dtdevs_lock);