Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3449681ybl; Mon, 19 Aug 2019 19:19:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOLAYV4BiLX13jFyRac1Sj0I8JrwgncBzfRODCnPZxiCm2+tpExwqr7pBNEW1CCoU7Ya1t X-Received: by 2002:a17:902:5a5:: with SMTP id f34mr25229277plf.178.1566267569204; Mon, 19 Aug 2019 19:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566267569; cv=none; d=google.com; s=arc-20160816; b=U2zS/NMF4UgrIWk9xyqXxIoV9q+aIPfCXYockcvaMK4QMKNBQg83AfHwXg/Kwegwl/ w8oPLN+GDianHGmR995VO/d7fCbP7MhqEHuV8mATqWtmbEkPBxMEE+SId25TWetfIffQ EC544jwX8iTZDhEXycJzoqs1y0+EHfHZEX7AafLEu6v6HUC9LKE2ZjHTvywI2PD7xM29 Mh9Qm9Em92NjCa56D1XBDQcDw28A7cKkeL6DuKr0E9ZzMK7e3hJ1yGlIKebpLcTdmHOl z6Ubeu9ywtfCxbyS2mE1b2lsW4UAgZPz3eq4lBDWT3PlQjLCTSNy82Yv5Pnso1zY5stY zIag== 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=F/OrcfZwWFqsFsruT6j+6UKRgCUztA0G/9Vz1yBC0ps=; b=qspKLymjxReXDHE6qT7hrzg8pIxU0NGGraxn8gktxqNhQ0lz7PXcC/9WNGL03/2cPz RpJo4Gzn5JhT/iT5t08s8BV0qy5YJ7A13T5a7eg6dUtx6+5DMxdJy9hDNsWHBr2+Ca+1 wsgHXkZZ0X5nrGbUUiYK7gX9jNd17urtNrpnUTCmo+jcyAGnVvzXFLbQhTt0OMvonkXm UNMMqTiabSbh+PTjxLWEiVnG1B/pC+iu9Ei8zMw+s9ynFdM8in9nc88OK6l0SMZagJDP /tnu+fgkVjdUK8oV4WSR8bLs+WbqA7fL4ANTyP/+Tfl80CNzKwkTr8GKCyULd5ITPdfT lROw== 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 a63si4392728pla.381.2019.08.19.19.19.14; Mon, 19 Aug 2019 19:19:29 -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 S1729082AbfHTCQy (ORCPT + 99 others); Mon, 19 Aug 2019 22:16:54 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33870 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbfHTCQy (ORCPT ); Mon, 19 Aug 2019 22:16:54 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7K2D2c9013822; Mon, 19 Aug 2019 22:14:38 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ug4kcx2yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Aug 2019 22:14:38 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7K2Eb6C017504; Mon, 19 Aug 2019 22:14:37 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ug4kcx2y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Aug 2019 22:14:37 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7K29pRM012657; Tue, 20 Aug 2019 02:14:36 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma03wdc.us.ibm.com with ESMTP id 2ug0ck2067-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Aug 2019 02:14:36 +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 x7K2EYje45547874 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2019 02:14:34 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C37BFC6059; Tue, 20 Aug 2019 02:14:34 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B237BC6055; Tue, 20 Aug 2019 02:14:31 +0000 (GMT) Received: from morokweng.localdomain.com (unknown [9.85.220.248]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 20 Aug 2019 02:14:31 +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 v4 13/16] powerpc/pseries/iommu: Don't use dma_iommu_ops on secure guests Date: Mon, 19 Aug 2019 23:13:23 -0300 Message-Id: <20190820021326.6884-14-bauerman@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190820021326.6884-1-bauerman@linux.ibm.com> References: <20190820021326.6884-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-08-20_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=627 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908200018 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 to bounce buffers for DMA. Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/platforms/pseries/iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 889dc2e44b89..8d9c2b17ad54 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "pseries.h" @@ -1318,7 +1319,15 @@ 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); + /* + * Secure guest memory is inacessible to devices so regular DMA isn't + * possible. + * + * In that case keep devices' dma_map_ops as NULL so that the generic + * DMA code path will use SWIOTLB to bounce buffers for DMA. + */ + if (!is_secure_guest()) + set_pci_dma_ops(&dma_iommu_ops); } static int __init disable_multitce(char *str)