From patchwork Fri Feb 4 15:47:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 81914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id EC64CB713F for ; Sat, 5 Feb 2011 03:16:00 +1100 (EST) Received: from localhost ([127.0.0.1]:44068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlOES-00007i-CT for incoming@patchwork.ozlabs.org; Fri, 04 Feb 2011 11:10:00 -0500 Received: from [140.186.70.92] (port=51748 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlNuw-00062U-3j for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlNuu-00080I-Ex for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlNuu-0007zd-7R for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:48 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p14Fnl6M029054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Feb 2011 10:49:47 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p14Fnlmq001435; Fri, 4 Feb 2011 10:49:47 -0500 Received: from amt.cnet (vpn2-8-97.ams2.redhat.com [10.36.8.97]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p14Fnh2Q002225; Fri, 4 Feb 2011 10:49:45 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 52720652135; Fri, 4 Feb 2011 13:48:11 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p14Fm78O017677; Fri, 4 Feb 2011 13:48:07 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Fri, 4 Feb 2011 13:47:13 -0200 Message-Id: <0d845fc30b68cad95db6b37ad26a2198f918ed1d.1296834446.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 10/23] kvm: Provide sigbus services arch-independently X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka Provide arch-independent kvm_on_sigbus* stubs to remove the #ifdef'ery from cpus.c. This patch also fixes --disable-kvm build by providing the missing kvm_on_sigbus_vcpu kvm-stub. Signed-off-by: Jan Kiszka Reviewed-by: Paolo Bonzini Acked-by: Alexander Graf Signed-off-by: Marcelo Tosatti --- cpus.c | 10 ++++------ kvm-all.c | 10 ++++++++++ kvm-stub.c | 5 +++++ kvm.h | 7 +++++-- target-i386/kvm.c | 4 ++-- target-ppc/kvm.c | 10 ++++++++++ target-s390x/kvm.c | 10 ++++++++++ 7 files changed, 46 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index 8475757..3a32828 100644 --- a/cpus.c +++ b/cpus.c @@ -543,10 +543,9 @@ static void sigbus_reraise(void) static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo, void *ctx) { -#if defined(TARGET_I386) - if (kvm_on_sigbus(siginfo->ssi_code, (void *)(intptr_t)siginfo->ssi_addr)) -#endif + if (kvm_on_sigbus(siginfo->ssi_code, (void *)(intptr_t)siginfo->ssi_addr)) { sigbus_reraise(); + } } static void qemu_kvm_eat_signal(CPUState *env, int timeout) @@ -579,10 +578,9 @@ static void qemu_kvm_eat_signal(CPUState *env, int timeout) switch (r) { case SIGBUS: -#ifdef TARGET_I386 - if (kvm_on_sigbus_vcpu(env, siginfo.si_code, siginfo.si_addr)) -#endif + if (kvm_on_sigbus_vcpu(env, siginfo.si_code, siginfo.si_addr)) { sigbus_reraise(); + } break; default: break; diff --git a/kvm-all.c b/kvm-all.c index 55f6ac3..a83aff2 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1366,3 +1366,13 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign) return -ENOSYS; #endif } + +int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) +{ + return kvm_arch_on_sigbus_vcpu(env, code, addr); +} + +int kvm_on_sigbus(int code, void *addr) +{ + return kvm_arch_on_sigbus(code, addr); +} diff --git a/kvm-stub.c b/kvm-stub.c index 88682f2..d6b6c8e 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -147,6 +147,11 @@ int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign) return -ENOSYS; } +int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) +{ + return 1; +} + int kvm_on_sigbus(int code, void *addr) { return 1; diff --git a/kvm.h b/kvm.h index ca57517..b2fb5c6 100644 --- a/kvm.h +++ b/kvm.h @@ -81,6 +81,9 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset); int kvm_pit_in_kernel(void); int kvm_irqchip_in_kernel(void); +int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr); +int kvm_on_sigbus(int code, void *addr); + /* internal API */ struct KVMState; @@ -121,8 +124,8 @@ int kvm_arch_init_vcpu(CPUState *env); void kvm_arch_reset_vcpu(CPUState *env); -int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr); -int kvm_on_sigbus(int code, void *addr); +int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr); +int kvm_arch_on_sigbus(int code, void *addr); struct kvm_guest_debug; struct kvm_debug_exit_arch; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 05010bb..9df8ff8 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1839,7 +1839,7 @@ static void kvm_mce_inj_srao_memscrub2(CPUState *env, target_phys_addr_t paddr) #endif -int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) +int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr) { #if defined(KVM_CAP_MCE) void *vaddr; @@ -1889,7 +1889,7 @@ int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) return 0; } -int kvm_on_sigbus(int code, void *addr) +int kvm_arch_on_sigbus(int code, void *addr) { #if defined(KVM_CAP_MCE) if ((first_cpu->mcg_cap & MCG_SER_P) && addr && code == BUS_MCEERR_AO) { diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 710eca1..93ecc57 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -404,3 +404,13 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env) { return true; } + +int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr) +{ + return 1; +} + +int kvm_arch_on_sigbus(int code, void *addr) +{ + return 1; +} diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 38823f5..1702c46 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -505,3 +505,13 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env) { return true; } + +int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr) +{ + return 1; +} + +int kvm_arch_on_sigbus(int code, void *addr) +{ + return 1; +}