Skip to content

Commit 2e2ca8d

Browse files
kpchoiAnemptyship
andauthored
Fix MD5 hash mismatch on big-endian systems (s390x) (#240)
* Fix MD5 hash mismatch on big-endian systems (s390x) - Make md5_trans() endian-safe by explicitly decoding bytes to u32 words - Use compile-time check to preserve zero-copy performance on little-endian - Fix md5_finish() to write length and digest in little-endian byte order - Add md5_update_16() for safe 16-bit pixel data processing Signed-off-by: Anemptyship <hanbin1931@gmail.com> * Refactor: internalize endianness macros and simplify MD5 implementation - oapv_port.h: Introduce cross-platform endianness swap and conversion macros (OAPV_SWAP*, OAPV_LE32_TO_CPU). - oapv_util.c: Replace manual byte swapping with new macros in MD5 transform to improve readability and maintainability. - Standardize endianness handling across the codebase. Signed-off-by: Anemptyship <hanbin1931@gmail.com> * CI: Support s390x build - Add cross-compilation job for s390x using QEMU - Increase test timeouts in CMakeLists.txt for emulated environment Signed-off-by: Anemptyship <hanbin1931@gmail.com> * Replace endianness macros with byte-wise MD5 read/write helpers Signed-off-by: KP Choi <kp5.choi@samsung.com> --------- Signed-off-by: Anemptyship <hanbin1931@gmail.com> Signed-off-by: KP Choi <kp5.choi@samsung.com> Co-authored-by: Anemptyship <hanbin1931@gmail.com>
1 parent 23c0a9c commit 2e2ca8d

3 files changed

Lines changed: 187 additions & 130 deletions

File tree

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8+
workflow_dispatch:
89

910
jobs:
1011
build-linux-amd64:
@@ -68,6 +69,25 @@ jobs:
6869
cmake -S ${{github.workspace}} -B ${{github.workspace}}/build-arm -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/arm64_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
6970
cmake --build ${{github.workspace}}/build-arm
7071
72+
build-linux-s390x:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v6
77+
78+
- name: Set up CMake
79+
uses: jwlawson/actions-setup-cmake@v2
80+
81+
- name: Install s390x toolchain
82+
run: |
83+
sudo apt-get update
84+
sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu binutils-s390x-linux-gnu libc6-s390x-cross
85+
86+
- name: Build (crosscompile) PC Linux s390x
87+
run: |
88+
cmake -S ${{github.workspace}} -B ${{github.workspace}}/build-s390x -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=s390x -DCMAKE_C_COMPILER=s390x-linux-gnu-gcc -DCMAKE_CXX_COMPILER=s390x-linux-gnu-g++ -DCMAKE_BUILD_TYPE=Release
89+
cmake --build ${{github.workspace}}/build-s390x
90+
7191
build-darwin-arm64:
7292
runs-on: macos-latest
7393
steps:
@@ -124,3 +144,29 @@ jobs:
124144
with:
125145
name: LastTest.log
126146
path: ${{github.workspace}}/build/Testing/Temporary/LastTest.log
147+
148+
test-linux-s390x:
149+
runs-on: ubuntu-latest
150+
env:
151+
QEMU_LD_PREFIX: /usr/s390x-linux-gnu
152+
steps:
153+
- name: Checkout code
154+
uses: actions/checkout@v6
155+
156+
- name: Set up CMake
157+
uses: jwlawson/actions-setup-cmake@v2
158+
159+
- name: Install s390x toolchain and emulator
160+
run: |
161+
sudo apt-get update
162+
sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu binutils-s390x-linux-gnu libc6-s390x-cross qemu-user qemu-user-static
163+
164+
- name: Build (crosscompile) PC Linux s390x for tests
165+
run: |
166+
cmake -S ${{github.workspace}} -B ${{github.workspace}}/build-s390x -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=s390x -DCMAKE_C_COMPILER=s390x-linux-gnu-gcc -DCMAKE_CXX_COMPILER=s390x-linux-gnu-g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CROSSCOMPILING_EMULATOR="qemu-s390x;-L;/usr/s390x-linux-gnu"
167+
cmake --build ${{github.workspace}}/build-s390x
168+
169+
- name: Run tests for s390x
170+
run: |
171+
cd build-s390x
172+
ctest --output-on-failure --timeout 15

CMakeLists.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ set_tests_properties(encode PROPERTIES
280280
# Test - decode
281281
add_test(NAME decode COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i out.oapv)
282282
set_tests_properties(decode PROPERTIES
283-
TIMEOUT 10
283+
TIMEOUT 20
284284
DEPENDS encode
285285
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
286286
PASS_REGULAR_EXPRESSION "Decoded frame count = 125"
@@ -290,7 +290,7 @@ set_tests_properties(decode PROPERTIES
290290
# Test - decode qp_A.apv
291291
add_test(NAME decode_qp_A COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/qp_A.apv -v 3 --hash)
292292
set_tests_properties(decode_qp_A PROPERTIES
293-
TIMEOUT 10
293+
TIMEOUT 20
294294
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
295295
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
296296
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -299,7 +299,7 @@ set_tests_properties(decode_qp_A PROPERTIES
299299
# Test - decode qp_B.apv
300300
add_test(NAME decode_qp_B COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/qp_B.apv -v 3 --hash)
301301
set_tests_properties(decode_qp_B PROPERTIES
302-
TIMEOUT 10
302+
TIMEOUT 20
303303
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
304304
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
305305
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -308,7 +308,7 @@ set_tests_properties(decode_qp_B PROPERTIES
308308
# Test - decode qp_C.apv
309309
add_test(NAME decode_qp_C COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/qp_C.apv -v 3 --hash)
310310
set_tests_properties(decode_qp_C PROPERTIES
311-
TIMEOUT 10
311+
TIMEOUT 20
312312
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
313313
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
314314
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -317,7 +317,7 @@ set_tests_properties(decode_qp_C PROPERTIES
317317
# Test - decode qp_D.apv
318318
add_test(NAME decode_qp_D COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/qp_D.apv -v 3 --hash)
319319
set_tests_properties(decode_qp_D PROPERTIES
320-
TIMEOUT 10
320+
TIMEOUT 20
321321
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
322322
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
323323
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -326,7 +326,7 @@ set_tests_properties(decode_qp_D PROPERTIES
326326
# Test - decode qp_E.apv
327327
add_test(NAME decode_qp_E COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/qp_E.apv -v 3 --hash)
328328
set_tests_properties(decode_qp_E PROPERTIES
329-
TIMEOUT 10
329+
TIMEOUT 20
330330
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
331331
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
332332
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -335,7 +335,7 @@ set_tests_properties(decode_qp_E PROPERTIES
335335
# Test - decode syn_A.apv
336336
add_test(NAME decode_syn_A COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/syn_A.apv -v 3 --hash)
337337
set_tests_properties(decode_syn_A PROPERTIES
338-
TIMEOUT 10
338+
TIMEOUT 20
339339
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
340340
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
341341
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -344,7 +344,7 @@ set_tests_properties(decode_syn_A PROPERTIES
344344
# Test - decode syn_B.apv
345345
add_test(NAME decode_syn_B COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/syn_B.apv -v 3 --hash)
346346
set_tests_properties(decode_syn_B PROPERTIES
347-
TIMEOUT 10
347+
TIMEOUT 20
348348
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
349349
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
350350
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -353,7 +353,7 @@ set_tests_properties(decode_syn_B PROPERTIES
353353
# Test - decode tile_A.apv
354354
add_test(NAME decode_tile_A COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/tile_A.apv -v 3 --hash)
355355
set_tests_properties(decode_tile_A PROPERTIES
356-
TIMEOUT 10
356+
TIMEOUT 20
357357
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
358358
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
359359
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -362,7 +362,7 @@ set_tests_properties(decode_tile_A PROPERTIES
362362
# Test - decode tile_B.apv
363363
add_test(NAME decode_tile_B COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/tile_B.apv -v 3 --hash)
364364
set_tests_properties(decode_tile_B PROPERTIES
365-
TIMEOUT 10
365+
TIMEOUT 20
366366
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
367367
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
368368
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -371,7 +371,7 @@ set_tests_properties(decode_tile_B PROPERTIES
371371
# Test - decode tile_C.apv
372372
add_test(NAME decode_tile_C COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/tile_C.apv -v 3 --hash)
373373
set_tests_properties(decode_tile_C PROPERTIES
374-
TIMEOUT 10
374+
TIMEOUT 20
375375
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
376376
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
377377
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -380,7 +380,7 @@ set_tests_properties(decode_tile_C PROPERTIES
380380
# Test - decode tile_D.apv
381381
add_test(NAME decode_tile_D COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/tile_D.apv -v 3 --hash)
382382
set_tests_properties(decode_tile_D PROPERTIES
383-
TIMEOUT 10
383+
TIMEOUT 20
384384
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
385385
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
386386
PASS_REGULAR_EXPRESSION ".*hash:match.*"
@@ -389,7 +389,7 @@ set_tests_properties(decode_tile_D PROPERTIES
389389
# Test - decode tile_E.apv
390390
add_test(NAME decode_tile_E COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/oapv_app_dec -i ${CMAKE_CURRENT_SOURCE_DIR}/test/bitstream/tile_E.apv -v 3 --hash)
391391
set_tests_properties(decode_tile_E PROPERTIES
392-
TIMEOUT 10
392+
TIMEOUT 20
393393
FAIL_REGULAR_EXPRESSION "Decoded frame count = 0"
394394
PASS_REGULAR_EXPRESSION "Decoded frame count = 3"
395395
PASS_REGULAR_EXPRESSION ".*hash:match.*"

0 commit comments

Comments
 (0)