Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwinEsch committed Mar 26, 2024
1 parent 7803671 commit f9c2e3c
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--- a/libavcodec/x86/mathops.h
+++ b/libavcodec/x86/mathops.h
@@ -35,12 +35,20 @@
static av_always_inline av_const int MULL(int a, int b, unsigned shift)
{
int rt, dummy;
+ if (__builtin_constant_p(shift))
__asm__ (
"imull %3 \n\t"
"shrdl %4, %%edx, %%eax \n\t"
:"=a"(rt), "=d"(dummy)
- :"a"(a), "rm"(b), "ci"((uint8_t)shift)
+ :"a"(a), "rm"(b), "i"(shift & 0x1F)
);
+ else
+ __asm__ (
+ "imull %3 \n\t"
+ "shrdl %4, %%edx, %%eax \n\t"
+ :"=a"(rt), "=d"(dummy)
+ :"a"(a), "rm"(b), "c"((uint8_t)shift)
+ );
return rt;
}

@@ -113,19 +121,31 @@ __asm__ volatile(\
// avoid +32 for shift optimization (gcc should do that ...)
#define NEG_SSR32 NEG_SSR32
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
+ if (__builtin_constant_p(s))
__asm__ ("sarl %1, %0\n\t"
: "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
);
+ else
+ __asm__ ("sarl %1, %0\n\t"
+ : "+r" (a)
+ : "c" ((uint8_t)(-s))
+ );
return a;
}

#define NEG_USR32 NEG_USR32
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
+ if (__builtin_constant_p(s))
__asm__ ("shrl %1, %0\n\t"
: "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
);
+ else
+ __asm__ ("shrl %1, %0\n\t"
+ : "+r" (a)
+ : "c" ((uint8_t)(-s))
+ );
return a;
}

4 changes: 2 additions & 2 deletions depends/common/ffmpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ if(NOT WIN32)
--enable-gnutls
--enable-libzvbi
${STANDARD_CONF}
${EXTRA_CONF} ||
${EXTRA_CONF})#[===[ ||
cmake -E echo "=========================================================" &&
cmake -E echo "FFMPEG configure error" &&
cmake -E echo "The associated config.log is output for troubleshooting." &&
cmake -E echo "--------------------------------- FFMPEG CONFIG LOG START" &&
cat ${CMAKE_BINARY_DIR}/ffmpeg-prefix/src/ffmpeg-build/ffbuild/config.log &&
cmake -E echo "----------------------------------- FFMPEG CONFIG LOG END" &&
exit 1)
exit 1)]===]

if(CORE_SYSTEM_NAME STREQUAL darwin_embedded)
externalproject_add_step(ffmpeg
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From a333f0d2dde8cfc6d784351be4ec062f12a21dd8 Mon Sep 17 00:00:00 2001
From: Alwin Esch <[email protected]>
Date: Tue, 26 Mar 2024 22:52:39 +0100
Subject: [PATCH] hack-fix-about-rsa_compute_root_tr

---
lib/nettle/backport/rsa-sign-tr.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/nettle/backport/rsa-sign-tr.c b/lib/nettle/backport/rsa-sign-tr.c
index 83a5d52..6b22dc4 100644
--- a/lib/nettle/backport/rsa-sign-tr.c
+++ b/lib/nettle/backport/rsa-sign-tr.c
@@ -88,10 +88,10 @@ rsa_unblind (const struct rsa_public_key *pub,
* attacks which rely on faults on hardware, or even software MPI
* implementation. */
int
-rsa_compute_root_tr(const struct rsa_public_key *pub,
- const struct rsa_private_key *key,
- void *random_ctx, nettle_random_func *random,
- mpz_t x, const mpz_t m)
+backport_rsa_compute_root_tr(const struct rsa_public_key *pub,
+ const struct rsa_private_key *key,
+ void *random_ctx, nettle_random_func *random,
+ mpz_t x, const mpz_t m)
{
int res;
mpz_t t, mb, xb, ri;
@@ -142,7 +142,7 @@ _rsa_sec_compute_root_tr(const struct rsa_public_key *pub,

nn = mpz_size (pub->n);

- res = rsa_compute_root_tr(pub, key, random_ctx, random, xz,
+ res = backport_rsa_compute_root_tr(pub, key, random_ctx, random, xz,
mpz_roinit_n(mz, m, nn));

if (res)
@@ -347,10 +347,10 @@ _rsa_sec_compute_root_tr(const struct rsa_public_key *pub,
* in buffer copying both in case of success or error.
*/
int
-rsa_compute_root_tr(const struct rsa_public_key *pub,
- const struct rsa_private_key *key,
- void *random_ctx, nettle_random_func *random,
- mpz_t x, const mpz_t m)
+backport_rsa_compute_root_tr(const struct rsa_public_key *pub,
+ const struct rsa_private_key *key,
+ void *random_ctx, nettle_random_func *random,
+ mpz_t x, const mpz_t m)
{
TMP_GMP_DECL (l, mp_limb_t);
mp_size_t nn = mpz_size(pub->n);
--
2.40.1

0 comments on commit f9c2e3c

Please sign in to comment.