From patchwork Fri Sep 28 08:33:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10619155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E61714BD for ; Fri, 28 Sep 2018 08:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90AAC28497 for ; Fri, 28 Sep 2018 08:33:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8467B2863D; Fri, 28 Sep 2018 08:33: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,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 043DE28497 for ; Fri, 28 Sep 2018 08:33:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729229AbeI1Oz5 (ORCPT ); Fri, 28 Sep 2018 10:55:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31367 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbeI1Oz5 (ORCPT ); Fri, 28 Sep 2018 10:55:57 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 695E9308123E; Fri, 28 Sep 2018 08:33:19 +0000 (UTC) Received: from thuth.com (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3FC720155E2; Fri, 28 Sep 2018 08:33:17 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Drew Jones , Janosch Frank Subject: [kvm-unit-tests PATCH 2/4] x86: Add missing prototypes and mark more local functions as static Date: Fri, 28 Sep 2018 10:33:00 +0200 Message-Id: <1538123582-17442-3-git-send-email-thuth@redhat.com> In-Reply-To: <1538123582-17442-1-git-send-email-thuth@redhat.com> References: <1538123582-17442-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 28 Sep 2018 08:33:19 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To be able to compile with -Wmissing-prototypes, we also need prototypes for functions that are called from assembler code. We put the prototypes into the .c files and not into header files here, since these functions are not called from other .c files. While we're at it, also mark some more functions as static in these files which are only used locally. Signed-off-by: Thomas Huth --- lib/x86/desc.c | 5 +++++ lib/x86/setup.c | 4 +++- x86/eventinj.c | 6 ++++-- x86/kvmclock.c | 11 ++++++----- x86/pku.c | 3 ++- x86/smap.c | 1 + x86/taskswitch2.c | 12 +++++++----- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/x86/desc.c b/lib/x86/desc.c index 23a0d5a..0108555 100644 --- a/lib/x86/desc.c +++ b/lib/x86/desc.c @@ -3,6 +3,11 @@ #include "processor.h" #include +#ifndef __x86_64__ +__attribute__((regparm(1))) +#endif +void do_handle_exception(struct ex_regs *regs); + void set_idt_entry(int vec, void *addr, int dpl) { idt_entry_t *e = &boot_idt[vec]; diff --git a/lib/x86/setup.c b/lib/x86/setup.c index ff7c8d3..28bbcf4 100644 --- a/lib/x86/setup.c +++ b/lib/x86/setup.c @@ -35,7 +35,9 @@ struct mbi_module { #define ENV_SIZE 16384 -extern void setup_env(char *env, int size); +void setup_env(char *env, int size); +void setup_multiboot(struct mbi_bootinfo *bootinfo); +void setup_libcflat(void); char *initrd; u32 initrd_size; diff --git a/x86/eventinj.c b/x86/eventinj.c index cbfc03f..8064eb9 100644 --- a/x86/eventinj.c +++ b/x86/eventinj.c @@ -14,17 +14,19 @@ # define R "e" #endif +void do_pf_tss(void); + static inline void io_delay(void) { } -void apic_self_ipi(u8 v) +static void apic_self_ipi(u8 v) { apic_icr_write(APIC_DEST_SELF | APIC_DEST_PHYSICAL | APIC_DM_FIXED | APIC_INT_ASSERT | v, 0); } -void apic_self_nmi(void) +static void apic_self_nmi(void) { apic_icr_write(APIC_DEST_PHYSICAL | APIC_DM_NMI | APIC_INT_ASSERT, 0); } diff --git a/x86/kvmclock.c b/x86/kvmclock.c index e7b6054..de30a5e 100644 --- a/x86/kvmclock.c +++ b/x86/kvmclock.c @@ -61,6 +61,7 @@ static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift) __rem; \ }) #else +u32 __attribute__((weak)) __div64_32(u64 *n, u32 base); u32 __attribute__((weak)) __div64_32(u64 *n, u32 base) { u64 rem = *n; @@ -121,7 +122,7 @@ u32 __attribute__((weak)) __div64_32(u64 *n, u32 base) * 0 <= tv_nsec < NSEC_PER_SEC * For negative values only the tv_sec field is negative ! */ -void set_normalized_timespec(struct timespec *ts, long sec, s64 nsec) +static void set_normalized_timespec(struct timespec *ts, long sec, s64 nsec) { while (nsec >= NSEC_PER_SEC) { /* @@ -179,7 +180,7 @@ cycle_t __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src) return src->system_time + offset; } -cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src) +static cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src) { unsigned version; cycle_t ret; @@ -246,9 +247,9 @@ void kvm_clock_clear(void *data) wrmsr(MSR_KVM_SYSTEM_TIME_NEW, 0LL); } -void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock, - struct pvclock_vcpu_time_info *vcpu_time, - struct timespec *ts) +static void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock, + struct pvclock_vcpu_time_info *vcpu_time, + struct timespec *ts) { u32 version; u64 delta; diff --git a/x86/pku.c b/x86/pku.c index d51d26f..3d7c5cd 100644 --- a/x86/pku.c +++ b/x86/pku.c @@ -14,7 +14,7 @@ volatile int pf_count = 0; volatile unsigned save; volatile unsigned test; -void set_cr0_wp(int wp) +static void set_cr0_wp(int wp) { unsigned long cr0 = read_cr0(); @@ -24,6 +24,7 @@ void set_cr0_wp(int wp) write_cr0(cr0); } +void do_pf_tss(unsigned long error_code); void do_pf_tss(unsigned long error_code) { pf_count++; diff --git a/x86/smap.c b/x86/smap.c index f316c14..afa3644 100644 --- a/x86/smap.c +++ b/x86/smap.c @@ -9,6 +9,7 @@ volatile int pf_count = 0; volatile int save; volatile unsigned test; +void do_pf_tss(unsigned long error_code); // When doing ring 3 tests, page fault handlers will always run on a // separate stack (the ring 0 stack). Seems easier to use the alt_stack diff --git a/x86/taskswitch2.c b/x86/taskswitch2.c index 8714ade..62f0ead 100644 --- a/x86/taskswitch2.c +++ b/x86/taskswitch2.c @@ -17,6 +17,8 @@ static volatile unsigned int test_divider; static char *fault_addr; static ulong fault_phys; +void do_pf_tss(ulong *error_code); + static inline void io_delay(void) { } @@ -115,7 +117,7 @@ start: goto start; } -void test_kernel_mode_int() +static void test_kernel_mode_int(void) { unsigned int res; @@ -193,7 +195,7 @@ void test_kernel_mode_int() report("PF exeption", test_count == 1); } -void test_gdt_task_gate(void) +static void test_gdt_task_gate(void) { /* test that calling a task by lcall works */ test_count = 0; @@ -219,7 +221,7 @@ void test_gdt_task_gate(void) report("ljmp", test_count == 1); } -void test_vm86_switch(void) +static void test_vm86_switch(void) { static tss32_t main_tss; static tss32_t vm86_tss; @@ -266,7 +268,7 @@ void test_vm86_switch(void) #define IOPL_SHIFT 12 -void test_conforming_switch(void) +static void test_conforming_switch(void) { /* test lcall with conforming segment, cs.dpl != cs.rpl */ test_count = 0; @@ -281,7 +283,7 @@ void test_conforming_switch(void) report("lcall with cs.rpl != cs.dpl", test_count == 1); } -int main() +int main(void) { setup_vm(); setup_idt();