From nobody Tue Jul 23 17:46:51 2024 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WT4My1FK4z5SJKg; Tue, 23 Jul 2024 17:46:54 +0000 (UTC) (envelope-from melounmichal@gmail.com) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WT4Mx6Zr7z4lwV; Tue, 23 Jul 2024 17:46:53 +0000 (UTC) (envelope-from melounmichal@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-426636ef8c9so41805895e9.2; Tue, 23 Jul 2024 10:46:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721756812; x=1722361612; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:reply-to:user-agent:mime-version:date:message-id:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=T/OxNgsLkcDjtcabClmbDUS6GHlRL4lIOJ6tDCdO+6M=; b=ebx7omKUmi7Ib6FZbmvTJEGj9l8rZhofgkqFZEcg27OlmGXtXanto5IGZwPCjTr+Ci DTjGSOYmo/6Di+lGZiHVa9ErayL2lFuTgCWw4tdU/TvDolILSKnNrEpPfeNnMubDauIM 89uU3UjL1yYRqz/0PIVeHUNooT4rRaydXKFef5mPp7U1NcNNsFYI0ArBIuCDD3b7tc2V cWVvyUm+QhjDmx7/3VFE94fCaxs65PNvU2TSzAwcBZxZBbCQKzbb4dzLY//V6czbYoAL 4UNaUBs0+14kmFxvvPa7IVRLI5aHSPNDwoU9CLTbMi2Ynbcf992VgMU7aqsnOBONBg88 EFWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721756812; x=1722361612; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:reply-to:user-agent:mime-version:date:message-id:from :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=T/OxNgsLkcDjtcabClmbDUS6GHlRL4lIOJ6tDCdO+6M=; b=d6o2HJWTS/FRwn5clM1wksqWV3AREXCZe6EfMMiIEe6hBUo9FHGWS1ZC/4xR3OTVI3 GpPSxxHKq7ExkHpTT6Oa5OhbYIkjFXhU7JkPh/uiDv254YqqMvjsRtiYS3bgbpHBhmgk W/IIgjCA5nj+N3Hr6oERERUgz/qhi4w6VahGMjk5uxylfueRAABlyWDTXmTcpAnzrFH4 8J0DLFi/JY5b7j3Ri5XXHFdRM9tWmSGg7gnWOEXc/lvsUUuiZ9dTKPhF7x4DOXltogj0 Lhi4hGwOo/2MqNuFZbgjjaZAKeHstECYg3QgLBoDTjqLHZSqsKpqwliQPZW4b2NI5IV+ H+AQ== X-Forwarded-Encrypted: i=1; AJvYcCWTQn9K1UifCK5PrQEr7iHoiGXWuu46EiYFfYSWG5h7ROtdkBzc1uEZzooAHdjffHRGt76qjkm4YVwJYVXT7v76f+36h4zdagMT88N2We1LjZBjoCLy8S4+wG8vdsaLPECsemUF X-Gm-Message-State: AOJu0YxJ2dwF96if0t3fgCUuIPyN+U2er2UNmGQl2R4D8TeYnUaWtjCc bkXFL4QS2OxvuSlJcIl82SF/maR4t6ELxrLkCZStpMyCSvMVyjEF09JNAdSA X-Google-Smtp-Source: AGHT+IHvAIHzW/78+lvjhwenOnhTP45EJu9CXBEUesogv7ExlBYkEexSDswDU2nPeJSirBq/RFt8wQ== X-Received: by 2002:a05:600c:4f4d:b0:425:7796:8e2c with SMTP id 5b1f17b1804b1-427dc520498mr64200175e9.12.1721756812415; Tue, 23 Jul 2024 10:46:52 -0700 (PDT) Received: from ?IPV6:2001:67c:14a0:5fe0:55eb:52e:1154:1d18? ([2001:67c:14a0:5fe0:55eb:52e:1154:1d18]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427e29d11d5sm116168975e9.38.2024.07.23.10.46.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jul 2024 10:46:51 -0700 (PDT) From: Michal Meloun X-Google-Original-From: Michal Meloun Message-ID: <6a969609-fa0e-419d-83d5-e4fcf0f6ec35@freebsd.org> Date: Tue, 23 Jul 2024 19:46:51 +0200 List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: mmel@freebsd.org Subject: Re: armv7-on-aarch64 stuck at urdlck To: Konstantin Belousov Cc: Mark Millard , FreeBSD Current , "freebsd-arm@freebsd.org" References: <724db42b-5550-4381-8277-2971e6b3e8f1@freebsd.org> <86185657-e521-466b-89e2-f291aaac10a6@freebsd.org> <0EF18174-8735-46A4-BD71-FFA3472B319F@yahoo.com> <33251aa3-681f-4d17-afe9-953490afeaf0@gmail.com> <0DD19771-3AAB-469E-981B-1203F1C28233@yahoo.com> Content-Language: cs, en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4WT4Mx6Zr7z4lwV On 23.07.2024 11:36, Konstantin Belousov wrote: > On Tue, Jul 23, 2024 at 09:53:41AM +0200, Michal Meloun wrote: >> The good news is that I'm finally able to generate a working/locking >> test case. The culprit (at least for me) is if "-mcpu" is used when >> compiling libthr (e.g. indirectly injected via CPUTYPE in /etc/make.conf). >> If it is not used, libthr is broken (regardless of -O level or debug/normal >> build), but -mcpu=cortex-a15 will always produce a working libthr. > > I think this is very significant progress. > > Do you plan to drill down more to see what is going on? So the problem is now clear, and I fear it may apply to other architectures as well. dlopen_object() (from rtld_elf), https://cgit.freebsd.org/src/tree/libexec/rtld-elf/rtld.c#n3766, holds the rtld_bind_lock write lock for almost the entire time a new library is loaded. If the code uses a yet unresolved symbol to load the library, the rtl_bind() function attempts to get read lock of rtld_bind_lock and a deadlock occurs. In this case, it round_up() in _thr_stack_fix_protection, https://cgit.freebsd.org/src/tree/lib/libthr/thread/thr_stack.c#n136. Issued by __aeabi_uidiv (since not all armv7 processors support HW divide). Unfortunately, I'm not sure how to fix it. The compiler can emit __aeabi_<> in any place, and I'm not sure if it can resolve all the symbols used by rtld_eld and libthr beforehand. Michal