Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4889325imu; Tue, 29 Jan 2019 09:10:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN5tr9zAZzXx3LXbCIdehHAbtKkeFucLtY82owKOYl2BPAnAd+XckTdFdafqIbAyx4bBIEJQ X-Received: by 2002:a63:ca02:: with SMTP id n2mr24535613pgi.187.1548781816282; Tue, 29 Jan 2019 09:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548781816; cv=none; d=google.com; s=arc-20160816; b=NOxIZ226Go/IzkmJGVcqC1SEeL00aL8srW+aftw2rnOZIUAWtrdns6irN5xf0vbJfM ZXfpPTdOZgBINlTR3zuWfzHN4g4/dx5gFN3F6vTwOMvpaAcRMvPLBKWfQskUTeeEv/Y4 NdGikO8uP9Z8HCZwMqGadaxCNBl2BRAmmXuZtKtyScvYIQB9TRXl71Hxco3Vuj5ABSEr 9iqY91RDndHl7KnIcPmG6oFkQweBvU5/A5ZUQMuuZcGpdLn67cZzGZ49dY6jVIR/KXaE Eozdeu+bMZKk8xcCWf8toC4ZP0oG2J9FECaex+6ez0B4GyaUtzso3K2eq6D+nVdWiQWq 3+5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:mime-version:date:subject:cc :to:from:user-agent; bh=xFYoBu1jErRqe1Lwrq9QF3Dxt70BMw4zy22mO8T0Yk0=; b=npn0KPEePl1i9wwh+m8yyBP1z4hCR973+/e4yU/lGfiyAvAqPijghZ9jrdGt1RmV2r L2PUSzqalofU4NAE6jNNC9GDudgsngTRyO7ugqu7xxRelA5bzEKcIoZtJS/PgPz31FqY KdpULMtX1Ah4ZZbCqIe86zCgT/3gR5MVWsOxKxj9VHfWxjzPOerYOuk2x8HHQIBzfEl5 5l9lDCMMjrBEdUDLyK+8LJI4hlhAeA22WkmoPEmi8zj/94YrGd7vemMG6MCNaV1EKu78 fGXqezMUJq5ARZ4t595P8vfjXr/iJS9uHcET+aNnwbq+NNYAwuXW82zu8rAUzNv9zyae QwZg== 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 v20si6146393pgk.103.2019.01.29.09.10.00; Tue, 29 Jan 2019 09:10:16 -0800 (PST) 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 S1728839AbfA2RIq (ORCPT + 99 others); Tue, 29 Jan 2019 12:08:46 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41418 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbfA2RIq (ORCPT ); Tue, 29 Jan 2019 12:08:46 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0TGwnY7024327 for ; Tue, 29 Jan 2019 12:08:45 -0500 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2qat093eyp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Jan 2019 12:08:44 -0500 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 Jan 2019 17:08:44 -0000 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 29 Jan 2019 17:08:39 -0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0TH8cau11927726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 29 Jan 2019 17:08:38 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D0B2BE051; Tue, 29 Jan 2019 17:08:38 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F477BE054; Tue, 29 Jan 2019 17:08:26 +0000 (GMT) Received: from morokweng.localdomain (unknown [9.85.217.24]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTPS; Tue, 29 Jan 2019 17:08:24 +0000 (GMT) User-agent: mu4e 1.0; emacs 26.1 From: Thiago Jung Bauermann To: virtualization@lists.linux-foundation.org Cc: linuxppc-devel@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, "Michael S . Tsirkin" , Jason Wang , Christoph Hellwig , David Gibson , Alexey Kardashevskiy , Paul Mackerras , Benjamin Herrenschmidt , Ram Pai Subject: [RFC PATCH] virtio_ring: Use DMA API if guest memory is encrypted Date: Tue, 29 Jan 2019 15:08:12 -0200 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 19012917-0012-0000-0000-00001701BAEA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010499; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000277; SDB=6.01153539; UDB=6.00601409; IPR=6.00933905; MB=3.00025342; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-29 17:08:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012917-0013-0000-0000-000056010087 Message-Id: <87zhrj8kcp.fsf@morokweng.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-29_13:,, 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901290127 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, With Christoph's rework of the DMA API that recently landed, the patch below is the only change needed in virtio to make it work in a POWER secure guest under the ultravisor. The other change we need (making sure the device's dma_map_ops is NULL so that the dma-direct/swiotlb code is used) can be made in powerpc-specific code. Of course, I also have patches (soon to be posted as RFC) which hook up to the powerpc secure guest support code. What do you think? From d0629a36a75c678b4a72b853f8f7f8c17eedd6b3 Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann Date: Thu, 24 Jan 2019 22:08:02 -0200 Subject: [RFC PATCH] virtio_ring: Use DMA API if guest memory is encrypted The host can't access the guest memory when it's encrypted, so using regular memory pages for the ring isn't an option. Go through the DMA API. Signed-off-by: Thiago Jung Bauermann --- drivers/virtio/virtio_ring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index cd7e755484e3..321a27075380 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -259,8 +259,11 @@ static bool vring_use_dma_api(struct virtio_device *vdev) * not work without an even larger kludge. Instead, enable * the DMA API if we're a Xen guest, which at least allows * all of the sensible Xen configurations to work correctly. + * + * Also, if guest memory is encrypted the host can't access + * it directly. In this case, we'll need to use the DMA API. */ - if (xen_domain()) + if (xen_domain() || sev_active()) return true; return false;