Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1729324ybi; Fri, 12 Jul 2019 23:05:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKZFhWVUn5dUjgzOBZJozAOM3o5GjICTaT/mguCCOuhNkEo6lUvZyGpf9YGrY8u0eftm+n X-Received: by 2002:a17:902:9004:: with SMTP id a4mr16164803plp.109.1562997901354; Fri, 12 Jul 2019 23:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562997901; cv=none; d=google.com; s=arc-20160816; b=aYgHGp/Uhmz/h5EshMdyNePoTUjsay6nl7sOvJu0KqN2lG63IlJTXTJK3FRNYTxEO7 n6I1VxJ6cc6fuDHirqbxZkaNVhQbuJCNm9oe85WXHev1RUeAJDxxj7luPAcDHbpuu2g8 41qUTSZZ6eS0H6OqfW72hpyRaVEGVM5hdcKD7YCrzAM8PpOEpWmWkOZeRvhrQ8A6LzBF JQraitsWkD9RzZ9Tv4aWDzXYAbKoMc0L8gEWo0PKIhxAmFsl4ruO8wug8BN36UYC/4a+ IFx2OA6cfapDDYaMeFeN98SbCPqRwLM2RSfs4g21+z7nj/bV+7vEbZ0SZPzk8+bNugdj QQTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mwP2hKYaYIrBhwYsKal56EXyo7iU5lzqyXSltfl+6MI=; b=wpQrKFCLZoapqucvMp23Z14b1pkeMcj3+NEN6cE1dMMjxnKd8GcQpZE9c8NOkH5kWC aFF7D/FGh46xT2jF2Y2EYVfasRO/d9d9UE848OqrHUJdDB78F2NZQ8sy0Xx+e6vX5mhR Lhd7vCRJlhafPGWtrAWdxc+lQqx4E0GBN1dPG4Uo54HJUbv0cCNhxDFi06QC6NnEGod8 5MOtQ1AKvRXGz+F1jKnLIs/stkbcV0p59FFXEAtU3xVLx3rIpf7ntXsxApx1nAZDoGQc Qig0nKc4EAdZuyMwVgUmHz3EQBGUSp149desZFwtI4P3m7uI5PUJoz7TklffH5n6/HRs vG7w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si11010824pgc.522.2019.07.12.23.04.45; Fri, 12 Jul 2019 23:05:01 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbfGMGDl (ORCPT + 99 others); Sat, 13 Jul 2019 02:03:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56344 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726274AbfGMGDl (ORCPT ); Sat, 13 Jul 2019 02:03:41 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6D5uMfT020954; Sat, 13 Jul 2019 02:01:20 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tq8vh9417-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 13 Jul 2019 02:01:20 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x6D5wnLX024849; Sat, 13 Jul 2019 02:01:19 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tq8vh940c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 13 Jul 2019 02:01:19 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6D608G3001218; Sat, 13 Jul 2019 06:01:19 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma03dal.us.ibm.com with ESMTP id 2tq6x6gtp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 13 Jul 2019 06:01:19 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6D61Hb657934204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Jul 2019 06:01:17 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53E40C6057; Sat, 13 Jul 2019 06:01:17 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B48CC605F; Sat, 13 Jul 2019 06:01:14 +0000 (GMT) Received: from morokweng.localdomain.com (unknown [9.85.135.203]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Sat, 13 Jul 2019 06:01:14 +0000 (GMT) From: Thiago Jung Bauermann To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Alexey Kardashevskiy , Anshuman Khandual , Benjamin Herrenschmidt , Christoph Hellwig , Michael Ellerman , Mike Anderson , Paul Mackerras , Ram Pai , Claudio Carvalho , Thiago Jung Bauermann Subject: [PATCH v2 11/13] powerpc/pseries/iommu: Don't use dma_iommu_ops on secure guests Date: Sat, 13 Jul 2019 03:00:21 -0300 Message-Id: <20190713060023.8479-12-bauerman@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190713060023.8479-1-bauerman@linux.ibm.com> References: <20190713060023.8479-1-bauerman@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-13_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=679 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907130070 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Secure guest memory is inacessible to devices so regular DMA isn't possible. In that case set devices' dma_map_ops to NULL so that the generic DMA code path will use SWIOTLB and DMA to bounce buffers. Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/platforms/pseries/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 03bbb299320e..7d9550edb700 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -50,6 +50,7 @@ #include #include #include +#include #include "pseries.h" @@ -1332,7 +1333,10 @@ void iommu_init_early_pSeries(void) of_reconfig_notifier_register(&iommu_reconfig_nb); register_memory_notifier(&iommu_mem_nb); - set_pci_dma_ops(&dma_iommu_ops); + if (is_secure_guest()) + set_pci_dma_ops(NULL); + else + set_pci_dma_ops(&dma_iommu_ops); } static int __init disable_multitce(char *str)