Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2932755lqt; Tue, 23 Apr 2024 06:14:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUb/AggQeYRMwBj8aDZSuQoMy8U6PpElL/jsBqEUcB9Je7xJlYNVfL/S209kPI0FJJUNTOXyo9OhMSV5meA0LpP1CXiAM5cteK5UyIb6g== X-Google-Smtp-Source: AGHT+IHndEJ8h4M565ungxzne23uPkkIuOOMkbFCOL6DtVQwaRM6UeDI7S+84LK5QoM4vSZ16WNA X-Received: by 2002:a17:902:9a46:b0:1de:f91:3cf3 with SMTP id x6-20020a1709029a4600b001de0f913cf3mr12284503plv.55.1713878056689; Tue, 23 Apr 2024 06:14:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713878056; cv=pass; d=google.com; s=arc-20160816; b=lRMOWZkQ8cC9UZPqfsVHN6LGjqrAzQHcyTP7c0I2G7ilJ3iDtz2RYAsKTdCeNowr8i 4yU+TVMB2QkIiMzDdY7KF0IVTKG/j3/s2EJ4GAhu+PCqKa8/P56g5l79J1SvGBh91qb8 C7l+bnlr6sRTkLpMPHhTJwwMafX10itIExYFGj15QkjfagJrVEAAs8mHajcbKqTaUEFL C8ju+ruOI72faOUnUWEjzcoq2CR9eJoK2ux+G2nZJ4tMjWjJLBQFiETx+NcT9yvCAy2C pUw1s4hSz0XdQo8psL3RPLDmxKlRIOrWdoyUSZdew1u5rBoauEBcdikzktc0pRQ9nUZf LCRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=1Id41yHvdTscUsFAax+DNoLOYykqRWumjAUWJN9I2VY=; fh=JJfhIQkD0YZ+ztki0w3M/FwdHZMMDMfcl/t90KqIJSU=; b=zqqzkN10djMFYn7s1Qy5bC82/G8CquC6ydTot0TMVy0uVIqnnOFkN0xKrtM5ecImKE 4dDjsVRWXvlackyjrSWQioeDbODJjvvcCEXc1wq5IHZcsyegTz29GIg03hQKu/60CYcr sIiBwqO50SgoH5PV947WZivd2fVqYsTFCDTX6nYMbqIh4fMok/6cNd1q8HPFvSGTQuZ3 Av9wsqCBTeY/P6MpWz2kRkvS6GnTRBpY/AiGsyV7G2U3S3+4kNhCvolI1UgfU+H8/JJs P1aa+6QjbzTjhD5dB6jfObsUGpFiJDyi4TgFBVW4vDwTY/0FZhMkg8/AM+NQs+LPwjnF tftA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmKMFT0m; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmKMFT0m; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-155249-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h5-20020a170902f70500b001e039a37289si9943742plo.613.2024.04.23.06.14.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 06:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155249-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmKMFT0m; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmKMFT0m; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-155249-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 068C1286E57 for ; Tue, 23 Apr 2024 13:08:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04A7C134CCC; Tue, 23 Apr 2024 13:08:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qmKMFT0m"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9nRhQWg3"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qmKMFT0m"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9nRhQWg3" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F161745E2; Tue, 23 Apr 2024 13:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713877686; cv=none; b=XK/k0Xl3CAZLwZEK/rlpXrfiJBJblGr28K90NF3wVG4Y3ThSY5zvMoN2EkeOcDXDdXnidQxOk7oXo7csggDesEbU45UMtgxc+TbmH8agfus79m2l3zYAtfKIaVXtFlKR1K/9FcSpi/lEAHsDIB3vj8QKXfjtSUNhw/JviMNHswU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713877686; c=relaxed/simple; bh=iLUrBbUOU5gdH+eZbJLreYBsbpQPZFCk+4aYIpqdju4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nuowu7ss6z5fe596EZzrdSHioUuL32Ph0n6zQoGTpZmrN/TER2qPHuuTQ7+4heQVJOp+ccejVpssCrguWUlv5ebxbctnds7f4cAXpepRkc0oPrS9hoFYQcRK+gslAcE642gKEf5nafrBeXFTZeSuuLOTKX9ULcK2w/ycTjdzwPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qmKMFT0m; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=9nRhQWg3; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qmKMFT0m; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=9nRhQWg3; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6778F37F9F; Tue, 23 Apr 2024 13:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713877676; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=1Id41yHvdTscUsFAax+DNoLOYykqRWumjAUWJN9I2VY=; b=qmKMFT0mlZ5lMemlzm3IMqpOJgMMdFt7iU2esq1/LeqFi9+L+zuwXWN8NLBj3YLBcJcqyp NLxQi+wz7v5+y/etBqCdyehMvdlqGLm1/cljwq9XN9lDdXQnztGYvnJ8PTbjMLDZzn5NHb tuWwNQHLLnl5BYFeZaUGklviJgswXyc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713877676; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=1Id41yHvdTscUsFAax+DNoLOYykqRWumjAUWJN9I2VY=; b=9nRhQWg3Lddeb3Ejm5yfTgZXrZNOJ8ErCcBzqxhu11oVqyX0ubIOBNgAVW1iCAc1maYNLz CM5qwk08G/5TIPAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713877676; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=1Id41yHvdTscUsFAax+DNoLOYykqRWumjAUWJN9I2VY=; b=qmKMFT0mlZ5lMemlzm3IMqpOJgMMdFt7iU2esq1/LeqFi9+L+zuwXWN8NLBj3YLBcJcqyp NLxQi+wz7v5+y/etBqCdyehMvdlqGLm1/cljwq9XN9lDdXQnztGYvnJ8PTbjMLDZzn5NHb tuWwNQHLLnl5BYFeZaUGklviJgswXyc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713877676; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=1Id41yHvdTscUsFAax+DNoLOYykqRWumjAUWJN9I2VY=; b=9nRhQWg3Lddeb3Ejm5yfTgZXrZNOJ8ErCcBzqxhu11oVqyX0ubIOBNgAVW1iCAc1maYNLz CM5qwk08G/5TIPAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 162F013894; Tue, 23 Apr 2024 13:07:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id 7DhbBKyyJ2btXwAAD6G6ig (envelope-from ); Tue, 23 Apr 2024 13:07:56 +0000 Message-ID: <1722c1b6-59a5-429d-905c-bc1951a68a68@suse.de> Date: Tue, 23 Apr 2024 15:07:51 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] fbdev: fix incorrect address computation in deferred IO To: Nam Cao , Jaya Kumar , Daniel Vetter , Helge Deller , Javier Martinez Canillas , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: tiwai@suse.de, bigeasy@linutronix.de, patrik.r.jakobsson@gmail.com, Vegard Nossum , George Kennedy , Darren Kenny , chuansheng.liu@intel.com, Harshit Mogalapalli , stable@vger.kernel.org References: <20240423115053.4490-1-namcao@linutronix.de> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN1qylK9i3gPoQjXGhpBpQYwRrEyQyjuvk+Ev0K1Jc5tVDeJAuau3TGNgah4Yc hdHm3bkPjz9EErV85RwvImQ1dptvx6s7xzwXTgGAsaYZsL8WCwDaTuqFa1d1jjlaxg6+tZsB 9GluwvIhSezPgnEmimZDkGnZRRSFiGP8yjqTjjWuf0bSj5rUnTGiyLyRZRNGcXmu6hjlABEB AAHNJ1Rob21hcyBaaW1tZXJtYW5uIDx0emltbWVybWFubkBzdXNlLmRlPsLAjgQTAQgAOAIb AwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftODH AAoJEGgNwR1TC3ojx1wH/0hKGWugiqDgLNXLRD/4TfHBEKmxIrmfu9Z5t7vwUKfwhFL6hqvo lXPJJKQpQ2z8+X2vZm/slsLn7J1yjrOsoJhKABDi+3QWWSGkaGwRJAdPVVyJMfJRNNNIKwVb U6B1BkX2XDKDGffF4TxlOpSQzdtNI/9gleOoUA8+jy8knnDYzjBNOZqLG2FuTdicBXblz0Mf vg41gd9kCwYXDnD91rJU8tzylXv03E75NCaTxTM+FBXPmsAVYQ4GYhhgFt8S2UWMoaaABLDe 7l5FdnLdDEcbmd8uLU2CaG4W2cLrUaI4jz2XbkcPQkqTQ3EB67hYkjiEE6Zy3ggOitiQGcqp j//OwE0EWznS4AEIAMYmP4M/V+T5RY5at/g7rUdNsLhWv1APYrh9RQefODYHrNRHUE9eosYb T6XMryR9hT8XlGOYRwKWwiQBoWSDiTMo/Xi29jUnn4BXfI2px2DTXwc22LKtLAgTRjP+qbU6 3Y0xnQN29UGDbYgyyK51DW3H0If2a3JNsheAAK+Xc9baj0LGIc8T9uiEWHBnCH+RdhgATnWW GKdDegUR5BkDfDg5O/FISymJBHx2Dyoklv5g4BzkgqTqwmaYzsl8UxZKvbaxq0zbehDda8lv hFXodNFMAgTLJlLuDYOGLK2AwbrS3Sp0AEbkpdJBb44qVlGm5bApZouHeJ/+n+7r12+lqdsA EQEAAcLAdgQYAQgAIAIbDBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftOH6AAoJEGgNwR1T C3ojVSkIALpAPkIJPQoURPb1VWjh34l0HlglmYHvZszJWTXYwavHR8+k6Baa6H7ufXNQtThR yIxJrQLW6rV5lm7TjhffEhxVCn37+cg0zZ3j7zIsSS0rx/aMwi6VhFJA5hfn3T0TtrijKP4A SAQO9xD1Zk9/61JWk8OysuIh7MXkl0fxbRKWE93XeQBhIJHQfnc+YBLprdnxR446Sh8Wn/2D Ya8cavuWf2zrB6cZurs048xe0UbSW5AOSo4V9M0jzYI4nZqTmPxYyXbm30Kvmz0rYVRaitYJ 4kyYYMhuULvrJDMjZRvaNe52tkKAvMevcGdt38H4KSVXAylqyQOW5zvPc4/sq9c= In-Reply-To: <20240423115053.4490-1-namcao@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Level: X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_TWELVE(0.00)[17]; FREEMAIL_TO(0.00)[linutronix.de,intworks.biz,ffwll.ch,gmx.de,redhat.com,vger.kernel.org,lists.freedesktop.org]; FREEMAIL_ENVRCPT(0.00)[gmail.com,gmx.de]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[suse.de,linutronix.de,gmail.com,oracle.com,intel.com,vger.kernel.org]; MID_RHS_MATCH_FROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email] X-Spam-Score: -2.79 X-Spam-Flag: NO Hi Am 23.04.24 um 13:50 schrieb Nam Cao: > With deferred IO enabled, a page fault happens when data is written to the > framebuffer device. Then driver determines which page is being updated by > calculating the offset of the written virtual address within the virtual > memory area, and uses this offset to get the updated page within the > internal buffer. This page is later copied to hardware (thus the name > "deferred IO"). > > This offset calculation is only correct if the virtual memory area is > mapped to the beginning of the internal buffer. Otherwise this is wrong. > For example, if users do: > mmap(ptr, 4096, PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, 0xff000); > > Then the virtual memory area will mapped at offset 0xff000 within the > internal buffer. This offset 0xff000 is not accounted for, and wrong page > is updated. > > Correct the calculation by using vmf->pgoff instead. With this change, the > variable "offset" will no longer hold the exact offset value, but it is > rounded down to multiples of PAGE_SIZE. But this is still correct, because > this variable is only used to calculate the page offset. > > Reported-by: Harshit Mogalapalli > Closes: https://lore.kernel.org/linux-fbdev/271372d6-e665-4e7f-b088-dee5f4ab341a@oracle.com > Fixes: 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct") > Cc: > Signed-off-by: Nam Cao Reviewed-by: Thomas Zimmermann Thank you so much. I'll take care of merging the patch later this week. Best regards Thomas > --- > v2: > - simplify the patch by using vfg->pgoff > - remove tested-by tag, as the patch is now different > > drivers/video/fbdev/core/fb_defio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c > index 1ae1d35a5942..b9607d5a370d 100644 > --- a/drivers/video/fbdev/core/fb_defio.c > +++ b/drivers/video/fbdev/core/fb_defio.c > @@ -196,7 +196,7 @@ static vm_fault_t fb_deferred_io_track_page(struct fb_info *info, unsigned long > */ > static vm_fault_t fb_deferred_io_page_mkwrite(struct fb_info *info, struct vm_fault *vmf) > { > - unsigned long offset = vmf->address - vmf->vma->vm_start; > + unsigned long offset = vmf->pgoff << PAGE_SHIFT; > struct page *page = vmf->page; > > file_update_time(vmf->vma->vm_file); -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)