1 // SPDX-License-Identifier: Zlib
6 #include <linux/kmsan-checks.h>
7 #include <linux/zutil.h>
10 * C wrapper for the DEFLATE CONVERSION CALL instruction.
14 DFLTCC_CC_OP1_TOO_SHORT
= 1,
15 DFLTCC_CC_OP2_TOO_SHORT
= 2,
16 DFLTCC_CC_OP2_CORRUPT
= 2,
24 #define HBT_CIRCULAR (1 << 7)
25 #define DFLTCC_FN_MASK ((1 << 7) - 1)
27 #define HB_SIZE (1 << HB_BITS)
29 static inline dfltcc_cc
dfltcc(
39 Byte
*t2
= op1
? *op1
: NULL
;
40 unsigned char *orig_t2
= t2
;
41 size_t t3
= len1
? *len1
: 0;
42 const Byte
*t4
= op2
? *op2
: NULL
;
43 size_t t5
= len2
? *len2
: 0;
44 register int r0
__asm__("r0") = fn
;
45 register void *r1
__asm__("r1") = param
;
46 register Byte
*r2
__asm__("r2") = t2
;
47 register size_t r3
__asm__("r3") = t3
;
48 register const Byte
*r4
__asm__("r4") = t4
;
49 register size_t r5
__asm__("r5") = t5
;
53 ".insn rrf,0xb9390000,%[r2],%[r4],%[hist],0\n"
64 t2
= r2
; t3
= r3
; t4
= r4
; t5
= r5
;
67 * Unpoison the parameter block and the output buffer.
68 * This is a no-op in non-KMSAN builds.
70 switch (fn
& DFLTCC_FN_MASK
) {
72 kmsan_unpoison_memory(param
, sizeof(struct dfltcc_qaf_param
));
75 kmsan_unpoison_memory(param
, offsetof(struct dfltcc_param_v0
, csb
));
78 kmsan_unpoison_memory(param
, sizeof(struct dfltcc_param_v0
));
79 kmsan_unpoison_memory(
82 (((struct dfltcc_param_v0
*)param
)->sbb
== 0 ? 0 : 1));
85 kmsan_unpoison_memory(param
, sizeof(struct dfltcc_param_v0
));
86 kmsan_unpoison_memory(orig_t2
, t2
- orig_t2
);
98 return (cc
>> 28) & 3;
101 static inline int is_bit_set(
106 return bits
[n
/ 8] & (1 << (7 - (n
% 8)));
109 static inline void turn_bit_off(
114 bits
[n
/ 8] &= ~(1 << (7 - (n
% 8)));
117 static inline int dfltcc_are_params_ok(
124 return (level_mask
& (1 << level
)) != 0 &&
125 (window_bits
== HB_BITS
) &&
126 (strategy
== Z_DEFAULT_STRATEGY
);
129 char *oesc_msg(char *buf
, int oesc
);
131 #endif /* DFLTCC_UTIL_H */