From nobody Sun Nov 26 05:09:50 2023 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 4SdGxR1dJVz521pt for ; Sun, 26 Nov 2023 05:10:03 +0000 (UTC) (envelope-from bakul@iitbombay.org) Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SdGxR18tmz3bJ4 for ; Sun, 26 Nov 2023 05:10:03 +0000 (UTC) (envelope-from bakul@iitbombay.org) Authentication-Results: mx1.freebsd.org; none Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-285be6134ecso2692a91.2 for ; Sat, 25 Nov 2023 21:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20230601.gappssmtp.com; s=20230601; t=1700975402; x=1701580202; darn=freebsd.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=9xNWr9/pFW2Ed00t/1PACQeEqQd0Vhs83sTkisJwx/Q=; b=1LdFN7jzA5oycAK2O4AQY2r3Kk7qBr0o7SDrtGzh0wTLCAYZWmBZ4DB4ICvq+jzCLU ECrMvC/y5ZUou2nE6L5obMtBPSSiRZpiEMT7KT/tP4LJ+tpG6HYWUNLdmznNbxdvQ0fG 7Lk5A77g7vIyFlWznW4m1pQz5WDZwlvTFOC5/tVeMOKX2kTE6ehRtb95LK9DLtYtuVkN IYBkl4PasIR7AI8bhbTct+0rzNaS9iX55s/CFk44OUmBVzxMh78h0hTYhcK9+c4n07JG ka/SxOJpRJtIvkDYICYLrN7tHpny7fnQE18jyocnG3nB5mY1EX6N9ZPHsKMvtDL1k16r ifYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700975402; x=1701580202; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9xNWr9/pFW2Ed00t/1PACQeEqQd0Vhs83sTkisJwx/Q=; b=ILtkaSGn0neD2xv41mB6xH9MlWr/cieWXywre9acK/USdoyARKlsoxv/5sTekb7CO8 uRshr8j8S9x4aSnPmGBtDiq270S5R8w6oQBhQyae2rllKhPnwV5i9pG2eoTex0dUcFty VI4P0Xdi79avFcRU8v2Q67XPbai+k96ANCqJ0Y8eCyLFMZ96WdeCXCNo+zPIha+QGQOm b9qFKMzSM0RlBi6ffHUBzn+zR1Ro2A0AWzA9pcnKTNJgonV/evoXYrsLUjQTL4jdLWu3 iT9MC7gxPAY0BNwNXNIO4yvLWwjMNeRrOSBgWyfANBdLwJLy+ecLVA26WysVOueuV7kT TRmA== X-Gm-Message-State: AOJu0YzrHhPB1ZjlID4sxg+uDGoEzYLxYkqjz2X5UGwmY/u2BihbNbWE nT0tGTRuMpIZY1+M2+a880LuZw== X-Google-Smtp-Source: AGHT+IF+13hK06FUAIL2m5FKQ4fzrSeUOF5Pm9vtICYkGObIxIc8QiJd0Td+Zs/XJ9umbGRjIP09tg== X-Received: by 2002:a17:90b:3e86:b0:285:93f0:b2a7 with SMTP id rj6-20020a17090b3e8600b0028593f0b2a7mr4797897pjb.22.1700975401793; Sat, 25 Nov 2023 21:10:01 -0800 (PST) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id qj8-20020a17090b28c800b00285790ff232sm4267307pjb.32.2023.11.25.21.10.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Nov 2023 21:10:01 -0800 (PST) From: Bakul Shah Message-Id: <4BA4DB2E-859A-427E-85AC-80F8F266C7BE@iitbombay.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6" 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 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) Subject: Re: sbrk Date: Sat, 25 Nov 2023 21:09:50 -0800 In-Reply-To: Cc: Joseph Holsten , "freebsd-arm@freebsd.org" To: Warner Losh References: <2F758BA2-F7F5-4A2C-85CF-6969EE50309C@iitbombay.org> <949f8f16-1219-4f4a-abf6-f9727c95681b@Spark> <5668E8DE-B3B3-408D-978E-C2358A614803@iitbombay.org> X-Mailer: Apple Mail (2.3774.200.91.1.1) 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)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4SdGxR18tmz3bJ4 --Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On Nov 25, 2023, at 8:56=E2=80=AFPM, Warner Losh wrote: >=20 > I see that it also uses tcc, which I coincidentally was looking at in = the cdefs modernization efforts I've been doing. You'll need at least = one patch to cdefs to get even the basics to compile. And three tests = fail (one doesn't matter, one is constructors and dtors and a third = fails to detect out of bounds access). I think only the ctor/dtor one is = going to make things hard for you. I've not looked into any of the test = failures, just a short-coming in cdefs.h since tcc doesn't support = .symver yet. using tcc fails with In file included from /tmp/v_1001/ncpu.2284299819361377756.tmp.c:430: /usr/include/stdlib.h:352: error: ARM asm not implemented. tcc also doesn't pass as many tests as clang on amd64 (unfortunately, as = it is compiles so much faster). Its native compiler is nowhere near = ready. It doesn't work well with the ported tcc on freebsd (I forget the = details now). But if you have any bug fixes I am interested! > sbrk can be faked with mmap of a large area up front with MAP_GUARD = that's then grown or shrunk as new sbrk calls happen and remapped with = MAP_FIXED. The only draw-back is you need reserve enough address space = for all the program's memory needs (like GB of space maybe). The = MAP_GUARD mappings are relatively cheap until it's actually used. Heck, = you can even map SIGSEGV to check to see if you've "overflowed" the area = to make it bigger (I hate that I know this trick, thank you Bourne = shell). I worked around with #define USE_MMAP 1. SIGSEGV to grow the stack -- that was a problem on V7 shell on 68000! = Luckily now that is only fit for old farts discussion on TUHS :-) > Looks fun to play with. Maybe I'd help (but I already have too many = fun and even more un-fun projects). It seems to be so far but I haven't written enough code to find its = gotchas.= --Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 On Nov 25, = 2023, at 8:56=E2=80=AFPM, Warner Losh <imp@bsdimp.com> = wrote:

I see that it also uses tcc, which I = coincidentally was looking at in the cdefs modernization efforts I've = been doing. You'll need at least one patch to cdefs to get even the = basics to compile. And three tests fail (one doesn't matter, one is = constructors and dtors and a third fails to detect out of bounds = access). I think only the ctor/dtor one is going to make things hard for = you. I've not looked into any of the test failures, just a short-coming = in cdefs.h since tcc doesn't support .symver = yet.

using tcc fails = with

In file included = from = /tmp/v_1001/ncpu.2284299819361377756.tmp.c:430:
/usr/include/stdlib.h:352: error: ARM asm not = implemented.

tcc also doesn't pass = as many tests as clang on amd64 (unfortunately, as it is compiles so = much faster). Its native compiler is nowhere near = ready.

It doesn't work well with the ported tcc = on freebsd (I forget the details now). But if you have any bug fixes I = am interested!

sbrk can be = faked with mmap of a large area up front with MAP_GUARD that's then = grown or shrunk as new sbrk calls happen and remapped with MAP_FIXED. = The only draw-back is you need reserve enough address space for all the = program's memory needs (like GB of space maybe). The MAP_GUARD mappings = are relatively cheap until it's actually used. Heck, you can even map = SIGSEGV to check to see if you've "overflowed" the area to make it = bigger (I hate that I know this trick, thank you Bourne = shell).

I worked around with = #define USE_MMAP 1.

SIGSEGV to grow the stack = -- that was a problem on V7 shell on 68000! Luckily now that is only fit = for old farts discussion on TUHS :-)

Looks fun to play with. Maybe I'd help (but I already have too = many fun and even more un-fun = projects).

It seems to be so far = but I haven't written enough code to find its = gotchas.
= --Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6--