From nobody Thu Aug 29 09:04:08 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 4Wvb1n0p1bz5Mb85; Thu, 29 Aug 2024 09:04:13 +0000 (UTC) (envelope-from meloun.michal@gmail.com) Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 4Wvb1m6DPWz4DNp; Thu, 29 Aug 2024 09:04:12 +0000 (UTC) (envelope-from meloun.michal@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-428e1915e18so3428405e9.1; Thu, 29 Aug 2024 02:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724922251; x=1725527051; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=Ie1l6zB59PV1FsKJ02copGSpO2j7unYz35K1pLMWyMQ=; b=DnkgINKITpUsxicLztMTwPdbH6d+hDoCA5qkcvQ+vkwOGU4mdHkjRQhA3XroqfDLfS oyXB4Din3EOLEowpCyRJsUzijBx37So6GdW6vfUV8wum2LVt3HKA/a50+x9LRSX6Vl+4 ATsykNH+q4yFMIXABS2FBU11SbvRVBG5WVt3Wc9Vo169JTG6n3+9oC4bxTXZSYgyiOED kBR2w3Sv3vnNZ92k5d9rRnnnGF4LNSDstGRRXBZNBE3pUO8SMnM4Boh1mSyE+Y97Wfid VUfJ33ByafvbKq/zLNujThkR9Tf9WViltYHYzGSciNm6pxxGss/LDMqZuq1UayGCAEag gQbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724922251; x=1725527051; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ie1l6zB59PV1FsKJ02copGSpO2j7unYz35K1pLMWyMQ=; b=uojA3QuQb/GZiJQuJbBU63YZd5v7Aq5c6DVc7GzlOiCxeeUfgx1QNKW0rnXNpeQ35f 3gpEYWMJHhZS1XPznJ/emP4St1hTgoF2BOE5a91Man3X39jSDTpjol5crB+w0kCgQ/5L HzUqqYFi+WqGEFsOGcEqIp/0T9JNfaLUKYXp0RKaM1GyFfOuc8FDzplgsG5WFfm+Z1qH eZxQR9uqpmHOiq0ujlsOYPsVpf8RTuR0fxhqLgzwItjt6oCyYRZnvjP9xHG8g3MHrrP+ X2WyarVsoUn9K+Uc2qn4HWJNEfNMti2gv1C8dFbyDkmW1NIXpZDtZLvZk/JNCPkb2pua GWwA== X-Forwarded-Encrypted: i=1; AJvYcCUSUtZiyHEgwYxkEcrKmrfQHdaHwApXMrYwybSKiNCurFEBhYkqRcHa7uj63BXkbKk663hHUo/c8k+iMwJOhQ==@freebsd.org, AJvYcCVk6sOVsEV7+2kDlAYuK0E85dNf0SxU+xAK6ZgjPBJSHsM7WqQt7CGj6XZCocjQoWG83eazxwE=@freebsd.org, AJvYcCXRawABGvc4dBRP4NfNJ1+KDTM40IuR8VgZPRZVuNcjItjPz6fvyRcAaKV1PTjeF6tvXQDdEDg=@freebsd.org, AJvYcCXa7mZExzw6PcmF2YjLd6k8VZHTiuFcR6+QnQVm7D9XA3TPl7vJ6ruwZLE2lo3BAp7ex759KZlD+mJUNMg=@freebsd.org X-Gm-Message-State: AOJu0YxU48FO23+qIP+0bupQJTmlcetEiecLS0mMAhHHzXb+XxhdObyK WPyAx5HgYRVjncC4FFIo8wI4EKKEB2+PsKetC0KSlnP+QEGaAb3H X-Google-Smtp-Source: AGHT+IH6uQcnkhflEqPdBKfwLpR3cwPuRMhEek9INbt9ovKcCHonLOrU6bHSOzIpg7VGP7FefyqjUA== X-Received: by 2002:a05:600c:a49:b0:426:51ce:bb14 with SMTP id 5b1f17b1804b1-42bb27a2863mr12256985e9.30.1724922250071; Thu, 29 Aug 2024 02:04:10 -0700 (PDT) Received: from ?IPV6:2001:67c:14a0:5fe0:dc9d:8b84:f911:72d3? ([2001:67c:14a0:5fe0:dc9d:8b84:f911:72d3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6a10353sm10149345e9.1.2024.08.29.02.04.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Aug 2024 02:04:09 -0700 (PDT) Message-ID: Date: Thu, 29 Aug 2024 11:04:08 +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 Subject: Re: security/nss targeting armv7 tries to compile armv8-a source code: nss/lib/freebl/aes-armv8.c To: Mark Millard , "gecko@freebsd.org" , FreeBSD ARM List , FreeBSD Mailing List Cc: Tomoaki AOKI , Brooks Davis References: <4C7FBDDC-35E8-46E2-A424-58F5779199F8.ref@yahoo.com> <4C7FBDDC-35E8-46E2-A424-58F5779199F8@yahoo.com> Content-Language: en-US From: Michal Meloun In-Reply-To: <4C7FBDDC-35E8-46E2-A424-58F5779199F8@yahoo.com> 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: 4Wvb1m6DPWz4DNp On 29. 8. 2024 9:48, Mark Millard wrote: > nss/lib/freebl/Makefile has: > > ifeq ($(CPU_ARCH),arm) > $(OBJDIR)/$(PROG_PREFIX)aes-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a -mfpu=crypto-neon-fp-armv8 > $(OBJDIR)/$(PROG_PREFIX)gcm-arm32-neon$(OBJ_SUFFIX): CFLAGS += -mfpu=neon > endif > > but targeting -mcpu=cortex-a7 (an armv7) results in the likes of: > > cc -o FreeBSD15.0_OPT.OBJ/FreeBSD_SINGLE_SHLIB/aes-armv8.o -c -std=c99 -O2 -gline-tables-only -pipe -mcpu=cortex-a7 . . . . -march=armv8-a -mfpu=crypto-neon-fp-armv8 aes-armv8.c > cc: warning: ignoring extension 'sha2' because the 'armv7-a' architecture does not support it [-Winvalid-command-line-argument] > cc: warning: ignoring extension 'aes' because the 'armv7-a' architecture does not support it [-Winvalid-command-line-argument] > aes-armv8.c:14:2: error: "Compiler option is invalid" > 14 | #error "Compiler option is invalid" > | ^ > > from nss/lib/freebl/aes-armv8.c: > > . . . > #include "secerr.h" > #include "rijndael.h" > > #if ((defined(__clang__) || \ > (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ > (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8)))) && \ > defined(IS_LITTLE_ENDIAN)) > > #ifndef __ARM_FEATURE_CRYPTO > #error "Compiler option is invalid" > #endif > > #include > . . . > > (The example happens to be for 3.103 .) > > Seems odd to me to have armv7 targeting have any dependency on > armv8 encoded instructions that from well after armv7 was > defined. (Even if the goal is to have the processor reject the > instructions.) > The short answer is that nss works fine (compiled with default options). The longer story is that nss dynamically determines the optimal/fastest implementation of various cryptographic routines. Because of this, you need to compile all versions - basic, using neon, or using 32-bit armv8 encryption instructions (sha2, aes)... Passing -mcpu or -march will break everything. This is probably a small problem with nss make (and there is a question what the expected behavior is), but the actual impact of this bug for freebsd users is imho close to zero.. Michal Meloun > > Note: I ran into this trying to see if I could build www/firefox > in a armv7 jail on a aarch64 that supports armv7 code. BE_WASM > for llvm*'s may be a waste of resources if armv7 based builds > are just not going to work. (I do not normally build firefox.) > > === > Mark Millard > marklmi at yahoo.com > >