Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1666995ybp; Fri, 11 Oct 2019 18:36:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOT/X9y/3UtIBteATEfPUqe8p4OUEBbb9FYw6KSLE3KvjcXW/nI22LIP7oYWg3nXktEyLR X-Received: by 2002:a17:906:c801:: with SMTP id cx1mr17437964ejb.266.1570844168455; Fri, 11 Oct 2019 18:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570844168; cv=none; d=google.com; s=arc-20160816; b=PudL2P7emanBWkdAz8Nue9pSqZhRLadVjbvuQGfkAZy+PwA+/3Jh9ROk7GTbUqMdFX y/IirQ/KZWmQxLNAPHsO9AY+vYcBjgrGfXGVvGXs6XxZp1UY4JFuo3FVcb4DsXjr0HGv bR2OST6Q1wG4PH+W6n3vXSDUiDFRgadEhPCnPBMVKOUp5aqf6+71DQsyubqXOs0yOdG4 GQprG98ooZ/+qtBM2R0GfOSklBr+h9Ck0pLQ8cW+x7iLFFIWRqieelkvAnrC+wCalqUI hHqdtfOAu02SHU08eT8sjiQjARTnPoX1wNlQt97tc1hp73VMyF8ylcztNVNhEGfhNHzt K0xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=bCTS3HRsMwaL5FZpxbg2xnc1FVticzKBXuUSPViya58=; b=ItQNYG8p5KKzBpAB2zMnfUiERAcra/oGu5n0UFxlCyo2Xd+4AidVadRBEkeMCwSMEO 9scePfNLTjSMk44DoDd/MwShkCOcsBYSi80avsD6aufK3BE41GCQGFq2oPf/RGk2xS0C zstagrhUAHZK45szPJdtl2NU5jdV52eDqkc6D0io3NIZLGyM6b+XZ8LCRTrrxddgS4hS JO6VPo6Dtx6S21XgmC+i2u7WSEnqj/+z1oyMuK7FBLH/LWcxQL7m8Qfmxq6EhxI8a7RS rf9qnmuTnNhjmTEAm9508yquCGMj6i+EBYrz4Pj7GB4Crg+p566vPWJ8aoPRVXWZLUsv 0J9Q== 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 r17si7049212edx.257.2019.10.11.18.35.44; Fri, 11 Oct 2019 18:36:08 -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 S1728329AbfJLBZ4 (ORCPT + 99 others); Fri, 11 Oct 2019 21:25:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50654 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727345AbfJLBZ4 (ORCPT ); Fri, 11 Oct 2019 21:25:56 -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 x9C1N1Nd014838 for ; Fri, 11 Oct 2019 21:25:55 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vk1hmng97-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 Oct 2019 21:25:54 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 12 Oct 2019 02:25:52 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sat, 12 Oct 2019 02:25:48 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9C1Plsf54657110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Oct 2019 01:25:47 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADFAA52052; Sat, 12 Oct 2019 01:25:47 +0000 (GMT) Received: from oc0525413822.ibm.com (unknown [9.85.130.213]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 56EB752050; Sat, 12 Oct 2019 01:25:43 +0000 (GMT) From: Ram Pai To: linux-kernel@vger.kernel.org Cc: iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, benh@kernel.crashing.org, david@gibson.dropbear.id.au, mpe@ellerman.id.au, paulus@ozlabs.org, mdroth@linux.vnet.ibm.com, aik@linux.ibm.com, paul.burton@mips.com, robin.murphy@arm.com, b.zolnierkie@samsung.com, m.szyprowski@samsung.com, hch@lst.de, jasowang@redhat.com, linuxram@us.ibm.com, andmike@us.ibm.com, sukadev@linux.vnet.ibm.com Subject: [PATCH 0/2] virtio: Support encrypted memory on powerpc secure guests Date: Fri, 11 Oct 2019 18:25:17 -0700 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 19101201-0020-0000-0000-00000378559F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19101201-0021-0000-0000-000021CE689F Message-Id: <1570843519-8696-1-git-send-email-linuxram@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-11_12:,, 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=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=984 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910120005 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org **We would like the patches to be merged through the virtio tree. Please review, and ack merging the DMA mapping change through that tree. Thanks!** The memory of powerpc secure guests can't be accessed by the hypervisor / virtio device except for a few memory regions designated as 'shared'. At the moment, Linux uses bounce-buffering to communicate with the hypervisor, with a bounce buffer marked as shared. This is how the DMA API is implemented on this platform. In particular, the most convenient way to use virtio on this platform is by making virtio use the DMA API: in fact, this is exactly what happens if the virtio device exposes the flag VIRTIO_F_ACCESS_PLATFORM. However, bugs in the hypervisor on the powerpc platform do not allow setting this flag, with some hypervisors already in the field that don't set this flag. At the moment they are forced to use emulated devices when guest is in secure mode; virtio is only useful when guest is not secure. Normally, both device and driver must support VIRTIO_F_ACCESS_PLATFORM: if one of them doesn't, the other mustn't assume it for communication to work. However, a guest-side work-around is possible to enable virtio for these hypervisors with guest in secure mode: it so happens that on powerpc secure platform the DMA address is actually a physical address - that of the bounce buffer. For these platforms we can make the virtio driver go through the DMA API even though the device itself ignores the DMA API. These patches implement this work around for virtio: we detect that - secure guest mode is enabled - so we know that since we don't share most memory and Hypervisor has not enabled VIRTIO_F_ACCESS_PLATFORM, regular virtio code won't work. - DMA API is giving us addresses that are actually also physical addresses. - Hypervisor has not enabled VIRTIO_F_ACCESS_PLATFORM. and if all conditions are true, we force all data through the bounce buffer. To put it another way, from hypervisor's point of view DMA API is not required: hypervisor would be happy to get access to all of guest memory. That's why it does not set VIRTIO_F_ACCESS_PLATFORM. However, guest decides that it does not trust the hypervisor and wants to force a bounce buffer for its own reasons. Thiago Jung Bauermann (2): dma-mapping: Add dma_addr_is_phys_addr() virtio_ring: Use DMA API if memory is encrypted arch/powerpc/include/asm/dma-mapping.h | 21 +++++++++++++++++++++ arch/powerpc/platforms/pseries/Kconfig | 1 + drivers/virtio/virtio.c | 18 ++++++++++++++++++ drivers/virtio/virtio_ring.c | 8 ++++++++ include/linux/dma-mapping.h | 20 ++++++++++++++++++++ include/linux/virtio_config.h | 14 ++++++++++++++ kernel/dma/Kconfig | 3 +++ 7 files changed, 85 insertions(+) -- 1.8.3.1