Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aes_platform.h: add missing ppc64 define #23245

Closed
wants to merge 1 commit into from

Conversation

barracuda156
Copy link
Contributor

Fixes: #23220

@t8m Could you please review this?

P. S. We could get the same effect for macOS by adding __POWERPC__, but that gonna also include BeOS, and I have no idea if related code gonna work there or not. Perhaps __ppc64__ is a better pick.

@openssl-machine openssl-machine added the hold: cla required The contributor needs to submit a license agreement label Jan 9, 2024
@openssl-machine openssl-machine removed the hold: cla required The contributor needs to submit a license agreement label Jan 9, 2024
@t8m t8m added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member triaged: feature The issue/pr requests/adds a feature cla: trivial One of the commits is marked as 'CLA: trivial' tests: exempted The PR is exempt from requirements for testing labels Jan 10, 2024
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Jan 10, 2024
@t8m
Copy link
Member

t8m commented Jan 10, 2024

Hmm, actually we do not use __ppc64__anywhere. Is it possible that _ARCH_PPC is defined even on the 64 bit PowerPC?

If not, we use _ARCH_PPC64 elsewhere in the code instead. Also please note there are other places where we use only defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC) so this might not be a complete fix.

@barracuda156
Copy link
Contributor Author

barracuda156 commented Jan 10, 2024

Hmm, actually we do not use __ppc64__anywhere. Is it possible that _ARCH_PPC is defined even on the 64 bit PowerPC?

If not, we use _ARCH_PPC64 elsewhere in the code instead. Also please note there are other places where we use only defined(powerpc) || defined(ppc) || defined(_ARCH_PPC) so this might not be a complete fix.

@t8m The issue is that neither of these three is defined on Darwin ppc64. What will work is either __ppc64__ or __POWERPC__ (which is equivalent to having both ppc and ppc64 on macOS).

Of course, it is not needed to do in every file, if there are numerous instances; what can be done then is a single OpenSSL-internal define in a general header, something like SSL_PPC32 and SSL_PPC64 or whatever to the same effect, and then just use those in the code. This is how Abseil, NodeJS and multiple other projects deal with the matter (not just for PowerPC, but to avoid numerous complex arch macros).

Notice, by the way, GCC does use __ppc64__ when specifically ppc64 is needed: https://github.com/gcc-mirror/gcc/blob/7de5bb642c1265ff57a009dd889ab435b098bfca/gcc/config/rs6000/rs6000.h#L274-L276
And uses __POWERPC__ when both ppc and ppc64 are meant: https://github.com/gcc-mirror/gcc/blob/7de5bb642c1265ff57a009dd889ab435b098bfca/gcc/config/rs6000/rs6000.h#L202

@t8m
Copy link
Member

t8m commented Jan 10, 2024

Please use __POWERPC__ then. Also please also add it to the similar ifdef in crypto/modes/gcm128.c.

@barracuda156
Copy link
Contributor Author

barracuda156 commented Jan 10, 2024

@t8m Sure, will do. Do we still retain __ppc__ in those instances or it can be dropped? I am not sure if it is used for anything outside of macOS. On the latter as long as __POWERPC__ is used, there is no need to have separate macros for 32- and 64-bit versions. (Obviously, when both are in fact meant; for exclusive cases, if such are there, it is still needed to have __ppc__ for “32 but not 64” and __ppc64__ for “64 but not 32” – unless something else is used to differentiate those.)

@t8m
Copy link
Member

t8m commented Jan 10, 2024

Yeah, __ppc__ can be dropped.

Current PowerPC-related defines omit Darwin ppc64 case.
Use __POWERPC__ in place of __ppc__ + __ppc64__
Fixes openssl#23220

CLA: trivial
@barracuda156
Copy link
Contributor Author

@t8m Done as advised.

@t8m t8m removed the approval: otc review pending This pull request needs review by an OTC member label Jan 10, 2024
@t8m
Copy link
Member

t8m commented Jan 10, 2024

@t8m Done as advised.

I assume you've tried to build it on the Power Mac and the tests passed?

@barracuda156
Copy link
Contributor Author

@t8m Yes originally, let me run again in the form to which we arrived, and confirm. Will be done in a couple of hours.

@barracuda156
Copy link
Contributor Author

@t8m YES, with two instances changed to __POWERPC__, everything passes on G5 when built for ppc64:

--->  Testing openssl3
Executing:  cd "/opt/local/var/macports/build/_opt_PPCLeopardPorts_devel_openssl3/openssl3/work/openssl-3.1.4" && /usr/bin/make test 
/usr/bin/make depend && /usr/bin/make _tests
( SRCTOP=. \
	  BLDTOP=. \
	  PERL="/opt/local/bin/perl5" \
	  FIPSKEY="f4556650ac31d35461610bac4ed81b1a181b2d8a43ea2854cbae22ca74560813" \
	  EXE_EXT= \
	  /opt/local/bin/perl5 ./test/run_tests.pl  )
00-prep_fipsmodule_cnf.t .. skipped: FIPS module config file only supported in a fips build
Files=1, Tests=0,  1 wallclock secs ( 0.02 usr  0.01 sys +  0.57 cusr  0.10 csys =  0.70 CPU)
Result: NOTESTS
01-test_abort.t .................... ok
01-test_fipsmodule_cnf.t ........... skipped: Test only supported in a fips build
01-test_sanity.t ................... ok
01-test_symbol_presence.t .......... skipped: Test is disabled on MacOS
01-test_test.t ..................... ok
02-test_errstr.t ................... ok
02-test_internal_context.t ......... ok
02-test_internal_ctype.t ........... ok
02-test_internal_exts.t ............ ok
02-test_internal_keymgmt.t ......... ok
02-test_internal_provider.t ........ ok
02-test_lhash.t .................... ok
02-test_localetest.t ............... ok
02-test_ordinals.t ................. ok
02-test_sparse_array.t ............. ok
02-test_stack.t .................... ok
03-test_exdata.t ................... ok
03-test_fipsinstall.t .............. skipped: Test only supported in a fips build
03-test_internal_asn1.t ............ ok
03-test_internal_asn1_dsa.t ........ ok
03-test_internal_bn.t .............. ok
03-test_internal_chacha.t .......... ok
03-test_internal_curve448.t ........ ok
03-test_internal_ec.t .............. ok
03-test_internal_ffc.t ............. ok
03-test_internal_mdc2.t ............ ok
03-test_internal_modes.t ........... ok
03-test_internal_namemap.t ......... ok
03-test_internal_poly1305.t ........ ok
03-test_internal_rsa_sp800_56b.t ... ok
03-test_internal_siphash.t ......... ok
03-test_internal_sm2.t ............. ok
03-test_internal_sm3.t ............. ok
03-test_internal_sm4.t ............. ok
03-test_internal_ssl_cert_table.t .. ok
03-test_internal_x509.t ............ ok
03-test_params_api.t ............... ok
03-test_property.t ................. ok
03-test_ui.t ....................... ok
04-test_asn1_decode.t .............. ok
04-test_asn1_encode.t .............. ok
04-test_asn1_string_table.t ........ ok
04-test_bio_callback.t ............. ok
04-test_bio_core.t ................. ok
04-test_bioprint.t ................. ok
04-test_conf.t ..................... ok
04-test_encoder_decoder.t .......... ok
04-test_encoder_decoder_legacy.t ... ok
04-test_err.t ...................... ok
04-test_hexstring.t ................ ok
04-test_nodefltctx.t ............... ok
04-test_param_build.t .............. ok
04-test_params.t ................... ok
04-test_params_conversion.t ........ ok
04-test_pem_read_depr.t ............ ok
04-test_pem_reading.t .............. ok
04-test_provfetch.t ................ ok
04-test_provider.t ................. ok
04-test_provider_fallback.t ........ ok
04-test_provider_pkey.t ............ ok
04-test_punycode.t ................. ok
04-test_upcalls.t .................. ok
05-test_bf.t ....................... ok
05-test_cast.t ..................... ok
05-test_cmac.t ..................... ok
05-test_des.t ...................... ok
05-test_hmac.t ..................... ok
05-test_idea.t ..................... ok
05-test_pbe.t ...................... ok
05-test_rand.t ..................... ok
05-test_rc2.t ...................... ok
05-test_rc4.t ...................... ok
05-test_rc5.t ...................... skipped: rc5 is not supported by this OpenSSL build
06-test_algorithmid.t .............. ok
06-test_rdcpu_sanity.t ............. ok
10-test_bn.t ....................... ok
10-test_exp.t ...................... ok
15-test_dh.t ....................... ok
15-test_dsa.t ...................... ok
15-test_dsaparam.t ................. ok
15-test_ec.t ....................... ok
15-test_ecdsa.t .................... ok
15-test_ecparam.t .................. ok
15-test_gendh.t .................... ok
15-test_gendhparam.t ............... ok
15-test_gendsa.t ................... ok
15-test_genec.t .................... ok
15-test_genrsa.t ................... ok
15-test_mp_rsa.t ................... ok
15-test_out_option.t ............... ok
15-test_rsa.t ...................... ok
15-test_rsaoaep.t .................. ok
15-test_rsapss.t ................... ok
15-test_sha.t ...................... ok
20-test_app.t ...................... ok
20-test_cli_fips.t ................. skipped: Test only supported in a fips build with security checks
20-test_dgst.t ..................... ok
20-test_dhparam.t .................. ok
20-test_dhparam_check.t ............ ok
20-test_enc.t ...................... ok
20-test_enc_more.t ................. ok
20-test_kdf.t ...................... ok
20-test_legacy_okay.t .............. ok
20-test_mac.t ...................... ok
20-test_passwd.t ................... ok
20-test_pkeyutl.t .................. ok
20-test_rand_config.t .............. ok
20-test_spkac.t .................... ok
25-test_crl.t ...................... ok
25-test_d2i.t ...................... ok
25-test_eai_data.t ................. ok
25-test_pkcs7.t .................... ok
25-test_req.t ...................... ok
25-test_rusext.t ................... ok
25-test_sid.t ...................... ok
25-test_verify.t ................... ok
25-test_verify_store.t ............. ok
25-test_x509.t ..................... ok
30-test_acvp.t ..................... skipped: ACVP is not supported by this test
30-test_aesgcm.t ................... ok
30-test_afalg.t .................... skipped: test_afalg not supported for this build
30-test_defltfips.t ................ ok
30-test_engine.t ................... ok
30-test_evp.t ...................... ok
30-test_evp_extra.t ................ ok
30-test_evp_fetch_prov.t ........... ok
30-test_evp_kdf.t .................. ok
30-test_evp_libctx.t ............... ok
30-test_evp_pkey_dparam.t .......... ok
30-test_evp_pkey_provided.t ........ ok
30-test_pbelu.t .................... ok
30-test_pkey_meth.t ................ ok
30-test_pkey_meth_kdf.t ............ ok
30-test_prov_config.t .............. ok
30-test_provider_status.t .......... ok
40-test_rehash.t ................... ok
60-test_x509_check_cert_pkey.t ..... ok
60-test_x509_dup_cert.t ............ ok
60-test_x509_store.t ............... ok
60-test_x509_time.t ................ ok
61-test_bio_prefix.t ............... ok
61-test_bio_readbuffer.t ........... ok
65-test_cmp_asn.t .................. ok
65-test_cmp_client.t ............... ok
65-test_cmp_ctx.t .................. ok
65-test_cmp_hdr.t .................. ok
65-test_cmp_msg.t .................. ok
65-test_cmp_protect.t .............. ok
65-test_cmp_server.t ............... ok
65-test_cmp_status.t ............... ok
65-test_cmp_vfy.t .................. ok
66-test_ossl_store.t ............... ok
70-test_asyncio.t .................. ok
70-test_bad_dtls.t ................. ok
70-test_clienthello.t .............. ok
70-test_comp.t ..................... ok
70-test_key_share.t ................ ok
70-test_packet.t ................... ok
70-test_recordlen.t ................ ok
70-test_renegotiation.t ............ ok
70-test_servername.t ............... ok
70-test_sslcbcpadding.t ............ ok
70-test_sslcertstatus.t ............ ok
70-test_sslextension.t ............. ok
70-test_sslmessages.t .............. ok
70-test_sslrecords.t ............... ok
70-test_sslsessiontick.t ........... ok
70-test_sslsigalgs.t ............... ok
70-test_sslsignature.t ............. ok
70-test_sslskewith0p.t ............. ok
70-test_sslversions.t .............. ok
70-test_sslvertol.t ................ ok
70-test_tls13alerts.t .............. ok
70-test_tls13cookie.t .............. ok
70-test_tls13downgrade.t ........... ok
70-test_tls13hrr.t ................. ok
70-test_tls13kexmodes.t ............ ok
70-test_tls13messages.t ............ ok
70-test_tls13psk.t ................. ok
70-test_tlsextms.t ................. ok
70-test_verify_extra.t ............. ok
70-test_wpacket.t .................. ok
71-test_ssl_ctx.t .................. ok
79-test_http.t ..................... ok
80-test_ca.t ....................... ok
80-test_cipherbytes.t .............. ok
80-test_cipherlist.t ............... ok
80-test_ciphername.t ............... ok
80-test_cmp_http.t ................. ok
80-test_cms.t ...................... ok
80-test_cmsapi.t ................... ok
80-test_ct.t ....................... ok
80-test_dane.t ..................... ok
80-test_dtls.t ..................... ok
80-test_dtls_mtu.t ................. ok
80-test_dtlsv1listen.t ............. ok
80-test_ocsp.t ..................... ok
80-test_pkcs12.t ................... ok
80-test_policy_tree.t .............. ok
80-test_ssl_new.t .................. ok
80-test_ssl_old.t .................. ok
80-test_ssl_test_ctx.t ............. ok
80-test_sslcorrupt.t ............... ok
80-test_tsa.t ...................... ok
80-test_x509aux.t .................. ok
81-test_cmp_cli.t .................. ok
90-test_asn1_time.t ................ ok
90-test_async.t .................... ok
90-test_bio_enc.t .................. ok
90-test_bio_memleak.t .............. ok
90-test_constant_time.t ............ ok
90-test_fatalerr.t ................. ok
90-test_fipsload.t ................. skipped: Test is disabled with disabled fips
90-test_gmdiff.t ................... ok
90-test_ige.t ...................... ok
90-test_includes.t ................. ok
90-test_memleak.t .................. skipped: MacOS currently doesn't support leak sanitizer
90-test_overhead.t ................. ok
90-test_secmem.t ................... ok
90-test_shlibload.t ................ ok
90-test_srp.t ...................... ok
90-test_sslapi.t ................... ok
90-test_sslbuffers.t ............... ok
90-test_store.t .................... ok
90-test_store_cases.t .............. ok
90-test_sysdefault.t ............... ok
90-test_threads.t .................. ok
90-test_time_offset.t .............. ok
90-test_tls13ccs.t ................. ok
90-test_tls13encryption.t .......... ok
90-test_tls13secrets.t ............. ok
90-test_traceapi.t ................. ok
90-test_v3name.t ................... ok
91-test_pkey_check.t ............... ok
95-test_external_gost_engine.t ..... skipped: No external tests in this configuration
95-test_external_krb5.t ............ skipped: No external tests in this configuration
95-test_external_oqsprovider.t ..... skipped: No external tests in this configuration
95-test_external_pyca.t ............ skipped: No external tests in this configuration
95-test_external_tlsfuzzer.t ....... skipped: No external tests in this configuration
99-test_ecstress.t ................. ok
99-test_fuzz_asn1.t ................ ok
99-test_fuzz_asn1parse.t ........... ok
99-test_fuzz_bignum.t .............. ok
99-test_fuzz_bndiv.t ............... ok
99-test_fuzz_client.t .............. ok
99-test_fuzz_cmp.t ................. ok
99-test_fuzz_cms.t ................. ok
99-test_fuzz_conf.t ................ ok
99-test_fuzz_crl.t ................. ok
99-test_fuzz_ct.t .................. ok
99-test_fuzz_server.t .............. ok
99-test_fuzz_x509.t ................ ok
All tests successful.
Files=252, Tests=3324, 1276 wallclock secs (16.82 usr  4.29 sys + 942.92 cusr 311.06 csys = 1275.09 CPU)
Result: PASS

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK with CLA: trivial

@t8m t8m requested a review from a team January 11, 2024 13:19
@tom-cosgrove-arm
Copy link
Contributor

tom-cosgrove-arm commented Jan 11, 2024

There are a few instances of __PPC__ in poly1305_ieee754.c - is __POWERPC__ needed in any of those places? (e.g. lines 69, 98, 137, etc)

@barracuda156
Copy link
Contributor Author

@tom-cosgrove-arm Hmm, from a first glance it is needed (unless the file itself is excluded for macOS for a good reason), but the code is non-trivial and has to be specifically tested both for ppc and ppc64, since apparently it was never being compiled on macOS PowerPC.

Allow me to do that.

@t8m
Copy link
Member

t8m commented Jan 11, 2024

Maybe this should be a separate PR then?

@barracuda156
Copy link
Contributor Author

@t8m Fair enough, that does not need to be here. Then this one should be good to merge.

@t8m
Copy link
Member

t8m commented Jan 11, 2024

Ping @openssl/committers for second approval.

Copy link
Contributor

@tom-cosgrove-arm tom-cosgrove-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a PPC expert (it's a long time since I booted that G4 Mac mini of mine), but looks good to me.

Okay with trivial

@tom-cosgrove-arm tom-cosgrove-arm added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jan 11, 2024
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Jan 12, 2024
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@t8m
Copy link
Member

t8m commented Jan 12, 2024

Merged to the master branch. Thank you for your contribution.

@t8m t8m closed this Jan 12, 2024
openssl-machine pushed a commit that referenced this pull request Jan 12, 2024
Current PowerPC-related defines omit Darwin ppc64 case.
Use __POWERPC__ in place of __ppc__ + __ppc64__
Fixes #23220

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23245)
@barracuda156
Copy link
Contributor Author

Thank you!

@barracuda156 barracuda156 deleted the ppc64 branch January 13, 2024 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch cla: trivial One of the commits is marked as 'CLA: trivial' severity: fips change The pull request changes FIPS provider sources tests: exempted The PR is exempt from requirements for testing triaged: feature The issue/pr requests/adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[macOS PowerPC] aes_platform.h does not have a macro for ppc64
4 participants