Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp24620lfe; Fri, 15 Apr 2022 17:43:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOoKy/rlId44GKKQwtGOUXA6UMrACGQGy3Mm4nz2NAKh7EnCK0vW5HzB2W3f2YqWX6II0d X-Received: by 2002:a17:90a:e295:b0:1cb:8b15:1232 with SMTP id d21-20020a17090ae29500b001cb8b151232mr6894678pjz.172.1650069802998; Fri, 15 Apr 2022 17:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069802; cv=none; d=google.com; s=arc-20160816; b=YrWAcdvLadoz6L2+cEHJWKDFOf2y03Ji42KrfaoEmAAhdE4JG9sEWdlXqHUxlQlxpB FXuAZEtQaOYFRWMmYkO2yTbbBajM8ztnGyQj2HSxUENoq/Xlrr5gqlH4/oGMJJYvZ0HJ oEzWp4hUmELSYUqgooXUmyJoi/Qdv3A2RRZDnmhq4s77KorXpqdNwPeNTTQPxvFXXA5w zpa6S0SSsIuYcKqTc07kuG4/jTaCvW5de7ujT+qqS0a5QbmkOR3G/TFB3uQ5Sq1UMr9D roOQtLBC+MvKMVpZiEGlnVLNqyP8UepPlpGsi2Iwy1s209n7qPO1AS84Z3hwJo+KbQ7V hR+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=DTM6C0j+8kzfw3ctLOTOFgM3JOlv83WMMxs1vx3d56k=; b=XrSunIq6SmUDq2UoM+JIUYsa7kPWEijqQ29kcVADSpTzIObSPPgpbf4xH8Pq6p8qYc 0V8TEQ1/xpH2s8NrhEBkiwWJXpKv/27n4SZ0hL2WUD6fRiPUJfCrKLiGBOE60/VUso92 MVi3KYF1OFmgT4T+n8v+he6PnoHHxJ7f8ssfGZkfpf0AVtsrSd8SF5kO5cIGG1eSf/FB +GFSuk9WMQgEIQ44GsxDsL0CVrmszOWdD+ly6cHr2B1U1snTR1wIRZQf8TOJRU75MCJy krDSfO8BELcQTmmjo31fTELeyVHxXivcsipHpvz5otKqQJjHaCmO4bgLRXvPw+yYoViK 46jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DXvqR0Ke; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id na7-20020a17090b4c0700b001c6deb4730asi6642120pjb.109.2022.04.15.17.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:43:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DXvqR0Ke; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D6C531512; Fri, 15 Apr 2022 17:35:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244019AbiDOWFT (ORCPT + 99 others); Fri, 15 Apr 2022 18:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232305AbiDOWFS (ORCPT ); Fri, 15 Apr 2022 18:05:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84D4E3AA60 for ; Fri, 15 Apr 2022 15:02:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3BDD4B8311F for ; Fri, 15 Apr 2022 22:02:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B080C385A4; Fri, 15 Apr 2022 22:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650060165; bh=jMIyyGQ4CRdsA1X7oxI8CTQb0IBKbJqeD84G5GJpvrs=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=DXvqR0Keim+tfwUUwYyM6574yaiWEcj28C/cHng/0XCSegk9hetkQruScA8hrYQlS /ZD/C1AjvTcFvA+XXBN77pc/acwLax0/RDIpW6c218usILvr5ehxi1F/0eyj6WXzi0 O1cDrfH+NOQVSkSKclpyrjWv3CIlYFatU0R4G+J4pyaE20kPRekBJxB7JLzPqRIi6V 30Zgqtkgwwv4XNEXn71dvq+Z2MUUCB9bMJs4PyIAj1Q+y/GnNOBNaGU0Est8neT7EQ qOK3sD4Gg9vLArJLSsNa+wTCI6qfW56EyOoPpLezZK1AlyLe43X1zlkbJFNu3ymWJS /vTcXwOaDkD2w== Date: Fri, 15 Apr 2022 15:02:45 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Oleksandr Tyshchenko cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall Subject: Re: [RFC PATCH 6/6] arm/xen: Assign xen-virtio DMA ops for virtio devices in Xen guests In-Reply-To: <1649963973-22879-7-git-send-email-olekstysh@gmail.com> Message-ID: References: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> <1649963973-22879-7-git-send-email-olekstysh@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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, 14 Apr 2022, Oleksandr Tyshchenko wrote: > From: Oleksandr Tyshchenko > > Call xen_virtio_setup_dma_ops() only for Xen-aware virtio devices > in Xen guests if restricted access to the guest memory is enabled. > > Signed-off-by: Oleksandr Tyshchenko > --- > include/xen/arm/xen-ops.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/xen/arm/xen-ops.h b/include/xen/arm/xen-ops.h > index 621da05..28b2ad3 100644 > --- a/include/xen/arm/xen-ops.h > +++ b/include/xen/arm/xen-ops.h > @@ -2,12 +2,19 @@ > #ifndef _ASM_ARM_XEN_OPS_H > #define _ASM_ARM_XEN_OPS_H > > +#include > #include > +#include > > static inline void xen_setup_dma_ops(struct device *dev) > { > if (xen_swiotlb_detect()) > dev->dma_ops = &xen_swiotlb_dma_ops; > + > +#ifdef CONFIG_XEN_VIRTIO > + if (arch_has_restricted_virtio_memory_access() && xen_is_virtio_device(dev)) > + xen_virtio_setup_dma_ops(dev); > +#endif This makes sense overall. Considering that the swiotlb-xen case and the virtio case are mutually exclusive, I would write it like this: if (arch_has_restricted_virtio_memory_access() && xen_is_virtio_device(dev)) xen_virtio_setup_dma_ops(dev); else if (xen_swiotlb_detect()) dev->dma_ops = &xen_swiotlb_dma_ops; There is no need for #ifdef (also see other comments).