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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFD38CD3427 for ; Thu, 7 May 2026 03:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZaiVA7FK64HzHiW79paCCu3hRwFlMBFKVgvgM3gbwUQ=; b=pAiJsYZErc1Sd6y0J8SRuxyP/m 5tGGNiLPG1ktTzDrpV1w9dLc15rYzJeN3zAla5OYo2W/QG0aQuV9PMn5IqXW8o65Rwtmx6Ckuyvil hMlbODAS6t0fTPOEIPrf2BU+FlYMEcGzLl1iNyzZX4vUjA+FBNd6NRY3TZcPgfIDcvtG/gxB5Eq9T ZsjZ1u2mwtdJQPGg0v/AzZbZvLbwcv/JokBS7P/UDpWSvsW0h2+q9ynEl4AziKhEq5KgTgs7bJD5R OXtVgXeNZo0MzNtZBUIbF+/xeUtxUh3BK5oITcwKBW19uAZobS/Vo3dcestlT4P2TiyHdeKQtOZb8 9E32xTYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wKpeG-00000002f3j-0krg; Thu, 07 May 2026 03:43:40 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wKpeE-00000002f3L-1hue; Thu, 07 May 2026 03:43:38 +0000 Received: from [10.95.65.64] (unknown [167.220.238.64]) by linux.microsoft.com (Postfix) with ESMTPSA id 33FE320B7165; Wed, 6 May 2026 20:43:26 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 33FE320B7165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1778125413; bh=ZaiVA7FK64HzHiW79paCCu3hRwFlMBFKVgvgM3gbwUQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ZNlBaGdBTGgWhXBzXBgqOVZm/b/shQdBDzoIUFvlVMUYDb35gRYc2aRNtfBtUwVde 0yvNU7byjWVWhwL6ErC+tJLxcEwic9+viIQo4EvQsOVk3Ed9dZyD3pgRTvCuHQWwws ORdyFcW2lS6CP3jUPBUMPamNznpGn0N/JJmWavVk= Message-ID: Date: Thu, 7 May 2026 09:13:27 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 09/15] Drivers: hv: mshv_vtl: Move hv_vtl_configure_reg_page() to x86 To: Michael Kelley Cc: Marc Zyngier , Timothy Hayes , Lorenzo Pieralisi , Sascha Bischoff , mrigendrachaubey , "linux-hyperv@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "vdso@mailbox.org" , "ssengar@linux.microsoft.com" , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "H . Peter Anvin" , Arnd Bergmann , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti References: <20260423124206.2410879-1-namjain@linux.microsoft.com> <20260423124206.2410879-10-namjain@linux.microsoft.com> <567cf73b-6a48-4fc3-b312-9be6d71e2f22@linux.microsoft.com> <024aed8c-cd97-45f0-a653-489fc334a2b9@linux.microsoft.com> Content-Language: en-US From: Naman Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260506_204338_487349_394C3262 X-CRM114-Status: GOOD ( 40.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/6/2026 8:06 PM, Michael Kelley wrote: > From: Naman Jain Sent: Tuesday, May 5, 2026 10:50 PM >> >> On 5/4/2026 9:36 PM, Michael Kelley wrote: >>> From: Naman Jain Sent: Wednesday, April 29, 2026 2:58 AM >>>> >>>> On 4/27/2026 11:10 AM, Michael Kelley wrote: >>>>> From: Naman Jain Sent: Thursday, April 23, 2026 5:42 AM >>>>>> >>>>>> Move hv_vtl_configure_reg_page() from drivers/hv/mshv_vtl_main.c to >>>>>> arch/x86/hyperv/hv_vtl.c. The register page overlay is an x86-specific >>>>>> feature that uses HV_X64_REGISTER_REG_PAGE, so its configuration belongs >>>>>> in architecture-specific code. >>>>>> >>>>>> Move struct mshv_vtl_per_cpu and union hv_synic_overlay_page_msr to >>>>>> include/asm-generic/mshyperv.h so they are visible to both arch and >>>>>> driver code. >>>>>> >>>>>> Change the return type from void to bool so the caller can determine >>>>>> whether the register page was successfully configured and set >>>>>> mshv_has_reg_page accordingly. >>>>>> >>>>>> Signed-off-by: Naman Jain >>>>>> --- >>>>>> arch/x86/hyperv/hv_vtl.c | 32 ++++++++++++++++++++++ >>>>>> drivers/hv/mshv_vtl_main.c | 49 +++------------------------------- >>>>>> include/asm-generic/mshyperv.h | 17 ++++++++++++ >>>>>> 3 files changed, 53 insertions(+), 45 deletions(-) >>>>>> >>>> >>>> >>>> >>>>>> #if IS_ENABLED(CONFIG_HYPERV_VTL_MODE) >>>>>> +/* SYNIC_OVERLAY_PAGE_MSR - internal, identical to hv_synic_simp */ >>>>> >>>>> This comment pre-dates your patch, but I don't understand the point >>>>> it is trying to make. The comment is factually true, but I don't know >>>>> why calling that out is relevant. The REG_PAGE MSR seems to be >>>>> conceptually separate and distinct from the SIMP MSR, so the fact >>>>> that the layouts are the same is just a coincidence. Or is there some >>>>> relationship between the two MSRs that I'm not aware of, and the >>>>> comment is trying (and failing?) to point out? >>>> >>>> This was added as per suggestion from Nuno in my initial series for >>>> MSHV_VTL. If the reference in "identical to" is misleading, I should >>>> remove it. >>>> >>>> https://lore.kernel.org/all/68143eb0-e6a7-4579-bedb-4c2ec5aaef6b@linux.microsoft.com/ >>>> >>>> Quoting: >>>> """ >>>> it is a generic structure that >>>> appears to be used for several overlay page MSRs (SIMP, SIEF, etc). >>>> >>>> But, the type doesn't appear in the hv*dk headers explicitly; it's just >>>> used internally by the hypervisor. >>>> >>>> I think it should be renamed with a hv_ prefix to indicate it's part of >>>> the hypervisor ABI, and a brief comment with the provenance: >>>> >>>> /* SYNIC_OVERLAY_PAGE_MSR - internal, identical to hv_synic_simp */ >>>> union hv_synic_overlay_page_msr { >>>> /* */ >>>> }; >>> >>> OK, so this union is not associated *only* with the REG_PAGE MSR >>> (though that MSR is the only current user). Instead, it is intended to >>> be a more generic description of MSRs that set up overlay pages. I >>> don't think I had previously noticed Nuno's comment on the topic. >>> >>> Looking through hvgdk_mini.h and hvhdk.h, I see 6 definitions that >>> are exactly the same: >>> >>> * union hv_reference_tsc_msr >>> * union hv_x64_msr_hypercall_contents >>> * union hv_vp_assist_msr_contents >>> * union hv_synic_simp >>> * union hv_synic_siefp >>> * union hv_synic_sirbp >>> >>> There's an argument to be made for removing these 6 unique definitions >>> and using union hv_synic_overlay_page_msr instead (though "synic" >>> would need to be removed from the name). I would not object to such >>> an approach. It's a small extra layer of conceptual indirection, but saves >>> some lines of code for duplicative definitions. The alternative is to drop >>> the idea of a generic overlay page MSR layout, and replace union >>> hv_synic_overlay_page_msr with a definition that is specific to the >>> REG_PAGE MSR, like the other six above. >>> >> >> Hi Michael, >> >> While having a generic definition looks good to have here, I can see two >> reasons for not going ahead with generic overlay page definition: >> 1. All of the above definitions are present in Hyper-V headers and >> generalizing them would deviate from the strategy of keeping the kernel >> headers in line with Hyper-V headers. >> 2. For any of these definitions, if the use-case requires using some of >> these reserved bits, then it would be a problem. I can actually see that >> happening in "hv_x64_msr_hypercall_contents" in the corresponding >> variant in the Hyper-V header. > > Your points are certainly valid, and I'm good with not going the > generic route. > >> >>> I could go either way. If we want to use a generic overlay page definition, >>> then that approach should be applied everywhere. With the current >>> state of your patch set, we're halfway in between -- the generic definition >>> is used one place, but duplicative specific MSR definitions are used other >>> places. That's probably the least desirable approach. >>> >>> Michael >> >> >> Now, coming back to the hv_synic_overlay_page_msr definition. While >> Nuno's comment hinted at it being "generic", the same is not documented >> in the name of this structure or its comments. So it should be safe to >> assume that it is specific to synic_overlay_page_msr usage. But since it >> is not part of Hyper-V header as such, we needed that comment: >> "/* SYNIC_OVERLAY_PAGE_MSR - internal, identical to hv_synic_simp */" >> > > An "overlay page" is a generic concept in the Hyper-V world, and it is used > in multiple places in the guest<->hypervisor interface. The old PDF version of > the Hyper-V TLFS describes overlay pages in the section 5.2.1 entitled "GPA > Overlay Pages". See [1]. Unfortunately, this material about overlay pages > doesn't seem to have been carried over to the web page version of the TLFS. > > So in my thinking, the name "hv_synic_overlay_page_msr" is inherently > a generic definition that could be applied to multiple MSRs that are used to > specify overlay pages. Your patch is about a specific MSR, > HV_X64_REGISTER_REG_PAGE, which happens to be used to define an > overlay page. But if the decision is to *not* go the generic route, I > would expect to see something like "union hv_x64_reg_page_msr" > that is specific to the REG_PAGE MSR, and to have that type used in > hv_vtl_configure_reg_page(). The definition of hv_x64_reg_page_msr > would not have a comment referencing the SIMP or any other MSR > because it would be a standalone definition that is specific to > HV_X64_REGISTER_REG_PAGE. Then the pattern would be the same as > the other six cases that I listed above. > > When not using the generic approach, hv_synic_overlay_page_msr > really has no purpose, and could go away. > > Michael > > [1] https://github.com/MicrosoftDocs/Virtualization-Documentation/raw/live/tlfs/Hypervisor%20Top%20Level%20Functional%20Specification%20v6.0b.pdf Thanks for suggesting this, I was not aware of it. I'll change it to hv_x64_reg_page_msr and remove the comment. Regards, Naman