target-arm: Add support for AArch32 ARMv8 CRC32 instructions
cover target-arm: Add support for AArch32 ARMv8 CRC32 instructions
This series adds support for the AArch32 CRC32 instructions added in ARMv8. The CRC-32 algorithm is added alongside the existing CRC-32C implementation which requires a small fix to the crc32c.h header file.
Will Newton (3):
include/qemu/crc32c.h: Rename include guards to match filename util/crc32.c: Add CRC-32 implementation
target-arm: Add support for AArch32 ARMv8 CRC32 instructions
include/qemu/crc32.h | 15 ++++++++ include/qemu/crc32c.h | 4 +-- target-arm/helper.c | 37 +++++++++++++++++++ target-arm/helper.h | 3 ++ target-arm/translate.c | 48 +++++++++++++++++++++++++ util/Makefile.objs | 1 + util/crc32.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 include/qemu/crc32.h create mode 100644 util/crc32.c
Signature · 1 line
1.8.1.4
PATCH 1/3 include/qemu/crc32c.h: Rename include guards to match filename
--- include/qemu/crc32c.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/qemu/crc32c.h +2 -2
@@ -25,8 +25,8 @@* */ -#ifndef QEMU_CRC32_H -#define QEMU_CRC32_H +#ifndef QEMU_CRC32C_H +#define QEMU_CRC32C_H #include "qemu-common.h"
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 1/3] include/qemu/crc32c.h: Rename include guards to match filename
Quoted 10 lines · Will Newton
Signed-off-by Will Newton <[email protected]>--- include/qemu/crc32c.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/qemu/crc32c.h +0
-0
include/qemu/crc32c.h line 31
Quoted 9 lines
include/qemu/crc32c.h +2
-2@@ -25,8 +25,8 @@* */ -#ifndef QEMU_CRC32_H -#define QEMU_CRC32_H +#ifndef QEMU_CRC32C_H +#define QEMU_CRC32C_H #include "qemu-common.h"
-- PMM
PATCH 2/3 util/crc32.c: Add CRC-32 implementation
In reply to Will NewtonAdd a table-driven CRC-32 implementation similar in style to the existing CRC-32C implementation.
--- include/qemu/crc32.h | 15 ++++++++ util/Makefile.objs | 1 + util/crc32.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 include/qemu/crc32.h create mode 100644 util/crc32.c
include/qemu/crc32.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* CRC32C Checksum Algorithm +* +* Polynomial: 0x04C11DB7 +* +*/ + +#ifndef QEMU_CRC32_H +#define QEMU_CRC32_H + +#include "qemu-common.h" + +uint32_t crc32 (uint32_t crc,const uint8_t *data,unsigned int length); + +#endif
util/Makefile.objs +1 -0
@@ -14,3 +14,4 @@ util-obj-y += crc32c.o util-obj-y += throttle.o util-obj-y += getauxval.o util-obj-y += readline.o +util-obj-y += crc32.o
util/crc32.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 2/3] util/crc32.c: Add CRC-32 implementation
Quoted 8 lines · Will Newton
Add a table-driven CRC-32 implementation similar in style to the existing CRC-32C implementation.
+++
b/include/qemu/crc32.hinclude/qemu/crc32.h new file +3
-0@@ -0,0 +1,15 @@ +/* +* CRC32C Checksum Algorithm +*
include/qemu/crc32.h line 13
Quoted 10 lines
include/qemu/crc32.h new file +10
-0+* Polynomial: 0x04C11DB7 +* +*/ + +#ifndef QEMU_CRC32_H +#define QEMU_CRC32_H + +#include "qemu-common.h" + +uint32_t crc32 (uint32_t crc,const uint8_t *data,unsigned int length);
This seems like a bad idea because we have quite a bit of code in QEMU which uses crc32() from zlib.h.
Is it possible to just use that implementation?
thanks
-- PMM
PATCH 3/3 target-arm: Add support for AArch32 ARMv8 CRC32 instructions
In reply to Will NewtonAdd support for AArch32 CRC32 and CRC32C instructions added in ARMv8.
--- target-arm/helper.c | 37 +++++++++++++++++++++++++++++++++++++ target-arm/helper.h | 3 +++ target-arm/translate.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+)
target-arm/helper.c +37 -0
@@ -5,6 +5,8 @@#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qemu/bitops.h" +#include "qemu/crc32.h" +#include "qemu/crc32c.h" #ifndef CONFIG_USER_ONLY static inline int get_phys_addr(CPUARMState *env, uint32_t address,
@@ -4468,3 +4470,38 @@ int arm_rmode_to_sf(int rmode) }return rmode; } + +static void crc_init_buffer (uint8_t *buf,uint32_t val,uint32_t bytes) +{ +memset (buf,0 ,4 ); + +if (bytes ==1 ) { + buf[0 ] = val &0xff ; + }else if (bytes ==2 ) { + buf[0 ] = val &0xff ; + buf[1 ] = (val >>8 ) &0xff ; + }else { + buf[0 ] = val &0xff ; + buf[1 ] = (val >>8 ) &0xff ; + buf[2 ] = (val >>16 ) &0xff ; + buf[3 ] = (val >>24 ) &0xff ; + } +} + +uint32_t HELPER (crc32 )(uint32_t acc,uint32_t val,uint32_t bytes) +{ +uint8_t buf[4 ]; + +crc_init_buffer (buf, val, bytes); + +return crc32 (acc, buf, bytes) ^0xffffffff ; +} + +uint32_t HELPER (crc32c )(uint32_t acc,uint32_t val,uint32_t bytes) +{ +uint8_t buf[4 ]; + +crc_init_buffer (buf, val, bytes); + +return crc32c (acc, buf, bytes) ^0xffffffff ; +}
target-arm/helper.h +3 -0
@@ -494,6 +494,9 @@ DEF_HELPER_3(neon_qzip32, void, env, i32, i32) DEF_HELPER_4(crypto_aese, void, env, i32, i32, i32) DEF_HELPER_4(crypto_aesmc, void, env, i32, i32, i32) +DEF_HELPER_3(crc32, i32, i32, i32, i32) +DEF_HELPER_3(crc32c, i32, i32, i32, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif
target-arm/translate.c +48 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.1.4