Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5372510imu; Tue, 29 Jan 2019 18:26:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN6XWIzdHQFaIn3xngaylWRYtz3gLjD953gRq2cvSBGXlzamXJzpljdbhP0g8X7Ti2cldZA3 X-Received: by 2002:a62:d005:: with SMTP id p5mr28791024pfg.175.1548815183946; Tue, 29 Jan 2019 18:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548815183; cv=none; d=google.com; s=arc-20160816; b=ZpVm5kfMJgxqujM8tsSx+OrtEd8mu/FNi8rT9kf56P1+L6s9xNrmLtzZVUv00lNTOc dxIVHfQNw867oWJP2rBlMS+98DHzSAGGOdS/rgBw/5I4H3BT3/xo9gMzN7DqOSlGpBrY 7T4SooQT7Bau9qZxqwsbD7+Esun9BsRsAQ/u0ZZtZeCYkJ0vYB057JDlUDimowWplSOa z+iQoPsH6ua5vyOkDF3M+0IXpuBINtFqlUVcxlUSrgv49kFVx0lPBZ5SdloA7lHdsP/Z 23EvgZogwPHbUjDuN/fa37j72ah5KQ1tUbDQc9r+XhxeFrRWEHWV5C3wZqkw0J9GkJek X3/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Gjrz9He/wRaSb9Z6bNGegeEk/CMXh7m7lTqRlERtlVA=; b=BgeUFft+9Duy9jmz1XEqWNWooEOUTnXYAIfL/5oQtf+zpV5qceQmWcEDtVXsW35jiB muHX9M6MvvSDbW8wkv3F/kYbnFUnKunTttcmCN1yD2rVAZSxXzoqmCZFC+3d85BhHTfo I3JOOHBGeyaHRZ3991saBWb3TNBJFk30C1FMd0CrgDhteYtPMFq80+q3Zq2DlVRxkVm1 eOu6OmXRng6CKkfJ8MK23DGdhmLZM1mFkhu9gIPC0XQWgbBeCOxQqolWIcC+sJixT2c7 nkiae+PaxfleMO6TU5X0OPCSJfK+HYT3ULyKCnVSOs6qIuLmijHxeqgQV3qi0xJa+dOr 9mRA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si145332plr.311.2019.01.29.18.26.08; Tue, 29 Jan 2019 18:26:23 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729806AbfA3CYN (ORCPT + 99 others); Tue, 29 Jan 2019 21:24:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbfA3CYN (ORCPT ); Tue, 29 Jan 2019 21:24:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21AB888E5F; Wed, 30 Jan 2019 02:24:12 +0000 (UTC) Received: from [10.72.12.156] (ovpn-12-156.pek2.redhat.com [10.72.12.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C55A62C8CA; Wed, 30 Jan 2019 02:24:03 +0000 (UTC) Subject: Re: [RFC PATCH] virtio_ring: Use DMA API if guest memory is encrypted To: "Michael S. Tsirkin" , Thiago Jung Bauermann Cc: virtualization@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Christoph Hellwig , David Gibson , Alexey Kardashevskiy , Paul Mackerras , Benjamin Herrenschmidt , Ram Pai , Jean-Philippe Brucker References: <87zhrj8kcp.fsf@morokweng.localdomain> <87womn8inf.fsf@morokweng.localdomain> <20190129134750-mutt-send-email-mst@kernel.org> From: Jason Wang Message-ID: <6c68f7f7-1b28-6eba-9b8b-2c32efac9701@redhat.com> Date: Wed, 30 Jan 2019 10:24:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190129134750-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 30 Jan 2019 02:24:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/1/30 上午3:02, Michael S. Tsirkin wrote: > On Tue, Jan 29, 2019 at 03:42:44PM -0200, Thiago Jung Bauermann wrote: >> Fixing address of powerpc mailing list. >> >> Thiago Jung Bauermann writes: >> >>> 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 > Well I think this will come back to bite us (witness xen which is now > reworking precisely this path - but at least they aren't to blame, xen > came before ACCESS_PLATFORM). > > I also still think the right thing would have been to set > ACCESS_PLATFORM for all systems where device can't access all memory. > > But I also think I don't have the energy to argue about power secure > guest anymore. So be it for power secure guest since the involved > engineers disagree with me. Hey I've been wrong in the past ;). > > But the name "sev_active" makes me scared because at least AMD guys who > were doing the sensible thing and setting ACCESS_PLATFORM (unless I'm > wrong? I reemember distinctly that's so) will likely be affected too. > We don't want that. > > So let's find a way to make sure it's just power secure guest for now > pls. > > I also think we should add a dma_api near features under virtio_device > such that these hacks can move off data path. Anyway the current Xen code is conflict with spec which said: "If this feature bit is set to 0, then the device has same access to memory addresses supplied to it as the driver has. In particular, the device will always use physical addresses matching addresses used by the driver (typically meaning physical addresses used by the CPU) and not translated further, and can access any address supplied to it by the driver. When clear, this overrides any platform-specific description of whether device access is limited or translated in any way, e.g. whether an IOMMU may be present. " I wonder how much value that the above description can give us. It's kind of odd that the behavior of "when the feature is not negotiated" is described in the spec. Personally I think we can remove the above and then we can switch to use DMA API unconditionally in guest driver. It may have single digit regression probably, we can try to overcome it. Thanks > > By the way could you please respond about virtio-iommu and > why there's no support for ACCESS_PLATFORM on power? > > I have Cc'd you on these discussions. > > > Thanks! > > >>> --- >>> 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; >> >> -- >> Thiago Jung Bauermann >> IBM Linux Technology Center