From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9212AC433E0 for ; Thu, 9 Jul 2020 08:57:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B21D2067D for ; Thu, 9 Jul 2020 08:57:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Mb1kxzyi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726509AbgGII5u (ORCPT ); Thu, 9 Jul 2020 04:57:50 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:31705 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726245AbgGII5t (ORCPT ); Thu, 9 Jul 2020 04:57:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594285068; 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=Uuu+zY4NPg4PuTlF+PQGGUGcG4doQrWeXP0ejsFOJm8=; b=Mb1kxzyip68o3Ibg5LLQq00DM9Ofp2Ycz9NwHJkCOMmOIQEx97Q5kZ7Hap5wxI0XALSvdJ FnM9zeQpucFomaRU2RHgJeqPYm5XDM89qoXJGmHrhsjUR7AvGNMkzAjOY6PzyGRoa9MX2p CvAkJ4BzBLLcbmTfHVm6dgi0u8o2HWo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-4H2J2Rk0NmOUFgwMeq6Q6A-1; Thu, 09 Jul 2020 04:57:44 -0400 X-MC-Unique: 4H2J2Rk0NmOUFgwMeq6Q6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 275F580040A; Thu, 9 Jul 2020 08:57:42 +0000 (UTC) Received: from gondolin (ovpn-113-62.ams2.redhat.com [10.36.113.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id E62C26FECC; Thu, 9 Jul 2020 08:57:35 +0000 (UTC) Date: Thu, 9 Jul 2020 10:57:33 +0200 From: Cornelia Huck To: Pierre Morel Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, mst@redhat.com, jasowang@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, heiko.carstens@de.ibm.com, gor@linux.ibm.com Subject: Re: [PATCH v5 2/2] s390: virtio: PV needs VIRTIO I/O device protection Message-ID: <20200709105733.6d68fa53.cohuck@redhat.com> In-Reply-To: <1594283959-13742-3-git-send-email-pmorel@linux.ibm.com> References: <1594283959-13742-1-git-send-email-pmorel@linux.ibm.com> <1594283959-13742-3-git-send-email-pmorel@linux.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 9 Jul 2020 10:39:19 +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 > --- > arch/s390/mm/init.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c > index 6dc7c3b60ef6..b8e6f90117da 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,32 @@ 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, "device must provide VIRTIO_F_VERSION_1\n"); I'd probably use "legacy virtio not supported with protected virtualization". > + return -ENODEV; > + } > + > + if (!virtio_has_feature(dev, VIRTIO_F_IOMMU_PLATFORM)) { > + dev_warn(&dev->dev, > + "device must provide VIRTIO_F_IOMMU_PLATFORM\n"); "support for limited memory access required for protected virtualization" ? Mentioning the feature flag is shorter in both cases, though. > + return -ENODEV; > + } > + > + return 0; > +} > + > /* protected virtualization */ > static void pv_init(void) > { Either way, Reviewed-by: Cornelia Huck