I'm expecting an upstream fix for this problem soon, based on this discussion (lkml):
>From Dexuan Cui: "d1cd12108346: x86, pageattr: Prevent overflow in slow_virt_to_phys() for X86_PAE" was unintentionally removed by the recent "34437e67a672: x86/mm: Fix slow_virt_to_phys() to handle large PAT bit". And, the variable 'phys_addr' was defined as "unsigned long" by mistake -- it should be "phys_addr_t". As a result, Hyper-V network driver in 32-PAE Linux guest can't work again. Fixes: "commmit 34437e67a672: x86/mm: Fix slow_virt_to_phys() to handle large PAT bit" Signed-off-by: Dexuan Cui <de...@microsoft.com> Cc: Toshi Kani <toshi.k...@hpe.com> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: K. Y. Srinivasan <k...@microsoft.com> Cc: Haiyang Zhang <haiya...@microsoft.com> Cc: gre...@linuxfoundation.org Cc: linux...@kvack.org Cc: o...@aepfle.de Cc: a...@canonical.com Cc: jasow...@redhat.com Cc: sta...@vger.kernel.org --- arch/x86/mm/pageattr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 2440814..9cf96d8 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -419,24 +419,30 @@ pmd_t *lookup_pmd_address(unsigned long address) phys_addr_t slow_virt_to_phys(void *__virt_addr) { unsigned long virt_addr = (unsigned long)__virt_addr; - unsigned long phys_addr, offset; + phys_addr_t phys_addr; + unsigned long offset; enum pg_level level; pte_t *pte; pte = lookup_address(virt_addr, &level); BUG_ON(!pte); + /* + * pXX_pfn() returns unsigned long, which must be cast to phys_addr_t + * before being left-shifted PAGE_SHIFT bits -- this trick is to + * make 32-PAE kernel work correctly. + */ switch (level) { case PG_LEVEL_1G: - phys_addr = pud_pfn(*(pud_t *)pte) << PAGE_SHIFT; + phys_addr = (phys_addr_t)pud_pfn(*(pud_t *)pte) << PAGE_SHIFT; offset = virt_addr & ~PUD_PAGE_MASK; break; case PG_LEVEL_2M: - phys_addr = pmd_pfn(*(pmd_t *)pte) << PAGE_SHIFT; + phys_addr = (phys_addr_t)pmd_pfn(*(pmd_t *)pte) << PAGE_SHIFT; offset = virt_addr & ~PMD_PAGE_MASK; break; default: - phys_addr = pte_pfn(*pte) << PAGE_SHIFT; + phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT; offset = virt_addr & ~PAGE_MASK; } >From Toshi Kani: On Thu, 2016-02-25 at 01:58 -0800, Dexuan Cui wrote: > "d1cd12108346: x86, pageattr: Prevent overflow in slow_virt_to_phys() for > X86_PAE" > was unintentionally removed by the recent > "34437e67a672: x86/mm: Fix slow_virt_to_phys() to handle large PAT bit". > > And, the variable 'phys_addr' was defined as "unsigned long" by mistake > -- it should > be "phys_addr_t". > > As a result, Hyper-V network driver in 32-PAE Linux guest can't work > again. > > Fixes: "commmit 34437e67a672: x86/mm: Fix slow_virt_to_phys() to handle > large PAT bit" > Signed-off-by: Dexuan Cui <de...@microsoft.com> > Cc: Toshi Kani <toshi.k...@hpe.com> > Cc: Andrew Morton <a...@linux-foundation.org> > Cc: Thomas Gleixner <t...@linutronix.de> > Cc: K. Y. Srinivasan <k...@microsoft.com> > Cc: Haiyang Zhang <haiya...@microsoft.com> > Cc: gre...@linuxfoundation.org > Cc: linux...@kvack.org > Cc: o...@aepfle.de > Cc: a...@canonical.com > Cc: jasow...@redhat.com > Cc: sta...@vger.kernel.org Thanks for the fix and adding the comment to explain the trick! The change looks good to me. Reviewed-by: Toshi Kani <toshi.k...@hpe.com> -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to linux in Ubuntu. https://bugs.launchpad.net/bugs/1549601 Title: [Hyper-V] x86,pageattr: prevent overflow in slow_virt_to_phys() for X86_PAE Status in linux package in Ubuntu: Triaged Bug description: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d1cd1210834649ce1ca6bafe5ac25d2f40331343 x86, pageattr: Prevent overflow in slow_virt_to_phys() for X86_PAE pte_pfn() returns a PFN of long (32 bits in 32-PAE), so "long << PAGE_SHIFT" will overflow for PFNs above 4GB. Due to this issue, some Linux 32-PAE distros, running as guests on Hyper-V, with 5GB memory assigned, can't load the netvsc driver successfully and hence the synthetic network device can't work (we can use the kernel parameter mem=3000M to work around the issue). Cast pte_pfn() to phys_addr_t before shifting. To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1549601/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp