From patchwork Thu Mar 19 19:29:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 46107 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E4F1A21515 for ; Thu, 19 Mar 2015 19:32:51 +0000 (UTC) Received: by lamq1 with SMTP id q1sf14245561lam.3 for ; Thu, 19 Mar 2015 12:32:50 -0700 (PDT) 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=EH4gDXMmX1+91y4aEB+tPnckRezV6JbTQzopS9LhIz0=; b=FLO+ZEfYwIKY4x6atjRwIFeBc7TIwf8oZ/vMwAs7ikic8MrYfBvnoIy7sOupvsGChs +mH3weBhXDJbGL0xSTb4jg6y0fJHXQW9P832r2z2u3UBh+sZhrhH3xuh4OcLBG+4grP+ 6tHWqzuUCew6gFjPvEkYvnAOBPPD5u88bOitxvWQdtOc5VU0rZXg5AO4+SE7bgyi6u20 /hw/MF5Vngag8ciHKrKSMUGn1El4T0xGvU21iN/DYoFw29ttWA2Lnlpy9cmuzNcAFVdf XmAPC835diYdRPJJ0wanAUXETmhnMXBqw4vr46gqMfLqHzA9jDz3MmrbWONyVJr3/Q6j seLQ== X-Gm-Message-State: ALoCoQk9Xqb00i9Xu5zY/yah8AbzRb5QLIc3gIqrMuIlpGQpcEyQFvBWYItPxRWJ0Gy3xeE1En0x X-Received: by 10.180.91.76 with SMTP id cc12mr2060234wib.7.1426793570920; Thu, 19 Mar 2015 12:32:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.134 with SMTP id r6ls380523laa.59.gmail; Thu, 19 Mar 2015 12:32:50 -0700 (PDT) X-Received: by 10.112.29.231 with SMTP id n7mr67256205lbh.99.1426793570679; Thu, 19 Mar 2015 12:32:50 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id d1si1682943laa.39.2015.03.19.12.32.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 12:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lagg8 with SMTP id g8so70667777lag.1 for ; Thu, 19 Mar 2015 12:32:50 -0700 (PDT) X-Received: by 10.112.185.66 with SMTP id fa2mr68851154lbc.117.1426793570368; Thu, 19 Mar 2015 12:32:50 -0700 (PDT) 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.35.133 with SMTP id h5csp597796lbj; Thu, 19 Mar 2015 12:32:49 -0700 (PDT) X-Received: by 10.55.15.159 with SMTP id 31mr102917019qkp.29.1426793552985; Thu, 19 Mar 2015 12:32:32 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id g91si2254768qgf.0.2015.03.19.12.32.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 19 Mar 2015 12:32:32 -0700 (PDT) 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 1YYg9z-00050H-Oo; Thu, 19 Mar 2015 19:31:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YYg9y-0004wA-Bp for xen-devel@lists.xenproject.org; Thu, 19 Mar 2015 19:31:14 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 5B/49-02005-1042B055; Thu, 19 Mar 2015 19:31:13 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1426793472!13832772!1 X-Originating-IP: [74.125.82.177] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26761 invoked from network); 19 Mar 2015 19:31:12 -0000 Received: from mail-we0-f177.google.com (HELO mail-we0-f177.google.com) (74.125.82.177) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 19 Mar 2015 19:31:12 -0000 Received: by wegp1 with SMTP id p1so65609660weg.1 for ; Thu, 19 Mar 2015 12:31:12 -0700 (PDT) X-Received: by 10.180.89.34 with SMTP id bl2mr19183503wib.23.1426793472666; Thu, 19 Mar 2015 12:31:12 -0700 (PDT) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id hl8sm3203005wjb.38.2015.03.19.12.31.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2015 12:31:11 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 19 Mar 2015 19:29:49 +0000 Message-Id: <1426793399-6283-24-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426793399-6283-1-git-send-email-julien.grall@linaro.org> References: <1426793399-6283-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v4 23/33] 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.47 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 Acked-by: Stefano Stabellini --- Note: This behavior is documented in a following patch which extend DOMCT_*assign_device to support non-PCI passthrough. Changes in v4: - Add Stefano's ack 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 a7a7da9..7261834 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2649,7 +2649,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) @@ -2659,6 +2659,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 05ab274..0ec4103 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -80,15 +80,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);