ject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NSrsZ0BAbTt25iHUbpOO7sVMEAeZOWBj8i5DxLVKIbc=; b=d3ZvvHC2w3DFlmWWjbi0ucGNk6h/kF3WzTOGXILb2XzpZ5hpn+94fTtJ1IRARBUVb9yi8U ccb15xedgLgwKvga7OZZqlsyMtHvBg1tMin6kTWwLNPBS3taHzN72r2793Yb/H9KXodDEx al2P1zQXsiUCAC2EtTi9xQ0iIUYiWx6et2uG6jmkLzDaOok4uUMYlwYuQq8eE6Vv+HFDIn hPmFWSg1e7dn/rmEVI9ln2G4LheSX9E/zK3zKm7t1Xn8VdOeJ0pdv6p2tqj4L7C5U+auNP pyqfkmqX/7FEUUgRws0ERiHSWm9vlyT1oN+vWrp1b9Fln4y6Eg5iLX5wywEMng== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VtJch0WxXzhjZ for ; Mon, 3 Jun 2024 16:11:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 453GBFgb093465 for ; Mon, 3 Jun 2024 16:11:15 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 453GBFQZ093464 for bugs@FreeBSD.org; Mon, 3 Jun 2024 16:11:15 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 279501] linuxulator: amd64 Global Descriptor Table ABI incompatibility Date: Mon, 03 Jun 2024 16:11:15 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: theron.tarigo@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279501 Bug ID: 279501 Summary: linuxulator: amd64 Global Descriptor Table ABI incompatibility Product: Base System Version: Unspecified Hardware: amd64 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: theron.tarigo@gmail.com Created attachment 251198 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D251198&action= =3Dedit Minimal test of executing 32bit code from 64bit process On amd64, a program may jump between 32bit and 64bit code using far returns= to set the code segment register. The mechanism is OS-dependent since it depe= nds on the layout of the Global Descriptor Table initialized by the kernel. It= is used for example for a 64bit program to utilize 32bit assembly libraries or= for a 32bit compatibility layer implemented using 64bit libraries as with WINE's WOW64. Currently this mechanism is broken in the linux compatibility layer: whereas the program expects a Linux GDT, it is the FreeBSD GDT in effect. Also, Li= nux program code reading the cs register gets different results than expected: = 0x23 vs 0x33 for 32bit, 0x33 vs 0x43 for 64bit. $ yasm -fbin -o test testgdt.asm produces a FreeBSD executable which writes "A", then writes "B", then exits. $ yasm -fbin -o test testgdt.asm -DLINUX -DLINUX_GDT produces a Linux executable with the expected result only when run on Linux x86_64. On FreeBSD it writes "A" before dying with a bus error. $ yasm -fbin -o test testgdt.asm -DLINUX produces an executable which writes the "expected result" only when run on FreeBSD amd64 with linux compatibility. On Linux it writes "A" before dying with a segfault. --=20 You are receiving this mail because: You are the assignee for the bug.=