Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1603464pxy; Mon, 2 Aug 2021 06:02:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw671r0sLnTiuN+8+iioAurKcTUVEhFsuYG05+eQBjKQ+kxnVVNWUYMvGsxxAbtaysoEYs X-Received: by 2002:a2e:3919:: with SMTP id g25mr11210172lja.382.1627909358414; Mon, 02 Aug 2021 06:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627909358; cv=none; d=google.com; s=arc-20160816; b=t+TYsJbOa90YQG4uqQBcT0KyjDZ9sqgA2MkkS2dkpGNKTjeOQMnj4w9goOLiyz91Vk xmWWsutoTCY+CRaGWuaJDGLjGSnIDo9NfEjYqYsZlLoXzb3MFb1GTCLbdZbu/4uUSP05 PmENFZBrUlRD70R+/Bj81iyZIZDcuY1Dj944YcjIuFyaURI5KYaTFJP+j7vom3+jIinT GGfgkvM6zjoUC1aBK8HjPJ7birWXFbrdaLpgCh9urEMJpKVvcb4CEswZr3N2vhkb7XBA RGtPsDHNjY/FgLbTjn9CCOnJQHxTzPruaq5nptoTxnkJhXJ4lAHTACAokXpi55sRnbx4 QXwQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=x6kAH5ECncd1uHMaelcXJw4UPfhSIt05/jv5Mbs0uto=; b=XIU1BChGJeFHg8xn9vfpHfAW0sN8dIdMQ/PuANorS8f3/SHz4dg7AxDnhA5BC+xmrk tVgX3S4ufYPpazYALVGvaO5KQNE269JxhmRnp/eRh7SE1NwE/6OchDdOIy7H//TfIt2R 1iXckLmyCLhu3MxTJGasnR1J5gd/56vqeiWW9b4EIomKk9pkO0TTzVVZKE+0BbNGXmDm N/lEV1c9jFBe198ZPIKazkS5cP99muwz+8+e21I8Q3yJomyqhpQ/d/hMkE8CtPk5RJ4S wuVb+P6pAUj5BaPfHR303dZuT5/JCfukTRwPMPtO6wE/xHjYWQalG54sDMNtjZdEpRqV OCNA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ov18si9264528ejb.417.2021.08.02.06.02.14; Mon, 02 Aug 2021 06:02:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233835AbhHBM6n (ORCPT + 99 others); Mon, 2 Aug 2021 08:58:43 -0400 Received: from 8bytes.org ([81.169.241.247]:52982 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232629AbhHBM6m (ORCPT ); Mon, 2 Aug 2021 08:58:42 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 9AD29379; Mon, 2 Aug 2021 14:58:30 +0200 (CEST) Date: Mon, 2 Aug 2021 14:58:26 +0200 From: Joerg Roedel 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, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, will@kernel.org, davem@davemloft.net, kuba@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, arnd@arndb.de, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, ardb@kernel.org, Tianyu.Lan@microsoft.com, rientjes@google.com, martin.b.radev@gmail.com, akpm@linux-foundation.org, rppt@kernel.org, kirill.shutemov@linux.intel.com, aneesh.kumar@linux.ibm.com, krish.sadhukhan@oracle.com, saravanand@fb.com, xen-devel@lists.xenproject.org, pgonda@google.com, david@redhat.com, keescook@chromium.org, hannes@cmpxchg.org, sfr@canb.auug.org.au, michael.h.kelley@microsoft.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, anparri@microsoft.com Subject: Re: [PATCH 07/13] HV/Vmbus: Add SNP support for VMbus channel initiate message Message-ID: References: <20210728145232.285861-1-ltykernel@gmail.com> <20210728145232.285861-8-ltykernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210728145232.285861-8-ltykernel@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 28, 2021 at 10:52:22AM -0400, Tianyu Lan wrote: > + if (hv_is_isolation_supported()) { > + vmbus_connection.monitor_pages_va[0] > + = vmbus_connection.monitor_pages[0]; > + vmbus_connection.monitor_pages[0] > + = memremap(msg->monitor_page1, HV_HYP_PAGE_SIZE, > + MEMREMAP_WB); > + if (!vmbus_connection.monitor_pages[0]) > + return -ENOMEM; > + > + vmbus_connection.monitor_pages_va[1] > + = vmbus_connection.monitor_pages[1]; > + vmbus_connection.monitor_pages[1] > + = memremap(msg->monitor_page2, HV_HYP_PAGE_SIZE, > + MEMREMAP_WB); > + if (!vmbus_connection.monitor_pages[1]) { > + memunmap(vmbus_connection.monitor_pages[0]); > + return -ENOMEM; > + } > + > + memset(vmbus_connection.monitor_pages[0], 0x00, > + HV_HYP_PAGE_SIZE); > + memset(vmbus_connection.monitor_pages[1], 0x00, > + HV_HYP_PAGE_SIZE); > + } Okay, let me see if I got this right. In Hyper-V Isolation VMs, when the guest wants to make memory shared, it does": - Call to the Hypervisor the mark the pages shared. The Hypervisor will do the RMP update and remap the pages at (VTOM + pa) - The guest maps the memory again into its page-table, so that the entries point to the correct GPA (which is above VTOM now). Or in other words, Hyper-V implements a hardware-independent and configurable c-bit position, as the VTOM value is always power-of-two aligned. Is that correct? This would at least explain why there is no separate allocation/dealloction of memory for the shared range. Thanks, Joerg