Re: macppc kernel and clang
Here is a new diff for macppc's ofw_stack() problem, without using __attribute__((noinline)). I use this diff to build and run a macppc kernel with clang. It also works with gcc. The kernel did 3 steps to prepare an Open Firmware call: 1. turn off interrupts (EE and RI in msr) 2. move the stack pointer %r1 to firmstk 3. switch to Open Firmware's pmap? I don't understand these steps, but I tried to preserve all 3 steps as I shuffled the code. The diff doesn't touch step 3. The problem was at step 2: ofw_stack() copied the caller's stack frame to firmstk, and changed the caller's return address to ofw_back (which will restore the old %r1 and msr). If clang inlines the caller into another function, then ofw_back would run too late. I move step 2 into openfirmware(), so there is no more copying a stack frame nor hijacking a return address. (I claim that firmstk+NBPG-16 is a multiple of 16; that mtctr,bctrl is more idiomatic than mtlr,blrl.) ofw_stack() becomes s = ofw_msr() and only does step 1, turning off EE and RI in msr. ppc_mtmsr(s) restores the saved msr. I don't use intr_disable() because it turns off only EE, not RI. I changed OF_call_method*() to turn off EE (external interrupts) before they touch their static args. Some functions, like OF_boot() and OF_quiesce(), seem unused, so I can't know if my changes are correct. To build a kernel with clang, I do # make CC=clang COMPILER_VERSION=clang Is this OK to commit? Would it be better to use intr_disable() in OF_*() and turn off RI in ofwreal.S fwentry? Index: ofw_machdep.h === RCS file: /cvs/src/sys/arch/macppc/macppc/ofw_machdep.h,v retrieving revision 1.9 diff -u -p -r1.9 ofw_machdep.h --- ofw_machdep.h 7 Apr 2015 14:36:34 - 1.9 +++ ofw_machdep.h 29 Mar 2020 16:16:27 - @@ -26,6 +26,9 @@ * */ +#include +#include + extern int cons_backlight_available; void ofwconprobe(void); @@ -49,3 +52,12 @@ void of_setbrightness(int); void of_setcolors(const uint8_t *, unsigned int, unsigned int); void OF_quiesce(void); + +static inline uint32_t +ofw_msr(void) +{ + uint32_t s = ppc_mfmsr(); + + ppc_mtmsr(s & ~(PSL_EE|PSL_RI)); /* turn off interrupts */ + return s; +} Index: ofwreal.S === RCS file: /cvs/src/sys/arch/macppc/macppc/ofwreal.S,v retrieving revision 1.5 diff -u -p -r1.5 ofwreal.S --- ofwreal.S 3 Sep 2019 14:37:22 - 1.5 +++ ofwreal.S 29 Mar 2020 16:16:27 - @@ -355,96 +355,32 @@ _ENTRY(_C_LABEL(fwentry)) addi%r1,%r1,16 blr +.lcomm firmstk,NBPG,16 +.comm _C_LABEL(OF_buf),NBPG + /* * OpenFirmware entry point + * + * Note: caller has to set the machine state register (msr) + * to be correct for OpenFirmware. */ _ENTRY(_C_LABEL(openfirmware)) - stwu%r1,-16(%r1) - mflr%r0 /* save return address */ - stw %r0,20(%r1) + mflr%r0 + stw %r0,4(%r1) /* save return address */ + + /* switch to OpenFirmware real mode stack */ + lis %r7,firmstk+NBPG-16@ha + addi%r7,%r7,firmstk+NBPG-16@l + stw %r1,0(%r7) + mr %r1,%r7 lis %r4,fwcall@ha lwz %r4,fwcall@l(%r4) - mtlr%r4 - blrl - - lwz %r0,20(%r1) - mtlr%r0 - lwz %r1,0(%r1) - blr - -/* - * Switch to/from OpenFirmware real mode stack - * - * Note: has to be called as the very first thing in OpenFirmware interface routines. - * E.g.: - * int - * OF_xxx(arg1, arg2) - * type arg1, arg2; - * { - * static struct { - * char *name; - * int nargs; - * int nreturns; - * char *method; - * int arg1; - * int arg2; - * int ret; - * } args = { - * "xxx", - * 2, - * 1, - * }; - * - * ofw_stack(); - * args.arg1 = arg1; - * args.arg2 = arg2; - * if (openfirmware() < 0) - * return -1; - * return args.ret; - * } - */ -.lcomm firmstk,NBPG,16 -.comm _C_LABEL(OF_buf),NBPG - -_ENTRY(_C_LABEL(ofw_stack)) - mfmsr %r8 /* turn off interrupts */ - andi. %r0,%r8,~(PSL_EE|PSL_RI)@l - mtmsr %r0 - stw %r8,4(%r1) /* abuse return address slot */ - - lwz %r5,0(%r1) /* get length of stack frame */ - subf%r5,%r1,%r5 - - lis %r7,firmstk+NBPG-8@ha - addi%r7,%r7,firmstk+NBPG-8@l - li %r6,0xf - andc%r7,%r7,%r6 - lis %r6,ofw_back@ha - addi%r6,%r6,ofw_back@l - subf%r4,%r5,%r7 /* make room for stack frame on new stack */ - stwu%r1,-16(%r7) - stw %r6,4(%r7) /* setup return pointer */ + mtctr %r4 + bctrl - stw
[patch] Tweak libssl manpages
Hi there! It seems these are just a coded form for no return value, unless this is some libssl slang I am not aware of. Best, Martin Index: SSL_CTX_set_client_CA_list.3 === RCS file: /cvs/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3,v retrieving revision 1.5 diff -u -p -r1.5 SSL_CTX_set_client_CA_list.3 --- SSL_CTX_set_client_CA_list.327 Mar 2018 17:35:50 - 1.5 +++ SSL_CTX_set_client_CA_list.329 Mar 2020 20:18:28 - @@ -143,11 +143,6 @@ or .Pp These functions are only useful for TLS/SSL servers. .Sh RETURN VALUES -.Fn SSL_CTX_set_client_CA_list -and -.Fn SSL_set_client_CA_list -do not return diagnostic information. -.Pp .Fn SSL_CTX_add_client_CA and .Fn SSL_add_client_CA Index: SSL_CTX_set_quiet_shutdown.3 === RCS file: /cvs/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3,v retrieving revision 1.5 diff -u -p -r1.5 SSL_CTX_set_quiet_shutdown.3 --- SSL_CTX_set_quiet_shutdown.38 Jun 2019 15:25:43 - 1.5 +++ SSL_CTX_set_quiet_shutdown.329 Mar 2020 20:18:28 - @@ -144,11 +144,6 @@ This behaviour violates the TLS standard .Pp The default is normal shutdown behaviour as described by the TLS standard. .Sh RETURN VALUES -.Fn SSL_CTX_set_quiet_shutdown -and -.Fn SSL_set_quiet_shutdown -do not return diagnostic information. -.Pp .Fn SSL_CTX_get_quiet_shutdown and .Fn SSL_get_quiet_shutdown Index: SSL_CTX_set_tmp_dh_callback.3 === RCS file: /cvs/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3,v retrieving revision 1.7 diff -u -p -r1.7 SSL_CTX_set_tmp_dh_callback.3 --- SSL_CTX_set_tmp_dh_callback.3 27 Mar 2018 17:35:50 - 1.7 +++ SSL_CTX_set_tmp_dh_callback.3 29 Mar 2020 20:18:29 - @@ -175,11 +175,6 @@ and .Fa is_export and simply supply at least 2048-bit parameters in the callback. .Sh RETURN VALUES -.Fn SSL_CTX_set_tmp_dh_callback -and -.Fn SSL_set_tmp_dh_callback -do not return diagnostic output. -.Pp .Fn SSL_CTX_set_tmp_dh and .Fn SSL_set_tmp_dh Index: SSL_free.3 === RCS file: /cvs/src/lib/libssl/man/SSL_free.3,v retrieving revision 1.4 diff -u -p -r1.4 SSL_free.3 --- SSL_free.3 27 Mar 2018 17:35:50 - 1.4 +++ SSL_free.3 29 Mar 2020 20:18:29 - @@ -103,9 +103,6 @@ was not used to set the .Vt SSL_SENT_SHUTDOWN state, the session will also be removed from the session cache as required by RFC2246. -.Sh RETURN VALUES -.Fn SSL_free -does not provide diagnostic information. .Sh SEE ALSO .Xr ssl 3 , .Xr SSL_clear 3 , Index: SSL_set_shutdown.3 === RCS file: /cvs/src/lib/libssl/man/SSL_set_shutdown.3,v retrieving revision 1.4 diff -u -p -r1.4 SSL_set_shutdown.3 --- SSL_set_shutdown.3 27 Mar 2018 17:35:50 - 1.4 +++ SSL_set_shutdown.3 29 Mar 2020 20:18:29 - @@ -122,9 +122,6 @@ or .Fn SSL_set_shutdown itself. .Sh RETURN VALUES -.Fn SSL_set_shutdown -does not return diagnostic information. -.Pp .Fn SSL_get_shutdown returns the current setting. .Sh SEE ALSO
Re: [patch] Remove "do not return a value" from libcrypto/libssl manpages
Hi Martin, Martin Vahlensieck wrote on Sun, Mar 29, 2020 at 01:51:58AM +0100: > I found some more. Thanks, committed, also including in lh_stats(3). Ingo > Index: libcrypto/man/RC4.3 > === > RCS file: /cvs/src/lib/libcrypto/man/RC4.3,v > retrieving revision 1.7 > diff -u -p -r1.7 RC4.3 > --- libcrypto/man/RC4.3 6 Jun 2019 01:06:59 - 1.7 > +++ libcrypto/man/RC4.3 29 Mar 2020 00:48:17 - > @@ -112,11 +112,6 @@ yield a continuous key stream. > Since RC4 is a stream cipher (the input is XOR'ed with a pseudo-random > key stream to produce the output), decryption uses the same function > calls as encryption. > -.Sh RETURN VALUES > -.Fn RC4_set_key > -and > -.Fn RC4 > -do not return values. > .Sh SEE ALSO > .Xr blowfish 3 , > .Xr EVP_EncryptInit 3 , > Index: libcrypto/man/X509_STORE_CTX_set_verify_cb.3 > === > RCS file: /cvs/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3,v > retrieving revision 1.4 > diff -u -p -r1.4 X509_STORE_CTX_set_verify_cb.3 > --- libcrypto/man/X509_STORE_CTX_set_verify_cb.3 22 Mar 2018 17:38:08 > - 1.4 > +++ libcrypto/man/X509_STORE_CTX_set_verify_cb.3 29 Mar 2020 00:48:17 > - > @@ -108,9 +108,6 @@ In some cases (such as S/MIME verificati > structure is created and destroyed internally and the only way to set a > custom verification callback is by inheriting it from the associated > .Vt X509_STORE . > -.Sh RETURN VALUES > -.Fn X509_STORE_CTX_set_verify_cb > -does not return a value. > .Sh EXAMPLES > Default callback operation: > .Bd -literal > Index: libcrypto/man/X509_STORE_set_verify_cb_func.3 > === > RCS file: /cvs/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3,v > retrieving revision 1.8 > diff -u -p -r1.8 X509_STORE_set_verify_cb_func.3 > --- libcrypto/man/X509_STORE_set_verify_cb_func.3 27 Mar 2018 17:35:50 > - 1.8 > +++ libcrypto/man/X509_STORE_set_verify_cb_func.3 29 Mar 2020 00:48:17 > - > @@ -86,11 +86,6 @@ structure when it is initialized. > This can be used to set the verification callback when the > .Vt X509_STORE_CTX > is otherwise inaccessible (for example during S/MIME verification). > -.Sh RETURN VALUES > -.Fn X509_STORE_set_verify_cb > -and > -.Fn X509_STORE_set_verify_cb_func > -do not return a value. > .Sh SEE ALSO > .Xr X509_STORE_CTX_set_verify_cb 3 , > .Xr X509_STORE_new 3 > Index: libssl/man/SSL_set_verify_result.3 > === > RCS file: /cvs/src/lib/libssl/man/SSL_set_verify_result.3,v > retrieving revision 1.4 > diff -u -p -r1.4 SSL_set_verify_result.3 > --- libssl/man/SSL_set_verify_result.327 Mar 2018 17:35:50 - > 1.4 > +++ libssl/man/SSL_set_verify_result.329 Mar 2020 00:48:17 - > @@ -79,9 +79,6 @@ The valid codes for > .Fa verify_result > are documented in > .Xr openssl 1 . > -.Sh RETURN VALUES > -.Fn SSL_set_verify_result > -does not provide a return value. > .Sh SEE ALSO > .Xr openssl 1 , > .Xr ssl 3 ,
[PATCH v3 2/2] gost: populate params tables with new curves
Allow users to specify new curves via strings. Sponsored by ROSA Linux Signed-off-by: Dmitry Baryshkov --- src/lib/libcrypto/gost/gostr341001_params.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/lib/libcrypto/gost/gostr341001_params.c b/src/lib/libcrypto/gost/gostr341001_params.c index 13054cd0fc26..138860dee56e 100644 --- a/src/lib/libcrypto/gost/gostr341001_params.c +++ b/src/lib/libcrypto/gost/gostr341001_params.c @@ -94,12 +94,22 @@ static const GostR3410_params GostR3410_256_params[] = { { "0", NID_id_GostR3410_2001_TestParamSet }, { "XA", NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet }, { "XB", NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet }, + { "TCA", NID_id_tc26_gost_3410_12_256_paramSetA }, + { "TCB", NID_id_tc26_gost_3410_12_256_paramSetB }, + { "TCC", NID_id_tc26_gost_3410_12_256_paramSetC }, + { "TCD", NID_id_tc26_gost_3410_12_256_paramSetD }, { NULL, NID_undef }, }; static const GostR3410_params GostR3410_512_params[] = { { "A", NID_id_tc26_gost_3410_12_512_paramSetA }, { "B", NID_id_tc26_gost_3410_12_512_paramSetB }, + { "C", NID_id_tc26_gost_3410_12_512_paramSetC }, + { "0", NID_id_tc26_gost_3410_12_512_paramSetTest}, + /* Duplicates for compatibility with OpenSSL */ + { "TCA", NID_id_tc26_gost_3410_12_512_paramSetA }, + { "TCB", NID_id_tc26_gost_3410_12_512_paramSetB }, + { "TCC", NID_id_tc26_gost_3410_12_512_paramSetC }, { NULL, NID_undef }, }; -- 2.25.1
Re: [PATCH v2 2/2] gost: populate params tables with new curves
Hello, вс, 29 мар. 2020 г. в 06:03, Kinichiro Inoguchi : > > Hi, > I have 2 questions. > > In GostR3410_512_params[], "A" and "TCA" have the same NID, "B" and "TCB" too. > I thought these were redundant, but are there any reasons for this ? Compatibility with OpenSSL's gost engine, which uses TCA/TCB/TCC here. > In GostR3410_512_params[], don't you need the record for > NID_id_tc26_gost_3410_12_512_paramSetTest ? This param set is used for testing/example certificates. It should not be used in production. I will add in in V3 though. > Best regards, > > > On Sat, Mar 28, 2020 at 07:16:14PM +0300, Dmitry Baryshkov wrote: > > Allow users to specify new curves via strings. > > > > Sponsored by ROSA Linux > > > > Signed-off-by: Dmitry Baryshkov > > --- > > src/lib/libcrypto/gost/gostr341001_params.c | 7 +++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/src/lib/libcrypto/gost/gostr341001_params.c > > b/src/lib/libcrypto/gost/gostr341001_params.c > > index 13054cd0fc26..0f068d97eb0a 100644 > > --- a/src/lib/libcrypto/gost/gostr341001_params.c > > +++ b/src/lib/libcrypto/gost/gostr341001_params.c > > @@ -94,12 +94,19 @@ static const GostR3410_params GostR3410_256_params[] = { > > { "0", NID_id_GostR3410_2001_TestParamSet }, > > { "XA", NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet }, > > { "XB", NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet }, > > + { "TCA", NID_id_tc26_gost_3410_12_256_paramSetA }, > > + { "TCB", NID_id_tc26_gost_3410_12_256_paramSetB }, > > + { "TCC", NID_id_tc26_gost_3410_12_256_paramSetC }, > > + { "TCD", NID_id_tc26_gost_3410_12_256_paramSetD }, > > { NULL, NID_undef }, > > }; > > > > static const GostR3410_params GostR3410_512_params[] = { > > { "A", NID_id_tc26_gost_3410_12_512_paramSetA }, > > { "B", NID_id_tc26_gost_3410_12_512_paramSetB }, > > + { "TCA", NID_id_tc26_gost_3410_12_512_paramSetA }, > > + { "TCB", NID_id_tc26_gost_3410_12_512_paramSetB }, > > + { "TCC", NID_id_tc26_gost_3410_12_512_paramSetC }, > > { NULL, NID_undef }, > > }; > > > > -- > > 2.25.1 > > -- With best wishes Dmitry