Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1520805ybh; Thu, 16 Jul 2020 14:47:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgJXfHvCsB4NHZVjQJxUxQQ7VclGxokSmanqwNLoT04Wo1P+KfYxEQ4aFrWjq5ixeAqxtN X-Received: by 2002:a17:907:2105:: with SMTP id qn5mr5619184ejb.308.1594936025105; Thu, 16 Jul 2020 14:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594936025; cv=none; d=google.com; s=arc-20160816; b=FZkEUQQBkp0iGcZKuL/e+AFvs2Zx8BV+FpvlXpxb3skZId+kOl27cSpTHpqp13/TSH niVPXNuZFYtyucvqpCo6cG5i1nXrprtg0JtUlyYnycgs7F5HyyNQJOQjpjPb+IsNLxdU Bx2Ub9yvuOJEwQ0oWVcIdM+pRAHyjKTPJY3TSjIqi+RrGhW2Aoz86Q9f6QgvoX3AKAZU vzQ/wnWkXigZFm9j7wlK4MynxXNX7QT+ZEEUbOQ+g/HEY5c6mUlCjLN0vhwsHIzPss5S Ivv38eaJromgHSFcXyGOe47bD6UW6pv1cAfTnUsiqlyohO8eCZqHm3BHUBEHiWjRPQdx 5S3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BEo6DsOD3gtcpeqatc/jWU3HzAeT6ubK4oUjqlbQ034=; b=Y9TXs+2PVe5K+4fTkntRYlY0+CBOrmkjbQXfn3b9mr9GEYWNBnarvhlSwGOp1ISW6E 4+FTWgjbLZz5hWW5WEUoAaYxLwacMWEVvErLfSlbJvqvNHaLxp1c5wVNSfxz+BR1lRTh qX32oXLlulmu5OJX21j+7tvBgfyOfi+I1f65ahUjgVCZHuP2bWRR4wm48G7TxVwIz/Zu ix0XB6B31X9PV4xKgOTggduCgTviP+TX84EMDODuU/fCDGV3CaMemM9uoLyG5akB/HmJ 3ZWc/AKXkS+/HM4HNnripHnT6yUJlSQFO6OLjDcVW3+iCqyO9uSHmzGJ75UITcgrsd+A H5oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZzYdJTqB; 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 df18si3887295edb.501.2020.07.16.14.46.41; Thu, 16 Jul 2020 14:47:05 -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=ZzYdJTqB; 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 S1726546AbgGPVq1 (ORCPT + 99 others); Thu, 16 Jul 2020 17:46:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25062 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726528AbgGPVqZ (ORCPT ); Thu, 16 Jul 2020 17:46:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594935983; 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=BEo6DsOD3gtcpeqatc/jWU3HzAeT6ubK4oUjqlbQ034=; b=ZzYdJTqBcoRbBkP7QZdrktSO39GYoDQ1TTyaKvhVA7nF0B2KGthyCG/tUqVHB/1N7zJwqs kSJ02ArN2cQbk1lFf6gvM9wxQnJ4u+wQAeTSpisbYPa9I8/8i7QwH5PXWBFXBjOvz0DLp3 4vdFmWTOazjnKe6EpGoKegSOw0Y+b5U= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-zClFBwsDO62qMaDyt9VNFQ-1; Thu, 16 Jul 2020 17:46:21 -0400 X-MC-Unique: zClFBwsDO62qMaDyt9VNFQ-1 Received: by mail-wr1-f71.google.com with SMTP id f5so6262938wrv.22 for ; Thu, 16 Jul 2020 14:46:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=BEo6DsOD3gtcpeqatc/jWU3HzAeT6ubK4oUjqlbQ034=; b=MklnkcnKSP6aHIKp3fsBBD76ME0g4j09I6SZbNblwjgFGPehfkmmKgrgIPprhcTjZL Xv338K+i2jAF0DRufed9l6SvREbRxmlOKXnseTWzEyyzWHcFtpm67FxplL4OXkLAsD7J moa8JawWPrG+icdX6Q+jsCqVwAnV6hMzu9ORpK+FussupGD7mxKgQoF+tbgP7vZcAQAD 0e9fAA4w+vBVnbW+a7tpvWFZUPOJ+YqtRbMnwWOl6OtqW1AXnaAI1AIroW6OeQsMdBZr eBf9iUqLFjzJM0ynXRH7p8LHy1q4PdGCmBGS/h8iNVM692r7+jLrOB7fc4l43PygCxgK dIZA== X-Gm-Message-State: AOAM532+IUNiB37J3cy9iCHFJ6q5r+JDihU78fjLWV9ZfP76mEL3NYYx iufKs6SPMiYePrNfyRukiYA7XysVhZhrkTYiJHrYTCb+izSmS6pt/nHBdFW4FUfMkoVp//cgzOm UCWcaaXG/V1xDfFwW+u7F+nmp X-Received: by 2002:a1c:3b02:: with SMTP id i2mr5994134wma.24.1594935980615; Thu, 16 Jul 2020 14:46:20 -0700 (PDT) X-Received: by 2002:a1c:3b02:: with SMTP id i2mr5994113wma.24.1594935980304; Thu, 16 Jul 2020 14:46:20 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id k4sm10900176wrp.86.2020.07.16.14.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 14:46:19 -0700 (PDT) Date: Thu, 16 Jul 2020 17:46:15 -0400 From: "Michael S. Tsirkin" To: Christian Borntraeger Cc: Jason Wang , Pierre Morel , linux-kernel@vger.kernel.org, pasic@linux.ibm.com, frankja@linux.ibm.com, cohuck@redhat.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org, virtualization@lists.linux-foundation.org, thomas.lendacky@amd.com, david@gibson.dropbear.id.au, linuxram@us.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com Subject: Re: [PATCH v7 2/2] s390: virtio: PV needs VIRTIO I/O device protection Message-ID: <20200716174603-mutt-send-email-mst@kernel.org> References: <1594801869-13365-1-git-send-email-pmorel@linux.ibm.com> <1594801869-13365-3-git-send-email-pmorel@linux.ibm.com> <20200715054807-mutt-send-email-mst@kernel.org> <20200715074917-mutt-send-email-mst@kernel.org> <3782338a-6491-dc35-7c66-97b91a20df0d@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3782338a-6491-dc35-7c66-97b91a20df0d@de.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2020 at 01:19:55PM +0200, Christian Borntraeger wrote: > > > On 15.07.20 13:51, Michael S. Tsirkin wrote: > > On Wed, Jul 15, 2020 at 06:16:59PM +0800, Jason Wang wrote: > >> > >> On 2020/7/15 下午5:50, Michael S. Tsirkin wrote: > >>> On Wed, Jul 15, 2020 at 10:31:09AM +0200, Pierre Morel wrote: > >>>> If protected virtualization is active on s390, the virtio queues are > >>>> not accessible to the host, unless VIRTIO_F_IOMMU_PLATFORM has been > >>>> negotiated. Use the new arch_validate_virtio_features() interface to > >>>> fail probe if that's not the case, preventing a host error on access > >>>> attempt. > >>>> > >>>> Signed-off-by: Pierre Morel > >>>> Reviewed-by: Cornelia Huck > >>>> Acked-by: Halil Pasic > >>>> Acked-by: Christian Borntraeger > >>>> --- > >>>> arch/s390/mm/init.c | 28 ++++++++++++++++++++++++++++ > >>>> 1 file changed, 28 insertions(+) > >>>> > >>>> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c > >>>> index 6dc7c3b60ef6..d39af6554d4f 100644 > >>>> --- a/arch/s390/mm/init.c > >>>> +++ b/arch/s390/mm/init.c > >>>> @@ -45,6 +45,7 @@ > >>>> #include > >>>> #include > >>>> #include > >>>> +#include > >>>> pgd_t swapper_pg_dir[PTRS_PER_PGD] __section(.bss..swapper_pg_dir); > >>>> @@ -161,6 +162,33 @@ bool force_dma_unencrypted(struct device *dev) > >>>> return is_prot_virt_guest(); > >>>> } > >>>> +/* > >>>> + * arch_validate_virtio_features > >>>> + * @dev: the VIRTIO device being added > >>>> + * > >>>> + * Return an error if required features are missing on a guest running > >>>> + * with protected virtualization. > >>>> + */ > >>>> +int arch_validate_virtio_features(struct virtio_device *dev) > >>>> +{ > >>>> + if (!is_prot_virt_guest()) > >>>> + return 0; > >>>> + > >>>> + if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { > >>>> + dev_warn(&dev->dev, > >>>> + "legacy virtio not supported with protected virtualization\n"); > >>>> + return -ENODEV; > >>>> + } > >>>> + > >>>> + if (!virtio_has_feature(dev, VIRTIO_F_IOMMU_PLATFORM)) { > >>>> + dev_warn(&dev->dev, > >>>> + "support for limited memory access required for protected virtualization\n"); > >>>> + return -ENODEV; > >>>> + } > >>>> + > >>>> + return 0; > >>>> +} > >>>> + > >>>> /* protected virtualization */ > >>>> static void pv_init(void) > >>>> { > >>> What bothers me here is that arch code depends on virtio now. > >>> It works even with a modular virtio when functions are inline, > >>> but it seems fragile: e.g. it breaks virtio as an out of tree module, > >>> since layout of struct virtio_device can change. > >> > > If you prefer that, we can simply create an arch/s390/kernel/virtio.c ? How would that address the issues above?