From nobody Tue Apr 30 02:31:50 2024 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 148725781955891.56602858768531; Thu, 16 Feb 2017 07:10:19 -0800 (PST) Received: from localhost ([::1]:47231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNhH-0007I6-Et for importer@patchew.org; Thu, 16 Feb 2017 10:10:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6G-0003T1-Sa for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6F-0007yC-Vr for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:00 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:32814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6F-0007xZ-QB for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:31:59 -0500 Received: by mail-wm0-x242.google.com with SMTP id v77so3426568wmv.0 for ; Thu, 16 Feb 2017 06:31:59 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.31.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PdEF0EJAIfT4t4ViIfjOgoG41Hq/JsXu0D4dWMgTC1M=; b=UN9jcfNXKfljHmXWX/2Sz17tur3tDFWv5iZKsiTdE5Vgv7LXnEb86iVrZGDL+6tK5M 8Cgb9tb5G7truPu6+Y3q9cauESTVTl7rA6YE/SaIZx3F//1p+tgURRuUboKAazFd3k6H jn9dFYR/9cGIBgkZRalp4mpp9WAdBD+XPh01ewSCD6k+MnTO3zRgbwCr0WGOi2mPGLUa CKRqA74vg6QoxE8jlr9fSYyhd8UfbO2sQmfd3z0G4PZfBUwSqeh8QwVqldSISbxYQ2C8 4r7xZ0m2UkENlNiRC97wPZiIOTewRsGvOzYvO/OBVTIyJchtKlwZcBiPzArMuK3zA/lU Iptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PdEF0EJAIfT4t4ViIfjOgoG41Hq/JsXu0D4dWMgTC1M=; b=jGTDgYRL5troAntmwWUpZG71JnEA87u5oO4llIeEKmi2Uwq5sN5BbbnZRbf/OlUO12 s4aTiFwutKfAGZhmlM0hDFNSzos/NcB3eH0nPa7N8wdp8s2N68PVO1HAk3glRAfkEWYK SuuSU9Dm7N/+NZaso+cv3+yyq7qOo0PivlZbWXfYnKv89qAKfWXzZjDAj0JDEEJmzC/o uOYO6ZlmEl77Elt3v444e/uyYaagH86otai6fNAtHmro1BbCYzD8MdT9yy+hai6bvuHV 9p4qmHNRHjMJ/Nu3g18TkPx8oPFACcn+XEEYz6v96JyQ+u7Wjcg9VtRKhSJHakvKo/C6 +kTw== X-Gm-Message-State: AMke39lj8ACPVxyvC8tcRrvx6+1AaMa0EaG0bAzpYB4aGasH9SwfMwoJGgDn6JPRldXMAw== X-Received: by 10.28.139.134 with SMTP id n128mr13370199wmd.125.1487255518808; Thu, 16 Feb 2017 06:31:58 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:25 +0100 Message-Id: <1487255507-106654-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 01/23] kvm/ioapic: dump real object instead of a fake one 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: , Cc: Peter Xu 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" From: Peter Xu When we do "info ioapic" for kvm ioapic, we were building up a temporary ioapic object. Let's fetch the real one and update correspond to the real object as well. This fixes printing uninitialized version field in ioapic_print_redtbl(). Reported-by: Peter Maydell Suggested-by: Paolo Bonzini Signed-off-by: Peter Xu Message-Id: <1486106298-3699-2-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/kvm/ioapic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 8eb2c7a..716d59a 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -114,11 +114,11 @@ static void kvm_ioapic_put(IOAPICCommonState *s) =20 void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict) { - IOAPICCommonState s; + IOAPICCommonState *s =3D IOAPIC_COMMON(object_resolve_path("ioapic", N= ULL)); =20 - kvm_ioapic_get(&s); - - ioapic_print_redtbl(mon, &s); + assert(s); + kvm_ioapic_get(s); + ioapic_print_redtbl(mon, s); } =20 static void kvm_ioapic_reset(DeviceState *dev) --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258928284862.1578877542437; Thu, 16 Feb 2017 07:28:48 -0800 (PST) Received: from localhost ([::1]:47335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNzB-0006M4-PX for importer@patchew.org; Thu, 16 Feb 2017 10:28:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6J-0003W1-Fh for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6I-00080I-NL for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:03 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:34873) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6I-0007z6-HK for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:02 -0500 Received: by mail-wr0-x242.google.com with SMTP id q39so2263414wrb.2 for ; Thu, 16 Feb 2017 06:32:02 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.31.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=yLLGwLVlQnJ3EjGhuT76OIkM7bIWOEW8bHV0hhwEZ/M=; b=X9pvP8X97RDP/DZJ6xqUxP8mYo5i0ZS6YXruEMrV/jK8MTKZtW6VsEnkRtktCMbA3Z 17kGEK72Jvfp7cR0IASJW4Y4ZMVfoWPfRbc2QhwdrTxt0Zd8bA/GyAEUD1pPaCQVzo5G /4dK6c1UwXzNDf4rjtESHlQCsYvcIWRx0r28uW9OtfqBcB6mkaSr/4J1RZYmF41UEJo6 oUZIUsTFfFQ70wsFbtIIf1sFft7kBSSc9IJs7Dv6hfwKAOk4UqDFYriJ770tdb/UkCdo /3h+RKSCSJ68juLJdcZGoQTOWLuE4JjiuEePRhOWlmMVvfm3gpS1+vxVduS8FSUMJJEv 9ydA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=yLLGwLVlQnJ3EjGhuT76OIkM7bIWOEW8bHV0hhwEZ/M=; b=o3vFV3uu8VTw+zja1CrMugI1kXGkwDl8vkzLOqKfkqw4Yu+EhwSJfO0aHJfed7qbup T+x2d/2M+g8zKisPx+zjyjalwnkBNi+2AnRx+WN+M25eQ5dAN1Wwr1CuI0qeqYgiDEoI rUe7LTjFy1dj9e+mdy91fLtCU1EDjDpvnLjvJwxf3GsqtF+xH7oRWGE0+G23wDPwI7bj kWqrNt3zxX8dtctaH+Gj87UXf+KjnuYNgP6Mt1y0lI5CZ31SZ4b8+1Mf48PeM18qMvZb hcvvYnSivio0x3SLEgpug82o5aBYXnU44dxHoIfvebrfKI0lsjQ4UysoEnIVdg+nxKW1 laVw== X-Gm-Message-State: AMke39nu5hn+QBc68teOFDfiP/rhr29rniAigF/gQWMy+OmOpfypwKEm5esmyhSsVpcRqA== X-Received: by 10.223.175.71 with SMTP id z65mr2986924wrc.84.1487255521256; Thu, 16 Feb 2017 06:32:01 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:26 +0100 Message-Id: <1487255507-106654-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 02/23] ioapic: fix error report value of def version 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: , Cc: Peter Xu 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" From: Peter Xu It should be 0x20, rather than 0x11. Signed-off-by: Peter Xu Message-Id: <1486106298-3699-3-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/intc/ioapic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 9047b89..37c4386 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -408,13 +408,15 @@ static void ioapic_machine_done_notify(Notifier *noti= fier, void *data) #endif } =20 +#define IOAPIC_VER_DEF 0x20 + static void ioapic_realize(DeviceState *dev, Error **errp) { IOAPICCommonState *s =3D IOAPIC_COMMON(dev); =20 if (s->version !=3D 0x11 && s->version !=3D 0x20) { error_report("IOAPIC only supports version 0x11 or 0x20 " - "(default: 0x11)."); + "(default: 0x%x).", IOAPIC_VER_DEF); exit(1); } =20 @@ -429,7 +431,7 @@ static void ioapic_realize(DeviceState *dev, Error **er= rp) } =20 static Property ioapic_properties[] =3D { - DEFINE_PROP_UINT8("version", IOAPICCommonState, version, 0x20), + DEFINE_PROP_UINT8("version", IOAPICCommonState, version, IOAPIC_VER_DE= F), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487257228243741.109323240667; Thu, 16 Feb 2017 07:00:28 -0800 (PST) Received: from localhost ([::1]:47174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNXn-0007VE-3N for importer@patchew.org; Thu, 16 Feb 2017 10:00:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6L-0003YE-Ib for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6K-00081q-Oe for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:05 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:32829) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6K-00081Q-Iu for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:04 -0500 Received: by mail-wm0-x242.google.com with SMTP id v77so3426958wmv.0 for ; Thu, 16 Feb 2017 06:32:04 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BcimWc5neCHvgnwNA1SNd50KY04Ts7rUpyRR5xQDoVg=; b=M81xTVqPXoT3OfcGHkiqPoPfoOBz3ish6ZLygoeHa/7MCUYT7UQB0GQFCcZC9juHDQ UezyGmzcxX1fi6xud1RnNvtvyAI2/3zW2UrNHi4F60OVNMyPOMCwPz9GF/tErH9nv4mQ vmWbUbfVsTk2H1BN20oSURXI8WRk3rbNnNhcTydc0ren0hrqCoKQ+EwRzaaRVAysGisQ UkhssugLgTlkaI9QF19NDggxR62s9ZPGDtkGqenBia13XMM1bDVdLgQDY+ID3pJpsK7f GrTZ6yruxEBjM6kG8HAEiM7xmHxCl6llmcxVIYJqPm0ZnnWILzvBwMfHbK/fmjZ6Qdnp Zv9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=BcimWc5neCHvgnwNA1SNd50KY04Ts7rUpyRR5xQDoVg=; b=cZClGERNHb2hFcoIm7SOulFuqg6iy698R3VA+gcRdq0uA0K3fPZvui50IFaGmbqUHY iCF2PYjWia26+OtHFJMtim+L5HpxcMK3xiIIENOydly8/zuvD7ud9MMONKJWCuESNRKB YhHrvXpuiGOJlVRM9zyENoq2DZhGFe4QssmWKkHJ79iby9cx0n79ZcNe6CT4NGm+yw5D dtYqjTog44E+RHpsF4UOz7V6bSCnlcEZA3YdBAOVPOn6NYTA4FezqfpxcC1SuOSNGFqy ZDM9R/V9LTXSsoVd3fSsiKsYTh/UMSG1z4Mlyj3xbQtYTmLJyKyTkstiPv9y8us/78m8 hEdw== X-Gm-Message-State: AMke39mUtjKuW66bjS7CL03Pa/4rGm0n4XXCxmaU3+Bje5dkFmkIujl8TJ95uwsyV/c09g== X-Received: by 10.28.212.84 with SMTP id l81mr2856977wmg.119.1487255523438; Thu, 16 Feb 2017 06:32:03 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:27 +0100 Message-Id: <1487255507-106654-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 03/23] kvm/ioapic: correct kvm ioapic version 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: , Cc: Peter Xu 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" From: Peter Xu Signed-off-by: Peter Xu Message-Id: <1486106298-3699-4-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/kvm/ioapic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 716d59a..98ca480 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -143,6 +143,11 @@ static void kvm_ioapic_realize(DeviceState *dev, Error= **errp) IOAPICCommonState *s =3D IOAPIC_COMMON(dev); =20 memory_region_init_reservation(&s->io_memory, NULL, "kvm-ioapic", 0x10= 00); + /* + * KVM ioapic only supports 0x11 now. This will only be used when + * we want to dump ioapic version. + */ + s->version =3D 0x11; =20 qdev_init_gpio_in(dev, kvm_ioapic_set_irq, IOAPIC_NUM_PINS); } --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487259200292867.0273501782038; Thu, 16 Feb 2017 07:33:20 -0800 (PST) Received: from localhost ([::1]:47356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceO3X-0002kZ-SJ for importer@patchew.org; Thu, 16 Feb 2017 10:33:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6O-0003ZI-Qg for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6M-00082S-LZ for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:08 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6M-00082G-FW for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:06 -0500 Received: by mail-wm0-x243.google.com with SMTP id c85so3428880wmi.1 for ; Thu, 16 Feb 2017 06:32:06 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=GUGwq/beWJ0DD+EWfO+NUkx44xSd6L6FV+VLM49dNWI=; b=jHTuQ8QWYJseUPX+OB31kyxXb9t8kG9RUd/cNLCty5+M9UY7/YqpVhqrUcmeSzYXCB iUbtaTetdPsRTz37EPPibIdpuooCrnNMjde5xlF5Wy7726iglNAlll5Fq5jpOJxzfWYQ jcSkXaIcEn9ln6AL/7aKQ00vwt05BfntljuuAIb3FUXaQ8UHsvo4wzjya7eyYFNjDlH4 0m+fCVtJFW5CDLXuaZEtsjUOD+p418j0bavxchUEBQ/5DK0HD3WhpQiS0q5r4vY6+2kp rp7ecBY+8zn5/Duf44nQTq6mRbXb0K1lJCw+kYpnx4xuQAaGzDkX6TVoNC5w9k1gRkn2 Gt/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=GUGwq/beWJ0DD+EWfO+NUkx44xSd6L6FV+VLM49dNWI=; b=CefHkY+mMwTQbpBH706+XWwx3NYxUshGeUUzcePY4zBLoj2YRANi/zZu2TpPEF6Vk2 8m4hMGYee4TkE0SAfSwm9rLL/y9Yxfh89IVAKJMJDnW+IuwifFaMTqSUYkQKGdaDm5iR PRUMejJpn3hY5QDX+ecgQmeLmfEHpo41xcoqGolaLtqykU7AB7Sf0ERj88MTdU17vuCe LrAJQiHnq/KqGHqItK0sOCdrwp7G2outs2qm2czKs162iuR9sRLH6VBsH+AAlVNJXCY0 qLo4PoLAGXSefFcBbdyekaDlIekQJdPqR0FJjQbKSSRckQTHhSCrP6+NKkc5onVsliq5 r2pg== X-Gm-Message-State: AMke39lIaacl4jrO8zTdVxgxgLhM0PccFwl4IYGcCVHqWXDyNNoCnjeybiss65hTVIVe2g== X-Received: by 10.28.140.130 with SMTP id o124mr2828427wmd.48.1487255525288; Thu, 16 Feb 2017 06:32:05 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:28 +0100 Message-Id: <1487255507-106654-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 04/23] test-vmstate: remove yield_until_fd_readable 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" The function is not needed anymore now that migration is built on top of QIOChannel. Signed-off-by: Paolo Bonzini --- tests/test-vmstate.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index d0dd390..39f338a4 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -33,17 +33,6 @@ static char temp_file[] =3D "/tmp/vmst.test.XXXXXX"; static int temp_fd; =20 -/* Fake yield_until_fd_readable() implementation so we don't have to pull = the - * coroutine code as dependency. - */ -void yield_until_fd_readable(int fd) -{ - fd_set fds; - FD_ZERO(&fds); - FD_SET(fd, &fds); - select(fd + 1, &fds, NULL, NULL, NULL); -} - =20 /* Duplicate temp_fd and seek to the beginning of the file */ static QEMUFile *open_test_file(bool write) --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487259483907980.6655155144978; Thu, 16 Feb 2017 07:38:03 -0800 (PST) Received: from localhost ([::1]:47380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceO89-0006en-H6 for importer@patchew.org; Thu, 16 Feb 2017 10:38:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6Q-0003ad-2V for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6P-00082n-7A for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:10 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:36680) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6P-00082d-0U for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:09 -0500 Received: by mail-wr0-x242.google.com with SMTP id z61so1487307wrc.3 for ; Thu, 16 Feb 2017 06:32:08 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wxhew6z1gCaxtFCLCACx16w++ibxtQWx/mkRf0cMQ0E=; b=orN0DktkzqKvrRasSzpLGhA5AaZKwIriT1NJ5+YXyqQKre2bIEpNv1TIcx454uKTjY 3w7oJsIke0qWo/WZ8H/5GLKbmoo23IHZLCSQ2uWa1xcZu8j1PnurpdRLOdNLmW76IxVq 9ravQxand6WIBHdiqDHwHccRynD5lio1k5jbngcMjNZrUPV6Ge96guqY0A7M4HOmc1HN eDWeSkL5btnenBayth3OBs3hRKjQafEcuzD4+sHuPZn2V7HOl661c1Bkbzgsy9ct8blO yGb0DOy3f8maAHfogBHl3oj+nKyAqdndbiloIGVUt3k1AWeRVZFXXGFtnLzjixLa23iw UsLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Wxhew6z1gCaxtFCLCACx16w++ibxtQWx/mkRf0cMQ0E=; b=Pu3Ut6LR66VK+ObLjbaGstP7RE/fX15cxTIH8k+rk2EFzvToCZvjPm7A+EldYgVhDn Xq1ZCVTbxurxg7gsaE9ZyeWvshqpz2f+CfFZhmN/Irar7wJJ7PBAQvzcVqMxekNdc0De qelHNclSJQ9rdvkJF/PukoFihTLaqtroxC/xcg1IBxAm7tQOS1McVxM1l6jv4E660LNg NtaAg68PsVF/jXk08lbBYGOC2mxxs2JeliYzWS4fHRgR4s3Xt7eRryPn1/hVK+2qVWL1 wIZ4IcnIps4YoP+CDf5H7s1h56woAiip7+P/fl/YTywPskcqY5oyLzo7qKoYlR7jUN3f MSeA== X-Gm-Message-State: AMke39msPBwGhnBSXuWaV5vdI9DKHsBIjGhxx3lAv6FJy2TKSi9Mwyb25sN9G5sysQN3fQ== X-Received: by 10.223.163.142 with SMTP id l14mr156190wrb.35.1487255527855; Thu, 16 Feb 2017 06:32:07 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:29 +0100 Message-Id: <1487255507-106654-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 05/23] qemu-char: socket backend: disconnect on write error 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: , Cc: "Denis V. Lunev" , Anton Nefedov , =?UTF-8?q?Marc-Andr=C3=83=C2=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Anton Nefedov Socket backend read handler should normally perform a disconnect, however the read handler may not get a chance to run if the frontend is not ready (qemu_chr_be_can_write() =3D=3D 0). This means that in virtio-serial frontend case if - the host has disconnected (giving EPIPE on socket write) - and the guest has disconnected (-> frontend not ready -> backend will not read) - and there is still data (frontend->backend) to flush (has to be a really tricky timing but nevertheless, we have observed the case in production) This results in virtio-serial trying to flush this data continiously forming a busy loop. Solution: react on write error in the socket write handler. errno is not reliable after qio_channel_writev_full(), so we may not get the exact EPIPE, so disconnect on any error but QIO_CHANNEL_ERR_BLOCK which io_channel_send_full() converts to errno EAGAIN. We must not disconnect right away though, there still may be data to read (see 4bf1cb0). Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev CC: Paolo Bonzini CC: Daniel P. Berrange CC: Marc-Andr=C3=83=C2=A9 Lureau Message-Id: <1486045589-8074-1-git-send-email-den@openvz.org> Signed-off-by: Paolo Bonzini --- chardev/char-socket.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 4068dc5..865c527 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -97,6 +97,9 @@ static gboolean tcp_chr_accept(QIOChannel *chan, GIOCondition cond, void *opaque); =20 +static int tcp_chr_read_poll(void *opaque); +static void tcp_chr_disconnect(Chardev *chr); + /* Called with chr_write_lock held. */ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) { @@ -114,6 +117,13 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *= buf, int len) s->write_msgfds_num =3D 0; } =20 + if (ret < 0 && errno !=3D EAGAIN) { + if (tcp_chr_read_poll(chr) <=3D 0) { + tcp_chr_disconnect(chr); + return len; + } /* else let the read handler finish it properly */ + } + return ret; } else { /* XXX: indicate an error ? */ --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487259750589446.2756696020681; Thu, 16 Feb 2017 07:42:30 -0800 (PST) Received: from localhost ([::1]:47403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOCR-0002og-4Z for importer@patchew.org; Thu, 16 Feb 2017 10:42:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6S-0003cz-Bh for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6Q-000836-Ua for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:12 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:32856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6Q-00082z-OZ; Thu, 16 Feb 2017 09:32:10 -0500 Received: by mail-wr0-x242.google.com with SMTP id i10so2280901wrb.0; Thu, 16 Feb 2017 06:32:10 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=JqajGCsMm+buwKmhbKgAecuJ3k4XMm8a265dEqZbvR4=; b=JME0xSDJOSklRFWV3pq5Wk7kAHnPKzg9U5aAT7fQfA8IkDkN/pvqTArWItpY57unyc sO+/Dnl9qctor8xfAy/2azS0V2j193uMGsRuzjtjHkPDqoYvXKZIIGx9c5mTWuS3gsLG dYtLDLyGFiPmyTQ3TChUSG+Zn/GQ90i/MANDFzd/Bih5kwNL4HYFFLwTOmCZwm5HuZfv awRDzVBHqPHgl8RnzazykVgkNnC3Ra0cQDpKRR+H8ol8iQCQs/YnkNAtxfLq4QwOyXEO SimjlxiU+kj4sHKBkujfHT9A6T4AF+Z4fEh2HaKPPVHRM5qqrFxqJ4EmNoPMiFFR/zoA Qnaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=JqajGCsMm+buwKmhbKgAecuJ3k4XMm8a265dEqZbvR4=; b=RFfLICrRb13tjOsGF/HedxgvGkE+twDB0uCHUb8h8enH7JmPt5yw+EMrr/Ay4jim04 n9jNZ2d3b/qRSP1j41lGNVr7jJwNHhmcJvjjcVO1mJRnZBqW/ghUD/jBFINZ2l7ADN7Y 5mfc7xbMXPh6fRlKdce78DyOl9pKkm/Ka9ZDVzHuJ5A9EVUK3nQf9zB8hYEBgewG3L/F gjDvyJ3JTMuIMSVITZrMdy8qt+H0Vr1B/QIFt1KRMFeJ/7n00kG9ZnOjsUtPpG4omI1K UarodOt50MWJVvK/aOk00qstuFCNfsDiWnfss3wGxn06Ykkj7eLM1671rhFh6ZD00qLS T3jA== X-Gm-Message-State: AMke39lw1li3YaosdFRV17J9v/jS4wMkp4xuDRNtIPfIvCoRCFlyve2CVTrsy5ttWYZLow== X-Received: by 10.223.148.35 with SMTP id 32mr2822178wrq.18.1487255529626; Thu, 16 Feb 2017 06:32:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:30 +0100 Message-Id: <1487255507-106654-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 06/23] apic: reset apic_delivered global variable on machine reset 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: , Cc: qemu-stable@nongnu.org, Pavel Dovgalyuk 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" From: Pavel Dovgalyuk This patch adds call to apic_reset_irq_delivered when the virtual machine is reset. Signed-off-by: Pavel Dovgalyuk Message-Id: <20170131114054.276.62201.stgit@PASHA-ISP> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- hw/intc/apic_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 6ce8ef7..7a6e771 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -251,6 +251,8 @@ static void apic_reset_common(DeviceState *dev) s->apicbase =3D APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE; s->id =3D s->initial_apic_id; =20 + apic_reset_irq_delivered(); + s->vapic_paddr =3D 0; info->vapic_base_update(s); =20 --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487260018145591.897320202995; Thu, 16 Feb 2017 07:46:58 -0800 (PST) Received: from localhost ([::1]:47437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOGk-0007Sa-A0 for importer@patchew.org; Thu, 16 Feb 2017 10:46:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6W-0003hL-K6 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6S-00083s-IF for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:16 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6S-00083U-Ce for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:12 -0500 Received: by mail-wm0-x244.google.com with SMTP id r18so3407207wmd.3 for ; Thu, 16 Feb 2017 06:32:12 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5XijFqdtx5n8pydRVs1yrIRuPf5XcW5W2KAXrbRdmN4=; b=AdQ+o0dNIbAOsETuqT2gUcvJHFLuxY1oY06nO6FKgDtY5/GaG8sx7wTXyaasRjfat3 Ffi2puySgzKfnjNH95+kU+868N8HWJI3NLlve3QKu93PBF29VvRILDoGtLJjnH459j/E 9dOJ8MHhQuWDyk+faAW9/BsamRt+2NXnZ5nYBVcIy0okfd/1Yovqa1LP+bhpb/W0UHgI sV1Nc/CPGkI94urHocZNabyNwA8jg+snpKNW4HZduzeC0YIHn5WhMs14qEpcQj5VRdSO 4X7BpwegLBt/vRje1p6bJU8S0EDTfOhLhOd+Ffq3mO2Zdn122mQNGBaWw60Yv0Fp6fZm inUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5XijFqdtx5n8pydRVs1yrIRuPf5XcW5W2KAXrbRdmN4=; b=Br39sBb1L1z4SOa+r/mFql4u4FgFSkLGBztiWNeMhuqCYu3kh5iLf7B6NP4vMBjoWC /Rq1JH+PHo83rKrx0w9oTm3picS/AAd0d3wVXbb/lrTSuD9q/I61EvKJ7m3miwUW91Ed M3Lmp6qpF73SgpsMYuQvXgAXVMpFU2Y1HY7kdwZG0q086nglS7S6ikB5q/LyjRUbB1u1 IzMBcjiF1dZ1RkrJ/ExcEE95OBR/ZWFOEttytjkBwyguNVOjmJb+AM7OnjiE1r/GLe9R i1U0V8Ar3/elYpqu4QkrvuhFvTNY1d29bdgANSRqogdiD7Gl5pRVpK19KPunmeTwzd6X tbbg== X-Gm-Message-State: AMke39mYEIJw+Jd/tkp41JcE+GP8LF7dGJ8KnpnxUoXnHnRYbQqfHLuSYI5SvipOgRe45w== X-Received: by 10.28.92.83 with SMTP id q80mr2892797wmb.108.1487255531130; Thu, 16 Feb 2017 06:32:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:31 +0100 Message-Id: <1487255507-106654-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 07/23] char: drop data written to a disconnected pty 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: , Cc: Ed Swierk 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" From: Ed Swierk When a serial port writes data to a pty that's disconnected, drop the data and return the length dropped. This avoids triggering pointless retries in callers like the 16550A serial_xmit(), and causes qemu_chr_fe_write() to write all data to the log file, rather than logging only while a pty client like virsh console happens to be connected. Signed-off-by: Ed Swierk Message-Id: <1485870329-79428-1-git-send-email-eswierk@skyportsystems.com> Signed-off-by: Paolo Bonzini --- chardev/char-pty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 27eb85f..ecf2c7a 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -129,7 +129,7 @@ static int char_pty_chr_write(Chardev *chr, const uint8= _t *buf, int len) /* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked(chr); if (!s->connected) { - return 0; + return len; } } return io_channel_send(s->ioc, buf, len); --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258152458225.32100647185484; Thu, 16 Feb 2017 07:15:52 -0800 (PST) Received: from localhost ([::1]:47266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNmg-0004Qo-52 for importer@patchew.org; Thu, 16 Feb 2017 10:15:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6X-0003iG-LK for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6V-00085L-5L for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:17 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:32861) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6U-00084l-VQ for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:15 -0500 Received: by mail-wr0-x242.google.com with SMTP id i10so2281066wrb.0 for ; Thu, 16 Feb 2017 06:32:14 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=CRNfbxLiiO7kW0F/rJMb1DkAER13sK3/rf7HPkFOWpQ=; b=mPQeMwIstnRyfd7934upO/ZGZjKWkXXP6tZFW7gY232g4JogX/kITa2rEvX4GF7lS0 H1z5KOGcD6eXE2cAXs2bUHmGCQ5XHxPhFDeFyMlIActV2lw2Wf9TK0c05WVE0JOxLlNk Ni64cbdK/7slSzWmcNGEDq1zK/G0LF0ILGVXAoCljV1cccGxYkRgnn9iKBeqMoohvBwu 6Y98SiKU+KPO6x9BQs1d0BHZP5RcQHRE6sL756R5YdVbjwCJPVtJ2Yw+1w5Z+PbvGebQ ym2cSwdysX2fiAmKvGNOePhmSKf9QpYu3vMh5Vb04FoaVfgre9jtVWCsarJCXAm9ZrQz 6OMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=CRNfbxLiiO7kW0F/rJMb1DkAER13sK3/rf7HPkFOWpQ=; b=TrrtOa8dDrkvvH+GL6Hv6OQrDausqMqPhe1nZ4CP5nuz0U3xJBu0j6Tf5ZsWgdZJOB OeHz43BHE8X4Ay3o8o5YHFQaCePMZmpiTYJXzeKA5nDbZkNaYpFrork/uctqIqZhEOmg Kc1xLaaV+wqV9IfgNjJTLrWjoXQQrT1QJDqEwuVIbTQKMHWD1w7Dw8ENxT5l4+w0/hzp RrUGmqSwesIQ7FnSbxms0s3YjRFHpEI5d2HE6/s6OyEVjCbJ+9I79B1vQAc1mKiqTJCY B5bjP/ENx52K9DN3y+/ILxoEImhn/KEp6LExPTV8Rp3CR+nAZBRQX8Uw3AhrC46T4rSG SHbA== X-Gm-Message-State: AMke39n7KciRWPMi6djMUJHhpeentYDuxiqs9N7ivMHqXHVHNeAJlBLaCM7CuAJp6ImQeQ== X-Received: by 10.223.136.50 with SMTP id d47mr2934473wrd.167.1487255533773; Thu, 16 Feb 2017 06:32:13 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:32 +0100 Message-Id: <1487255507-106654-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 08/23] move vm_start to cpus.c 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: , Cc: Claudio Imbrenda 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" From: Claudio Imbrenda This patch: * moves vm_start to cpus.c. * exports qemu_vmstop_requested, since it's needed by vm_start. * extracts vm_prepare_start from vm_start; it does what vm_start did, except restarting the cpus. * vm_start now calls vm_prepare_start and then restarts the cpus. Signed-off-by: Claudio Imbrenda Message-Id: <1487092068-16562-2-git-send-email-imbrenda@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini --- cpus.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/sysemu/sysemu.h | 2 ++ vl.c | 30 +----------------------------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/cpus.c b/cpus.c index 71a82e5..0bcb5b5 100644 --- a/cpus.c +++ b/cpus.c @@ -1578,6 +1578,48 @@ int vm_stop(RunState state) return do_vm_stop(state); } =20 +/** + * Prepare for (re)starting the VM. + * Returns -1 if the vCPUs are not to be restarted (e.g. if they are alrea= dy + * running or in case of an error condition), 0 otherwise. + */ +int vm_prepare_start(void) +{ + RunState requested; + int res =3D 0; + + qemu_vmstop_requested(&requested); + if (runstate_is_running() && requested =3D=3D RUN_STATE__MAX) { + return -1; + } + + /* Ensure that a STOP/RESUME pair of events is emitted if a + * vmstop request was pending. The BLOCK_IO_ERROR event, for + * example, according to documentation is always followed by + * the STOP event. + */ + if (runstate_is_running()) { + qapi_event_send_stop(&error_abort); + res =3D -1; + } else { + replay_enable_events(); + cpu_enable_ticks(); + runstate_set(RUN_STATE_RUNNING); + vm_state_notify(1, RUN_STATE_RUNNING); + } + + /* We are sending this now, but the CPUs will be resumed shortly later= */ + qapi_event_send_resume(&error_abort); + return res; +} + +void vm_start(void) +{ + if (!vm_prepare_start()) { + resume_all_vcpus(); + } +} + /* does a state transition even if the VM is already stopped, current state is forgotten forever */ int vm_stop_force_state(RunState state) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 4d50694..eda5241 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -37,6 +37,7 @@ void vm_state_notify(int running, RunState state); #define VMRESET_REPORT true =20 void vm_start(void); +int vm_prepare_start(void); int vm_stop(RunState state); int vm_stop_force_state(RunState state); =20 @@ -60,6 +61,7 @@ void qemu_register_powerdown_notifier(Notifier *notifier); void qemu_system_debug_request(void); void qemu_system_vmstop_request(RunState reason); void qemu_system_vmstop_request_prepare(void); +bool qemu_vmstop_requested(RunState *r); int qemu_shutdown_requested_get(void); int qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); diff --git a/vl.c b/vl.c index b4eaf03..0d866ad 100644 --- a/vl.c +++ b/vl.c @@ -724,7 +724,7 @@ StatusInfo *qmp_query_status(Error **errp) return info; } =20 -static bool qemu_vmstop_requested(RunState *r) +bool qemu_vmstop_requested(RunState *r) { qemu_mutex_lock(&vmstop_lock); *r =3D vmstop_requested; @@ -745,34 +745,6 @@ void qemu_system_vmstop_request(RunState state) qemu_notify_event(); } =20 -void vm_start(void) -{ - RunState requested; - - qemu_vmstop_requested(&requested); - if (runstate_is_running() && requested =3D=3D RUN_STATE__MAX) { - return; - } - - /* Ensure that a STOP/RESUME pair of events is emitted if a - * vmstop request was pending. The BLOCK_IO_ERROR event, for - * example, according to documentation is always followed by - * the STOP event. - */ - if (runstate_is_running()) { - qapi_event_send_stop(&error_abort); - } else { - replay_enable_events(); - cpu_enable_ticks(); - runstate_set(RUN_STATE_RUNNING); - vm_state_notify(1, RUN_STATE_RUNNING); - resume_all_vcpus(); - } - - qapi_event_send_resume(&error_abort); -} - - /***********************************************************/ /* real time host monotonic timer */ =20 --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487260312068976.1004226772338; Thu, 16 Feb 2017 07:51:52 -0800 (PST) Received: from localhost ([::1]:47465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOLW-0003ry-7H for importer@patchew.org; Thu, 16 Feb 2017 10:51:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6Y-0003jU-Qe for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6X-00086f-BZ for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:18 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34082) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6X-00086B-1r for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:17 -0500 Received: by mail-wr0-x243.google.com with SMTP id c4so2274991wrd.1 for ; Thu, 16 Feb 2017 06:32:16 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VHxF4Q7yQYC+13Y5/zMK7K0BRNkkXWaNgoBGtbt0S+A=; b=cG9ne33qLxNylcPcK047AGLr4uImHIisSO0frDQsxJdVLBFSAQ1jhDpxRWlrtGonLQ PzbxGxHts13vDtDp3W3wqn10ET55rR8aLQ4uKXrzXFmCUh7vgtRRyLNr2Rqhh0Du/6lT 5mkUtiHWug0Znxqr8fEx1ozB0x6lxphkHLBo1DmBh3olNVA0E5ltJ2QseAnQXq73ukhx UEh94JgPEjnhfYuEqxSQ5sJxJkSgov+TgKhHPtN/yN06/wNfI9D3XLzwR9ABpZwQ4Kvr wqGKb1S1loaJDGdCRG8sKABVQeJOlDQMowOUl7o91aqcJZajP5ui12YMBTXGGvAbdtSV 0mkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VHxF4Q7yQYC+13Y5/zMK7K0BRNkkXWaNgoBGtbt0S+A=; b=KkDL1hoel9OfG1NWlfPy9iPTHf6mZ3PZXTDLYb9BwaULtw868gRxVjxGds0B6jkhzQ 9Q3Ha1b2aT34t+sK0k24O1ppo0b68EtN3lPFVbAACKD/ohIUR3k/UOxlXLfpncz2q9qe NFcY+SIE2F9TxuG/mGXSRAotrtRQkWbisjdOkXw5wNRK3SxcLQTqdVcbvSoqvik84Nzx IEbhcalnLPPhIWoYOuq6XPU03mjtLWesCRzF8+FSNt7fBeRApYgZOyuOmD0sMuk5+shD Z2BSNQW6v54OTnlT5qB7b/hA4b37kxyQWfMkOwDqxZRctvECiJTv8b4Nj6kRTQBQ1fEd MwKw== X-Gm-Message-State: AMke39m0iXNSkh/qkmz44wZ375lCsRFCzaKYqUtQ/P5pDKTUPx8c1VTSY0fPJVzyp0JGeg== X-Received: by 10.223.152.175 with SMTP id w44mr2866177wrb.151.1487255535696; Thu, 16 Feb 2017 06:32:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:33 +0100 Message-Id: <1487255507-106654-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 09/23] gdbstub: Fix vCont behaviour 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: , Cc: Claudio Imbrenda 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" From: Claudio Imbrenda When GDB issues a "vCont", QEMU was not handling it correctly when multiple VCPUs are active. For vCont, for each thread (VCPU), it can be specified whether to single step, continue or stop that thread. The default is to stop a thread. However, when (for example) "vCont;s:2" is issued, all VCPUs continue to run, although all but VCPU nr 2 are to be stopped. This patch completely rewrites the vCont parsing code. Please note that this improvement only works in system emulation mode, when in userspace emulation mode the old behaviour is preserved. Signed-off-by: Claudio Imbrenda Message-Id: <1487092068-16562-3-git-send-email-imbrenda@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini --- gdbstub.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++++----------= ---- 1 file changed, 162 insertions(+), 47 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 755a8e3..9911153 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -387,6 +387,60 @@ static inline void gdb_continue(GDBState *s) #endif } =20 +/* + * Resume execution, per CPU actions. For user-mode emulation it's + * equivalent to gdb_continue. + */ +static int gdb_continue_partial(GDBState *s, char *newstates) +{ + CPUState *cpu; + int res =3D 0; +#ifdef CONFIG_USER_ONLY + /* + * This is not exactly accurate, but it's an improvement compared to t= he + * previous situation, where only one CPU would be single-stepped. + */ + CPU_FOREACH(cpu) { + if (newstates[cpu->cpu_index] =3D=3D 's') { + cpu_single_step(cpu, sstep_flags); + } + } + s->running_state =3D 1; +#else + int flag =3D 0; + + if (!runstate_needs_reset()) { + if (vm_prepare_start()) { + return 0; + } + + CPU_FOREACH(cpu) { + switch (newstates[cpu->cpu_index]) { + case 0: + case 1: + break; /* nothing to do here */ + case 's': + cpu_single_step(cpu, sstep_flags); + cpu_resume(cpu); + flag =3D 1; + break; + case 'c': + cpu_resume(cpu); + flag =3D 1; + break; + default: + res =3D -1; + break; + } + } + } + if (flag) { + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true); + } +#endif + return res; +} + static void put_buffer(GDBState *s, const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY @@ -785,6 +839,107 @@ static int is_query_packet(const char *p, const char = *query, char separator) (p[query_len] =3D=3D '\0' || p[query_len] =3D=3D separator); } =20 +/** + * gdb_handle_vcont - Parses and handles a vCont packet. + * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if the= re is + * a format error, 0 on success. + */ +static int gdb_handle_vcont(GDBState *s, const char *p) +{ + int res, idx, signal =3D 0; + char cur_action; + char *newstates; + unsigned long tmp; + CPUState *cpu; +#ifdef CONFIG_USER_ONLY + int max_cpus =3D 1; /* global variable max_cpus exists only in system = mode */ + + CPU_FOREACH(cpu) { + max_cpus =3D max_cpus <=3D cpu->cpu_index ? cpu->cpu_index + 1 : m= ax_cpus; + } +#endif + /* uninitialised CPUs stay 0 */ + newstates =3D g_new0(char, max_cpus); + + /* mark valid CPUs with 1 */ + CPU_FOREACH(cpu) { + newstates[cpu->cpu_index] =3D 1; + } + + /* + * res keeps track of what error we are returning, with -ENOTSUP meani= ng + * that the command is unknown or unsupported, thus returning an empty + * packet, while -EINVAL and -ERANGE cause an E22 packet, due to inval= id, + * or incorrect parameters passed. + */ + res =3D 0; + while (*p) { + if (*p++ !=3D ';') { + res =3D -ENOTSUP; + goto out; + } + + cur_action =3D *p++; + if (cur_action =3D=3D 'C' || cur_action =3D=3D 'S') { + cur_action =3D tolower(cur_action); + res =3D qemu_strtoul(p + 1, &p, 16, &tmp); + if (res) { + goto out; + } + signal =3D gdb_signal_to_target(tmp); + } else if (cur_action !=3D 'c' && cur_action !=3D 's') { + /* unknown/invalid/unsupported command */ + res =3D -ENOTSUP; + goto out; + } + /* thread specification. special values: (none), -1 =3D all; 0 =3D= any */ + if ((p[0] =3D=3D ':' && p[1] =3D=3D '-' && p[2] =3D=3D '1') || (p[= 0] !=3D ':')) { + if (*p =3D=3D ':') { + p +=3D 3; + } + for (idx =3D 0; idx < max_cpus; idx++) { + if (newstates[idx] =3D=3D 1) { + newstates[idx] =3D cur_action; + } + } + } else if (*p =3D=3D ':') { + p++; + res =3D qemu_strtoul(p, &p, 16, &tmp); + if (res) { + goto out; + } + idx =3D tmp; + /* 0 means any thread, so we pick the first valid CPU */ + if (!idx) { + idx =3D cpu_index(first_cpu); + } + + /* + * If we are in user mode, the thread specified is actually a + * thread id, and not an index. We need to find the actual + * CPU first, and only then we can use its index. + */ + cpu =3D find_cpu(idx); + /* invalid CPU/thread specified */ + if (!idx || !cpu) { + res =3D -EINVAL; + goto out; + } + /* only use if no previous match occourred */ + if (newstates[cpu->cpu_index] =3D=3D 1) { + newstates[cpu->cpu_index] =3D cur_action; + } + } + } + s->signal =3D signal; + gdb_continue_partial(s, newstates); + +out: + g_free(newstates); + + return res; +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -830,60 +985,20 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) return RS_IDLE; case 'v': if (strncmp(p, "Cont", 4) =3D=3D 0) { - int res_signal, res_thread; - p +=3D 4; if (*p =3D=3D '?') { put_packet(s, "vCont;c;C;s;S"); break; } - res =3D 0; - res_signal =3D 0; - res_thread =3D 0; - while (*p) { - int action, signal; - - if (*p++ !=3D ';') { - res =3D 0; - break; - } - action =3D *p++; - signal =3D 0; - if (action =3D=3D 'C' || action =3D=3D 'S') { - signal =3D gdb_signal_to_target(strtoul(p, (char **)&p= , 16)); - if (signal =3D=3D -1) { - signal =3D 0; - } - } else if (action !=3D 'c' && action !=3D 's') { - res =3D 0; - break; - } - thread =3D 0; - if (*p =3D=3D ':') { - thread =3D strtoull(p+1, (char **)&p, 16); - } - action =3D tolower(action); - if (res =3D=3D 0 || (res =3D=3D 'c' && action =3D=3D 's'))= { - res =3D action; - res_signal =3D signal; - res_thread =3D thread; - } - } + + res =3D gdb_handle_vcont(s, p); + if (res) { - if (res_thread !=3D -1 && res_thread !=3D 0) { - cpu =3D find_cpu(res_thread); - if (cpu =3D=3D NULL) { - put_packet(s, "E22"); - break; - } - s->c_cpu =3D cpu; - } - if (res =3D=3D 's') { - cpu_single_step(s->c_cpu, sstep_flags); + if ((res =3D=3D -EINVAL) || (res =3D=3D -ERANGE)) { + put_packet(s, "E22"); + break; } - s->signal =3D res_signal; - gdb_continue(s); - return RS_IDLE; + goto unknown_command; } break; } else { --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487257521758553.8382796449707; Thu, 16 Feb 2017 07:05:21 -0800 (PST) Received: from localhost ([::1]:47207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNcT-00034X-4x for importer@patchew.org; Thu, 16 Feb 2017 10:05:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6a-0003lT-Ev for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6Z-00087i-12 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:20 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6Y-00087P-Mi for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:18 -0500 Received: by mail-wm0-x242.google.com with SMTP id c85so3430026wmi.1 for ; Thu, 16 Feb 2017 06:32:18 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=iSkXQVPdhCY2wOgbkVgOgB8FvcGd4vFUPTFajGA0PNk=; b=Q0L3ewG1fPsWsHao4caAy9CwhfxXt2aekQKziUca+3oBsI0EGMZpP2nWj8LWK0QtCL ZZn/fmISgC/dkX4k8EgMXS00s5PZOVOi96NARauA6Iz45AGYA3SeB92UMSvxn0X/AdWz rJYu6rMxiGSyGeSCdkzNjPTLdWEx45dT8UShaGwrBuhbQ9aa+fGvaruCwtj74U51yR2X ajfM0OMcFoB0P5a8Fx6y55UWCwebpRr3gO7aBIhjKTI0PWwpA5yIypVEWh6VeYYIjo3e wBQucE9pLhAw+i1UoKxV3dsduBTfzDksnvMvg+4IUjFV3YhL+oge+xcpRkdoC3/mmRWS ENTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=iSkXQVPdhCY2wOgbkVgOgB8FvcGd4vFUPTFajGA0PNk=; b=MXi/nZDS/6ymNHSTpbvpOLdYk4isTIr0kS/PmBbLMu8wotb/C8RdYds4W6qMXVVlhE cn0aPTjaLrBJQCPa1QNg537ymj7qFS2R3gLyiDhxD/7Dn4zITKdAm2e0K+kj/BC5c1cW k1DGUHSzpZv1WcvNzdoAaFBM8JZ2AVtCChiIcli8kUF7Oq4fxGQYTnaHiLtAfUo+WPmU 3qwrzH0VK3LaRT4MkZpDGx59QgONouSadHe2pEjDideN6l4OHYw8OExCTUvvGgHr3vYn zPvidgyuCtbgoOwfWfMZ4PjJa6ygQo9toN+t/XPZIQPk8r9/CJJBM4QkUo5pXgeRy6N+ eMJQ== X-Gm-Message-State: AMke39nBN5YjFMlo8EPUy3wtvM7X8nsmJYZaGNq76KusTc/mZOHGMDWkHNsfezRDX6SzPw== X-Received: by 10.28.129.147 with SMTP id c141mr13482939wmd.12.1487255537456; Thu, 16 Feb 2017 06:32:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:34 +0100 Message-Id: <1487255507-106654-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 10/23] hw/char/mcf_uart: QOMify the ColdFire UART 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: , Cc: Thomas Huth 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" From: Thomas Huth Use type_init() etc. to adapt the ColdFire UART to the latest QEMU device conventions. Signed-off-by: Thomas Huth Message-Id: <1485586582-6490-1-git-send-email-huth@tuxfamily.org> Signed-off-by: Paolo Bonzini --- hw/char/mcf_uart.c | 102 +++++++++++++++++++++++++++++++++++++---------= ---- hw/m68k/mcf5208.c | 6 +-- include/hw/m68k/mcf.h | 6 +-- 3 files changed, 81 insertions(+), 33 deletions(-) diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c index 80c380e..e69672f 100644 --- a/hw/char/mcf_uart.c +++ b/hw/char/mcf_uart.c @@ -7,12 +7,15 @@ */ #include "qemu/osdep.h" #include "hw/hw.h" +#include "hw/sysbus.h" #include "hw/m68k/mcf.h" #include "sysemu/char.h" #include "exec/address-spaces.h" #include "qapi/error.h" =20 typedef struct { + SysBusDevice parent_obj; + MemoryRegion iomem; uint8_t mr[2]; uint8_t sr; @@ -30,6 +33,9 @@ typedef struct { CharBackend chr; } mcf_uart_state; =20 +#define TYPE_MCF_UART "mcf-uart" +#define MCF_UART(obj) OBJECT_CHECK(mcf_uart_state, (obj), TYPE_MCF_UART) + /* UART Status Register bits. */ #define MCF_UART_RxRDY 0x01 #define MCF_UART_FFULL 0x02 @@ -220,8 +226,10 @@ void mcf_uart_write(void *opaque, hwaddr addr, mcf_uart_update(s); } =20 -static void mcf_uart_reset(mcf_uart_state *s) +static void mcf_uart_reset(DeviceState *dev) { + mcf_uart_state *s =3D MCF_UART(dev); + s->fifo_len =3D 0; s->mr[0] =3D 0; s->mr[1] =3D 0; @@ -275,36 +283,80 @@ static void mcf_uart_receive(void *opaque, const uint= 8_t *buf, int size) mcf_uart_push_byte(s, buf[0]); } =20 -void *mcf_uart_init(qemu_irq irq, Chardev *chr) -{ - mcf_uart_state *s; - - s =3D g_malloc0(sizeof(mcf_uart_state)); - s->irq =3D irq; - if (chr) { - qemu_chr_fe_init(&s->chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&s->chr, mcf_uart_can_receive, - mcf_uart_receive, mcf_uart_event, - s, NULL, true); - } - mcf_uart_reset(s); - return s; -} - static const MemoryRegionOps mcf_uart_ops =3D { .read =3D mcf_uart_read, .write =3D mcf_uart_write, .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 -void mcf_uart_mm_init(MemoryRegion *sysmem, - hwaddr base, - qemu_irq irq, - Chardev *chr) +static void mcf_uart_instance_init(Object *obj) +{ + SysBusDevice *dev =3D SYS_BUS_DEVICE(obj); + mcf_uart_state *s =3D MCF_UART(dev); + + memory_region_init_io(&s->iomem, obj, &mcf_uart_ops, s, "uart", 0x40); + sysbus_init_mmio(dev, &s->iomem); + + sysbus_init_irq(dev, &s->irq); +} + +static void mcf_uart_realize(DeviceState *dev, Error **errp) +{ + mcf_uart_state *s =3D MCF_UART(dev); + + qemu_chr_fe_set_handlers(&s->chr, mcf_uart_can_receive, mcf_uart_recei= ve, + mcf_uart_event, s, NULL, true); +} + +static Property mcf_uart_properties[] =3D { + DEFINE_PROP_CHR("chardev", mcf_uart_state, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void mcf_uart_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + + dc->realize =3D mcf_uart_realize; + dc->reset =3D mcf_uart_reset; + dc->props =3D mcf_uart_properties; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); +} + +static const TypeInfo mcf_uart_info =3D { + .name =3D TYPE_MCF_UART, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(mcf_uart_state), + .instance_init =3D mcf_uart_instance_init, + .class_init =3D mcf_uart_class_init, +}; + +static void mcf_uart_register(void) +{ + type_register_static(&mcf_uart_info); +} + +type_init(mcf_uart_register) + +void *mcf_uart_init(qemu_irq irq, Chardev *chrdrv) +{ + DeviceState *dev; + + dev =3D qdev_create(NULL, TYPE_MCF_UART); + if (chrdrv) { + qdev_prop_set_chr(dev, "chardev", chrdrv); + } + qdev_init_nofail(dev); + + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); + + return dev; +} + +void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chrdrv) { - mcf_uart_state *s; + DeviceState *dev; =20 - s =3D mcf_uart_init(irq, chr); - memory_region_init_io(&s->iomem, NULL, &mcf_uart_ops, s, "uart", 0x40); - memory_region_add_subregion(sysmem, base, &s->iomem); + dev =3D mcf_uart_init(irq, chrdrv); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); } diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index bad1d33..6563518 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -255,9 +255,9 @@ static void mcf5208evb_init(MachineState *machine) /* Internal peripherals. */ pic =3D mcf_intc_init(address_space_mem, 0xfc048000, cpu); =20 - mcf_uart_mm_init(address_space_mem, 0xfc060000, pic[26], serial_hds[0]= ); - mcf_uart_mm_init(address_space_mem, 0xfc064000, pic[27], serial_hds[1]= ); - mcf_uart_mm_init(address_space_mem, 0xfc068000, pic[28], serial_hds[2]= ); + mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]); + mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]); + mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]); =20 mcf5208_sys_init(address_space_mem, pic); =20 diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h index 9a0bcfa..0db49c5 100644 --- a/include/hw/m68k/mcf.h +++ b/include/hw/m68k/mcf.h @@ -4,17 +4,13 @@ =20 #include "target/m68k/cpu-qom.h" =20 -struct MemoryRegion; - /* mcf_uart.c */ uint64_t mcf_uart_read(void *opaque, hwaddr addr, unsigned size); void mcf_uart_write(void *opaque, hwaddr addr, uint64_t val, unsigned size); void *mcf_uart_init(qemu_irq irq, Chardev *chr); -void mcf_uart_mm_init(struct MemoryRegion *sysmem, - hwaddr base, - qemu_irq irq, Chardev *chr); +void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr); =20 /* mcf_intc.c */ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem, --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258616841507.99020840748733; Thu, 16 Feb 2017 07:23:36 -0800 (PST) Received: from localhost ([::1]:47303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNuA-0005BY-2d for importer@patchew.org; Thu, 16 Feb 2017 10:23:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6c-0003oa-HH for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6b-0008Ac-KC for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:22 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:34089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6b-00089z-Dp for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:21 -0500 Received: by mail-wr0-x244.google.com with SMTP id c4so2275240wrd.1 for ; Thu, 16 Feb 2017 06:32:21 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=8TdVYE1nWfrjliKi5Y839QFZGz7Sh7r/yUEBVJN5AiE=; b=f2QM550FQ5UkQkq784GA8jrj4y7KpjpWlzqWf9/sGQRYxbjXft5TN5SAFEX6nEMdp4 TRT/gaHfusvq5CwjhmVvKYWEipKkcAeAsuTMLG5OVo4M9tzTa2awIPKHg+ndOsV7DslH 7qiwOns56puWwgUwI4VD3YkbKKna2vVO7Di2Iz6lH9pc45zdzlwO16XO295M9Xc1U2EL jFwvEDhRkrGjq7I8JeFrUOgqrhRita4jz1MKTEE3kIHDGS4P79GimGhkGt1w3BeVXs0p iei3/ZTR21UOox+VDp8hcCXItbW1ns+wVxI0sQhZUsVH5P8e7cXY+3JrSSZXbzfgvTn4 1P1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=8TdVYE1nWfrjliKi5Y839QFZGz7Sh7r/yUEBVJN5AiE=; b=LM2s0IeIef72ARqwhrm47pMvcxxm5fnIQ5GlrZGi7sBEuJKbX4VPcGUH7QuiA3XFoT hi7oW8QcoAkpFpZf023/fSmDgclWOa2llJRC5A5OLbPD/ObLIVfS3EpSZ0cXpjOynXFw PzmUYnuEjLrYhzUNXYvl3Bg2BHM/3Tn/yKfe+xwmE2A6TPZcsyu5g0V11kh3xA3x+msc oKauhjM/BjxkSLKDKDq4Pxuq1im6bYpYEjMDRWrPFrt7xWyMrcClGuvEuaSYhDdQqtGl upenwHlw3Xjy3DUZK/2lEhQ8UGqz3Puw4+G+5w5C6XwqQXj7Ot1NqU9pQpk5CWrwGdTF vl6g== X-Gm-Message-State: AMke39ltaML87IHBcrIiubT/iLNmKw+8t+I3jrotmNGHFGI6fYvaA0GwWTba8Cl5H8bScg== X-Received: by 10.223.150.73 with SMTP id c9mr2898938wra.19.1487255540178; Thu, 16 Feb 2017 06:32:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:35 +0100 Message-Id: <1487255507-106654-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 11/23] cpu-exec: fix icount out-of-bounds access 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" When icount is active, tb_add_jump is surprisingly called with an out of bounds basic block index. I have no idea how that can work, but it does not seem like a good idea. Clear *last_tb for all TB_EXIT_ICOUNT_EXPIRED cases, even when all you have to do is refill icount_extra. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 7 ++++--- include/exec/exec-all.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 57583f1..1f7d217 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -542,7 +542,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, Tran= slationBlock *tb, =20 trace_exec_tb(tb, tb->pc); ret =3D cpu_tb_exec(cpu, tb); - *last_tb =3D (TranslationBlock *)(ret & ~TB_EXIT_MASK); + tb =3D (TranslationBlock *)(ret & ~TB_EXIT_MASK); *tb_exit =3D ret & TB_EXIT_MASK; switch (*tb_exit) { case TB_EXIT_REQUESTED: @@ -566,6 +566,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, Tran= slationBlock *tb, abort(); #else int insns_left =3D cpu->icount_decr.u32; + *last_tb =3D NULL; if (cpu->icount_extra && insns_left >=3D 0) { /* Refill decrementer and continue execution. */ cpu->icount_extra +=3D insns_left; @@ -575,17 +576,17 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, Tr= anslationBlock *tb, } else { if (insns_left > 0) { /* Execute remaining instructions. */ - cpu_exec_nocache(cpu, insns_left, *last_tb, false); + cpu_exec_nocache(cpu, insns_left, tb, false); align_clocks(sc, cpu); } cpu->exception_index =3D EXCP_INTERRUPT; - *last_tb =3D NULL; cpu_loop_exit(cpu); } break; #endif } default: + *last_tb =3D tb; break; } } diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index bbc9478..21ab7bf 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -318,6 +318,7 @@ static inline void tb_set_jmp_target(TranslationBlock *= tb, static inline void tb_add_jump(TranslationBlock *tb, int n, TranslationBlock *tb_next) { + assert(n < ARRAY_SIZE(tb->jmp_list_next)); if (tb->jmp_list_next[n]) { /* Another thread has already done this while we were * outside of the lock; nothing to do in this case */ --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487259136768535.2491437285481; Thu, 16 Feb 2017 07:32:16 -0800 (PST) Received: from localhost ([::1]:47352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceO2W-0000rP-T8 for importer@patchew.org; Thu, 16 Feb 2017 10:32:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6h-0003tS-FY for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6d-0008C7-D2 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:27 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34865) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6d-0008BX-6O for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:23 -0500 Received: by mail-wm0-x244.google.com with SMTP id u63so3407905wmu.2 for ; Thu, 16 Feb 2017 06:32:23 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=UJLz1mYBLxgzNQ8zHk6ll/URPR/HuwJESzovWuk1TJA=; b=XGNk+/7zUUPmFowemEztEyPZwcFPMel0GfiClWUx6lqw6MR/nDdYJNybkBDyS8/7cT 7XwDKDr3S3MoqQ+ESuT/fDeFtiFyHXSBLUSxD1gn70Obubw+yyFPczY8cCU0zbHg2/W+ bCgHbUyamgilgbQbmkKYhq77i/Dy4lb+oH+Z3OZgz3YxT5fzSmG2vKMRiuGeU2P4xE/a 3kAsP7VgjXASRs41+nEfwMZ7novBomJUY3WyY19u0Gu10WIVqayfcAwgFBY80mNirLIt f6/axabIWsgRJ41vPYB/0c+KIccsBHPxbk5HhUkSduNHrF/7yriXJt+ezhW5Y+OcULsJ 0fGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=UJLz1mYBLxgzNQ8zHk6ll/URPR/HuwJESzovWuk1TJA=; b=rjAcb3yTGm47VV5cR4xsftI8kXgspgT+TyFBRSQWVISWoWgZr+f7+J6gvtZKvZ13SO irZ86GbZYQlT/qr/gQ8xhzAKVkoyjPfFMw2fuhseGF49lcFJ3avpeRmqOUi4LoMx3dkE oRLMVb/covTxkWy2YfcbE+oQIMKEto9ntURspJckJUaCvKLKiZfTuv/6tAf8phZlV0Df gYaK6qFL6OPDjWqnSwO26dEjuZtzUuB7/erFBlml6fQaE2WLEoesTYuvIbNBAcJ5W2qQ ORoSb3ddS/P88CmKvsdrDgd6c2O5NH1xpy20SIz0SEB7qOgApgmamhFj2/bGbtJBwtwQ rK0w== X-Gm-Message-State: AMke39lO+qJLznNNkpzHjb2jOMVjn8invr8IpmC7diJ7cpHAAEscXaEbI65OfJl3erS0RA== X-Received: by 10.28.167.68 with SMTP id q65mr2853113wme.126.1487255542071; Thu, 16 Feb 2017 06:32:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:36 +0100 Message-Id: <1487255507-106654-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 12/23] cpu-exec: tighten barrier on TCG_EXIT_REQUESTED 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" This seems to have worked just fine so far on weakly-ordered architectures, but I don't see anything that prevents the reordering from: store 1 to exit_request store 1 to tcg_exit_req load tcg_exit_req store 0 to tcg_exit_req load exit_request store 0 to exit_request store 1 to exit_request store 1 to tcg_exit_req to this: store 1 to exit_request store 1 to tcg_exit_req load tcg_exit_req load exit_request store 1 to exit_request store 1 to tcg_exit_req store 0 to tcg_exit_req store 0 to exit_request therefore losing a request. It's possible that other memory barriers (e.g. in rcu_read_unlock) are hiding it, but better safe than sorry. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 1f7d217..d50625b 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -552,11 +552,11 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, Tr= anslationBlock *tb, * have set something else (eg exit_request or * interrupt_request) which we will handle * next time around the loop. But we need to - * ensure the tcg_exit_req read in generated code + * ensure the zeroing of tcg_exit_req (see cpu_tb_exec) * comes before the next read of cpu->exit_request * or cpu->interrupt_request. */ - smp_rmb(); + smp_mb(); *last_tb =3D NULL; break; case TB_EXIT_ICOUNT_EXPIRED: --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258871440732.6533486689785; Thu, 16 Feb 2017 07:27:51 -0800 (PST) Received: from localhost ([::1]:47331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNyH-00057r-VY for importer@patchew.org; Thu, 16 Feb 2017 10:27:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6g-0003sU-IK for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6f-0008D7-6l for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:26 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6f-0008CW-0N for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:25 -0500 Received: by mail-wr0-x243.google.com with SMTP id c4so2275630wrd.1 for ; Thu, 16 Feb 2017 06:32:24 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=MUHRgiAbIxDrsdnFzUR/4sf6GwHfWsA4xp6xSQV7BT4=; b=rOL1ESzgaI017cb2Tm73s4xHlrb2VTpzUHJlyubxNirVlYPj/VN6rSP0uUvqZ7K8zu AtLc6nylsPo+/IiF0Wtj0bzR+UCX5co8Y3UcU2rZuElzj1Ujsf6K4XZdkrXm1ovC/4MU SY23fc94ULOmlo/Rf/YR8MuNxz8QG+xOvt4w6vV1+X3s1ix7XwUE8zJX0Zl2CB3bnCEM pwjBAGjocnEXT28oujcTeHnqtRR1p4dmYda7exCRfC9rcAir0z6JMXdc79Jorn2U5x+b TQKskGrfYTVegO5Mxry3IRICXwgK6/JSjOB7LunqcGblq0E/0fTKy1XizXWTHlfHSMSx iRSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=MUHRgiAbIxDrsdnFzUR/4sf6GwHfWsA4xp6xSQV7BT4=; b=lIsJanomVzp6F75uH9oF1HfJ10pi8nPVUJoDp64nCG2rsWc8Bpvfd8VeVTSG4crO21 CZcJRD1hs4h4exHCUJlNY+paxmtUKnepHnM1cpMFXkFUK3LcJDzuUMhSP3l9E/Jz2O9r xLCbrmpfVOJrqL0tq0OBri8vvSd3cdTbJ8K/tgC1L4F8W2PLvPXNGQfvZpoewQuJzE87 XpzpTjbQXq8IfrRwHx1BVCyIkQJDsLdr6GQUUFIeBzA6ZD1hi9rHxAdNhDvg/3vhl4fR hISOuZYQThhmp05LppNtVtt72zBuSibyy4IyvqJaUxP90a5OqVJAAqmV4195+hbjvqY7 j75g== X-Gm-Message-State: AMke39mujK2vKrK5MAUuBuMtl9Mw1pCQ5gcxkd4haUR33zN/Pw7HdczRevt4MnVhYHTo/A== X-Received: by 10.223.129.4 with SMTP id 4mr2970814wrm.27.1487255543807; Thu, 16 Feb 2017 06:32:23 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:37 +0100 Message-Id: <1487255507-106654-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 13/23] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt 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" The siglongjmp goes straight back to the beginning of cpu_exec's outermost loop. We do not need a siglongjmp, we can simply leave the inner TB execution loop. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index d50625b..ed2fbc6 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -461,7 +461,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) return false; } =20 -static inline void cpu_handle_interrupt(CPUState *cpu, +static inline bool cpu_handle_interrupt(CPUState *cpu, TranslationBlock **last_tb) { CPUClass *cc =3D CPU_GET_CLASS(cpu); @@ -475,7 +475,7 @@ static inline void cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu->interrupt_request &=3D ~CPU_INTERRUPT_DEBUG; cpu->exception_index =3D EXCP_DEBUG; - cpu_loop_exit(cpu); + return true; } if (replay_mode =3D=3D REPLAY_MODE_PLAY && !replay_has_interrupt()= ) { /* Do nothing */ @@ -484,7 +484,7 @@ static inline void cpu_handle_interrupt(CPUState *cpu, cpu->interrupt_request &=3D ~CPU_INTERRUPT_HALT; cpu->halted =3D 1; cpu->exception_index =3D EXCP_HLT; - cpu_loop_exit(cpu); + return true; } #if defined(TARGET_I386) else if (interrupt_request & CPU_INTERRUPT_INIT) { @@ -494,13 +494,13 @@ static inline void cpu_handle_interrupt(CPUState *cpu, cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0); do_cpu_init(x86_cpu); cpu->exception_index =3D EXCP_HALTED; - cpu_loop_exit(cpu); + return true; } #else else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - cpu_loop_exit(cpu); + return true; } #endif /* The target hook has 3 exit conditions: @@ -526,8 +526,10 @@ static inline void cpu_handle_interrupt(CPUState *cpu, if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt()= )) { atomic_set(&cpu->exit_request, 0); cpu->exception_index =3D EXCP_INTERRUPT; - cpu_loop_exit(cpu); + return true; } + + return false; } =20 static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, @@ -625,7 +627,7 @@ int cpu_exec(CPUState *cpu) for(;;) { /* prepare setjmp context for exception handling */ if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { - TranslationBlock *tb, *last_tb =3D NULL; + TranslationBlock *last_tb =3D NULL; int tb_exit =3D 0; =20 /* if an exception is pending, we execute it here */ @@ -633,14 +635,13 @@ int cpu_exec(CPUState *cpu) break; } =20 - for(;;) { - cpu_handle_interrupt(cpu, &last_tb); - tb =3D tb_find(cpu, last_tb, tb_exit); + while (!cpu_handle_interrupt(cpu, &last_tb)) { + TranslationBlock *tb =3D tb_find(cpu, last_tb, tb_exit); cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); /* Try to align the host and virtual clocks if the guest is in advance */ align_clocks(&sc, cpu); - } /* for(;;) */ + } } else { #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) /* Some compilers wrongly smash all local variables after --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487257821693277.2686477409193; Thu, 16 Feb 2017 07:10:21 -0800 (PST) Received: from localhost ([::1]:47232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNhK-0007LN-I5 for importer@patchew.org; Thu, 16 Feb 2017 10:10:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6h-0003tv-PO for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6g-0008ES-Vt for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:27 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6g-0008Dv-Pn for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:26 -0500 Received: by mail-wm0-x243.google.com with SMTP id v77so3429115wmv.0 for ; Thu, 16 Feb 2017 06:32:26 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=1TTYfXqbKG+aN88Xyh3R+gs6WXoY4FWdnBM8F5xEq8Q=; b=HFJdOj9KgX8sXs0LrOu5MRbYNGibBdEGxS03+FvJGLt5X6R5+55btyTl7Aw1cA+Kkt dGiXByGt8tnJRFieqozt+PvGEoH5FJS8lr0OH20xEmMyZRQJpn4gK4UGZnz8Q9mH76cN 0exWVQ2Izj4+OP9eEHLLCubZy8qX+y3eyxgKi9fG78rbo4zkBO4asDM7jOOdIt06FWbf 2q6KSHuEZxjBDqoz6bAtwtAKaH6Ze4hlv++g73ryHyfBIRICSVXET0FbhZY2PcxDCFBM sDpdKNSDy47xHaR9eNLkiHYR1g12eg0hq6mMDd5a+P3No9/B8PNNRPzq6O51FnZam8uq rCxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=1TTYfXqbKG+aN88Xyh3R+gs6WXoY4FWdnBM8F5xEq8Q=; b=beksvpZGU8jHBr/xbp+W9Ff5fW917RSF1+iz6zQXcwwBrEuGkiVIjc8CjFS8O7cE9k DnOl3xIf6Rsw7ErRCHkLwJAd2GYK2newZpAnTGCmoSeHUjqH9CHF8J53pZzFgQCw1dLO MgQZ6kP0okx2z/sOSNovisHKZfznhYn7cjF1z1w2M04dU3rTAvlUPN3lNlcm12uBTTs2 VlPFBWh9INzQ8tV3CzrNog33eyK7JUV1gALQ949oIAQjn3/Dd1DWxqY6t/p8smir66P1 RngfqnsdhkPnGmgQ6qOdr4TPUsguMWqARhRiSpqQE3WmK8FeXhZ03dRlMGHLRHBjaCpY wjFA== X-Gm-Message-State: AMke39mkYh6Hqm4BuUVvFBE9s64ulnSVzIt04PC3dpofOsgGFOSoarq2/7Xg1JcB5kK06w== X-Received: by 10.28.126.12 with SMTP id z12mr2941004wmc.84.1487255545648; Thu, 16 Feb 2017 06:32:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:38 +0100 Message-Id: <1487255507-106654-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 14/23] cpu-exec: avoid repeated sigsetjmp on interrupts 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" The sigsetjmp only needs to be prepared once for the whole execution of cpu_exec. This patch takes care of the "=3D=3D 0" side, using a nested loop so that cpu_handle_interrupt goes straight back to cpu_handle_exception without doing another sigsetjmp. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index ed2fbc6..865015c 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -627,21 +627,21 @@ int cpu_exec(CPUState *cpu) for(;;) { /* prepare setjmp context for exception handling */ if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { - TranslationBlock *last_tb =3D NULL; - int tb_exit =3D 0; - /* if an exception is pending, we execute it here */ - if (cpu_handle_exception(cpu, &ret)) { - break; + while (!cpu_handle_exception(cpu, &ret)) { + TranslationBlock *last_tb =3D NULL; + int tb_exit =3D 0; + + while (!cpu_handle_interrupt(cpu, &last_tb)) { + TranslationBlock *tb =3D tb_find(cpu, last_tb, tb_exit= ); + cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); + /* Try to align the host and virtual clocks + if the guest is in advance */ + align_clocks(&sc, cpu); + } } + break; =20 - while (!cpu_handle_interrupt(cpu, &last_tb)) { - TranslationBlock *tb =3D tb_find(cpu, last_tb, tb_exit); - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); - /* Try to align the host and virtual clocks - if the guest is in advance */ - align_clocks(&sc, cpu); - } } else { #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) /* Some compilers wrongly smash all local variables after --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487260858559361.61057330163; Thu, 16 Feb 2017 08:00:58 -0800 (PST) Received: from localhost ([::1]:47516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOUC-00056P-Ce for importer@patchew.org; Thu, 16 Feb 2017 11:00:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6q-00040k-EY for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6k-0008Fj-GK for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:36 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6k-0008FF-AA for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:30 -0500 Received: by mail-wm0-x243.google.com with SMTP id c85so3431039wmi.1 for ; Thu, 16 Feb 2017 06:32:30 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=QTB/zGcxNdZMI6lnAQEmf2gVBiLjy9DGEJkV55HW+Fw=; b=h7s4vxrOiFmjS0dUL6oCfUCnW5Anwx+EdF082ukKfcFPg/hMhrgmk2bekAg8NHxhBu yyXq9WK9rHyRMysKorGKl3b3H8YgWLjqdscBTv4/FBgtqfIOxgnmzDZ4edTcFAjfvVB8 leFMYX0Wif+B13MB3k6zwEtvfeCC+V+Y2520L7dbtaWmqjCUPUpHrRH5VIYmjEExelWF g3iqtaYLjl5FMmbnQsuj4ImKyxKy8bB9aHjerkun6yPr5M/TgnM3TDNi+StnJb/iXEYL whyaKxo7wC1TjM3FZbtnCdKmP+AdrGLK/bQggHDiE/9ijt7Nc+AHEFt/IdkbFaI5SLQq 2yeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=QTB/zGcxNdZMI6lnAQEmf2gVBiLjy9DGEJkV55HW+Fw=; b=NTeA8ZFEt1UDQWI+3M1w+gVEWZkUeP0pCKrE7UDrRTheJY8NaTdZM0++HsZpBRWAvr WGpR4kHqIyaIYNDcQwYWzCF7LA0EU6iSY7lxtvrkjoHK8e2H4nC/6RaNuSA9UdUevOD4 Ymw70E0kAEnFVEHstOP08Bp2O07CgIX6+dcDk2UeO6buonRCnUcm7+Z6zGPvlBSOooih F6j2CDEmENQlW7fAYy8HaFJI/sPG/grnIYQ41lsQpSquT3l2Bod+2FDMf6mvCHXYTXsb 0AuKpCnNczFOtT9WYDp8tNqSPd2LQNpGqdYqph4c6Qgs/2eDgZoOQFL4nfGAT8243f4C upNw== X-Gm-Message-State: AMke39m7RTXv9R7MboNeiLctedjTTu4mRjwMjo9gmL5MPn/BlISKnOWwCq32piITF+C6jg== X-Received: by 10.28.7.10 with SMTP id 10mr2923045wmh.55.1487255549131; Thu, 16 Feb 2017 06:32:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:39 +0100 Message-Id: <1487255507-106654-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 15/23] cpu-exec: remove outermost infinite loop 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" Reorganize the sigsetjmp so that the restart case falls through to cpu_handle_exception and the execution loop. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 58 +++++++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 865015c..b8ebb5c 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -624,41 +624,37 @@ int cpu_exec(CPUState *cpu) */ init_delay_params(&sc, cpu); =20 - for(;;) { - /* prepare setjmp context for exception handling */ - if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { - /* if an exception is pending, we execute it here */ - while (!cpu_handle_exception(cpu, &ret)) { - TranslationBlock *last_tb =3D NULL; - int tb_exit =3D 0; - - while (!cpu_handle_interrupt(cpu, &last_tb)) { - TranslationBlock *tb =3D tb_find(cpu, last_tb, tb_exit= ); - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); - /* Try to align the host and virtual clocks - if the guest is in advance */ - align_clocks(&sc, cpu); - } - } - break; - - } else { + /* prepare setjmp context for exception handling */ + if (sigsetjmp(cpu->jmp_env, 0) !=3D 0) { #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) - /* Some compilers wrongly smash all local variables after - * siglongjmp. There were bug reports for gcc 4.5.0 and clang. - * Reload essential local variables here for those compilers. - * Newer versions of gcc would complain about this code (-Wclo= bbered). */ - cpu =3D current_cpu; - cc =3D CPU_GET_CLASS(cpu); + /* Some compilers wrongly smash all local variables after + * siglongjmp. There were bug reports for gcc 4.5.0 and clang. + * Reload essential local variables here for those compilers. + * Newer versions of gcc would complain about this code (-Wclobber= ed). */ + cpu =3D current_cpu; + cc =3D CPU_GET_CLASS(cpu); #else /* buggy compiler */ - /* Assert that the compiler does not smash local variables. */ - g_assert(cpu =3D=3D current_cpu); - g_assert(cc =3D=3D CPU_GET_CLASS(cpu)); + /* Assert that the compiler does not smash local variables. */ + g_assert(cpu =3D=3D current_cpu); + g_assert(cc =3D=3D CPU_GET_CLASS(cpu)); #endif /* buggy compiler */ - cpu->can_do_io =3D 1; - tb_lock_reset(); + cpu->can_do_io =3D 1; + tb_lock_reset(); + } + + /* if an exception is pending, we execute it here */ + while (!cpu_handle_exception(cpu, &ret)) { + TranslationBlock *last_tb =3D NULL; + int tb_exit =3D 0; + + while (!cpu_handle_interrupt(cpu, &last_tb)) { + TranslationBlock *tb =3D tb_find(cpu, last_tb, tb_exit); + cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); + /* Try to align the host and virtual clocks + if the guest is in advance */ + align_clocks(&sc, cpu); } - } /* for(;;) */ + } =20 cc->cpu_exec_exit(cpu); rcu_read_unlock(); --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487260596816399.3226837345983; Thu, 16 Feb 2017 07:56:36 -0800 (PST) Received: from localhost ([::1]:47492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOQ5-0000Ko-CU for importer@patchew.org; Thu, 16 Feb 2017 10:56:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6p-00040A-TY for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6m-0008Gl-OW for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:35 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:32878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6m-0008GI-Hf for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:32 -0500 Received: by mail-wm0-x241.google.com with SMTP id v77so3429546wmv.0 for ; Thu, 16 Feb 2017 06:32:32 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rc9d+6HC4qOC/lmLWRgtgbvvbQTpdohdZtbH1G3SYtM=; b=AZkqI21cJR0p+dq3MBLKV5ZvTNStVyBBjzcF/PkngCwueLman62vHDRfcG6iU0C/dP 2UQ3od+Ak8WOf9+fzqYu4yCuXr0Y9AeyJA58b8inJbMSsLwj34BXoVq+6mDlGoXnoNAZ K1kxdy/wmTpZdQ/nk95OIPmZl6yqX9UDrXKir/bJMI5j+2n0grHOkzWqBBHwfDBerNm1 JvFE+So75Nl76rBGBPew96XJD22y/bHssbcB+rxfGyBWbmSCRjb7bRbm1isiKC6JIbnq CBMqpS3bLwGEGc76VgiZ3i0qGkzshdeB/iuHWNChe294eM4AcUgVJv1poIZ4vOL8pzaB Ybyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rc9d+6HC4qOC/lmLWRgtgbvvbQTpdohdZtbH1G3SYtM=; b=kYoRtIMgTotp7IrK+4LeD1cMCtMjlUoAu1FZbzEZDT8mGnhkWQsyuFd63cKiur9gaU 5thri5OlYjbzJINU+NTHTDsBGDWEeyyKAZ6lusWOJwz4gXI7Qh7nk3KnUXSunpl8yu9i Oda4iUCXWbVRkIQyQ9bSrqMcQaXbqPS8TM7BYd7pf6WHgfjP2aL24s3XRUCc5SNWKYMG aPMCmSxI71227SP2+DhkX/XmYnsPOQ6AcrRmxDw++CU+qh2GTGrkxRpN5WII5JF2NeWX GMNXMOAlDLVL/B3BPFWDdvceUGYVJhnmn5QFsHn+5vgi8v+Wgz8WiWQFpcAtDK20QOGf /xuA== X-Gm-Message-State: AMke39n93L1df5yzlSRfZ+prWqUnNBvzCVhZokKTU2m820qs3utaZxDgUPIf6gFpoCemoQ== X-Received: by 10.28.51.72 with SMTP id z69mr2985118wmz.38.1487255551504; Thu, 16 Feb 2017 06:32:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:40 +0100 Message-Id: <1487255507-106654-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 16/23] qemu-doc: Clarify that -vga std is now the default 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: , Cc: Alberto Garcia 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" From: Alberto Garcia The QEMU manual page states that Cirrus Logic is the default video card if the user doesn't specify any. However this is not true since QEMU 2.2. Signed-off-by: Alberto Garcia Message-Id: <20170127094154.19778-1-berto@igalia.com> Signed-off-by: Paolo Bonzini --- qemu-options.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index ac036b4..5633d39 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1194,12 +1194,12 @@ Select type of VGA card to emulate. Valid values fo= r @var{type} are Cirrus Logic GD5446 Video card. All Windows versions starting from Windows 95 should recognize and use this graphic card. For optimal performances, use 16 bit color depth in the guest and the host OS. -(This one is the default) +(This card was the default before QEMU 2.2) @item std Standard VGA card with Bochs VBE extensions. If your guest OS supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want to use high resolution modes (>=3D 1280x1024x16) then you should use -this option. +this option. (This card is the default since QEMU 2.2) @item vmware VMWare SVGA-II compatible adapter. Use it if you have sufficiently recent XFree86/XOrg server or Windows guest with a driver for this --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258091773451.99287968355054; Thu, 16 Feb 2017 07:14:51 -0800 (PST) Received: from localhost ([::1]:47256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNlf-0003Nz-U7 for importer@patchew.org; Thu, 16 Feb 2017 10:14:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6q-00041I-WD for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6p-0008IO-IF for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:36 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6p-0008Hq-8g for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:35 -0500 Received: by mail-wm0-x243.google.com with SMTP id u63so3408810wmu.2 for ; Thu, 16 Feb 2017 06:32:35 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7L4LOsUPfw3pqjJ5IfUKhk0FYTt4glWK7IaLdI+ve5M=; b=i9dUz8hLo31jS3MEhfVh8ugJrsAWIKSr8nAVKAF8695cmNVUlD/8yGTfQnEm2mS3U+ dCFC0GPrO7UBxO8tVoVOVTD6atHfUSFYOhNMTfg6I+nRmQ5nsOVak90uBGholOj/P5oQ GIV9KQoWfQsP20Hfn2UWwaohwr6oLnj61vpFs5q6lmx9Jn8f5CBHqH+rI3rqwTwJFNmq OW/TIr8WY6kiu2IoLttvQlySQ359EHmOQdYTRBHygVP0xvH+ndVPsXD+sKwHI6Gj3hNm CiazmhN2FEXyduz5nL2gqJ+s9oKKI3ro2EMU/HWDw+Hgyp7seok47pROxCRE+638mTz0 QY8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7L4LOsUPfw3pqjJ5IfUKhk0FYTt4glWK7IaLdI+ve5M=; b=Y96hZ1fQWfoysAwuN4oDK6OXjyWsPCbDK9KCxEQKXG2l/xxWtacAMvCef4A/IUneUm DBA0VCCEdMJhwthD8bGbXO9LlJkjEa+SDOOnbFy530BIZoRjcyhqUEjBXAHunUFxV2rs 98gRt6XjrSuFz+/4uhSHEkzXxRIy5m3CtT0NB+HXPkuBA7zNhLK7eSVQyq6tprvKJKJo B1f9iAGiAnFPU8VqUGWPfc8R/3xF5VMA5NpSSVRzGLUQmH3I2h6OqOdkMAjg5vigZkC6 siKqWtM4BI2701ujwk/Dd0mkJmNv6ulGYtgu0Lvp7ztxwRn+mOH5GgvZP1B0zuHN5rlL 4KlA== X-Gm-Message-State: AMke39kmrXn4rbDGHXgaIPOuhKT8bnCEikLG3YSQq3B9V7p8VQWwOVyuli7qJcmoXEgOMQ== X-Received: by 10.28.229.193 with SMTP id c184mr2936026wmh.83.1487255554095; Thu, 16 Feb 2017 06:32:34 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:41 +0100 Message-Id: <1487255507-106654-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 17/23] qemu-nbd: Implement socket activation. 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: , Cc: "Richard W.M. Jones" 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" From: "Richard W.M. Jones" Socket activation (sometimes known as systemd socket activation) allows an Internet superserver to pass a pre-opened listening socket to the process, instead of having qemu-nbd open a socket itself. This is done via the LISTEN_FDS and LISTEN_PID environment variables, and a standard file descriptor range. This change partially implements socket activation for qemu-nbd. If the environment variables are set correctly, then socket activation will happen automatically, otherwise everything works as before. The limitation is that LISTEN_FDS must be 1. Signed-off-by: Richard W.M. Jones Message-Id: <20170204100317.32425-2-rjones@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-nbd.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 163 insertions(+), 9 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index c734f62..e4fede6 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -463,6 +463,135 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char = *id, Error **errp) return creds; } =20 +static void setup_address_and_port(const char **address, const char **port) +{ + if (*address =3D=3D NULL) { + *address =3D "0.0.0.0"; + } + + if (*port =3D=3D NULL) { + *port =3D stringify(NBD_DEFAULT_PORT); + } +} + +#define FIRST_SOCKET_ACTIVATION_FD 3 /* defined by systemd ABI */ + +#ifndef _WIN32 +/* + * Check if socket activation was requested via use of the + * LISTEN_FDS and LISTEN_PID environment variables. + * + * Returns 0 if no socket activation, or the number of FDs. + */ +static unsigned int check_socket_activation(void) +{ + const char *s; + unsigned long pid; + unsigned long nr_fds; + unsigned int i; + int fd; + int err; + + s =3D getenv("LISTEN_PID"); + if (s =3D=3D NULL) { + return 0; + } + err =3D qemu_strtoul(s, NULL, 10, &pid); + if (err) { + if (verbose) { + fprintf(stderr, "malformed %s environment variable (ignored)\n= ", + "LISTEN_PID"); + } + return 0; + } + if (pid !=3D getpid()) { + if (verbose) { + fprintf(stderr, "%s was not for us (ignored)\n", + "LISTEN_PID"); + } + return 0; + } + + s =3D getenv("LISTEN_FDS"); + if (s =3D=3D NULL) { + return 0; + } + err =3D qemu_strtoul(s, NULL, 10, &nr_fds); + if (err) { + if (verbose) { + fprintf(stderr, "malformed %s environment variable (ignored)\n= ", + "LISTEN_FDS"); + } + return 0; + } + assert(nr_fds <=3D UINT_MAX); + + /* A limitation of current qemu-nbd is that it can only listen on + * a single socket. When that limitation is lifted, we can change + * this function to allow LISTEN_FDS > 1, and remove the assertion + * in the main function below. + */ + if (nr_fds > 1) { + error_report("qemu-nbd does not support socket activation with %s = > 1", + "LISTEN_FDS"); + exit(EXIT_FAILURE); + } + + /* So these are not passed to any child processes we might start. */ + unsetenv("LISTEN_FDS"); + unsetenv("LISTEN_PID"); + + /* So the file descriptors don't leak into child processes. */ + for (i =3D 0; i < nr_fds; ++i) { + fd =3D FIRST_SOCKET_ACTIVATION_FD + i; + if (fcntl(fd, F_SETFD, FD_CLOEXEC) =3D=3D -1) { + /* If we cannot set FD_CLOEXEC then it probably means the file + * descriptor is invalid, so socket activation has gone wrong + * and we should exit. + */ + error_report("Socket activation failed: " + "invalid file descriptor fd =3D %d: %m", + fd); + exit(EXIT_FAILURE); + } + } + + return (unsigned int) nr_fds; +} + +#else /* !_WIN32 */ +static unsigned int check_socket_activation(void) +{ + return 0; +} +#endif + +/* + * Check socket parameters compatibility when socket activation is used. + */ +static const char *socket_activation_validate_opts(const char *device, + const char *sockpath, + const char *address, + const char *port) +{ + if (device !=3D NULL) { + return "NBD device can't be set when using socket activation"; + } + + if (sockpath !=3D NULL) { + return "Unix socket can't be set when using socket activation"; + } + + if (address !=3D NULL) { + return "The interface can't be set when using socket activation"; + } + + if (port !=3D NULL) { + return "TCP port number can't be set when using socket activation"; + } + + return NULL; +} =20 int main(int argc, char **argv) { @@ -471,7 +600,7 @@ int main(int argc, char **argv) off_t dev_offset =3D 0; uint16_t nbdflags =3D 0; bool disconnect =3D false; - const char *bindto =3D "0.0.0.0"; + const char *bindto =3D NULL; const char *port =3D NULL; char *sockpath =3D NULL; char *device =3D NULL; @@ -533,6 +662,7 @@ int main(int argc, char **argv) char *trace_file =3D NULL; bool fork_process =3D false; int old_stderr =3D -1; + unsigned socket_activation; =20 /* The client thread uses SIGTERM to interrupt the server. A signal * handler ensures that "qemu-nbd -v -c" exits with a nice status code. @@ -751,6 +881,19 @@ int main(int argc, char **argv) trace_init_file(trace_file); qemu_set_log(LOG_TRACE); =20 + socket_activation =3D check_socket_activation(); + if (socket_activation =3D=3D 0) { + setup_address_and_port(&bindto, &port); + } else { + /* Using socket activation - check user didn't use -p etc. */ + const char *err_msg =3D socket_activation_validate_opts(device, so= ckpath, + bindto, port= ); + if (err_msg !=3D NULL) { + error_report("%s", err_msg); + exit(EXIT_FAILURE); + } + } + if (tlscredsid) { if (sockpath) { error_report("TLS is only supported with IPv4/IPv6"); @@ -855,7 +998,25 @@ int main(int argc, char **argv) snprintf(sockpath, 128, SOCKET_PATH, basename(device)); } =20 - saddr =3D nbd_build_socket_address(sockpath, bindto, port); + if (socket_activation =3D=3D 0) { + server_ioc =3D qio_channel_socket_new(); + saddr =3D nbd_build_socket_address(sockpath, bindto, port); + if (qio_channel_socket_listen_sync(server_ioc, saddr, &local_err) = < 0) { + object_unref(OBJECT(server_ioc)); + error_report_err(local_err); + return 1; + } + } else { + /* See comment in check_socket_activation above. */ + assert(socket_activation =3D=3D 1); + server_ioc =3D qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_F= D, + &local_err); + if (server_ioc =3D=3D NULL) { + error_report("Failed to use socket activation: %s", + error_get_pretty(local_err)); + exit(EXIT_FAILURE); + } + } =20 if (qemu_init_main_loop(&local_err)) { error_report_err(local_err); @@ -950,13 +1111,6 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } =20 - server_ioc =3D qio_channel_socket_new(); - if (qio_channel_socket_listen_sync(server_ioc, saddr, &local_err) < 0)= { - object_unref(OBJECT(server_ioc)); - error_report_err(local_err); - return 1; - } - if (device) { int ret; =20 --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487259428804849.2852515501434; Thu, 16 Feb 2017 07:37:08 -0800 (PST) Received: from localhost ([::1]:47376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceO7F-0005fO-Do for importer@patchew.org; Thu, 16 Feb 2017 10:37:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6s-00042s-Hy for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6r-0008Jw-Hn for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:38 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:32886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6r-0008JT-B5 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:37 -0500 Received: by mail-wm0-x244.google.com with SMTP id v77so3430019wmv.0 for ; Thu, 16 Feb 2017 06:32:37 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BXSnDQwOj/wIvRLMUP+w16apO7azycaoU1dMukLwKBY=; b=TFn+yTc4k1imK0iAa1bHK6ULJk4596OaBbbip4/PqfkfLaZmZnHhkndnqCjr11+tfq cheqZDIIturDt2YQT4v0xI9D6BZzmx0qOMh7cG6fjXXw9yNmkH50yUo5yAEvR09zO+pN QQiwS6I3Pc02PGodhEYNAam733FF45ySkCZPuDTogE33WzQPnokX9Y519E/+7L5BP9gx P29dk6eTbXtaUlWTqbPrSH9dX4DAT7vmEjKWdalDaPa5QuWljLR58grnwSvhxITxTRGw pq4Od0nTrd3Rn674uXb/Ga+LEFHNnPVoM5cdlMCnV3D4c1PYRA0n5fzRwQ9HE4yz8mQn yi0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=BXSnDQwOj/wIvRLMUP+w16apO7azycaoU1dMukLwKBY=; b=cBYY1gHGvhIVgHtaUA4MvFC5nVZT7ZPdCv2xkraakH69GHbXb8vdti0ipCfV8d4BSV paGm/2gG6qtNgd8OJsE/k2KsudyFoqoRl4TKmzms/EQYAnrSU+TQYmZD0aUDx9nRsCXj pFXkBGtz4SDZCKqZVIhuGRHq9DC4rFyuEGzj8VmE7V6eFz8XmxlONVWxNlT+Ab2R7C7q uLYZYdSOz1c6+b+U2pSsOWp3eZXs4dC2++PpsKxnYf39DQxyWnoi1kEjxuTH/B1MJTYJ JqfcpMoK/sPCK9eLfEQLkzF4fjQtUAXYKnxx791yCt3Op3WVevCfbB8FQwwbGcY+1nD6 fhxg== X-Gm-Message-State: AMke39msn8/BiWgMl7W9UCngq2VDXRac5WAl5O/M6zJaTGUKBfDIzoQs3ILnSr8TDXEJFw== X-Received: by 10.28.140.130 with SMTP id o124mr2830528wmd.48.1487255556214; Thu, 16 Feb 2017 06:32:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:42 +0100 Message-Id: <1487255507-106654-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 18/23] vl: Move the cpu_synchronize_all_post_init() after generic devices initialization 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: , Cc: Dou Liyang 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" From: Dou Liyang At the Qemu initialization, we call the cpu_synchronize_all_post_init() to synchronize All CPU states to KVM in the ./vl.c::main(). Currently, it is called before we initialize the CPUs, which is created by "-device" command and parsed by generic devices initialization, So, these CPUs may be ignored to synchronize. The patch moves the cpu_synchronize_all_post_init func after generic devices initialization to make sure that all the CPUs can be included. Signed-off-by: Dou Liyang Message-Id: <1485916178-17838-1-git-send-email-douly.fnst@cn.fujitsu.com> Reviewed-by: Eduardo Habkost Acked-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- vl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 0d866ad..a05671d 100644 --- a/vl.c +++ b/vl.c @@ -4462,8 +4462,6 @@ int main(int argc, char **argv, char **envp) =20 audio_init(); =20 - cpu_synchronize_all_post_init(); - if (hax_enabled()) { hax_sync_vcpus(); } @@ -4489,6 +4487,8 @@ int main(int argc, char **argv, char **envp) exit(1); } =20 + cpu_synchronize_all_post_init(); + numa_post_machine_init(); =20 rom_reset_order_override(); --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258440630285.5362158462077; Thu, 16 Feb 2017 07:20:40 -0800 (PST) Received: from localhost ([::1]:47285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNrK-0001Dx-Ah for importer@patchew.org; Thu, 16 Feb 2017 10:20:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6u-00044A-P9 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6t-0008L1-U5 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:40 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34892) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6t-0008KX-NP for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:39 -0500 Received: by mail-wm0-x243.google.com with SMTP id u63so3409230wmu.2 for ; Thu, 16 Feb 2017 06:32:39 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WqWt2+WsBYgajzpc+FDTaEgMXoDMLboYilzeRqdo1Mk=; b=dY+amUZfWJE9JFGf4U1ye1EYVTH4WlfGF6UqUJLMKJG4UXDCMEQTb5fg6jzlI2VRyH PWXMXIBVLxW0OdhnwaXDleCxJyrVmd7hP9oWYCGhjUHQQVTxryIbCZ8nROpq74kGwFSn xcy6w9f+LWZCXE1UJvjRdns7xiDyed7AFy4miaRIDGHfeY5iTxNI4uLwWF7NKNlj7h2L F6BjkOzgXYWlFU5WidZZT47kYOMZIY5IM/H/ywAjnggbqZRdJ4evoxPVMbdEnchRa/6Y 2m1Acr+SHOGxIioh4asoGi/qCIrmUTTYXm8TTbQZugtxsI3mzBJF+OAtGr62RSL16aus hwCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WqWt2+WsBYgajzpc+FDTaEgMXoDMLboYilzeRqdo1Mk=; b=rIusJgXg4YsoyLSr/r9CJFv4/hwquoFyDfSkaTvWLoqVaEh9LUv6g/1sa1We4m44j2 /GdKoDeNqPFgU3OTz77hEVFU6HrutdZr0q62YNK0/UEJzZFxgNDmJL/hbjwRt1i0dYnD vQn1UNN9xJNdIoj4m9PeTWqQ71Jqr+yKyV2hZosZIZp81jqIedoRFbP9RhQGGax4V2h5 qVQEp0TFx65xWH6AEpg+Fq7ST7ZTVf1rvur1HcqbB1yNS78eZCNZx3PmWzY1d5QN+aNS hBMAEdyXAOe4u8EKWo/ico+pDfX9J1H9X6JPyCo0wYnol6tfem12Wk2Al/g11bn2llha Oe4Q== X-Gm-Message-State: AMke39nP4sov3qQvdpyTFDWfdHu9dqMe9d90HDAX5hfbl+9goaZqiK9IdZsccFQm3ZbRlg== X-Received: by 10.28.6.78 with SMTP id 75mr2889349wmg.81.1487255558578; Thu, 16 Feb 2017 06:32:38 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:43 +0100 Message-Id: <1487255507-106654-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 19/23] Makefile: avoid leaving the temporary QEMU_PKGVERSION header file 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: , Cc: Lin Ma 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" From: Lin Ma By commit 67a1de0d, When we perform 'git pull && make && sudo make install', In 'make' stage a qemu-version.h.tmp will be generated. If the content of qemu-version.h.tmp and qemu-version.h aren't consistent, The qemu-version.h= .tmp will be renamed to qemu-version.h. Because of the target FORCE, The same ac= tion will be do again in 'make install' stage. In 'make install' stage, If there is no qemu-version.h.tmp exists and we run 'make install' with sudo, The owner and group of new qemu-version.h.tmp wil= l be privileged user/group. When we run 'make' next time, qemu-version.h.tmp can= 't be overwritten because of permission issue. This patch removed qemu-version.h.tmp after build to fix this issue. Signed-off-by: Lin Ma Message-Id: <20170215024030.23895-1-lma@suse.com> Reviewed-by: Fam Zheng Signed-off-by: Paolo Bonzini --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b993741..830fa5a 100644 --- a/Makefile +++ b/Makefile @@ -299,7 +299,11 @@ qemu-version.h: FORCE printf '""\n'; \ fi; \ fi) > $@.tmp) - $(call quiet-command, cmp -s $@ $@.tmp || mv $@.tmp $@) + $(call quiet-command, if ! cmp -s $@ $@.tmp; then \ + mv $@.tmp $@; \ + else \ + rm $@.tmp; \ + fi) =20 config-host.h: config-host.h-timestamp config-host.h-timestamp: config-host.mak --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258395412830.5639891545821; Thu, 16 Feb 2017 07:19:55 -0800 (PST) Received: from localhost ([::1]:47280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNqY-0000HC-34 for importer@patchew.org; Thu, 16 Feb 2017 10:19:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN70-00049u-Ri for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6x-0008Nc-M4 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:46 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:34952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6x-0008NG-Ah for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:43 -0500 Received: by mail-wr0-x242.google.com with SMTP id q39so2265576wrb.2 for ; Thu, 16 Feb 2017 06:32:43 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uACwJUGMMhFCuZrwDhKSuKTRqfeNBfShaRi4MwibeNc=; b=sz3a9H3dh9HFykut28x4xdSTN54hlOTIA8CN/NuLnFdC9lbRfVDRBuw6qgm58xQteV GzAdzpk35/5X/fXS9n6dG5YCxBrUW2nkexK9DAGrSOKO+Pr7Pb4do/3jl9l31Gd2jZAh m+AGWP7O0v8eIBtiQZWGK155rFVMJb2KhsvVLSDPbStwFS/hIHB1je7W+jubmFKobLbn 5Th17GQUgu6zvRcJ2b6BPXbJ5hnltPGcSsZNm8ksWC3MtEKVsc6WCbNhppkSn1AwbrOa o4w1wnCpR3baTjv5jyhnoldNhfb/UPZRfDbfBm8SQqWNhqnaMYWzM+GxjHr4OhOW4z8l KJtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uACwJUGMMhFCuZrwDhKSuKTRqfeNBfShaRi4MwibeNc=; b=gRPoa1WGUmtOQEzknQYaPFxfPj/Ht5OZ5GMUyq6e/cedvYnkE5ChZAGdo+mWIBZIuM ynU6baBaLY1KEKK93VDOm0JYMMjlUaUQUb1d0IqElkwSKJDh/9cHu8xilWUzhLwEYJwA InK3vlwcwfFwjwUKtNqcYqGNQC89K+tF8RbeMoh7dewplOHAXy2Lylz9yb3SAl7aZINq WMtdaWhQ1woSYBJCf4L6gjbPq6gOp58MYQfbwZEwuSVYd2nGgoWCYuBJX4LqdWKiNBmP xGnGXhyKAHE2+NrcV+7GurgmpM8GaxlaIWHntjGEkkBOesduyJoZ30WwpHSezIjt/myL NPdg== X-Gm-Message-State: AMke39nRYzH66hq0R4+YgwrbinY5n7LYy1fXIQ5Ab8uXOA+fA2w9Zi8z4wlmroq0rzkR2A== X-Received: by 10.223.173.183 with SMTP id w52mr2937351wrc.164.1487255562291; Thu, 16 Feb 2017 06:32:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:44 +0100 Message-Id: <1487255507-106654-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 20/23] i386/cpu: add crash-information QOM property 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: , Cc: "Denis V. Lunev" , Anton Nefedov 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" From: Anton Nefedov Windows reports BSOD parameters through Hyper-V crash MSRs. This information is very useful for initial crash analysis and thus it would be nice to have a way to fetch it. Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev Message-Id: <1487053524-18674-2-git-send-email-den@openvz.org> Signed-off-by: Paolo Bonzini --- kvm-all.c | 1 + qapi-schema.json | 24 ++++++++++++++++++++++++ target/i386/cpu.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/kvm-all.c b/kvm-all.c index a27c880..64f46c8 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2000,6 +2000,7 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D EXCP_INTERRUPT; break; case KVM_SYSTEM_EVENT_CRASH: + kvm_cpu_synchronize_state(cpu); qemu_mutex_lock_iothread(); qemu_system_guest_panicked(); qemu_mutex_unlock_iothread(); diff --git a/qapi-schema.json b/qapi-schema.json index 5edb08d..baa0d26 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5871,6 +5871,30 @@ 'data': [ 'pause', 'poweroff' ] } =20 ## +# @GuestPanicInformation: +# +# Information about a guest panic +# +# Since: 2.9 +## +{'union': 'GuestPanicInformation', + 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } } + +## +# @GuestPanicInformationHyperV: +# +# Hyper-V specific guest panic information (HV crash MSRs) +# +# Since: 2.9 +## +{'struct': 'GuestPanicInformationHyperV', + 'data': { 'arg1': 'uint64', + 'arg2': 'uint64', + 'arg3': 'uint64', + 'arg4': 'uint64', + 'arg5': 'uint64' } } + +## # @rtc-reset-reinjection: # # This command will reset the RTC interrupt reinjection backlog. diff --git a/target/i386/cpu.c b/target/i386/cpu.c index eb49980..71aa91f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3495,6 +3495,53 @@ static void x86_cpu_register_feature_bit_props(X86CP= U *cpu, x86_cpu_register_bit_prop(cpu, name, &cpu->env.features[w], bitnr); } =20 +static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + GuestPanicInformation *panic_info =3D NULL; + + if (env->features[FEAT_HYPERV_EDX] & HV_X64_GUEST_CRASH_MSR_AVAILABLE)= { + GuestPanicInformationHyperV *panic_info_hv =3D + g_malloc0(sizeof(GuestPanicInformationHyperV)); + panic_info =3D g_malloc0(sizeof(GuestPanicInformation)); + + panic_info->type =3D GUEST_PANIC_INFORMATION_KIND_HYPER_V; + panic_info->u.hyper_v.data =3D panic_info_hv; + + assert(HV_X64_MSR_CRASH_PARAMS >=3D 5); + panic_info_hv->arg1 =3D env->msr_hv_crash_params[0]; + panic_info_hv->arg2 =3D env->msr_hv_crash_params[1]; + panic_info_hv->arg3 =3D env->msr_hv_crash_params[2]; + panic_info_hv->arg4 =3D env->msr_hv_crash_params[3]; + panic_info_hv->arg5 =3D env->msr_hv_crash_params[4]; + } + + return panic_info; +} +static void x86_cpu_get_crash_info_qom(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + CPUState *cs =3D CPU(obj); + GuestPanicInformation *panic_info; + + if (!cs->crash_occurred) { + error_setg(errp, "No crash occured"); + return; + } + + panic_info =3D x86_cpu_get_crash_info(cs); + if (panic_info =3D=3D NULL) { + error_setg(errp, "No crash information"); + return; + } + + visit_type_GuestPanicInformation(v, "crash-information", &panic_info, + errp); + qapi_free_GuestPanicInformation(panic_info); +} + static void x86_cpu_initfn(Object *obj) { CPUState *cs =3D CPU(obj); @@ -3530,6 +3577,9 @@ static void x86_cpu_initfn(Object *obj) x86_cpu_get_feature_words, NULL, NULL, (void *)cpu->filtered_features, NULL); =20 + object_property_add(obj, "crash-information", "GuestPanicInformation", + x86_cpu_get_crash_info_qom, NULL, NULL, NULL, NULL= ); + cpu->hyperv_spinlock_attempts =3D HYPERV_SPINLOCK_NEVER_RETRY; =20 for (w =3D 0; w < FEATURE_WORDS; w++) { --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487261141145215.32973290945915; Thu, 16 Feb 2017 08:05:41 -0800 (PST) Received: from localhost ([::1]:47542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOYq-0000hi-BD for importer@patchew.org; Thu, 16 Feb 2017 11:05:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN71-0004AG-8n for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6z-0008OJ-Tr for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:47 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:32912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6z-0008Nr-Kl for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:45 -0500 Received: by mail-wr0-x244.google.com with SMTP id i10so2282608wrb.0 for ; Thu, 16 Feb 2017 06:32:45 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dFwIYpB2G2jc7gqbXuHS6Xyqdy+yTbsXPzXPGtX1z8Y=; b=M3NLKkU/DN6UYNRqviune6wto88b8UoFcUjP1LHCwar5fTkxytmSSlvABl34p9sHwa U6V4n+zj4+NQHPLUULZxTacJrS05YnzcAolgcDVEtpPHlANTozQtjy04Z1xi2y/BWP2c ABdAwACijAKqYybx6TN7vqkw7UHqgdl7TTi5yw4urz0XWgE5eiKu5FDSp9Yp0NAuy5Fx ddClHkvNspy7gk7oPfUvsN2xu2EI5GW90vElUY1KmYZ+MU+Vp9QtirUoYorWT84McC05 ZjdWWwoxQUE8X9sKsfQhKeM2tEvP1fgFvz6SxQtEiT0PCHQFHbJg1PLOmeBMlr9adPaz 85EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dFwIYpB2G2jc7gqbXuHS6Xyqdy+yTbsXPzXPGtX1z8Y=; b=ueJ7HjxbXGBUIwidd/qbjKVUzyxQ1u/PGE79dQq98MsGP5zlwAMxAgxMTjWeMeHbko h3d9XO1gr6Z+ahidG5LS1O8kVjnsTqOgJZtdr2I1tN9PBMhWfNitIFNm2Urf3EZ3Kr0l 1YgpjeDz0VThZpnTJ+RtDc+nQBTn03nLj6CdlCRB3QC79BUgbQsBqpbVL+tDTkcT2e9y B0/EjeLihffMPIBmR7ciccoIzryZjGlyaK8nLXWmC0CDGBbJuM556rMQS3ke0oPUuSWj X2sVOWaTYIenz0u+UhNha8e7fdKTGCF88relieHVY9mFQvwOfMwH9I8FiOQCICDnxCMg 2Z+g== X-Gm-Message-State: AMke39k2BzPnFJq/PCykoowHUs3yzwRw1njSPTZHovDuNysyOHoHKsU7jZSaubNDT68vwQ== X-Received: by 10.223.144.65 with SMTP id h59mr2991162wrh.30.1487255564347; Thu, 16 Feb 2017 06:32:44 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:45 +0100 Message-Id: <1487255507-106654-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 21/23] report guest crash information in GUEST_PANICKED event 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: , Cc: "Denis V. Lunev" , Anton Nefedov 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" From: Anton Nefedov it's not very convenient to use the crash-information property interface, so provide a CPU class callback to get the guest crash information, and pass that information in the event Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev Message-Id: <1487053524-18674-3-git-send-email-den@openvz.org> Signed-off-by: Paolo Bonzini --- hw/misc/pvpanic.c | 2 +- hw/ppc/spapr_rtas.c | 3 ++- include/qom/cpu.h | 10 ++++++++++ include/sysemu/sysemu.h | 2 +- kvm-all.c | 2 +- qapi/event.json | 6 ++++-- qom/cpu.c | 11 +++++++++++ target/i386/cpu.c | 1 + target/s390x/kvm.c | 4 ++-- vl.c | 11 ++++++++--- 10 files changed, 41 insertions(+), 11 deletions(-) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 0ac1e6a..57da7f2 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -42,7 +42,7 @@ static void handle_event(int event) } =20 if (event & PVPANIC_PANICKED) { - qemu_system_guest_panicked(); + qemu_system_guest_panicked(NULL); return; } } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index bb19944..619f32c 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -334,7 +334,8 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu, { target_ulong ret =3D 0; =20 - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, false, NULL, + &error_abort); =20 rtas_st(rets, 0, ret); } diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 45bcf21..f69b240 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -158,6 +158,7 @@ typedef struct CPUClass { uint8_t *buf, int len, bool is_write); void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprint= f, int flags); + GuestPanicInformation* (*get_crash_info)(CPUState *cpu); void (*dump_statistics)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags); int64_t (*get_arch_id)(CPUState *cpu); @@ -472,6 +473,15 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, = CPUState *cpu, void *opaque); =20 /** + * cpu_get_crash_info: + * @cpu: The CPU to get crash information for + * + * Gets the previously saved crash information. + * Caller is responsible for freeing the data. + */ +GuestPanicInformation *cpu_get_crash_info(CPUState *cpu); + +/** * CPUDumpFlags: * @CPU_DUMP_CODE: * @CPU_DUMP_FPU: dump FPU register state, not just integer diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index eda5241..576c7ce 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -66,7 +66,7 @@ int qemu_shutdown_requested_get(void); int qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(bool report); -void qemu_system_guest_panicked(void); +void qemu_system_guest_panicked(GuestPanicInformation *info); size_t qemu_target_page_bits(void); =20 void qemu_add_exit_notifier(Notifier *notify); diff --git a/kvm-all.c b/kvm-all.c index 64f46c8..0c94637 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2002,7 +2002,7 @@ int kvm_cpu_exec(CPUState *cpu) case KVM_SYSTEM_EVENT_CRASH: kvm_cpu_synchronize_state(cpu); qemu_mutex_lock_iothread(); - qemu_system_guest_panicked(); + qemu_system_guest_panicked(cpu_get_crash_info(cpu)); qemu_mutex_unlock_iothread(); ret =3D 0; break; diff --git a/qapi/event.json b/qapi/event.json index 7bf539b..970ff02 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -488,7 +488,9 @@ # # @action: action that has been taken, currently always "pause" # -# Since: 1.5 +# @info: optional information about a panic +# +# Since: 1.5 (@info since 2.9) # # Example: # @@ -497,7 +499,7 @@ # ## { 'event': 'GUEST_PANICKED', - 'data': { 'action': 'GuestPanicAction' } } + 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } =20 ## # @QUORUM_FAILURE: diff --git a/qom/cpu.c b/qom/cpu.c index 0e19b1a..ed87c50 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -218,6 +218,17 @@ static bool cpu_common_exec_interrupt(CPUState *cpu, i= nt int_req) return false; } =20 +GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + GuestPanicInformation *res =3D NULL; + + if (cc->get_crash_info) { + res =3D cc->get_crash_info(cpu); + } + return res; +} + void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags) { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 71aa91f..fd7add2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3734,6 +3734,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) cc->do_interrupt =3D x86_cpu_do_interrupt; cc->cpu_exec_interrupt =3D x86_cpu_exec_interrupt; cc->dump_state =3D x86_cpu_dump_state; + cc->get_crash_info =3D x86_cpu_get_crash_info; cc->set_pc =3D x86_cpu_set_pc; cc->synchronize_from_tb =3D x86_cpu_synchronize_from_tb; cc->gdb_read_register =3D x86_cpu_gdb_read_register; diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 6ed3876..2536780 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1864,7 +1864,7 @@ static void unmanageable_intercept(S390CPU *cpu, cons= t char *str, int pswoffset) str, cs->cpu_index, ldq_phys(cs->as, cpu->env.psa + pswof= fset), ldq_phys(cs->as, cpu->env.psa + pswoffset + 8)); s390_cpu_halt(cpu); - qemu_system_guest_panicked(); + qemu_system_guest_panicked(NULL); } =20 static int handle_intercept(S390CPU *cpu) @@ -1897,7 +1897,7 @@ static int handle_intercept(S390CPU *cpu) if (is_special_wait_psw(cs)) { qemu_system_shutdown_request(); } else { - qemu_system_guest_panicked(); + qemu_system_guest_panicked(NULL); } } r =3D EXCP_HALTED; diff --git a/vl.c b/vl.c index a05671d..5993270 100644 --- a/vl.c +++ b/vl.c @@ -1679,18 +1679,23 @@ void qemu_system_reset(bool report) cpu_synchronize_all_post_reset(); } =20 -void qemu_system_guest_panicked(void) +void qemu_system_guest_panicked(GuestPanicInformation *info) { if (current_cpu) { current_cpu->crash_occurred =3D true; } - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, + !!info, info, &error_abort); vm_stop(RUN_STATE_GUEST_PANICKED); if (!no_shutdown) { qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, - &error_abort); + !!info, info, &error_abort); qemu_system_shutdown_request(); } + + if (info) { + qapi_free_GuestPanicInformation(info); + } } =20 void qemu_system_reset_request(void) --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487258670726603.5416412776282; Thu, 16 Feb 2017 07:24:30 -0800 (PST) Received: from localhost ([::1]:47310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNv3-0006mP-DW for importer@patchew.org; Thu, 16 Feb 2017 10:24:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN71-0004Ad-Lp for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN70-0008Oi-TH for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:47 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34965) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN70-0008ON-Mh for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:46 -0500 Received: by mail-wr0-x241.google.com with SMTP id q39so2265874wrb.2 for ; Thu, 16 Feb 2017 06:32:46 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=HK6FL2PNyKgxSUYI/YwDJmWg2oUl7b5jgc/wI7+r434=; b=TvrG/uayItFDlRfVimrd5T+m/fj0t3KAK//3susTnN5F/+AwQakcig7fP97Pnzh15a J51u8wZ2TIjcvX1RFhhWM0zUY8u9+FtBHtClcLgBByOkJDMyPgskzyfJsTkU9wzvI3m7 iAvxT1OJ4OpLYFo33YKOfTat59hJI+4JCrmx5zoQTIk1MJ3fAgPjIZ27zt+Bp4T8kjMt tDSA5AAUD2AdvRHNJa4GoM6kETaDJbTKIMC5b5sCbOL0s8IFxx4sUBN+7guntoNEoEWq MqnBNdcd0H0FhV1vfsuz+b4p9bIfI6rTjPfxcOKPAbf7GXJPsOTrdXXPpkxquaDZII9b 5KpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=HK6FL2PNyKgxSUYI/YwDJmWg2oUl7b5jgc/wI7+r434=; b=LSHqM5W6FQLAP8xlSvh1YsKKRV6KQxvnkw9VjLH1tIfC0/d2ZK9DIwfuNi2+yyeG77 MuAElGlR9Mh95hgRnEHPL2MI2ZVusTuwwdPk+jR0X8CbQPZRk8stNoCXuboWGDIV5Y5Z 5X8qF9FMA6gNqUMkxpVc4DsRKmWaXUx86tSBMFT9gcfU5NMrhRmO1kTjxvrMPWmEyynY OYALypewPhVionyR6mX8uW6RJfKNS3QIqegpVwmZCS6vqSLy1ep6VQ13UFmGZJu42q2s 3Y8JGC3lp2SjrjdDzWe6x80YwFbHjAKbnJpch+txLh/5/C5U29uTM4FXBX03OGZSLlXV j8hQ== X-Gm-Message-State: AMke39kUeDspryALVcWfJOtm21h3P7HMXYu0gto6Xg0VKWq+vIUrbCWi3EVNQoV38d+U9w== X-Received: by 10.223.134.253 with SMTP id 58mr2964280wry.46.1487255565672; Thu, 16 Feb 2017 06:32:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:46 +0100 Message-Id: <1487255507-106654-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 22/23] vl: log available guest crash information 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: , Cc: "Denis V. Lunev" , Anton Nefedov 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" From: Anton Nefedov There is a suitable log mask for the purpose. Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev Message-Id: <1487053524-18674-4-git-send-email-den@openvz.org> Signed-off-by: Paolo Bonzini --- vl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vl.c b/vl.c index 5993270..27d9829 100644 --- a/vl.c +++ b/vl.c @@ -1681,6 +1681,8 @@ void qemu_system_reset(bool report) =20 void qemu_system_guest_panicked(GuestPanicInformation *info) { + qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n"); + if (current_cpu) { current_cpu->crash_occurred =3D true; } @@ -1694,6 +1696,15 @@ void qemu_system_guest_panicked(GuestPanicInformatio= n *info) } =20 if (info) { + if (info->type =3D=3D GUEST_PANIC_INFORMATION_KIND_HYPER_V) { + qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64 + " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n= ", + info->u.hyper_v.data->arg1, + info->u.hyper_v.data->arg2, + info->u.hyper_v.data->arg3, + info->u.hyper_v.data->arg4, + info->u.hyper_v.data->arg5); + } qapi_free_GuestPanicInformation(info); } } --=20 1.8.3.1 From nobody Tue Apr 30 02:31:50 2024 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 1487259700671557.27809917984; Thu, 16 Feb 2017 07:41:40 -0800 (PST) Received: from localhost ([::1]:47400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOBd-000204-8Z for importer@patchew.org; Thu, 16 Feb 2017 10:41:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN75-0004EY-Lq for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN73-0008Q3-9N for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:51 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:32919) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN72-0008Pe-W8; Thu, 16 Feb 2017 09:32:49 -0500 Received: by mail-wr0-x244.google.com with SMTP id i10so2282813wrb.0; Thu, 16 Feb 2017 06:32:48 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=cTyibSorT9nHv3WaosKcNKpEX969Ef6A9fauFWIgRlM=; b=dhTXGc1PhtbOzw76J6GWjuXHfkVNLSm1eMs8tDq28I9s70yBBZXfD9rZdeIwe9Y/S/ +0iRE7VXakaP7Ev4iUz3lVK+KpfYtoqHoKz6XeQyHcTl7JlarZHKHJuWNzvl1Q1l5qXU 3NGphe1Lxl5x1q5I9AFTHV35FCWWi/cNXvLHDuVAPtlMnnaELeyfxVrtjyNX4YxS8v0/ T6qDyIfyk+2dvG9eVmX7HfW8M6sAf2sREaflq09EPcmxJnp25os5x9ppkLIjLOi1K0Wl qzekNcopKRBHmXAHvdL63nGS51hV/p/5TEkqyfk6FKHvg0JAV7irXFzMpvxwuTXmWshj 2i/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=cTyibSorT9nHv3WaosKcNKpEX969Ef6A9fauFWIgRlM=; b=laXqHW4c9x8IS+ZwZYGI24DBH/QC1C86HUqTwzJ4IoXPo0wfXEY/24erWJRkUa0v2M 2oIAjxr53c6+ytOKMF21jJpmR8BAhqedUEfXF7bCSXonGlUmu6FGreD4ubI94dcPDNCN 2gUWpLRPYt2o0biD4UBOm7WH8y4AmEzcfAZOyxQuRcjqlJgR3VhKITN2EXdiQ7TVJs5c DQPrQyXwGY23nO0FNF8gYtvJRCi2kClQXJrXRzQTSFnRQZI5L5tMKLI3znXIn75s8xKv 2ldX9G65nWU+BgYoGG1daJSLf24FpWRkg5+FoB8Cb7Up0y0nhVfprFswfhoR7rqdqt53 EvLQ== X-Gm-Message-State: AMke39leXKOwU0P5j10BYbTX3Oi9FJP0+g4uFdYhy5bKPB4LGB/UUl5OZ4eX7ANL6jjsNw== X-Received: by 10.223.179.78 with SMTP id k14mr2950425wrd.34.1487255567571; Thu, 16 Feb 2017 06:32:47 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:47 +0100 Message-Id: <1487255507-106654-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 23/23] target-i386: correctly propagate retaddr into SVM helpers 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: , Cc: qemu-stable@nongnu.org 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" Commit 2afbdf8 ("target-i386: exception handling for memory helpers", 2015-09-15) changed tlb_fill's cpu_restore_state+raise_exception_err to raise_exception_err_ra. After this change, the cpu_restore_state and raise_exception_err's cpu_loop_exit are merged into raise_exception_err_ra's cpu_loop_exit_restore. This actually fixed some bugs, but when SVM is enabled there is a second path from raise_exception_err_ra to cpu_loop_exit. This is the VMEXIT path, and now cpu_vmexit is called without a cpu_restore_state before. The fix is to pass the retaddr to cpu_vmexit (via cpu_svm_check_intercept_param). All helpers can now use GETPC() to pass the correct retaddr, too. Cc: qemu-stable@nongnu.org Fixes: 2afbdf84807d673eb682cb78158e11cdacbf4673 Reported-by: Alexander Boettcher Tested-by: Alexander Boettcher Signed-off-by: Paolo Bonzini --- cpu-exec.c | 2 +- target/i386/cpu.h | 5 ++-- target/i386/excp_helper.c | 11 ++++---- target/i386/helper.h | 1 - target/i386/misc_helper.c | 24 ++++++++--------- target/i386/seg_helper.c | 6 ++--- target/i386/svm_helper.c | 65 ++++++++++++++++++++++---------------------= ---- 7 files changed, 56 insertions(+), 58 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index b8ebb5c..142a586 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -491,7 +491,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, X86CPU *x86_cpu =3D X86_CPU(cpu); CPUArchState *env =3D &x86_cpu->env; replay_interrupt(); - cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); cpu->exception_index =3D EXCP_HALTED; return true; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 4d788d5..cfb1ce0 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1621,8 +1621,9 @@ void helper_lock_init(void); =20 /* svm_helper.c */ void cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type, - uint64_t param); -void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1); + uint64_t param, uint64_t retaddr); +void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1, + uintptr_t retaddr); =20 /* seg_helper.c */ void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw); diff --git a/target/i386/excp_helper.c b/target/i386/excp_helper.c index f0dc499..923f1af 100644 --- a/target/i386/excp_helper.c +++ b/target/i386/excp_helper.c @@ -39,7 +39,8 @@ void helper_raise_exception(CPUX86State *env, int excepti= on_index) * needed. It should only be called, if this is not an interrupt. * Returns the new exception number. */ -static int check_exception(CPUX86State *env, int intno, int *error_code) +static int check_exception(CPUX86State *env, int intno, int *error_code, + uint64_t retaddr) { int first_contributory =3D env->old_exception =3D=3D 0 || (env->old_exception >=3D 10 && @@ -53,7 +54,7 @@ static int check_exception(CPUX86State *env, int intno, i= nt *error_code) #if !defined(CONFIG_USER_ONLY) if (env->old_exception =3D=3D EXCP08_DBLE) { if (env->hflags & HF_SVMI_MASK) { - cpu_vmexit(env, SVM_EXIT_SHUTDOWN, 0); /* does not return */ + cpu_vmexit(env, SVM_EXIT_SHUTDOWN, 0, retaddr); /* does not re= turn */ } =20 qemu_log_mask(CPU_LOG_RESET, "Triple fault\n"); @@ -93,10 +94,10 @@ static void QEMU_NORETURN raise_interrupt2(CPUX86State = *env, int intno, =20 if (!is_int) { cpu_svm_check_intercept_param(env, SVM_EXIT_EXCP_BASE + intno, - error_code); - intno =3D check_exception(env, intno, &error_code); + error_code, retaddr); + intno =3D check_exception(env, intno, &error_code, retaddr); } else { - cpu_svm_check_intercept_param(env, SVM_EXIT_SWINT, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_SWINT, 0, retaddr); } =20 cs->exception_index =3D intno; diff --git a/target/i386/helper.h b/target/i386/helper.h index 4c1aaff..6fb8fb9 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -99,7 +99,6 @@ DEF_HELPER_2(inl, tl, env, i32) DEF_HELPER_FLAGS_4(bpt_io, TCG_CALL_NO_WG, void, env, i32, i32, tl) =20 DEF_HELPER_3(svm_check_intercept_param, void, env, i32, i64) -DEF_HELPER_3(vmexit, void, env, i32, i64) DEF_HELPER_4(svm_check_io, void, env, i32, i32, i32) DEF_HELPER_3(vmrun, void, env, int, int) DEF_HELPER_1(vmmcall, void, env) diff --git a/target/i386/misc_helper.c b/target/i386/misc_helper.c index 5029efe..ca2ea09 100644 --- a/target/i386/misc_helper.c +++ b/target/i386/misc_helper.c @@ -101,7 +101,7 @@ void helper_cpuid(CPUX86State *env) { uint32_t eax, ebx, ecx, edx; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_CPUID, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_CPUID, 0, GETPC()); =20 cpu_x86_cpuid(env, (uint32_t)env->regs[R_EAX], (uint32_t)env->regs[R_E= CX], &eax, &ebx, &ecx, &edx); @@ -125,7 +125,7 @@ target_ulong helper_read_crN(CPUX86State *env, int reg) { target_ulong val; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_READ_CR0 + reg, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_READ_CR0 + reg, 0, GETPC()= ); switch (reg) { default: val =3D env->cr[reg]; @@ -143,7 +143,7 @@ target_ulong helper_read_crN(CPUX86State *env, int reg) =20 void helper_write_crN(CPUX86State *env, int reg, target_ulong t0) { - cpu_svm_check_intercept_param(env, SVM_EXIT_WRITE_CR0 + reg, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_WRITE_CR0 + reg, 0, GETPC(= )); switch (reg) { case 0: cpu_x86_update_cr0(env, t0); @@ -179,7 +179,7 @@ void helper_invlpg(CPUX86State *env, target_ulong addr) { X86CPU *cpu =3D x86_env_get_cpu(env); =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_INVLPG, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_INVLPG, 0, GETPC()); tlb_flush_page(CPU(cpu), addr); } =20 @@ -190,7 +190,7 @@ void helper_rdtsc(CPUX86State *env) if ((env->cr[4] & CR4_TSD_MASK) && ((env->hflags & HF_CPL_MASK) !=3D 0= )) { raise_exception_ra(env, EXCP0D_GPF, GETPC()); } - cpu_svm_check_intercept_param(env, SVM_EXIT_RDTSC, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_RDTSC, 0, GETPC()); =20 val =3D cpu_get_tsc(env) + env->tsc_offset; env->regs[R_EAX] =3D (uint32_t)(val); @@ -208,7 +208,7 @@ void helper_rdpmc(CPUX86State *env) if ((env->cr[4] & CR4_PCE_MASK) && ((env->hflags & HF_CPL_MASK) !=3D 0= )) { raise_exception_ra(env, EXCP0D_GPF, GETPC()); } - cpu_svm_check_intercept_param(env, SVM_EXIT_RDPMC, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_RDPMC, 0, GETPC()); =20 /* currently unimplemented */ qemu_log_mask(LOG_UNIMP, "x86: unimplemented rdpmc\n"); @@ -228,7 +228,7 @@ void helper_wrmsr(CPUX86State *env) { uint64_t val; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 1); + cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 1, GETPC()); =20 val =3D ((uint32_t)env->regs[R_EAX]) | ((uint64_t)((uint32_t)env->regs[R_EDX]) << 32); @@ -388,7 +388,7 @@ void helper_rdmsr(CPUX86State *env) { uint64_t val; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 0, GETPC()); =20 switch ((uint32_t)env->regs[R_ECX]) { case MSR_IA32_SYSENTER_CS: @@ -557,7 +557,7 @@ void helper_hlt(CPUX86State *env, int next_eip_addend) { X86CPU *cpu =3D x86_env_get_cpu(env); =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_HLT, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_HLT, 0, GETPC()); env->eip +=3D next_eip_addend; =20 do_hlt(cpu); @@ -569,7 +569,7 @@ void helper_monitor(CPUX86State *env, target_ulong ptr) raise_exception_ra(env, EXCP0D_GPF, GETPC()); } /* XXX: store address? */ - cpu_svm_check_intercept_param(env, SVM_EXIT_MONITOR, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_MONITOR, 0, GETPC()); } =20 void helper_mwait(CPUX86State *env, int next_eip_addend) @@ -580,7 +580,7 @@ void helper_mwait(CPUX86State *env, int next_eip_addend) if ((uint32_t)env->regs[R_ECX] !=3D 0) { raise_exception_ra(env, EXCP0D_GPF, GETPC()); } - cpu_svm_check_intercept_param(env, SVM_EXIT_MWAIT, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_MWAIT, 0, GETPC()); env->eip +=3D next_eip_addend; =20 cpu =3D x86_env_get_cpu(env); @@ -597,7 +597,7 @@ void helper_pause(CPUX86State *env, int next_eip_addend) { X86CPU *cpu =3D x86_env_get_cpu(env); =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_PAUSE, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_PAUSE, 0, GETPC()); env->eip +=3D next_eip_addend; =20 do_pause(cpu); diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c index d24574d..5c845dc 100644 --- a/target/i386/seg_helper.c +++ b/target/i386/seg_helper.c @@ -1335,7 +1335,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) } else if (env->hflags2 & HF2_GIF_MASK) { if ((interrupt_request & CPU_INTERRUPT_SMI) && !(env->hflags & HF_SMM_MASK)) { - cpu_svm_check_intercept_param(env, SVM_EXIT_SMI, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_SMI, 0, 0); cs->interrupt_request &=3D ~CPU_INTERRUPT_SMI; do_smm_enter(cpu); ret =3D true; @@ -1356,7 +1356,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) (env->eflags & IF_MASK && !(env->hflags & HF_INHIBIT_IRQ_MASK))))) { int intno; - cpu_svm_check_intercept_param(env, SVM_EXIT_INTR, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_INTR, 0, 0); cs->interrupt_request &=3D ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ); intno =3D cpu_get_pic_interrupt(env); @@ -1372,7 +1372,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) !(env->hflags & HF_INHIBIT_IRQ_MASK)) { int intno; /* FIXME: this should respect TPR */ - cpu_svm_check_intercept_param(env, SVM_EXIT_VINTR, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_VINTR, 0, 0); intno =3D x86_ldl_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.int_vector)); qemu_log_mask(CPU_LOG_TB_IN_ASM, diff --git a/target/i386/svm_helper.c b/target/i386/svm_helper.c index 210f6aa..5fecf77 100644 --- a/target/i386/svm_helper.c +++ b/target/i386/svm_helper.c @@ -60,11 +60,8 @@ void helper_invlpga(CPUX86State *env, int aflag) { } =20 -void helper_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_inf= o_1) -{ -} - -void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1) +void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1, + uint64_t retaddr) { } =20 @@ -74,7 +71,7 @@ void helper_svm_check_intercept_param(CPUX86State *env, u= int32_t type, } =20 void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type, - uint64_t param) + uint64_t param, uint64_t retaddr) { } =20 @@ -130,7 +127,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next= _eip_addend) uint32_t event_inj; uint32_t int_ctl; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_VMRUN, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_VMRUN, 0, GETPC()); =20 if (aflag =3D=3D 2) { addr =3D env->regs[R_EAX]; @@ -355,7 +352,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next= _eip_addend) =20 void helper_vmmcall(CPUX86State *env) { - cpu_svm_check_intercept_param(env, SVM_EXIT_VMMCALL, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_VMMCALL, 0, GETPC()); raise_exception(env, EXCP06_ILLOP); } =20 @@ -364,7 +361,7 @@ void helper_vmload(CPUX86State *env, int aflag) CPUState *cs =3D CPU(x86_env_get_cpu(env)); target_ulong addr; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_VMLOAD, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_VMLOAD, 0, GETPC()); =20 if (aflag =3D=3D 2) { addr =3D env->regs[R_EAX]; @@ -404,7 +401,7 @@ void helper_vmsave(CPUX86State *env, int aflag) CPUState *cs =3D CPU(x86_env_get_cpu(env)); target_ulong addr; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_VMSAVE, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_VMSAVE, 0, GETPC()); =20 if (aflag =3D=3D 2) { addr =3D env->regs[R_EAX]; @@ -445,19 +442,19 @@ void helper_vmsave(CPUX86State *env, int aflag) =20 void helper_stgi(CPUX86State *env) { - cpu_svm_check_intercept_param(env, SVM_EXIT_STGI, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_STGI, 0, GETPC()); env->hflags2 |=3D HF2_GIF_MASK; } =20 void helper_clgi(CPUX86State *env) { - cpu_svm_check_intercept_param(env, SVM_EXIT_CLGI, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_CLGI, 0, GETPC()); env->hflags2 &=3D ~HF2_GIF_MASK; } =20 void helper_skinit(CPUX86State *env) { - cpu_svm_check_intercept_param(env, SVM_EXIT_SKINIT, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_SKINIT, 0, GETPC()); /* XXX: not implemented */ raise_exception(env, EXCP06_ILLOP); } @@ -467,7 +464,7 @@ void helper_invlpga(CPUX86State *env, int aflag) X86CPU *cpu =3D x86_env_get_cpu(env); target_ulong addr; =20 - cpu_svm_check_intercept_param(env, SVM_EXIT_INVLPGA, 0); + cpu_svm_check_intercept_param(env, SVM_EXIT_INVLPGA, 0, GETPC()); =20 if (aflag =3D=3D 2) { addr =3D env->regs[R_EAX]; @@ -480,8 +477,8 @@ void helper_invlpga(CPUX86State *env, int aflag) tlb_flush_page(CPU(cpu), addr); } =20 -void helper_svm_check_intercept_param(CPUX86State *env, uint32_t type, - uint64_t param) +void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type, + uint64_t param, uint64_t retaddr) { CPUState *cs =3D CPU(x86_env_get_cpu(env)); =20 @@ -491,27 +488,27 @@ void helper_svm_check_intercept_param(CPUX86State *en= v, uint32_t type, switch (type) { case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR0 + 8: if (env->intercept_cr_read & (1 << (type - SVM_EXIT_READ_CR0))) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } break; case SVM_EXIT_WRITE_CR0 ... SVM_EXIT_WRITE_CR0 + 8: if (env->intercept_cr_write & (1 << (type - SVM_EXIT_WRITE_CR0))) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } break; case SVM_EXIT_READ_DR0 ... SVM_EXIT_READ_DR0 + 7: if (env->intercept_dr_read & (1 << (type - SVM_EXIT_READ_DR0))) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } break; case SVM_EXIT_WRITE_DR0 ... SVM_EXIT_WRITE_DR0 + 7: if (env->intercept_dr_write & (1 << (type - SVM_EXIT_WRITE_DR0))) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } break; case SVM_EXIT_EXCP_BASE ... SVM_EXIT_EXCP_BASE + 31: if (env->intercept_exceptions & (1 << (type - SVM_EXIT_EXCP_BASE))= ) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } break; case SVM_EXIT_MSR: @@ -538,28 +535,28 @@ void helper_svm_check_intercept_param(CPUX86State *en= v, uint32_t type, t0 %=3D 8; break; default: - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); t0 =3D 0; t1 =3D 0; break; } if (x86_ldub_phys(cs, addr + t1) & ((1 << param) << t0)) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } } break; default: if (env->intercept & (1ULL << (type - SVM_EXIT_INTR))) { - helper_vmexit(env, type, param); + cpu_vmexit(env, type, param, retaddr); } break; } } =20 -void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type, - uint64_t param) +void helper_svm_check_intercept_param(CPUX86State *env, uint32_t type, + uint64_t param) { - helper_svm_check_intercept_param(env, type, param); + cpu_svm_check_intercept_param(env, type, param, GETPC()); } =20 void helper_svm_check_io(CPUX86State *env, uint32_t port, uint32_t param, @@ -578,17 +575,22 @@ void helper_svm_check_io(CPUX86State *env, uint32_t p= ort, uint32_t param, x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_inf= o_2), env->eip + next_eip_addend); - helper_vmexit(env, SVM_EXIT_IOIO, param | (port << 16)); + cpu_vmexit(env, SVM_EXIT_IOIO, param | (port << 16), GETPC()); } } } =20 /* Note: currently only 32 bits of exit_code are used */ -void helper_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_inf= o_1) +void cpu_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1, + uintptr_t retaddr) { CPUState *cs =3D CPU(x86_env_get_cpu(env)); uint32_t int_ctl; =20 + if (retaddr) { + cpu_restore_state(cs, retaddr); + } + qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmexit(%08x, %016" PRIx64 ", %016" PRIx64 ", " TARGET_FMT_lx ")!\n", exit_code, exit_info_1, @@ -766,9 +768,4 @@ void helper_vmexit(CPUX86State *env, uint32_t exit_code= , uint64_t exit_info_1) cpu_loop_exit(cs); } =20 -void cpu_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1) -{ - helper_vmexit(env, exit_code, exit_info_1); -} - #endif --=20 1.8.3.1