Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4009714ybl; Tue, 21 Jan 2020 11:08:26 -0800 (PST) X-Google-Smtp-Source: APXvYqx03yIb9EdNtSpArA9SI8YCTzYgo6EciIuokZVrhteNjm/4ZFW4GkP8ykK1gKqsiZTjg7hI X-Received: by 2002:a9d:7:: with SMTP id 7mr4525304ota.26.1579633706461; Tue, 21 Jan 2020 11:08:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579633706; cv=none; d=google.com; s=arc-20160816; b=kjlsSYZZcGCZwEHZ2t6EjWud3AP/Bkxbrt3bWFP6iLSVOqJKdKkQrPM5XO2VTjOCBd CSYVMCUvv77MjuAlAxA/IbiKKkUTqbalPMaW0Ec8S1GF65w7t2gizjiO2IMzFFZKc+MX bqwwy18Dj0jNPCkfk7n6UW41k1bvzbqc7g7gQtvmrDV2QVT8qRg5rTQ2wj6hkMjareXI iZdNqUjr1s7F6ys+OmGDjsZ7kkBmVuLMozfmowZdYGqMtFTtl0nvIWfu5H1ZebojmpyB eFe5gAB8AxAOUkzdwXm38hkpA20d8j3Xyfm4wkEZBjtQFXxZG/HIrJWf2bNfihLB7Ow4 ryQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=boGt6rcTHqDBd2dBqMthWov1ekDV3upnCebsaeiD+y8=; b=CJBYO/Yq0v3lhbbp35l5ZJ7pAXMWpmEaOxc6Vv18ruoDoaO3lsBCciINt0NlCn/ntp lfL8KLTeOCrT9UiThMSrWMZO61G4VNmJecc72RmkzdePJUJ6ZRNpR6/vt3lBsiNTaf2K sutoO9KQvEOY+y054hn/j1OmoBPqhlFA48vjt0Ak0aSY/PTBvNbs3CMeYs1YHx++PlH4 HCRKDGJaajRBiplSJPyneO1uKeY0tsiqdQ07e2jk0KH9r6qRIav1E9kKDCsRf7P5zQK1 9xTUx8cE11b4TpfSpLTbR2nTtawEwmuaUkADG9NLSD6FuYytMNgFcYFLMDGPuoSpu/IG 6KAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t125si20123079oih.183.2020.01.21.11.08.14; Tue, 21 Jan 2020 11:08:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729277AbgAUTFq convert rfc822-to-8bit (ORCPT + 99 others); Tue, 21 Jan 2020 14:05:46 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:59401 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729081AbgAUTFq (ORCPT ); Tue, 21 Jan 2020 14:05:46 -0500 Received: from mail-qk1-f179.google.com ([209.85.222.179]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPSA (Nemesis) id 1MJWgK-1jDhaK2DCy-00JqZz for ; Tue, 21 Jan 2020 20:05:44 +0100 Received: by mail-qk1-f179.google.com with SMTP id v195so3692498qkb.11 for ; Tue, 21 Jan 2020 11:05:44 -0800 (PST) X-Gm-Message-State: APjAAAXjnlpVaOOngHd2BX/VfCuLgpkhTECWffP0s0OJbOyAy9mdKIQY Khr1czL8Sy1J1/l/dvMaT8baVaThS0VrPpsgQtA= X-Received: by 2002:a05:620a:a5b:: with SMTP id j27mr6089006qka.286.1579633543424; Tue, 21 Jan 2020 11:05:43 -0800 (PST) MIME-Version: 1.0 References: <20200121114553.2667556-1-arnd@arndb.de> <20200121125546.GA71415@bogon.m.sigxcpu.org> <1971902c68ff805ee0b4a66f558afe06e6edf0c5.camel@pengutronix.de> In-Reply-To: <1971902c68ff805ee0b4a66f558afe06e6edf0c5.camel@pengutronix.de> From: Arnd Bergmann Date: Tue, 21 Jan 2020 20:05:27 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/etnaviv: only reject timeouts with tv_nsec >= 2 seconds To: Lucas Stach Cc: =?UTF-8?Q?Guido_G=C3=BCnther?= , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter , Philipp Zabel , Sam Ravnborg , Rob Herring , Emil Velikov , The etnaviv authors , dri-devel , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Provags-ID: V03:K1:A7s4Lt5X0zCzndHl88Iw7InqVkh84eNdaRaOzFUIVnRgzU4tPMO UjFnTXDSvB7wk/J/g4RhL0QsmHhCZ8LbOZeuHIKE8m5EGVMHYVeSNhNVpl79m8Hy0/Vr1N4 q60HMFaA5IusYnUXqGw+z6YVEvMRqZJpMM9t0eawCfqeh9a1uahlGkHwn5n3DWQxZZ3RCyF zZZk0Qy/OuRB9G7MLTI4w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Pym50AB6Nlo=:4xJilspjlsRR2I9O+dfSpE Cm+Z22oJDloqugpzfpIT/HdIAR8Ruyd6+FZJvtKcADfzpPniO3jwdUfmDbA2I4oHAJ3GBiyKF d6sK5EDNY7Wb25FrvITK7BlKm9VJrUrX3dODQP0ekY9yUE64aASaDRYK4gz4piAbLuzRZCW+O RLmOlZ4jHgIBhxJNucG22wA8qXzqv7NBupqOfKE7UDeXHFzX4zFiSVHFphUmFN6RWfqQ3NqkW hyRsd28h/2wCOv0N78VL5tTnocTQu6jg6DEuH9WCPQ9FH1x6m71rag34g5nJs5fBHJp+t8a+T VUI+E+dc+YqmeLCaWMtJhL3ZMypHLVpiLpYXF2UmLGeoOkQ8k2/LF+GPQZl8xT6Oan+M895fS E+qSyvIYjqoAYSfZZC//h4jKnja5dMaRlcAw30WPjk/vTTJJ69TgLdTdUNbhvJmy0IWAsBLgU 1+hfzMAQ56nvPSSMbZ+PY7297jh7uz4hBzfAsNp69gX9d0y7AMcvh1rJfmy7hkbWcxD9BZGZu E+yKoI0dZ3TDrsYYzq0BChxrCZ4HKnLljuF8kWyp78v0kGJwH5EmT9koJ+UlgsQAvR2apffEE j+V/TQG53mUvmrrKVvxXHqg6cxWhZ+QLaUXHhZP3fMEqXNYf6AvpSUhfZXqMczJRByoZ4pNsJ rFVdWOQRPVtT3juCEsMdlt1v3G4wGs0YBNMe+7iLueE7VptHR8sJ/s7Fv477GA/EIt0iTufx7 DAM8ixHkIkaQAxhxZBwHEx+FzVP2mG+8IGtw63Jx4LWdzH5hndD6/YYDRUG9dLT8ONN5DvIln 6Crr6bsQshQphxwjJ+ncHZJDftZ8KUOa3f29/wxSlALfIeQiLKdNw5zVFYMxVRB3bhwJ+7Ysq spQZB/Br1WPcrtQadgyA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 21, 2020 at 5:10 PM Lucas Stach wrote: > > Hi Guido, > > On Di, 2020-01-21 at 13:55 +0100, Guido Günther wrote: > > Hi, > > On Tue, Jan 21, 2020 at 12:45:25PM +0100, Arnd Bergmann wrote: > > > As Guido Günther reported, get_abs_timeout() in the etnaviv user space > > > sometimes passes timeouts with nanosecond values larger than 1000000000, > > > which gets rejected after my first patch. > > > > > > To avoid breaking this, while also not allowing completely arbitrary > > > values, set the limit to 1999999999 and use set_normalized_timespec64() > > > to get the correct format before comparing it. > > > > I'm seeing values up to 5 seconds so I need > > > > if (args->timeout.tv_nsec > (5 * NSEC_PER_SEC)) > > > > to unbreak rendering. Which seems to match what mesa's get_abs_timeout() > > does and how it's invoked. > > I have not tested this myself yet, only looked at the code. From the > code I quoted earlier, I don't see how we end up with 5 * NSEC_PER_SEC > in the tv_nsec member, even if the timeout passed to get_abs_timeout() > is 5 seconds. I can think of two different ways you'd end up with around five seconds here: a) you have a completely arbitrary 32-bit number through truncation, which is up to 4.2 seconds b) you have the same kind of 32-bit number, but add up to another 999999999 nanoseconds, so you get up to 5.2 seconds in the 64-bit field. It could of course be something completely different. If this works correctly today, we may need to allow any 64-bit input for the nanoseconds and do an expensive 64-bit div/mod in the kernel for normalization rather than the cheaper set_normalized_timespec64() from my patch. Arnd