From patchwork Wed Jun 27 08:02:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10490765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB5BD602B3 for ; Wed, 27 Jun 2018 08:02:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEDF11FF29 for ; Wed, 27 Jun 2018 08:02:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3119283BF; Wed, 27 Jun 2018 08:02:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,LOTS_OF_MONEY, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F6741FF29 for ; Wed, 27 Jun 2018 08:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933274AbeF0ICS (ORCPT ); Wed, 27 Jun 2018 04:02:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51876 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933106AbeF0ICO (ORCPT ); Wed, 27 Jun 2018 04:02:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 707F281A4EBC for ; Wed, 27 Jun 2018 08:02:14 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-127.ams2.redhat.com [10.36.116.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A41D2156880; Wed, 27 Jun 2018 08:02:13 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini Subject: [kvm-unit-tests PATCH 2/4] Make realmode.c compilable with -Wmissing-prototypes and -Wstrict-prototypes Date: Wed, 27 Jun 2018 10:02:06 +0200 Message-Id: <1530086528-21665-3-git-send-email-thuth@redhat.com> In-Reply-To: <1530086528-21665-1-git-send-email-thuth@redhat.com> References: <1530086528-21665-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 08:02:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 08:02:14 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ... to make sure that we're calling the functions with the right parameters everywhere... Signed-off-by: Thomas Huth --- x86/realmode.c | 67 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/x86/realmode.c b/x86/realmode.c index 6411654..303d093 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -9,6 +9,7 @@ typedef unsigned short u16; typedef unsigned u32; typedef unsigned long long u64; +void realmode_start(void); void test_function(void); asm( @@ -207,7 +208,7 @@ static void exec_in_big_real_mode(struct insn_desc *insn) #define R_SP 64 #define R_BP 128 -int regs_equal(int ignore) +static int regs_equal(int ignore) { const u32 *p1 = &inregs.eax, *p2 = &outregs.eax; // yuck int i; @@ -244,7 +245,7 @@ static void report(const char *name, u16 regs_ignore, _Bool ok) ); \ extern struct insn_desc insn_##name; -void test_xchg(void) +static void test_xchg(void) { MK_INSN(xchg_test1, "xchg %eax,%eax\n\t"); MK_INSN(xchg_test2, "xchg %eax,%ebx\n\t"); @@ -289,7 +290,7 @@ void test_xchg(void) outregs.eax == inregs.esp && outregs.esp == inregs.eax); } -void test_shld(void) +static void test_shld(void) { MK_INSN(shld_test, "shld $8,%edx,%eax\n\t"); @@ -298,7 +299,7 @@ void test_shld(void) report("shld", ~0, outregs.eax == 0xbeef); } -void test_mov_imm(void) +static void test_mov_imm(void) { MK_INSN(mov_r32_imm_1, "mov $1234567890, %eax"); MK_INSN(mov_r16_imm_1, "mov $1234, %ax"); @@ -326,7 +327,7 @@ void test_mov_imm(void) report("mov 5", R_AX, outregs.eax == 0x1234); } -void test_sub_imm(void) +static void test_sub_imm(void) { MK_INSN(sub_r32_imm_1, "mov $1234567890, %eax\n\t" "sub $10, %eax\n\t"); MK_INSN(sub_r16_imm_1, "mov $1234, %ax\n\t" "sub $10, %ax\n\t"); @@ -350,7 +351,7 @@ void test_sub_imm(void) report("sub 4", R_AX, outregs.eax == 0x24); } -void test_xor_imm(void) +static void test_xor_imm(void) { MK_INSN(xor_r32_imm_1, "mov $1234567890, %eax\n\t" "xor $1234567890, %eax\n\t"); MK_INSN(xor_r16_imm_1, "mov $1234, %ax\n\t" "xor $1234, %ax\n\t"); @@ -374,7 +375,7 @@ void test_xor_imm(void) report("xor 4", R_AX, outregs.eax == 0); } -void test_cmp_imm(void) +static void test_cmp_imm(void) { MK_INSN(cmp_test1, "mov $0x34, %al\n\t" "cmp $0x34, %al\n\t"); @@ -399,7 +400,7 @@ void test_cmp_imm(void) report("cmp 3", ~0, (outregs.eflags & (1<<6)) == 0); } -void test_add_imm(void) +static void test_add_imm(void) { MK_INSN(add_test1, "mov $0x43211234, %eax \n\t" "add $0x12344321, %eax \n\t"); @@ -415,7 +416,7 @@ void test_add_imm(void) report("add 2", ~0, outregs.eax == 0x33); } -void test_eflags_insn(void) +static void test_eflags_insn(void) { MK_INSN(clc, "clc"); MK_INSN(stc, "stc"); @@ -445,7 +446,7 @@ void test_eflags_insn(void) report("std", ~0, (outregs.eflags & (1 << 10))); } -void test_io(void) +static void test_io(void) { MK_INSN(io_test1, "mov $0xff, %al \n\t" "out %al, $0xe0 \n\t" @@ -497,12 +498,12 @@ void test_io(void) } asm ("retf: lretw"); -extern void retf(); +extern void retf(void); asm ("retf_imm: lretw $10"); -extern void retf_imm(); +extern void retf_imm(void); -void test_call(void) +static void test_call(void) { u32 esp[16]; u32 addr; @@ -550,7 +551,7 @@ void test_call(void) report("retf imm 1", 0, 1); } -void test_jcc_short(void) +static void test_jcc_short(void) { MK_INSN(jnz_short1, "jnz 1f\n\t" "mov $0x1234, %eax\n\t" @@ -575,7 +576,7 @@ void test_jcc_short(void) report("jmp short 1", ~0, 1); } -void test_jcc_near(void) +static void test_jcc_near(void) { /* encode near jmp manually. gas will not do it if offsets < 127 byte */ MK_INSN(jnz_near1, ".byte 0x0f, 0x85, 0x06, 0x00\n\t" @@ -598,7 +599,7 @@ void test_jcc_near(void) report("jmp near 1", 0, 1); } -void test_long_jmp() +static void test_long_jmp(void) { u32 esp[16]; @@ -612,7 +613,7 @@ void test_long_jmp() report("jmp far 1", R_AX, outregs.eax == 0x1234); } -void test_push_pop() +static void test_push_pop(void) { MK_INSN(push32, "mov $0x12345678, %eax\n\t" "push %eax\n\t" @@ -678,7 +679,7 @@ void test_push_pop() report("push/pop with high bits set in %esp", R_BX, outregs.ebx == 0x9977); } -void test_null(void) +static void test_null(void) { MK_INSN(null, ""); @@ -693,7 +694,7 @@ struct { char top[]; } tmp_stack; -void test_pusha_popa() +static void test_pusha_popa(void) { MK_INSN(pusha, "pusha\n\t" "pop %edi\n\t" @@ -726,7 +727,7 @@ void test_pusha_popa() report("pusha/popa 1", 0, 1); } -void test_iret() +static void test_iret(void) { MK_INSN(iret32, "pushf\n\t" "pushl %cs\n\t" @@ -781,7 +782,7 @@ void test_iret() report("iret 4", R_AX, 1); } -void test_int() +static void test_int(void) { inregs = (struct regs){ 0 }; @@ -794,7 +795,7 @@ void test_int() report("int 1", 0, 1); } -void test_imul() +static void test_imul(void) { MK_INSN(imul8_1, "mov $2, %al\n\t" "mov $-4, %cx\n\t" @@ -843,7 +844,7 @@ void test_imul() report("imul 6", R_AX | R_CX | R_DX, outregs.eax == 8); } -void test_mul() +static void test_mul(void) { MK_INSN(mul8, "mov $2, %al\n\t" "mov $4, %cx\n\t" @@ -869,7 +870,7 @@ void test_mul() report("mul 3", R_AX | R_CX | R_DX, outregs.eax == 8); } -void test_div() +static void test_div(void) { MK_INSN(div8, "mov $257, %ax\n\t" "mov $2, %cl\n\t" @@ -897,7 +898,7 @@ void test_div() outregs.eax == 102 && outregs.edx == 2); } -void test_idiv() +static void test_idiv(void) { MK_INSN(idiv8, "mov $256, %ax\n\t" "mov $-2, %cl\n\t" @@ -923,7 +924,7 @@ void test_idiv() report("idiv 3", R_AX | R_CX | R_DX, outregs.eax == (u32)-256); } -void test_cbw(void) +static void test_cbw(void) { MK_INSN(cbw, "mov $0xFE, %eax \n\t" "cbw\n\t"); @@ -939,7 +940,7 @@ void test_cbw(void) report("cwde 1", ~0, outregs.eax == 0xFFFFFFFE); } -void test_loopcc(void) +static void test_loopcc(void) { MK_INSN(loop, "mov $10, %ecx\n\t" "1: inc %eax\n\t" @@ -1251,7 +1252,7 @@ static void test_das(void) report("DAS", ~0, nr_fail == 0); } -void test_cwd_cdq() +static void test_cwd_cdq(void) { /* Sign-bit set */ MK_INSN(cwd_1, "mov $0x8000, %ax\n\t" @@ -1296,7 +1297,7 @@ static struct { 0x10, }; -void test_lds_lss() +static void test_lds_lss(void) { inregs = (struct regs){ .ebx = (unsigned long)&desc }; @@ -1346,7 +1347,7 @@ void test_lds_lss() outregs.ebx == desc.sel); } -void test_jcxz(void) +static void test_jcxz(void) { MK_INSN(jcxz1, "jcxz 1f\n\t" "mov $0x1234, %eax\n\t" @@ -1645,7 +1646,7 @@ static void test_perf_memory_rmw(void) print_serial(" cycles/emulated memory RMW instruction\n"); } -void test_dr_mod(void) +static void test_dr_mod(void) { MK_INSN(drmod, "movl %ebx, %dr0\n\t" ".byte 0x0f \n\t .byte 0x21 \n\t .byte 0x0\n\t"); @@ -1655,7 +1656,7 @@ void test_dr_mod(void) report("mov dr with mod bits", R_AX | R_BX, outregs.eax == 0xaced); } -void test_smsw(void) +static void test_smsw(void) { MK_INSN(smsw, "movl %cr0, %ebx\n\t" "movl %ebx, %ecx\n\t" @@ -1668,7 +1669,7 @@ void test_smsw(void) report("smsw", R_AX | R_BX | R_CX, outregs.eax == outregs.ebx); } -void test_xadd(void) +static void test_xadd(void) { MK_INSN(xadd, "xaddl %eax, %eax\n\t"); inregs.eax = 0x12345678;