From nobody Mon Feb 9 22:04:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488199953971355.97929506080857; Mon, 27 Feb 2017 04:52:33 -0800 (PST) Received: from localhost ([::1]:52253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciKn2-0001PL-HN for importer@patchew.org; Mon, 27 Feb 2017 07:52:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciKgo-0004id-KB for qemu-devel@nongnu.org; Mon, 27 Feb 2017 07:46:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciKgm-0000Zu-E8 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 07:46:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciKgm-0000Yo-34 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 07:46:04 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3AB324E4C6 for ; Mon, 27 Feb 2017 12:46:04 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-118.ams2.redhat.com [10.36.117.118]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RCjpe4028718 for ; Mon, 27 Feb 2017 07:46:03 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 13:45:43 +0100 Message-Id: <20170227124551.8673-10-pbonzini@redhat.com> In-Reply-To: <20170227124551.8673-1-pbonzini@redhat.com> References: <20170227124551.8673-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Feb 2017 12:46:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 09/17] KVM: remove kvm_arch_on_sigbus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Build it on kvm_arch_on_sigbus_vcpu instead. They do the same for "action optional" SIGBUSes, and the main thread should never get "action required" SIGBUSes because it blocks the signal. Signed-off-by: Paolo Bonzini --- include/sysemu/kvm.h | 1 - kvm-all.c | 9 ++++++++- target/arm/kvm.c | 5 ----- target/i386/kvm.c | 40 +++++----------------------------------- target/mips/kvm.c | 6 ------ target/ppc/kvm.c | 5 ----- target/s390x/kvm.c | 5 ----- 7 files changed, 13 insertions(+), 58 deletions(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 3045ee7..6ecb61c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -358,7 +358,6 @@ bool kvm_vcpu_id_is_valid(int vcpu_id); unsigned long kvm_arch_vcpu_id(CPUState *cpu); =20 int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); -int kvm_arch_on_sigbus(int code, void *addr); =20 void kvm_arch_init_irq_routing(KVMState *s); =20 diff --git a/kvm-all.c b/kvm-all.c index 0c94637..a433ad3 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2391,6 +2391,7 @@ int kvm_set_signal_mask(CPUState *cpu, const sigset_t= *sigset) =20 return r; } + int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr) { return kvm_arch_on_sigbus_vcpu(cpu, code, addr); @@ -2398,7 +2399,13 @@ int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void= *addr) =20 int kvm_on_sigbus(int code, void *addr) { - return kvm_arch_on_sigbus(code, addr); + /* Action required MCE kills the process if SIGBUS is blocked. Because + * that's what happens in the I/O thread, where we handle MCE via sign= alfd, + * we can only get action optional here. + */ + assert(code !=3D BUS_MCEERR_AR); + kvm_arch_on_sigbus_vcpu(first_cpu, code, addr); + return 0; } =20 int kvm_create_device(KVMState *s, uint64_t type, bool test) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 395e986..e5218f6 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -565,11 +565,6 @@ int kvm_arch_on_sigbus_vcpu(CPUState *cs, int code, vo= id *addr) return 1; } =20 -int kvm_arch_on_sigbus(int code, void *addr) -{ - return 1; -} - /* The #ifdef protections are until 32bit headers are imported and can * be removed once both 32 and 64 bit reach feature parity. */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index f49a786..2adf992 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -462,14 +462,13 @@ int kvm_arch_on_sigbus_vcpu(CPUState *c, int code, vo= id *addr) ram_addr_t ram_addr; hwaddr paddr; =20 + /* If we get an action required MCE, it has been injected by KVM + * while the VM was running. An action optional MCE instead should + * be coming from the main thread, which qemu_init_sigbus identifies + * as the "early kill" thread. + */ assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); =20 - /* Because the MCE happened while running the VCPU, KVM could have - * injected action required MCEs too. Action optional MCEs should - * be delivered to the main thread, which qemu_init_sigbus identifies - * as the "early kill" thread, but if we get one for whatever reason - * we just handle it just like the main thread would. - */ if ((env->mcg_cap & MCG_SER_P) && addr) { ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && @@ -491,35 +490,6 @@ int kvm_arch_on_sigbus_vcpu(CPUState *c, int code, voi= d *addr) return 0; } =20 -int kvm_arch_on_sigbus(int code, void *addr) -{ - X86CPU *cpu =3D X86_CPU(first_cpu); - - assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); - - if (code =3D=3D BUS_MCEERR_AR) { - hardware_memory_error(); - } - - /* Hope we are lucky for AO MCE */ - if ((cpu->env.mcg_cap & MCG_SER_P) && addr) { - ram_addr_t ram_addr; - hwaddr paddr; - - ram_addr =3D qemu_ram_addr_from_host(addr); - if (ram_addr !=3D RAM_ADDR_INVALID && - kvm_physical_memory_addr_from_host(first_cpu->kvm_state, - addr, &paddr)) { - kvm_hwpoison_page_add(ram_addr); - kvm_mce_inject(X86_CPU(first_cpu), paddr, code); - } - - fprintf(stderr, "Hardware memory error for memory used by " - "QEMU itself instead of guest system!: %p\n", addr); - } - return 0; -} - static int kvm_inject_mce_oldstyle(X86CPU *cpu) { CPUX86State *env =3D &cpu->env; diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 998c341..3e686e7 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -186,12 +186,6 @@ int kvm_arch_on_sigbus_vcpu(CPUState *cs, int code, vo= id *addr) return 1; } =20 -int kvm_arch_on_sigbus(int code, void *addr) -{ - DPRINTF("%s\n", __func__); - return 1; -} - void kvm_arch_init_irq_routing(KVMState *s) { } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 52bbea5..bc011c6 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2587,11 +2587,6 @@ int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code,= void *addr) return 1; } =20 -int kvm_arch_on_sigbus(int code, void *addr) -{ - return 1; -} - void kvm_arch_init_irq_routing(KVMState *s) { } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 5ec050c..e7eea6d 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2145,11 +2145,6 @@ int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code,= void *addr) return 1; } =20 -int kvm_arch_on_sigbus(int code, void *addr) -{ - return 1; -} - void kvm_s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word) --=20 2.9.3