Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1026233pxj; Wed, 2 Jun 2021 18:37:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAOsyXfCaNB7fARRWu/VZVCM+NUN+r0+iB/57R8jYWZvjOzob3ultqrAjk6xE3EdE5dsMz X-Received: by 2002:a05:6402:693:: with SMTP id f19mr14711245edy.185.1622684233406; Wed, 02 Jun 2021 18:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622684233; cv=none; d=google.com; s=arc-20160816; b=TtGjl57A0zAoUksA1kpx6zBuJ4j26C6cNo9njtlhTO2f/KcqTWra/LKuVjzD7jdrwn P2hkaV6MMVhKgLxfEuDYFnkGN3x1wpyYn0VTLHhrNzmPomb2jnhl20It5e3vgJ9mn3H/ 1j2Eiy28hvCNJyYf9r+OH/DDPoGyJQvrHxLvm5RsrPRVAdSfFpoLk4maUQAu9grIG1Bz dbmTCVwl8gmR8ci61G0PR8MVpJpTuFc7Bl1C/2WkrZLuZZwNdipQ+UuqAaV4h5yHSien SfZ4HH/tNeMebPqygRypHzSJ93F9Ni1NLqoBlmnuwpjJvJDYgXfvL0e3/urWmS8VF2NI eWng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Ay34ayc0XC/WtKXXL+jwzIp+HQgsy2OJ9U8cZG5Fktk=; b=0FNPjzptzk7QLsYtfrWe3pPvkXzJrUWLLnIICbAUeJZgTs1bH2YFvuxcVpXZVB+6s5 hGki78Dn9PIMcCi0ki1MxbXlAw43lWJrrH6QgNl0tXNUNXGeeaxkDEHuJLVaRf2pL5gY Ga4UV1D6oLIUJ975gntgPiH70OgLCRZNcuN4LKkYVype6hIGNcDvkYzKemDJ11RJr2/J 16C/7at6O25neHYP3Z14KcD1SUz8L31BO65FxJjfYZZoKFVSEXvvKNaPzCNLbhhvLL92 4kKPw8A+DqX/6HIqZG9/USFXjQJKC+vfK39cRScJR7cmqWktINTVP9y/GEwL2sAeUn9C ktZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iyz1Gaw1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a16si1174386ejb.149.2021.06.02.18.36.50; Wed, 02 Jun 2021 18:37:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iyz1Gaw1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbhFCBgG (ORCPT + 99 others); Wed, 2 Jun 2021 21:36:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41920 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbhFCBgF (ORCPT ); Wed, 2 Jun 2021 21:36:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622684060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ay34ayc0XC/WtKXXL+jwzIp+HQgsy2OJ9U8cZG5Fktk=; b=Iyz1Gaw1uWxsDteWAzzkxQNXmCVQe6oO6cLSYeCfxD4OeQZTZlmvWllAfNGTin4Qn5yIJ/ KHRtZYWP5Q9yGaArjHPmrGNamvaIckF9HAnfVaouDsft379JZGIknPkXLvhSPHTVZq6JA+ B+K4x+ECekjDzsNyOVsvjl4iUXLksik= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-qQcbRssrMz2AdMkxjj7-EQ-1; Wed, 02 Jun 2021 21:34:19 -0400 X-MC-Unique: qQcbRssrMz2AdMkxjj7-EQ-1 Received: by mail-pf1-f198.google.com with SMTP id g17-20020a056a0023d1b029028f419cb9a2so2577224pfc.4 for ; Wed, 02 Jun 2021 18:34:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Ay34ayc0XC/WtKXXL+jwzIp+HQgsy2OJ9U8cZG5Fktk=; b=H1l++2+/vU5T5PCsnVCMWayJUdKvFp39pJEDq1Cb1BN5NCnzgPDPaooz7ICSs+HPyY YuqCGAx1nEcIyzHoVeFAPdIsqyhTfmIQUtQ/1G5+ea0grpZa46KaYNGOQ7urh6wP/3CE q7L9CcgO8CbdP+syFm7yBstebjS8QeT95VphcNXgvQ2JI+4KXrWTGajWQTGJcipboL2t uZ9N5bu5OOGtP9oE0ciXfdqYmunHc+Z4Tc4Q3ISQT/pyWm68ytpso3a2Z9fpEhoxYsfd WwGzXDYHolTjEA+oBTdVA648Q3vJyvjGxGBVLMQ50VAdANuLaA7lwMJUNElHgSZMoK+L Pkfw== X-Gm-Message-State: AOAM533p6AoY+XJHSckdYNl5nMiERd8zEzXRhBa7r/0DdiiQBsRKCbiS Yn+EwJs6IONyKsLmcX5p5uA744jhZ1yMFp54cAjs4sEJAmFwE4FCXjQJPbDfNFei4cHKgyGfEvH 9Slfqt1898hmtjyW4X8p4/bEuHLzW5oOqa1Vl1ikOivilYrJXTzuXL0D1ZjhR6xAICMY6aTWQ4c n9 X-Received: by 2002:a63:cd16:: with SMTP id i22mr17954385pgg.251.1622684058205; Wed, 02 Jun 2021 18:34:18 -0700 (PDT) X-Received: by 2002:a63:cd16:: with SMTP id i22mr17954351pgg.251.1622684057916; Wed, 02 Jun 2021 18:34:17 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id c15sm884731pgt.68.2021.06.02.18.34.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Jun 2021 18:34:17 -0700 (PDT) Subject: Re: Virtio hardening for TDX To: Andi Kleen , mst@redhat.com Cc: virtualization@lists.linux-foundation.org, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org, x86@kernel.org, sathyanarayanan.kuppuswamy@linux.intel.com, jpoimboe@redhat.com, linux-kernel@vger.kernel.org References: <20210603004133.4079390-1-ak@linux.intel.com> From: Jason Wang Message-ID: <63d01084-68d2-a8d5-931d-541a22b5f231@redhat.com> Date: Thu, 3 Jun 2021 09:34:08 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210603004133.4079390-1-ak@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/6/3 上午8:41, Andi Kleen 写道: > [v1: Initial post] > > With confidential computing like TDX the guest doesn't trust the host > anymore. The host is allowed to DOS of course, but it is not allowed > to read or write any guest memory not explicitely shared with it. > > This has implication for virtio. Traditionally virtio didn't assume > the other side of the communication channel is malicious, and therefore > didn't do any boundary checks in virtio ring data structures. > > This patchkit does hardening for virtio. In a TDX like model > the only host memory accesses allowed are in the virtio ring, > as well as the (forced) swiotlb buffer. > > This patch kit does various changes to ensure there can be no > access outside these two areas. It is possible for the host > to break the communication, but this should result in a IO > error on the guest, but no memory safety violations. > > virtio is quite complicated with many modes. To simplify > the task we enforce that virtio is only in split mode without > indirect descriptors, when running as a TDX guest. We also > enforce use of the DMA API. > > Then these code paths are hardened against any corruptions > on the ring. > > This patchkit has components in three subsystems: > - Hardening changes to virtio, all in the generic virtio-ring > - Hardening changes to kernel/dma swiotlb to harden swiotlb against > malicious pointers. It requires an API change which needed a tree sweep. > - A single x86 patch to enable the arch_has_restricted_memory_access > for TDX > > It depends on Sathya's earlier patchkit that adds the basic infrastructure > for TDX. This is only needed for the "am I running in TDX" part. Note that it's probably needed by other cases as well: 1) Other encrypted VM technology 2) VDUSE[1] 3) Smart NICs We have already had discussions and some patches have been posted[2][3][4]. I think the basic idea is similar, basically,  we don't trust any metadata provided by the device. [2] is the series that use the metadata stored in the private memory which can't be accessed by swiotlb, this series aims to eliminate all the possible attacks via virtqueue metadata [3] is one example for the the used length validation [4] is the fix for the malicious config space Thanks [1] https://www.spinics.net/lists/netdev/msg743264.html [2] https://www.spinics.net/lists/kvm/msg241825.html [3] https://patches.linaro.org/patch/450733/ [4] https://lkml.org/lkml/2021/5/17/376 > > >