Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2672975pxb; Mon, 11 Jan 2021 16:47:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTy1UYCUSlKAX252svOGtIdkR7rzj331Dtp8+rrmxIp9n5g2qDJLdE6+JPiCTsvClAnimD X-Received: by 2002:a05:6402:1a54:: with SMTP id bf20mr1374899edb.65.1610412442649; Mon, 11 Jan 2021 16:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610412442; cv=none; d=google.com; s=arc-20160816; b=rOMCDb5pgqIqerOfZHWnT/QyAdO+Q3yjFHOVNvqiBXly6JsiS8W6Gpfn+hhp8I+FCy ie+mjmCQmhTq0SNNRHNhxvF3yL5GWyhjayutHFhZ892DZUI3TKmq96iyj28Mbw0tcktd +PtDjBuZgYw0AsOUpQcASrOyf02TY5VGVxAjPdEAKbnpKfq0MqNd3Br+hBHFPe/QvxJI RnzHt37QErc0FeSVSWpNaSp/opaIbjP2hSSRLklPKO1sgjH6IdB7087uXT/Y4YSYGm5E kfBXkmPE8Z1to1rG/c62B+FYXY8Udx9VqdQUH0evXkxYINKhFMCBOm3pGV4xRKN+JZYp rurA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P+dvU6Fq+GpzQnWUQ1BhiTQb4cwOdnjtfAhUD10i7Zo=; b=pytv09+ZPY4wTkrZ0tq4N3lbrAqhdxdEGe9wniBjKgp7ZFg1wcBxP549rmhZBMzItv 5D8W86KfTLf4XCgbNKuJRzeZo1jdSTB6fOIMYYngKqJ9sO2q+RBTZSl+YNzD417/QlgI 0Ln8UCj7tfjbgfhk1Z9B5VYjjPOqrMwztiRi++BXpGmoILUJgzn7fV3vsGArxZQGQ2FT vMoc3J0qU7aju8L8q/APUibUuB0gQl/aXUUON+MzrAqALFa/rJHQVcb9qgVUSBjPi3jK /VruZWHIiQe3dhUiCLfdGT2/jcql4cXq0/48v/hJOPiJEkfSL4N/SehOgHZUz1VTIkDE IDxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AP85rGQS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si391098ejc.573.2021.01.11.16.46.58; Mon, 11 Jan 2021 16:47:22 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AP85rGQS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728156AbhAKNBY (ORCPT + 99 others); Mon, 11 Jan 2021 08:01:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:48792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbhAKNBX (ORCPT ); Mon, 11 Jan 2021 08:01:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 212132255F; Mon, 11 Jan 2021 13:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370018; bh=a3pAockhqaO2qq23IpAEVWfGVyVPfxRXLfSJRt3TqoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AP85rGQSJnNAYbX+lDMZLGR5KwlXiUgXixNgIGA3VyIx0/J00oKyDx2UebDcyWKyX bnzuWosYMgKsBZ05P1WGtvr0+GICPMZGXKBJRI3Ey9up9XsdfBVYXxQCKSmhctMtKc 7HZwr0hequE4YBTaMjRAE84A9tLg7+qlr7fAvGGA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dexuan Cui , Sasha Levin Subject: [PATCH 4.4 15/38] video: hyperv_fb: Fix the mmap() regression for v5.4.y and older Date: Mon, 11 Jan 2021 14:00:47 +0100 Message-Id: <20210111130033.203402871@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130032.469630231@linuxfoundation.org> References: <20210111130032.469630231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dexuan Cui db49200b1dad is backported from the mainline commit 5f1251a48c17 ("video: hyperv_fb: Fix the cache type when mapping the VRAM"), to v5.4.y and older stable branches, but unluckily db49200b1dad causes mmap() to fail for /dev/fb0 due to EINVAL: [ 5797.049560] x86/PAT: a.out:1910 map pfn expected mapping type uncached-minus for [mem 0xf8200000-0xf85cbfff], got write-back This means the v5.4.y kernel detects an incompatibility issue about the mapping type of the VRAM: db49200b1dad changes to use Write-Back when mapping the VRAM, while the mmap() syscall tries to use Uncached-minus. That’s to say, the kernel thinks Uncached-minus is incompatible with Write-Back: see drivers/video/fbdev/core/fbmem.c: fb_mmap() -> vm_iomap_memory() -> io_remap_pfn_range() -> ... -> track_pfn_remap() -> reserve_pfn_range(). Note: any v5.5 and newer kernel doesn't have the issue, because they have commit d21987d709e8 ("video: hyperv: hyperv_fb: Support deferred IO for Hyper-V frame buffer driver") , and when the hyperv_fb driver has the deferred_io support, fb_deferred_io_init() overrides info->fbops->fb_mmap with fb_deferred_io_mmap(), which doesn’t check the mapping type incompatibility. Note: since it's VRAM here, the checking is not really necessary. Fix the regression by ioremap_wc(), which uses Write-combining. The kernel thinks it's compatible with Uncached-minus. The VRAM mappped by ioremap_wc() is slightly slower than mapped by ioremap_cache(), but is still significantly faster than by ioremap(). Change the comment accordingly. Linux VM on ARM64 Hyper-V is still not working in the latest mainline yet, and when it works in future, the ARM64 support is unlikely to be backported to v5.4 and older, so using ioremap_wc() in v5.4 and older should be ok. Note: this fix is only targeted at the stable branches: v5.4.y, v4.19.y, v4.14.y, v4.9.y and v4.4.y. Fixes: db49200b1dad ("video: hyperv_fb: Fix the cache type when mapping the VRAM") Signed-off-by: Dexuan Cui Signed-off-by: Sasha Levin --- drivers/video/fbdev/hyperv_fb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index 299412abb1658..883c06381e7c1 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -713,11 +713,9 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) } /* - * Map the VRAM cacheable for performance. This is also required for - * VM Connect to display properly for ARM64 Linux VM, as the host also - * maps the VRAM cacheable. + * Map the VRAM cacheable for performance. */ - fb_virt = ioremap_cache(par->mem->start, screen_fb_size); + fb_virt = ioremap_wc(par->mem->start, screen_fb_size); if (!fb_virt) goto err2; -- 2.27.0