Skip to content

Commit 3870cdc

Browse files
committed
Format code
1 parent d3674f8 commit 3870cdc

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

qemu/target/i386/unicorn.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void reg_reset(struct uc_struct *uc)
9999
memset(env->dr, 0, sizeof(env->dr));
100100
env->dr[6] = DR6_FIXED_1;
101101
env->dr[7] = DR7_FIXED_1;
102-
102+
103103
/* sysenter registers */
104104
env->sysenter_cs = 0;
105105
env->sysenter_esp = 0;
@@ -163,7 +163,7 @@ static void reg_reset(struct uc_struct *uc)
163163
HF_LMA_MASK | HF_OSFXSR_MASK;
164164
env->hflags &= ~(HF_ADDSEG_MASK);
165165
env->efer |= MSR_EFER_LMA | MSR_EFER_LME; // extended mode activated
166-
166+
167167
/* If we are operating in 64bit mode then add the Long Mode flag
168168
* to the CPUID feature flag
169169
*/
@@ -173,23 +173,23 @@ static void reg_reset(struct uc_struct *uc)
173173

174174
// CR initialization
175175
switch (uc->mode) {
176-
case UC_MODE_32:
177-
case UC_MODE_64: {
178-
uint32_t cr4 = 0;
179-
180-
if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) {
181-
cr4 |= CR4_OSFXSR_MASK | CR4_OSXSAVE_MASK;
182-
}
183-
if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_FSGSBASE) {
184-
cr4 |= CR4_FSGSBASE_MASK;
185-
}
176+
case UC_MODE_32:
177+
case UC_MODE_64: {
178+
uint32_t cr4 = 0;
186179

187-
cpu_x86_update_cr0(env, CR0_PE_MASK); // protected mode
188-
cpu_x86_update_cr4(env, cr4);
189-
break;
180+
if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) {
181+
cr4 |= CR4_OSFXSR_MASK | CR4_OSXSAVE_MASK;
190182
}
191-
default:
192-
break;
183+
if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_FSGSBASE) {
184+
cr4 |= CR4_FSGSBASE_MASK;
185+
}
186+
187+
cpu_x86_update_cr0(env, CR0_PE_MASK); // protected mode
188+
cpu_x86_update_cr4(env, cr4);
189+
break;
190+
}
191+
default:
192+
break;
193193
}
194194
}
195195

qemu/target/m68k/unicorn.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ uc_err reg_write(void *_env, int mode, unsigned int regid, const void *value,
173173
break;
174174
case UC_M68K_REG_CR_CACR: {
175175
CHECK_REG_TYPE(uint32_t);
176-
uint32_t val = *(uint32_t*)value;
176+
uint32_t val = *(uint32_t *)value;
177177
if (m68k_feature(env, M68K_FEATURE_M68020)) {
178178
env->cacr = val & 0x0000000f;
179179
} else if (m68k_feature(env, M68K_FEATURE_M68030)) {

tests/unit/test_ctl.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ static void test_uc_hook_cached_uaf(void)
277277

278278
uc_common_setup(&uc, UC_ARCH_X86, UC_MODE_32, code, sizeof(code) - 1);
279279

280-
OK(uc_hook_add(uc, &h, UC_HOOK_CODE, (void *)test_uc_hook_cached_cb, (void *)&count, 1,
281-
0));
280+
OK(uc_hook_add(uc, &h, UC_HOOK_CODE, (void *)test_uc_hook_cached_cb,
281+
(void *)&count, 1, 0));
282282

283283
OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0));
284284

@@ -288,9 +288,10 @@ static void test_uc_hook_cached_uaf(void)
288288
// This will clear deleted hooks and SHOULD clear cache.
289289
OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0));
290290

291-
// Now hooks are deleted and thus this _should not_ call test_uc_hook_cached_cb anymore.
292-
// If the hook is allocated like from malloc, and the code region is free-ed, this call _shall not_
293-
// call the hook anymore to avoid UAF.
291+
// Now hooks are deleted and thus this _should not_ call
292+
// test_uc_hook_cached_cb anymore. If the hook is allocated like from
293+
// malloc, and the code region is free-ed, this call _shall not_ call the
294+
// hook anymore to avoid UAF.
294295
OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0));
295296

296297
// Only 4 calls

tests/unit/test_mips.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ static void test_mips_stop_delay_slot_from_qiling(void)
107107
// 24 ab ff da addiu $t3, $a1, -0x26
108108
// 2d 62 00 02 sltiu $v0, $t3, 2
109109
// 10 40 00 32 beqz $v0, 0x47c8c9c
110-
// 00 00 00 00 nop
110+
// 00 00 00 00 nop
111111
char code[] =
112-
"\x24\x06\x00\x03\x10\xa6\x00\x79\x30\x42\x00\xfc\x10\x40\x00\x32\x24\xab\xff\xda\x2d\x62\x00\x02\x10\x40\x00\x32\x00\x00\x00\x00";
112+
"\x24\x06\x00\x03\x10\xa6\x00\x79\x30\x42\x00\xfc\x10\x40\x00\x32\x24"
113+
"\xab\xff\xda\x2d\x62\x00\x02\x10\x40\x00\x32\x00\x00\x00\x00";
113114
uint32_t r_pc = 0x0;
114115
uint32_t r_v0 = 0xff;
115116
uint32_t r_a1 = 0x3;
116-
117+
117118
uc_common_setup(&uc, UC_ARCH_MIPS, UC_MODE_MIPS32 | UC_MODE_BIG_ENDIAN,
118119
code, sizeof(code) - 1);
119120
OK(uc_reg_write(uc, UC_MIPS_REG_V0, &r_v0));
@@ -207,5 +208,6 @@ TEST_LIST = {
207208
{"test_mips_lwx_exception_issue_1314", test_mips_lwx_exception_issue_1314},
208209
{"test_mips_mips16", test_mips_mips16},
209210
{"test_mips_mips_fpr", test_mips_mips_fpr},
210-
{"test_mips_stop_delay_slot_from_qiling", test_mips_stop_delay_slot_from_qiling},
211+
{"test_mips_stop_delay_slot_from_qiling",
212+
test_mips_stop_delay_slot_from_qiling},
211213
{NULL, NULL}};

uc.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1981,12 +1981,13 @@ void helper_uc_tracecode(int32_t size, uc_hook_idx index, void *handle,
19811981
index &
19821982
UC_HOOK_FLAG_MASK; // The index here may contain additional flags. See
19831983
// the comments of uc_hook_idx for details.
1984-
// bool not_allow_stop = (size & UC_HOOK_FLAG_NO_STOP) || (hook_flags & UC_HOOK_FLAG_NO_STOP);
1984+
// bool not_allow_stop = (size & UC_HOOK_FLAG_NO_STOP) || (hook_flags &
1985+
// UC_HOOK_FLAG_NO_STOP);
19851986
bool not_allow_stop = hook_flags & UC_HOOK_FLAG_NO_STOP;
1986-
1987+
19871988
index = index & UC_HOOK_IDX_MASK;
1988-
// // Like hook index, only low 6 bits of size is used for representing sizes.
1989-
// size = size & UC_HOOK_IDX_MASK;
1989+
// // Like hook index, only low 6 bits of size is used for representing
1990+
// sizes. size = size & UC_HOOK_IDX_MASK;
19901991

19911992
// This has been done in tcg code.
19921993
// sync PC in CPUArchState with address

0 commit comments

Comments
 (0)