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=-9.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 E2700C47098 for ; Thu, 3 Jun 2021 15:38:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC59C61208 for ; Thu, 3 Jun 2021 15:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbhFCPkF (ORCPT ); Thu, 3 Jun 2021 11:40:05 -0400 Received: from mail-pg1-f172.google.com ([209.85.215.172]:38543 "EHLO mail-pg1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbhFCPkF (ORCPT ); Thu, 3 Jun 2021 11:40:05 -0400 Received: by mail-pg1-f172.google.com with SMTP id 6so5435014pgk.5; Thu, 03 Jun 2021 08:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BVYx1tfLGUQhuXKxLmm7FvDthvCK68hj9EtKYIRIQHQ=; b=miB2ljSk1RA9tY/uYJGQ9mMwA4UDMc4OP5R2SPNH1XSMN+zppyZP3Jc++5YNxmzOby kALkMRui/3t9gSuqF33Vb3xRJqf9zGMvEy1ThQuUuoC56/3xsrdMaI/j4lWWgNSF2sTJ COY0x0gCbiM503+Xvvp9Nsgl9aAqJhwkWUkCuJddQ5kBPKpL6maIzV4Esr2iyVTK2nDK TGTOiLPti6ZFCSfL7YPGf1T/ifO0Td+1Cseob26JVYcCljKap3dtfQjqMVk0i9iDWAeR pRTkE5bQUe239zrqx8ZeVhOf2I48ijf3+Yv7Odtm6yW32eQYlYwHea3YOPPmHlNYafZU cDkg== 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-language :content-transfer-encoding; bh=BVYx1tfLGUQhuXKxLmm7FvDthvCK68hj9EtKYIRIQHQ=; b=MBzkjYyU1bxPKcJPl/hmKhXY3+KqqWIVGjA76UkYWqFAz5VmhLCHAh8jYAUCBqxFWc NMhkYUDJz94pq+srIlyKRCe3S4uUO23JZy+j5vP3+ft56bzsK5igOM524tCIcfAGTEdf 1+zZ2AMSTlmdBVGbiECAjUvXYCCbGx2trpg6ChylnIvrzIKNfh1sAUjTMqIXUOAp2H4l g6NzkhNmGy/1Ung9cLmf+WjXRDZEAPUkJtdRaQxvAWqpDOy6jk5j1+sphx9ZCXmP3hPs yYjGKl18URdA06g3v/yjM0NpVfkTLFA04pfkdZPNZONF7gOoUA5pDwMh43OS3ZQSWNE4 ogpQ== X-Gm-Message-State: AOAM530t5ftDZxmCRn8F+9X+Xj8RdIUZ10Bwt42oC4WuZlB2kG6eQfmb 6PLiJ+nsDyPjIouQhN07TwI= X-Google-Smtp-Source: ABdhPJyuSSLvdEikeh+Nq/zhDPHcKBsCeWjVlIXCtWnktcvNT96pyk1AlIWziUacbt3mBXpwaDz9WA== X-Received: by 2002:aa7:8755:0:b029:2eb:8c8f:d1f1 with SMTP id g21-20020aa787550000b02902eb8c8fd1f1mr271415pfo.11.1622734640422; Thu, 03 Jun 2021 08:37:20 -0700 (PDT) Received: from ?IPv6:2404:f801:0:5:8000::4b1? ([2404:f801:9000:18:efec::4b1]) by smtp.gmail.com with ESMTPSA id r10sm3237979pga.48.2021.06.03.08.37.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 08:37:19 -0700 (PDT) Subject: Re: [RFC PATCH V3 09/11] HV/IOMMU: Enable swiotlb bounce buffer for Isolation VM To: Boris Ostrovsky , kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, rppt@kernel.org, hannes@cmpxchg.org, cai@lca.pw, krish.sadhukhan@oracle.com, saravanand@fb.com, Tianyu.Lan@microsoft.com, konrad.wilk@oracle.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, jgross@suse.com, sstabellini@kernel.org, joro@8bytes.org, will@kernel.org, xen-devel@lists.xenproject.org, davem@davemloft.net, kuba@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, sunilmut@microsoft.com References: <20210530150628.2063957-1-ltykernel@gmail.com> <20210530150628.2063957-10-ltykernel@gmail.com> <9488c114-81ad-eb67-79c0-5ed319703d3e@oracle.com> From: Tianyu Lan Message-ID: <1cdf4e6e-6499-e209-d499-7ab82992040b@gmail.com> Date: Thu, 3 Jun 2021 23:37:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@vger.kernel.org On 6/3/2021 12:02 AM, Boris Ostrovsky wrote: > > On 6/2/21 11:01 AM, Tianyu Lan wrote: >> Hi Boris: >>     Thanks for your review. >> >> On 6/2/2021 9:16 AM, Boris Ostrovsky wrote: >>> >>> On 5/30/21 11:06 AM, Tianyu Lan wrote: >>>> @@ -91,6 +92,6 @@ int pci_xen_swiotlb_init_late(void) >>>>   EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late); >>>>     IOMMU_INIT_FINISH(2, >>>> -          NULL, >>>> +          hyperv_swiotlb_detect, >>>>             pci_xen_swiotlb_init, >>>>             NULL); >>> >>> >>> Could you explain this change? >> >> Hyper-V allocates its own swiotlb bounce buffer and the default >> swiotlb buffer should not be allocated. swiotlb_init() in pci_swiotlb_init() is to allocate default swiotlb buffer. >> To achieve this, put hyperv_swiotlb_detect() as the first entry in the iommu_table_entry list. The detect loop in the pci_iommu_alloc() will exit once hyperv_swiotlb_detect() is called in Hyper-V VM and other iommu_table_entry callback will not be called. > > > > Right. But pci_xen_swiotlb_detect() will only do something for Xen PV guests, and those guests don't run on hyperV. It's either xen_pv_domain() (i.e. hypervisor_is_type(X86_HYPER_XEN_PV)) or hypervisor_is_type(X86_HYPER_MS_HYPERV) but never both. So I don't think there needs to be a dependency between the two callbacks. Yes, the dependency is between hyperv_swiotlb_detect() and pci_swiotlb_detect_override()/pci_swiotlb_detect_4gb(). Now pci_swiotlb_detect_override() and pci_swiotlb_detect_4gb() depends on pci_xen_swiotlb_detect(). To keep dependency between hyperv_swiotlb_detect() and pci_swiotlb_detect_override/4gb(), make pci_xen_swiotlb_detect() depends on hyperv_swiotlb_detect() and just to keep order in the IOMMU table. Current iommu_table_entry only has one depend callback and this is why I put xen depends on hyperv detect function. Thanks.