From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A133E1AA7AB for ; Sat, 2 Nov 2024 21:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730584748; cv=none; b=O910yNlDSLZKl1z67rfPgKEkBq3AWbP7FfReR+7iu7FE9CcztD8Vkp2WRSlH0MBM90X68F1Pm4PEAyrOPGwhN2JNkU/kyaMmlKb9CottEEjTWVWbq8ES8tJE5VZ3hZcnBWzeWPq3s9VG//ajerdQDuiyiaa4nPqwDt1oK0GtSKQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730584748; c=relaxed/simple; bh=iU/GFh5PxfwqsQ8XPruyq3jiA+Rzu6wWlnuHQDY2Z64=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=l8NNw//92STOqj+AqpXvpMaRiPEtI8vzfecuHaroZ/ntJOJtXvqiN6bp6udelGqW2C/8SIlgMvzJk3ErQaGs09WaoxPm2yfN2TbJx1ju/ZtoY1F69z2B6FiLVLQekEVXIyZtmp21R6/zvRwbmYYZiGiUeZx+HbwDxUnRh5OVF90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Crg+CbP+; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Crg+CbP+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730584745; h=from:from:reply-to:subject:subject: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; bh=ABp4GNt9hr2dQL86JdaUvGuLhtctNBvZysLpO4JDoJ8=; b=Crg+CbP+zrh9PCBsoJ8MrEb0R7kwJGZZluhSU/iQHx8TrMilaxiHko7ZV9UWVgx1MrL78s LhzYkbhV4VxeF+qWT1w+vfoDRiEqVkKmiTiDe7vd/JfmeZI+vrb7aw+kTu2qQxj9sdbJSP Lg1CEmYfR71x13n+nEdkCfiORBwBFjo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-400-CdByBlUuNH645wZNXiVUfg-1; Sat, 02 Nov 2024 17:59:00 -0400 X-MC-Unique: CdByBlUuNH645wZNXiVUfg-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8CE5019560B1; Sat, 2 Nov 2024 21:58:52 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.45.225.77]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E66E919560A3; Sat, 2 Nov 2024 21:58:45 +0000 (UTC) From: Florian Weimer To: =?utf-8?Q?Andr=C3=A9?= Almeida Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , Arnd Bergmann , sonicadvance1@gmail.com, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, linux-api@vger.kernel.org, Nathan Chancellor Subject: Re: [PATCH v2 0/3] futex: Create set_robust_list2 In-Reply-To: <20241101162147.284993-1-andrealmeid@igalia.com> (=?utf-8?Q?=22Andr=C3=A9?= Almeida"'s message of "Fri, 1 Nov 2024 13:21:44 -0300") References: <20241101162147.284993-1-andrealmeid@igalia.com> Date: Sat, 02 Nov 2024 22:58:42 +0100 Message-ID: <87ldy170x9.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 * Andr=C3=A9 Almeida: > 1) x86 apps can have 32bit pointers robust lists. For a x86-64 kernel > this is not a problem, because of the compat entry point. But there's > no such compat entry point for AArch64, so the kernel would do the > pointer arithmetic wrongly. Is also unviable to userspace to keep > track every addition/removal to the robust list and keep a 64bit > version of it somewhere else to feed the kernel. Thus, the new > interface has an option of telling the kernel if the list is filled > with 32bit or 64bit pointers. The size is typically different for 32-bit and 64-bit mode (12 vs 24 bytes). Why isn't this enough to disambiguate? > 2) Apps can set just one robust list (in theory, x86-64 can set two if > they also use the compat entry point). That means that when a x86 app > asks FEX-Emu to call set_robust_list(), FEX have two options: to > overwrite their own robust list pointer and make the app robust, or > to ignore the app robust list and keep the emulator robust. The new > interface allows for multiple robust lists per application, solving > this. Can't you avoid mixing emulated and general userspace code on the same thread? On emulator threads, you have full control over the TCB. QEMU hints towards further problems (in linux-user/syscall.c): case TARGET_NR_set_robust_list: case TARGET_NR_get_robust_list: /* The ABI for supporting robust futexes has userspace pass * the kernel a pointer to a linked list which is updated by * userspace after the syscall; the list is walked by the kernel * when the thread exits. Since the linked list in QEMU guest * memory isn't a valid linked list for the host and we have * no way to reliably intercept the thread-death event, we can't * support these. Silently return ENOSYS so that guest userspace * falls back to a non-robust futex implementation (which should * be OK except in the corner case of the guest crashing while * holding a mutex that is shared with another process via * shared memory). */ return -TARGET_ENOSYS; The glibc implementation is not really prepared for this (__ASSUME_SET_ROBUST_LIST is defined for must architectures). But a couple of years ago, we had a bunch of kernels that regressed robust list support on POWER, and I think we found out only when we tested an unrelated glibc update and saw unexpected glibc test suite failures =E2=80= =A6 Thanks, Florian