From owner-freebsd-emulation@FreeBSD.ORG Sun Aug 19 01:43:34 2012 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B434106566B; Sun, 19 Aug 2012 01:43:34 +0000 (UTC) (envelope-from meowthink@gmail.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id E64E18FC0A; Sun, 19 Aug 2012 01:43:33 +0000 (UTC) Received: by obbun3 with SMTP id un3so10175055obb.13 for ; Sat, 18 Aug 2012 18:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kppnjCb3ISk/qNzMbwcdcjj2mD1BKjRT+5GBNMjYCUk=; b=aTeYSDOlEdqe2HfQhI5F6mP3bHiRkfd7s7NNpOUoGuLuPdIW44rBtwuwGWfYacIylh lzBNkGnZBpynMyGj9CG1OzRW7C639JQHx2vHNKInhiyhpOEAeqPSJcPKjVUMUpHnaiwf IjkXA7mnHRLFAPgQhB+GvLZDU6koMIAl8NpOjQelKrd1egsMuk122j98Zs5HW20GrkJi 1lnYXvf5XEW1tpcvGeuG34xpnclzRxftheEalSIh8J5p5L2cplsRZ/mEZlr9nn6g7sQ4 xvDKeLSk6IGuW7/vgg1pjTPJnJFRQuc7SR8012IosWfenn0Q1kM0f8V/AfxQX+v4ET+0 qNpw== MIME-Version: 1.0 Received: by 10.50.56.236 with SMTP id d12mr5962913igq.66.1345340612633; Sat, 18 Aug 2012 18:43:32 -0700 (PDT) Received: by 10.64.51.200 with HTTP; Sat, 18 Aug 2012 18:43:32 -0700 (PDT) In-Reply-To: <20120818190225.GF33100@deviant.kiev.zoral.com.ua> References: <20120818190225.GF33100@deviant.kiev.zoral.com.ua> Date: Sun, 19 Aug 2012 09:43:32 +0800 Message-ID: From: Meowthink To: Konstantin Belousov Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-x11@freebsd.org, freebsd-emulation@freebsd.org Subject: Re: [CFT]Patch for dri / drm interoperability i386 world / amd64 kernel X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Aug 2012 01:43:34 -0000 On Sun, Aug 19, 2012 at 3:02 AM, Konstantin Belousov wrote: > On Sat, Aug 11, 2012 at 09:25:09AM +0800, Meowthink wrote: >> Hello all, >> >> So long FreeBSD's DRI implementation lacks of i386/amd64 >> interoperability, as discussed [0] [1]. This breaks wine, linuxulator >> etc. drawing using DRI-based OpenGL. >> Paul Mackerras et al. actually did that part for Linux implementation, >> so I simply translated their work to FreeBSD. Due to my poor >> programming skills, there's some limitations: >> 0. I tried to split compatible codes into separate files, like under >> Linux. But as a result of the difference between FreeBSD and Linux, >> the code is integrated in a "#include ...ioc32.c" form which is not >> so elegant. >> 1. For same reason, struct drm_driver_info has to be changed. > I fixed 0 and 1 to my liking and committed the patch. > > Thank you. > >> 2. There should be some assertions if a 64-bit pointer failed to fit >> in a 32-bit space. Linux implementation didn't do this either, but >> they're guaranteed by user-space ioctl structures. This may result >> unstable under heavy load. > I am not sure what do you mean exactly. Can you elaborate, please ? Excuse me for my poor expression. What I mean is, for example, line 177-180 in sys/dev/drm2/drm_ioc32.c reads: handle = map.handle; m32->mtrr = map.mtrr; m32->handle = (unsigned long)handle; drm_map.handle will be a 64-bit pointer under 64-bit mode, so I wonder this needs verification? But Linux version of drm didn't verify: if (__get_user(m32.offset, &map->offset) || __get_user(m32.size, &map->size) || __get_user(m32.type, &map->type) || __get_user(m32.flags, &map->flags) || __get_user(handle, &map->handle) || __get_user(m32.mtrr, &map->mtrr)) return -EFAULT; m32.handle = (unsigned long)handle; if (copy_to_user(argp, &m32, sizeof(m32))) return -EFAULT; In this case, drm_addmap(drm_bufs.c) guarantee the handle always a 32-bit integer, with 0s only in high 32 bits on amd64. But I'm not very sure that all kinds of this pointer operations, esp. those buffer-related address ops can guarantee a 32-bit pointer in all cases. Thanks for your review. Meowthink