From patchwork Thu Jul 31 15:00:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 34662 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 859ED20540 for ; Thu, 31 Jul 2014 15:02:36 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id p10sf1885450wes.2 for ; Thu, 31 Jul 2014 08:02:33 -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:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=HzTRMeztqDemJZG5FDZanzsum5bSDaZyVowCT6dsNsA=; b=l+JML5wN14UtpQ6e60WWVbb4up/wAl3UZL7nQF7wdFSdHI7IMZ3DZ2pluAgOZIhjCF vwBHtlkdDzOdrVQrMbX9nollNgnpylRrehg6ydgOhADXVSaoW0zQe/S6Dluo/kQVeSzZ 2wSvjYXpeuFmJOf9kJzyyxNEnQYPgF/0AWhn+cF6s3YlldvW5DTQDc36HU/jmRSgeLoZ wjKDB2qoE3SnUOCpg3n38lSjzyYmI3yZBbzWyaDy0HsjQG6ycpRzoIVtHirPxvTVfEPE omvo8PZW3dGZoXmJhelmYYHyNMKkwqCzD0kHCzAWPI0S+AuLPb0iwPkmxMpmLSjIrAN5 760g== X-Gm-Message-State: ALoCoQm4a63hxhDZvdgpPbcf+IbxcjYlsznIuEr1+uT0ZLkxW88O2DIts75QwkEFVCpgvbCbw1LT X-Received: by 10.112.95.228 with SMTP id dn4mr1199919lbb.2.1406818953643; Thu, 31 Jul 2014 08:02:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.36 with SMTP id b33ls1013294qgd.68.gmail; Thu, 31 Jul 2014 08:02:33 -0700 (PDT) X-Received: by 10.52.253.39 with SMTP id zx7mr15378615vdc.2.1406818953470; Thu, 31 Jul 2014 08:02:33 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id fw5si4619779vcb.46.2014.07.31.08.02.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 31 Jul 2014 08:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so4394183vcb.41 for ; Thu, 31 Jul 2014 08:02:32 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr13495223vcb.48.1406818952223; Thu, 31 Jul 2014 08:02:32 -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.221.37.5 with SMTP id tc5csp25089vcb; Thu, 31 Jul 2014 08:02:31 -0700 (PDT) X-Received: by 10.50.32.10 with SMTP id e10mr20276122igi.7.1406818951495; Thu, 31 Jul 2014 08:02:31 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w5si14871532igl.55.2014.07.31.08.02.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 31 Jul 2014 08:02:31 -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 1XCrrF-0000tl-8X; Thu, 31 Jul 2014 15:01:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XCrrE-0000rf-Cu for xen-devel@lists.xenproject.org; Thu, 31 Jul 2014 15:01:28 +0000 Received: from [85.158.137.68:41059] by server-8.bemta-3.messagelabs.com id BF/77-31195-74A5AD35; Thu, 31 Jul 2014 15:01:27 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-4.tower-31.messagelabs.com!1406818883!11068718!1 X-Originating-IP: [209.85.212.179] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30390 invoked from network); 31 Jul 2014 15:01:24 -0000 Received: from mail-wi0-f179.google.com (HELO mail-wi0-f179.google.com) (209.85.212.179) by server-4.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 31 Jul 2014 15:01:24 -0000 Received: by mail-wi0-f179.google.com with SMTP id f8so4309234wiw.6 for ; Thu, 31 Jul 2014 08:01:23 -0700 (PDT) X-Received: by 10.194.104.234 with SMTP id gh10mr17375312wjb.66.1406818882556; Thu, 31 Jul 2014 08:01:22 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id r20sm67128337wik.0.2014.07.31.08.01.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jul 2014 08:01:21 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Jul 2014 16:00:47 +0100 Message-Id: <1406818852-31856-17-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1406818852-31856-1-git-send-email-julien.grall@linaro.org> References: <1406818852-31856-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 v2 16/21] 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.220.182 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 --- Changes in v2: - Fix typoes in the commit message - Update commit message --- xen/drivers/passthrough/arm/smmu.c | 7 ++++--- xen/drivers/passthrough/device_tree.c | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index f4eb2a2..b25034e 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -1245,8 +1245,8 @@ static int arm_smmu_reassign_dt_dev(struct domain *s, struct domain *t, { int ret = 0; - /* Don't allow remapping on other domain than hwdom */ - if ( t != hardware_domain ) + /* Allow remapping either on the hardware domain or to nothing */ + if ( t && t != hardware_domain ) return -EPERM; if ( t == s ) @@ -1256,7 +1256,8 @@ static int arm_smmu_reassign_dt_dev(struct domain *s, struct domain *t, if ( ret ) return ret; - ret = arm_smmu_attach_dev(t, dev); + if ( t ) + ret = arm_smmu_attach_dev(t, dev); return ret; } diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index 45d4a59..f8affa0 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -75,14 +75,12 @@ int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev) spin_lock(&dtdevs_lock); - rc = hd->platform_ops->reassign_dt_device(d, hardware_domain, dev); + rc = hd->platform_ops->reassign_dt_device(d, NULL, 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);