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 X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E91EC388F2 for ; Tue, 3 Nov 2020 01:28:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BA5B22243 for ; Tue, 3 Nov 2020 01:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604366901; bh=p8CcsK59HrgvsonMBNa8Vf9L18kH0ZWkC9V7dQBVWYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=x0eCyUzRRvEFt0RDnbS3LaKekoasU5H0V7ClYIP5bkvxr0E/P7/cuO5ZBbUS5G1A4 pitYYvYHTi7UYbtRQ/61gIRDwXY9y6kE/jlx/V8aOT60pO8m08ltqB9Efiyqb3VUtM aF6oaW8xKgbqkJjojA2yD7mV6iqESrT+VUm/I7uo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728022AbgKCB2T (ORCPT ); Mon, 2 Nov 2020 20:28:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:60316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727298AbgKCBSv (ORCPT ); Mon, 2 Nov 2020 20:18:51 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D5E122243; Tue, 3 Nov 2020 01:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604366330; bh=p8CcsK59HrgvsonMBNa8Vf9L18kH0ZWkC9V7dQBVWYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IYOpetrqVFuyRPe5y1MiXTZHmm95JsyLXC9E/I09ljktre9r8fOwdwSzU74hUogrV oO+SBWku4uuTW+yzTZIzVwyIouVQcpReCjtdMLxpbo4D3ASjp1Al5bx3svT391HfGu 3hE7jXAYQa+PLMjp1xxP9zelmFaY7/bc0bbVJpVE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kairui Song , Ingo Molnar , Dexuan Cui , Jake Oshins , Wei Hu , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 07/35] hyperv_fb: Update screen_info after removing old framebuffer Date: Mon, 2 Nov 2020 20:18:12 -0500 Message-Id: <20201103011840.182814-7-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201103011840.182814-1-sashal@kernel.org> References: <20201103011840.182814-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kairui Song [ Upstream commit 3cb73bc3fa2a3cb80b88aa63b48409939e0d996b ] On gen2 HyperV VM, hyperv_fb will remove the old framebuffer, and the new allocated framebuffer address could be at a differnt location, and it might be no longer a VGA framebuffer. Update screen_info so that after kexec the kernel won't try to reuse the old invalid/stale framebuffer address as VGA, corrupting memory. [ mingo: Tidied up the changelog. ] Signed-off-by: Kairui Song Signed-off-by: Ingo Molnar Cc: Dexuan Cui Cc: Jake Oshins Cc: Wei Hu Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Stephen Hemminger Link: https://lore.kernel.org/r/20201014092429.1415040-3-kasong@redhat.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/hyperv_fb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index 02411d89cb462..e36fb1a0ecdbd 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1114,8 +1114,15 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) getmem_done: remove_conflicting_framebuffers(info->apertures, KBUILD_MODNAME, false); - if (!gen2vm) + + if (gen2vm) { + /* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */ + screen_info.lfb_size = 0; + screen_info.lfb_base = 0; + screen_info.orig_video_isVGA = 0; + } else { pci_dev_put(pdev); + } kfree(info->apertures); return 0; -- 2.27.0 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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 047ACC388F2 for ; Tue, 3 Nov 2020 01:18:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1127222B9 for ; Tue, 3 Nov 2020 01:18:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="IYOpetrq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1127222B9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 647306E073; Tue, 3 Nov 2020 01:18:52 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C3536E073 for ; Tue, 3 Nov 2020 01:18:51 +0000 (UTC) Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D5E122243; Tue, 3 Nov 2020 01:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604366330; bh=p8CcsK59HrgvsonMBNa8Vf9L18kH0ZWkC9V7dQBVWYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IYOpetrqVFuyRPe5y1MiXTZHmm95JsyLXC9E/I09ljktre9r8fOwdwSzU74hUogrV oO+SBWku4uuTW+yzTZIzVwyIouVQcpReCjtdMLxpbo4D3ASjp1Al5bx3svT391HfGu 3hE7jXAYQa+PLMjp1xxP9zelmFaY7/bc0bbVJpVE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 07/35] hyperv_fb: Update screen_info after removing old framebuffer Date: Mon, 2 Nov 2020 20:18:12 -0500 Message-Id: <20201103011840.182814-7-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201103011840.182814-1-sashal@kernel.org> References: <20201103011840.182814-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , linux-hyperv@vger.kernel.org, Wei Hu , Kairui Song , Haiyang Zhang , Dexuan Cui , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Jake Oshins , Stephen Hemminger , "K. Y. Srinivasan" , Ingo Molnar Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Kairui Song [ Upstream commit 3cb73bc3fa2a3cb80b88aa63b48409939e0d996b ] On gen2 HyperV VM, hyperv_fb will remove the old framebuffer, and the new allocated framebuffer address could be at a differnt location, and it might be no longer a VGA framebuffer. Update screen_info so that after kexec the kernel won't try to reuse the old invalid/stale framebuffer address as VGA, corrupting memory. [ mingo: Tidied up the changelog. ] Signed-off-by: Kairui Song Signed-off-by: Ingo Molnar Cc: Dexuan Cui Cc: Jake Oshins Cc: Wei Hu Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Stephen Hemminger Link: https://lore.kernel.org/r/20201014092429.1415040-3-kasong@redhat.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/hyperv_fb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index 02411d89cb462..e36fb1a0ecdbd 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1114,8 +1114,15 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) getmem_done: remove_conflicting_framebuffers(info->apertures, KBUILD_MODNAME, false); - if (!gen2vm) + + if (gen2vm) { + /* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */ + screen_info.lfb_size = 0; + screen_info.lfb_base = 0; + screen_info.orig_video_isVGA = 0; + } else { pci_dev_put(pdev); + } kfree(info->apertures); return 0; -- 2.27.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel