Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3033494pxj; Sun, 6 Jun 2021 23:54:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUpdowOo4Qbu39P2xj4y+KEDVEBqoBSDFdPgxNwJHm6iIrMa9Lc1+eAjMaqRFtLp1gj1Pj X-Received: by 2002:a17:906:7203:: with SMTP id m3mr16079311ejk.381.1623048840998; Sun, 06 Jun 2021 23:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623048840; cv=none; d=google.com; s=arc-20160816; b=QMTH2kleF9Nfgj960Jm3ezbqnQkZJSJKwLhgm8mu3W7j3+jtj99fyiatzXihVy1vHN C/yzDGenprNHHESTNavdEWIbifbMnSAo+ShqyYCJo2I+osy/464gG47ZLDdFZemjyrue csM6drW2tVU/60ameYUN/18zqja3b1GWQSU+3fLBMAnt7bPVuntWpnqMLL2LRscdo8Sd a8nL42Ynok8+98HQydgY5jTDRFJeirJ2+gesILoojzxtjOJPwvyn6sG9olGlnBKT8dUj lUUeIToAWaAvj/i2qKnDcR+uxhkLNfU+Ka0odvXV0QGyc1eQqe6Zb2/YXRbq5vfi+bU6 IZrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mBXe61OBwcseXhAHCBPWzsjCaUyqGEyTZgpYYeOEGRg=; b=q7h1mmpTNqWKC7d1eWNGVN3xyo1zvaVZtm8tX97sZ/glvSSOd6Rud+c0rUVuXGxm83 76cNhcE4UaZdNVDlObiGjgYbhIMBwNt9v3/0Zi81AwAU9/dPFDI/OPy9KuWm0fGb6uRf OOlsRm7T1gW/sPuQx04ocgcp6kdIuVud2QnSXTcklAtMAuF3R51Bkcl5Owg5HKYe2Qlb G8c5sKY9CFR8xkMWkbUthemiFYiEbIKWO3f4FcejCxdqc7yZxBQYsww72S7YQHstJDBT 23Exc400clZQm4DwhRoJw9aGgS9WEEKMHjhTO5YqNCQz2ZSMQlT46pRU5XKR0z5dY95o k+0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si7151916edm.116.2021.06.06.23.53.38; Sun, 06 Jun 2021 23:54:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbhFGGwF (ORCPT + 99 others); Mon, 7 Jun 2021 02:52:05 -0400 Received: from verein.lst.de ([213.95.11.211]:44679 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbhFGGwE (ORCPT ); Mon, 7 Jun 2021 02:52:04 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 6BD7A68AFE; Mon, 7 Jun 2021 08:50:07 +0200 (CEST) Date: Mon, 7 Jun 2021 08:50:07 +0200 From: Christoph Hellwig To: Tianyu Lan Cc: 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, boris.ostrovsky@oracle.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, 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 Subject: Re: [RFC PATCH V3 10/11] HV/Netvsc: Add Isolation VM support for netvsc driver Message-ID: <20210607065007.GE24478@lst.de> References: <20210530150628.2063957-1-ltykernel@gmail.com> <20210530150628.2063957-11-ltykernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210530150628.2063957-11-ltykernel@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 30, 2021 at 11:06:27AM -0400, Tianyu Lan wrote: > + if (hv_isolation_type_snp()) { > + pfns = kcalloc(buf_size / HV_HYP_PAGE_SIZE, sizeof(unsigned long), > + GFP_KERNEL); > + for (i = 0; i < buf_size / HV_HYP_PAGE_SIZE; i++) > + pfns[i] = virt_to_hvpfn(net_device->recv_buf + i * HV_HYP_PAGE_SIZE) + > + (ms_hyperv.shared_gpa_boundary >> HV_HYP_PAGE_SHIFT); > + > + vaddr = vmap_pfn(pfns, buf_size / HV_HYP_PAGE_SIZE, PAGE_KERNEL_IO); > + kfree(pfns); > + if (!vaddr) > + goto cleanup; > + net_device->recv_original_buf = net_device->recv_buf; > + net_device->recv_buf = vaddr; > + } This probably wnats a helper to make the thing more readable. But who came up with this fucked up communication protocol where the host needs to map random pfns into a contigous range? Sometime I really have to wonder what crack the hyper-v people take when comparing this to the relatively sane approach others take. > + for (i = 0; i < page_count; i++) > + dma_unmap_single(&hv_dev->device, packet->dma_range[i].dma, > + packet->dma_range[i].mapping_size, > + DMA_TO_DEVICE); > + > + kfree(packet->dma_range); Any reason this isn't simply using a struct scatterlist? > + for (i = 0; i < page_count; i++) { > + char *src = phys_to_virt((pb[i].pfn << HV_HYP_PAGE_SHIFT) > + + pb[i].offset); > + u32 len = pb[i].len; > + > + dma = dma_map_single(&hv_dev->device, src, len, > + DMA_TO_DEVICE); dma_map_single can only be used on page baked memory, and if this is using page backed memory you wouldn't need to do thee phys_to_virt tricks. Can someone explain the mess here in more detail? > struct rndis_device *dev = nvdev->extension; > struct rndis_request *request = NULL; > + struct hv_device *hv_dev = ((struct net_device_context *) > + netdev_priv(ndev))->device_ctx; Why not use a net_device_context local variable instead of this cast galore?