Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1163036iog; Wed, 15 Jun 2022 23:42:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vQiVR0epdU00JIOO0mRe/FusaivMyHxmxIX0l8hGEsQF07ftbTuph+phJqObs8Qr/oEspE X-Received: by 2002:a17:907:1b0c:b0:6fe:25bf:b3e5 with SMTP id mp12-20020a1709071b0c00b006fe25bfb3e5mr3070188ejc.689.1655361764528; Wed, 15 Jun 2022 23:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655361764; cv=none; d=google.com; s=arc-20160816; b=Riw02E4drFC65q0SFgblYwX2nEycigZk3nhcCHIJAOfbicsAvl2QQ9TO/4RwLEQRrv RBhvOBq0ONgvYD6AdOHVtIAFap+nWcCC7k4hZJv5OI4PsoAPOipVqb4HUL2kqtxRPmI0 wUH9ecPMssc5HiKGnYrYPA9b3/j7H6ahKj9tWdpm9gCnF3fswXxiIuhPMN10HFdrnIfP sFALfsCLQL7PvEMQhsrcscoZEtqg7kZdejO2bDLMIMUIw4AiyQlQL8U2ZIsajkUn/DuZ lMFXlSygSzB7amuG0ubnzsd0+tY8lG1G3pq8TWDFfeEWyxvNzcA9YVxbXqAriWmdGmvY TVBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iOBMPze3s2Lts4x7hCuI3brE8gqb/oK3vC99y6kJxTs=; b=zfe+1F4tYfMr9TKz/kx0Za1kEqbC3gWcy/HKpnlqp8Xn9ZvVxAAPNyN/mcB7Rld27q sXPW6676MZ8+lVBkE8E6CU1coVySmnL9oCv6dQBmyW+G3LstGnoeKDbAuUpp4hSZkXPA VY4PRZGoLj6lHlQZBt3pGCpLIHCqUmDAUPlBH/q7zl12/SAVNmZx6i4EI8fCvydIC8gp rkoQQzE5i3RjBnaAtMtGsNQzGtZ3w34tUyl+eaW2tvjjJ+rJPZr79ucGWYnFDxiMSQ5c KaDHgVVNYYhvy5z0aNP6UjzirccKPayp5LSsUinMQd1ng+LyfV2fwZQv8aQKoUjvqpXt +w1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FAJ6hHlf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a17090627c100b00711d133f605si803661ejc.600.2022.06.15.23.42.19; Wed, 15 Jun 2022 23:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FAJ6hHlf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358520AbiFPGDI (ORCPT + 99 others); Thu, 16 Jun 2022 02:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358882AbiFPGDG (ORCPT ); Thu, 16 Jun 2022 02:03:06 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47112167ED for ; Wed, 15 Jun 2022 23:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=iOBMPze3s2Lts4x7hCuI3brE8gqb/oK3vC99y6kJxTs=; b=FAJ6hHlfYq4a8A6nEmnUqy7YFQ H6/hQfIR6XVi3ZDAKoGfGTCP9dXBPMyzxG4Lsa0dRw/WjSE0HqqXy2alHlxN+uDU0JHEIsw+2JXvC b6kwpx1G1peN6Il1mC6O3gBJp5q8UWXHLbsyWvbj51yVdVpKRLOP82DAY66mybij8zNOC+uzjTlTy q7VP7rb3smIlUDJg8oqBQL3nhYJe12nt0DoK1OlYM+9g3TTif1VAm2XvNGh41lCUbfmhpYUZbDuSC 51k4GsSN3PmkQnngV8M9IYsuldfh1KvfxBW2ks3xs7mDwA5shOfORFQA4WXu99U0joY+rxSv1Vawd M6XM+gjQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1iaq-000fho-44; Thu, 16 Jun 2022 06:03:00 +0000 Date: Wed, 15 Jun 2022 23:03:00 -0700 From: Christoph Hellwig To: Juergen Gross Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, viresh.kumar@linaro.org, hch@infradead.org, Stefano Stabellini , Oleksandr Tyshchenko Subject: Re: [PATCH v2] xen: don't require virtio with grants for non-PV guests Message-ID: References: <20220616053715.3166-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220616053715.3166-1-jgross@suse.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 16, 2022 at 07:37:15AM +0200, Juergen Gross wrote: > Commit fa1f57421e0b ("xen/virtio: Enable restricted memory access using > Xen grant mappings") introduced a new requirement for using virtio > devices: the backend now needs to support the VIRTIO_F_ACCESS_PLATFORM > feature. > > This is an undue requirement for non-PV guests, as those can be operated > with existing backends without any problem, as long as those backends > are running in dom0. > > Per default allow virtio devices without grant support for non-PV > guests. > > Add a new config item to always force use of grants for virtio. What ?'d really expect here is to only set the limitations for the actual grant-based devic. Unfortunately PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS is global instead of per-device, but this is what coms closest to that intention without major refactoring: diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 1f9c3ba328333..07eb69f9e7df3 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -443,8 +443,6 @@ static int __init xen_guest_init(void) if (!xen_domain()) return 0; - xen_set_restricted_virtio_memory_access(); - if (!acpi_disabled) xen_acpi_guest_init(); else diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index 8b71b1dd76396..517a9d8d8f94d 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -195,8 +195,6 @@ static void __init xen_hvm_guest_init(void) if (xen_pv_domain()) return; - xen_set_restricted_virtio_memory_access(); - init_hvm_pv_info(); reserve_shared_info(); diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index e3297b15701c6..f33a4421e7cd6 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -109,8 +109,6 @@ static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc); static void __init xen_pv_init_platform(void) { - xen_set_restricted_virtio_memory_access(); - populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP)); set_fixmap(FIX_PARAVIRT_BOOTMAP, xen_start_info->shared_info); diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c index fc01424840017..f9bbacb5b5456 100644 --- a/drivers/xen/grant-dma-ops.c +++ b/drivers/xen/grant-dma-ops.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -333,6 +334,8 @@ void xen_grant_setup_dma_ops(struct device *dev) goto err; } + /* XXX: this really should be per-device instead of blobal */ + platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS); dev->dma_ops = &xen_grant_dma_ops; return; diff --git a/include/xen/xen.h b/include/xen/xen.h index 0780a81e140de..a99bab8175234 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -52,14 +52,6 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, extern u64 xen_saved_max_mem_size; #endif -#include - -static inline void xen_set_restricted_virtio_memory_access(void) -{ - if (IS_ENABLED(CONFIG_XEN_VIRTIO) && xen_domain()) - platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS); -} - #ifdef CONFIG_XEN_UNPOPULATED_ALLOC int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages); void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);