From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664266950; cv=none; d=zohomail.com; s=zohoarc; b=cQZ1nS7z1C3U4r3/zug6hlLnHhk+3obrCxuhhVRDQyd2bLro6w5G4NE2ZLaK88O572rk5Eh8Ab+1skEN9+bB5a9pa4MSfsGNsJ6K0Zlt5NM1Qw+e8fCaqcnS+ExC02ofKz/p155dJfQXe7eBzZp3nD5o5NMOCZTmbLGfdQ8/kks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664266950; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t+8ci7yIxQ8T3QiJDY00xznjj3eoJ5YaGlNk+syamAw=; b=BD5piR0tejdCYWvR/cHBdfO7aW3JgO+QO5YWPjyz1H63QUBRD9S7JX0HDrqNWfflJHCtT3MfjPZKeijhoLYyahticDgKWPvQMVBLSBoKGqzVrOmHvn5GWz48ZxRpT4xdQKsiDpNDDhOp1nZcdF0cRPS7EUELKxpXkc4dDM4ETYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664266950307501.74230027965166; Tue, 27 Sep 2022 01:22:30 -0700 (PDT) Received: from localhost ([::1]:43058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5rJ-00084A-3G for importer@patchew.org; Tue, 27 Sep 2022 04:22:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oL-00056u-EH for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oI-0000Hg-IA for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-ez4EkGUNMIqzUNW0gtG0BA-1; Tue, 27 Sep 2022 04:19:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9CD71E6818C; Tue, 27 Sep 2022 08:19:17 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58C8840CF8E2; Tue, 27 Sep 2022 08:19:14 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DA21B1800629; Tue, 27 Sep 2022 10:19:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+8ci7yIxQ8T3QiJDY00xznjj3eoJ5YaGlNk+syamAw=; b=ZNczbt232I9LzmhIQVOt8w646Pwy5jW8XbC48msXZLDfHwwldq0uLKpSOZlu9/EdB2X7ya DBD/NnnwF4jCkJ/7MjEYC4OdvRZEQjKjaLcnUvDe7Ol+iGQyQ2MKT2M0i+mHUlN8O5Pv/T crwPwkcNOOh9jTpwrLopkYfbMiN+gMM= X-MC-Unique: ez4EkGUNMIqzUNW0gtG0BA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Cal Peake Subject: [PULL 01/24] ui/console: Get tab completion working again in the SDL monitor vc Date: Tue, 27 Sep 2022 10:18:49 +0200 Message-Id: <20220927081912.180983-2-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664266951597100001 Content-Type: text/plain; charset="utf-8" From: Cal Peake Define a QEMU special key constant for the tab key and add an entry for it in the qcode_to_keysym table. This allows tab completion to work again in the SDL monitor virtual console, which has been broken ever since the migration from SDL1 to SDL2. Signed-off-by: Cal Peake Message-Id: <7054816e-99c-7e2-6737-7cf98cc56e2@absolutedigital.net> Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 + ui/console.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index c0520c694c23..e400ee9fa74b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -70,6 +70,7 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ #define QEMU_KEY_ESC1(c) ((c) | 0xe100) +#define QEMU_KEY_TAB 0x0009 #define QEMU_KEY_BACKSPACE 0x007f #define QEMU_KEY_UP QEMU_KEY_ESC1('A') #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') diff --git a/ui/console.c b/ui/console.c index 765892f84f1c..243f2f6e64ae 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1368,6 +1368,7 @@ static const int qcode_to_keysym[Q_KEY_CODE__MAX] =3D= { [Q_KEY_CODE_PGUP] =3D QEMU_KEY_PAGEUP, [Q_KEY_CODE_PGDN] =3D QEMU_KEY_PAGEDOWN, [Q_KEY_CODE_DELETE] =3D QEMU_KEY_DELETE, + [Q_KEY_CODE_TAB] =3D QEMU_KEY_TAB, [Q_KEY_CODE_BACKSPACE] =3D QEMU_KEY_BACKSPACE, }; =20 --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664269867; cv=none; d=zohomail.com; s=zohoarc; b=K998kgy32RIGB22/vKlfduvc9D60w5C+gVlnpMEoUU54RkZrJSKNiWTm9V4M6mb1LrQyoZnYpPSsVS1W55UlKS8K00/2FsBaGKpxsqcY+jsXGrBK7UOvHk3bqKiKd4bvXhk4v+YyrPJnWTS43iIc5bIoPhwiEx6Uq6+d9dKvHZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664269867; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/zq3OWtNsr/F8P8xBpqtvQmjLKJC+788Jtr6JhyFLLk=; b=VFs2a9yfaocgIvdaomSA5uurxvGPn3BNCBL/+jfgvFEGOIMEXjgwZRpDpjPWs5Oy9x+SR2tHzNKgv1ieMmtLW78XRzCHwvc/SBbZwL+s2hnrPd0zyDtfjIt9fN2RE2F79xEy4dBU3Mb0k2AuGujJf9MUoSFcnSjHxXdAC5+Tdh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664269867408639.0169287430059; Tue, 27 Sep 2022 02:11:07 -0700 (PDT) Received: from localhost ([::1]:36876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6cL-0007HI-Mx for importer@patchew.org; Tue, 27 Sep 2022 05:11:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oQ-0005OV-0q for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oI-0000He-Ia for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-V-sPBArWOO-3mYNN4Tp2xw-1; Tue, 27 Sep 2022 04:19:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7776C86C043; Tue, 27 Sep 2022 08:19:16 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDF132166B26; Tue, 27 Sep 2022 08:19:15 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 018DA180062D; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zq3OWtNsr/F8P8xBpqtvQmjLKJC+788Jtr6JhyFLLk=; b=FnxM3uLjYwNpBV/JsPy1kM4ptdwjuMVjRwSHydhn0TTezi9APzlShytu8MYcY8NOVE1TDd VziWMHzWU0VBAUfG58nuLBYAwnH3vDUsfV8fff4qRKXZYrvhDHAtcfxblYmkPRhMlOJK4v cKeBIyk9N3q3dd8sV/ewydmIqFtg01E= X-MC-Unique: V-sPBArWOO-3mYNN4Tp2xw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell Subject: [PULL 02/24] ui/cocoa: Run qemu_init in the main thread Date: Tue, 27 Sep 2022 10:18:50 +0200 Message-Id: <20220927081912.180983-3-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664269868220100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki This work is based on: https://patchew.org/QEMU/20220317125534.38706-1-philippe.mathieu.daude@gmai= l.com/ Simplify the initialization dance by running qemu_init() in the main thread before the Cocoa event loop starts. The secondary thread only runs only qemu_main_loop() and qemu_cleanup(). This fixes a case where addRemovableDevicesMenuItems() calls qmp_query_block() while expecting the main thread to still hold the BQL. Overriding the code after calling qemu_init() is done by dynamically replacing a function pointer variable, qemu_main when initializing ui/cocoa, which unifies the static implementation of main() for builds with ui/cocoa and ones without ui/cocoa. Signed-off-by: Akihiko Odaki Message-Id: <20220819132756.74641-2-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- include/qemu-main.h | 3 +- include/sysemu/sysemu.h | 2 +- softmmu/main.c | 10 +-- softmmu/vl.c | 2 +- tests/qtest/fuzz/fuzz.c | 2 +- docs/devel/fuzzing.rst | 4 +- ui/cocoa.m | 144 ++++++++++++++-------------------------- 7 files changed, 62 insertions(+), 105 deletions(-) diff --git a/include/qemu-main.h b/include/qemu-main.h index 6a3e90d0ad59..940960a7dbcb 100644 --- a/include/qemu-main.h +++ b/include/qemu-main.h @@ -5,6 +5,7 @@ #ifndef QEMU_MAIN_H #define QEMU_MAIN_H =20 -int qemu_main(int argc, char **argv, char **envp); +int qemu_default_main(void); +extern int (*qemu_main)(void); =20 #endif /* QEMU_MAIN_H */ diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 31aa45160be8..6a7a31e64dea 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -102,7 +102,7 @@ void qemu_boot_set(const char *boot_order, Error **errp= ); =20 bool defaults_enabled(void); =20 -void qemu_init(int argc, char **argv, char **envp); +void qemu_init(int argc, char **argv); int qemu_main_loop(void); void qemu_cleanup(void); =20 diff --git a/softmmu/main.c b/softmmu/main.c index 1b675a8c036f..694388bd7f7f 100644 --- a/softmmu/main.c +++ b/softmmu/main.c @@ -30,20 +30,20 @@ #include #endif =20 -int qemu_main(int argc, char **argv, char **envp) +int qemu_default_main(void) { int status; =20 - qemu_init(argc, argv, envp); status =3D qemu_main_loop(); qemu_cleanup(); =20 return status; } =20 -#ifndef CONFIG_COCOA +int (*qemu_main)(void) =3D qemu_default_main; + int main(int argc, char **argv) { - return qemu_main(argc, argv, NULL); + qemu_init(argc, argv); + return qemu_main(); } -#endif diff --git a/softmmu/vl.c b/softmmu/vl.c index e62b9cc35d75..9abadcc15051 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2605,7 +2605,7 @@ void qmp_x_exit_preconfig(Error **errp) } } =20 -void qemu_init(int argc, char **argv, char **envp) +void qemu_init(int argc, char **argv) { QemuOpts *opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 2b3bc1fb9df5..eb7520544b80 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -218,7 +218,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) g_free(pretty_cmd_line); } =20 - qemu_init(result.we_wordc, result.we_wordv, NULL); + qemu_init(result.we_wordc, result.we_wordv); =20 /* re-enable the rcu atfork, which was previously disabled in qemu_ini= t */ rcu_enable_atfork(); diff --git a/docs/devel/fuzzing.rst b/docs/devel/fuzzing.rst index 784ecb99e667..715330c85613 100644 --- a/docs/devel/fuzzing.rst +++ b/docs/devel/fuzzing.rst @@ -287,8 +287,8 @@ select the fuzz target. Then, the qtest client is initi= alized. If the target requires qos, qgraph is set up and the QOM/LIBQOS modules are initialized. Then the QGraph is walked and the QEMU cmd_line is determined and saved. =20 -After this, the ``vl.c:qemu_main`` is called to set up the guest. There are -target-specific hooks that can be called before and after qemu_main, for +After this, the ``vl.c:main`` is called to set up the guest. There are +target-specific hooks that can be called before and after main, for additional setup(e.g. PCI setup, or VM snapshotting). =20 ``LLVMFuzzerTestOneInput``: Uses qtest/qos functions to act based on the f= uzz diff --git a/ui/cocoa.m b/ui/cocoa.m index 5a8bd5dd84e0..660d3e093569 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -100,13 +100,9 @@ static void cocoa_switch(DisplayChangeListener *dcl, static int left_command_key_enabled =3D 1; static bool swap_opt_cmd; =20 -static int gArgc; -static char **gArgv; static bool stretch_video; static NSTextField *pauseLabel; =20 -static QemuSemaphore display_init_sem; -static QemuSemaphore app_started_sem; static bool allow_events; =20 static NSInteger cbchangecount =3D -1; @@ -597,7 +593,7 @@ - (void) updateUIInfo /* * Don't try to tell QEMU about UI information in the application * startup phase -- we haven't yet registered dcl with the QEMU UI - * layer, and also trying to take the iothread lock would deadlock. + * layer. * When cocoa_display_init() does register the dcl, the UI layer * will call cocoa_switch(), which will call updateUIInfo, so * we don't lose any information here. @@ -790,16 +786,6 @@ - (void) handleMonitorInput:(NSEvent *)event =20 - (bool) handleEvent:(NSEvent *)event { - if(!allow_events) { - /* - * Just let OSX have all events that arrive before - * applicationDidFinishLaunching. - * This avoids a deadlock on the iothread lock, which cocoa_displa= y_init() - * will not drop until after the app_started_sem is posted. (In th= eory - * there should not be any such events, but OSX Catalina now emits= some.) - */ - return false; - } return bool_with_iothread_lock(^{ return [self handleEventLocked:event]; }); @@ -1287,8 +1273,6 @@ - (void)applicationDidFinishLaunching: (NSNotificatio= n *) note { COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n"); allow_events =3D true; - /* Tell cocoa_display_init to proceed */ - qemu_sem_post(&app_started_sem); } =20 - (void)applicationWillTerminate:(NSNotification *)aNotification @@ -1919,92 +1903,45 @@ static void cocoa_clipboard_request(QemuClipboardIn= fo *info, /* * The startup process for the OSX/Cocoa UI is complicated, because * OSX insists that the UI runs on the initial main thread, and so we - * need to start a second thread which runs the vl.c qemu_main(): - * - * Initial thread: 2nd thread: + * need to start a second thread which runs the qemu_default_main(): * in main(): - * create qemu-main thread - * wait on display_init semaphore - * call qemu_main() - * ... - * in cocoa_display_init(): - * post the display_init semaphore - * wait on app_started semaphore - * create application, menus, etc - * enter OSX run loop - * in applicationDidFinishLaunching: - * post app_started semaphore - * tell main thread to fullscreen if n= eeded - * [...] - * run qemu main-loop - * - * We do this in two stages so that we don't do the creation of the - * GUI application menus and so on for command line options like --help - * where we want to just print text to stdout and exit immediately. + * in cocoa_display_init(): + * assign cocoa_main to qemu_main + * create application, menus, etc + * in cocoa_main(): + * create qemu-main thread + * enter OSX run loop */ =20 static void *call_qemu_main(void *opaque) { int status; =20 - COCOA_DEBUG("Second thread: calling qemu_main()\n"); - status =3D qemu_main(gArgc, gArgv, *_NSGetEnviron()); - COCOA_DEBUG("Second thread: qemu_main() returned, exiting\n"); + COCOA_DEBUG("Second thread: calling qemu_default_main()\n"); + qemu_mutex_lock_iothread(); + status =3D qemu_default_main(); + qemu_mutex_unlock_iothread(); + COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n"); [cbowner release]; exit(status); } =20 -int main (int argc, char **argv) { +static int cocoa_main() +{ QemuThread thread; =20 - COCOA_DEBUG("Entered main()\n"); - gArgc =3D argc; - gArgv =3D argv; - - qemu_sem_init(&display_init_sem, 0); - qemu_sem_init(&app_started_sem, 0); + COCOA_DEBUG("Entered %s()\n", __func__); =20 + qemu_mutex_unlock_iothread(); qemu_thread_create(&thread, "qemu_main", call_qemu_main, NULL, QEMU_THREAD_DETACHED); =20 - COCOA_DEBUG("Main thread: waiting for display_init_sem\n"); - qemu_sem_wait(&display_init_sem); - COCOA_DEBUG("Main thread: initializing app\n"); - - NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; - - // Pull this console process up to being a fully-fledged graphical - // app with a menubar and Dock icon - ProcessSerialNumber psn =3D { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - - [QemuApplication sharedApplication]; - - create_initial_menus(); - - /* - * Create the menu entries which depend on QEMU state (for consoles - * and removeable devices). These make calls back into QEMU functions, - * which is OK because at this point we know that the second thread - * holds the iothread lock and is synchronously waiting for us to - * finish. - */ - add_console_menu_entries(); - addRemovableDevicesMenuItems(); - - // Create an Application controller - QemuCocoaAppController *appController =3D [[QemuCocoaAppController all= oc] init]; - [NSApp setDelegate:appController]; - // Start the main event loop COCOA_DEBUG("Main thread: entering OSX run loop\n"); [NSApp run]; - COCOA_DEBUG("Main thread: left OSX run loop, exiting\n"); + COCOA_DEBUG("Main thread: left OSX run loop, which should never happen= \n"); =20 - [appController release]; - [pool release]; - - return 0; + abort(); } =20 =20 @@ -2083,25 +2020,42 @@ static void cocoa_refresh(DisplayChangeListener *dc= l) =20 static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) { + NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); =20 - /* Tell main thread to go ahead and create the app and enter the run l= oop */ - qemu_sem_post(&display_init_sem); - qemu_sem_wait(&app_started_sem); - COCOA_DEBUG("cocoa_display_init: app start completed\n"); + qemu_main =3D cocoa_main; + + // Pull this console process up to being a fully-fledged graphical + // app with a menubar and Dock icon + ProcessSerialNumber psn =3D { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + + [QemuApplication sharedApplication]; + + create_initial_menus(); + + /* + * Create the menu entries which depend on QEMU state (for consoles + * and removeable devices). These make calls back into QEMU functions, + * which is OK because at this point we know that the second thread + * holds the iothread lock and is synchronously waiting for us to + * finish. + */ + add_console_menu_entries(); + addRemovableDevicesMenuItems(); + + // Create an Application controller + QemuCocoaAppController *controller =3D [[QemuCocoaAppController alloc]= init]; + [NSApp setDelegate:controller]; =20 - QemuCocoaAppController *controller =3D (QemuCocoaAppController *)[[NSA= pplication sharedApplication] delegate]; /* if fullscreen mode is to be used */ if (opts->has_full_screen && opts->full_screen) { - dispatch_async(dispatch_get_main_queue(), ^{ - [NSApp activateIgnoringOtherApps: YES]; - [controller toggleFullScreen: nil]; - }); + [NSApp activateIgnoringOtherApps: YES]; + [controller toggleFullScreen: nil]; } if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) { - dispatch_async(dispatch_get_main_queue(), ^{ - [controller setFullGrab: nil]; - }); + [controller setFullGrab: nil]; } =20 if (opts->has_show_cursor && opts->show_cursor) { @@ -2121,6 +2075,8 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) qemu_event_init(&cbevent, false); cbowner =3D [[QemuCocoaPasteboardTypeOwner alloc] init]; qemu_clipboard_peer_register(&cbpeer); + + [pool release]; } =20 static QemuDisplay qemu_display_cocoa =3D { --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268541; cv=none; d=zohomail.com; s=zohoarc; b=QXu6ifI3Z/gpZc0ClC0fXXMkfL4d1hsfYF9tiiCTdZWjtZInDk1cJ69f8IxwPUcAqJAhEDKDkeHfFR06cJYaSNMiRUB3AnRp8b94K+W/qauTeMBPdRtBXTwizVfo2ro3rXVvW0AfzkyUluFQ3gbjTMjk7crTt9535ATytXLKV2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268541; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FTKq25OCJ8Ex90En1AKkU4cElLVlu/nURiwsIyiJ+es=; b=jmVA4HQ9wkeRNEYDpa3JjG2elhBNsPK9Mq2meHJZm2qsdN6HFUBe1ZuNg9l6H/IAJtQNzNKUyJU1H2E4fzHwiIMMoJ+0TqAAGm7BQITkMPQ0r5KRvP6vIV53ZSPI1p32VnRCuCAyuySECR3t0CJkCu4Bh1DVh0d86mxUkhZXmAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268541669421.43887340693175; Tue, 27 Sep 2022 01:49:01 -0700 (PDT) Received: from localhost ([::1]:49086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6Gy-0008L3-KG for importer@patchew.org; Tue, 27 Sep 2022 04:49:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oL-0005Ak-Or for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oI-0000Hh-Io for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:25 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-3sUqPSBAMkmIFLWw0Q3HJg-1; Tue, 27 Sep 2022 04:19:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E23053C10224; Tue, 27 Sep 2022 08:19:17 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99D8840C6EC2; Tue, 27 Sep 2022 08:19:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0ECF118007A4; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FTKq25OCJ8Ex90En1AKkU4cElLVlu/nURiwsIyiJ+es=; b=GVKdjVFlLthpk0hWWop1ZOnRLKGrqCv9m/g7/kGAsaNCEDtvlXBuILnSegK6YGbw+U/f4b I1FlRw68Ahb4cEeQWQJuV6sM+4gD3aylW9032D++qJ+HBIYLqIrvko+oXaykj7lTC3Rr/w aS43p/dwCy/bSLAfDEFVvjnPWTcbt08= X-MC-Unique: 3sUqPSBAMkmIFLWw0Q3HJg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Emanuele Giuseppe Esposito Subject: [PULL 03/24] Revert "main-loop: Disable block backend global state assertion on Cocoa" Date: Tue, 27 Sep 2022 10:18:51 +0200 Message-Id: <20220927081912.180983-4-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268543365100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki This reverts commit 47281859f66bdab1974fb122cab2cbb4a1c9af7f. Signed-off-by: Akihiko Odaki Reviewed-by: Emanuele Giuseppe Esposito Reviewed-by: Peter Maydell Reviewed-by: Paolo Bonzini Message-Id: <20220819132756.74641-3-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- include/qemu/main-loop.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index c50d1b7e3ab6..aac707d073a1 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -284,23 +284,10 @@ bool qemu_in_main_thread(void); * Please refer to include/block/block-global-state.h for more * information about GS API. */ -#ifdef CONFIG_COCOA -/* - * When using the Cocoa UI, addRemovableDevicesMenuItems() is called from - * a thread different from the QEMU main thread and can not take the BQL, - * triggering this assertions in the block layer (commit 0439c5a462). - * As the Cocoa fix is not trivial, disable this assertion for the v7.0.0 - * release (when using Cocoa); we will restore it immediately after the - * release. - * This issue is tracked as https://gitlab.com/qemu-project/qemu/-/issues/= 926 - */ -#define GLOBAL_STATE_CODE() -#else #define GLOBAL_STATE_CODE() \ do { \ assert(qemu_in_main_thread()); \ } while (0) -#endif /* CONFIG_COCOA */ =20 /* * Mark and check that the function is part of the I/O API. --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268005; cv=none; d=zohomail.com; s=zohoarc; b=n9s9QWFe1VGa9KfZq+ghJH41aUeTvYZy3RkzuVB0LhVgVTVcMI4zBDalCZgs9aU60O6u9+KjB2ygC/gqMNKDUD3SukqVRIVlglxt1aIyRKciA0qeUN6o473qj1uBbEU0v3uTB6ReSDt2O0yzDH7QIYm28t4Cx8P8uxs2z7ApZJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268005; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qz6m5wNnMR4b4k9F7KgrsOGoMcMDGwawdO4N7dnhA6U=; b=KeQ4G8E1cSovr+wAvDuyWGKrQxPnt/JgDabZ9QKQ+tlogltnYK/ULgGHCRxxOI65On1ZC++iQQqqwF/KiFWfX/GLJiIxpl46IEx3Y/XfJHNzV4kpfbbpsXFix0b5OzL3nMsmF6D1oizh+UnAOz9Si7LaEpl6Mrudlzs7dvm3KwY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268005599119.52974034114527; Tue, 27 Sep 2022 01:40:05 -0700 (PDT) Received: from localhost ([::1]:38526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od68K-0005t2-Ic for importer@patchew.org; Tue, 27 Sep 2022 04:40:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oU-0005RD-AL for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oJ-0000I6-PG for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-yZPhxNhgO3i6jADW-GYwXg-1; Tue, 27 Sep 2022 04:19:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69A4D803D4A; Tue, 27 Sep 2022 08:19:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26E5C2166B26; Tue, 27 Sep 2022 08:19:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1B999180091C; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qz6m5wNnMR4b4k9F7KgrsOGoMcMDGwawdO4N7dnhA6U=; b=bfEiFLTDPJ5/o7bqh0Zc7FNnmUty1X8S6Gar3qtcKb0Zy5R7xwI2LY8A7M4wtd5MrBke9o rCRZaEOWEtV1+Rc31s7L2PM5tLr2KellnixsZsK1f2sni4EMFSyx3OLGbWDfFjJgx6GnJ5 QqSl5X0bDX5uJmAeNbuTlNQVWAurkvE= X-MC-Unique: yZPhxNhgO3i6jADW-GYwXg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell Subject: [PULL 04/24] meson: Allow to enable gtk and sdl while cocoa is enabled Date: Tue, 27 Sep 2022 10:18:52 +0200 Message-Id: <20220927081912.180983-5-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268007752100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki As ui/cocoa does no longer override main(), ui/gtk and ui/sdl can be enabled even ui/cocoa is enabled. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Reviewed-by: Paolo Bonzini Message-Id: <20220819132756.74641-4-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- meson.build | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 3885fc107633..d9ac91ff3659 100644 --- a/meson.build +++ b/meson.build @@ -589,12 +589,6 @@ endif =20 cocoa =3D dependency('appleframeworks', modules: ['Cocoa', 'CoreVideo'], required: get_option('cocoa')) -if cocoa.found() and get_option('sdl').enabled() - error('Cocoa and SDL cannot be enabled at the same time') -endif -if cocoa.found() and get_option('gtk').enabled() - error('Cocoa and GTK+ cannot be enabled at the same time') -endif =20 vmnet =3D dependency('appleframeworks', modules: 'vmnet', required: get_op= tion('vmnet')) if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', @@ -921,7 +915,7 @@ if not get_option('brlapi').auto() or have_system endif =20 sdl =3D not_found -if not get_option('sdl').auto() or (have_system and not cocoa.found()) +if not get_option('sdl').auto() or have_system sdl =3D dependency('sdl2', required: get_option('sdl'), kwargs: static_k= wargs) sdl_image =3D not_found endif @@ -1187,7 +1181,7 @@ endif gtk =3D not_found gtkx11 =3D not_found vte =3D not_found -if not get_option('gtk').auto() or (have_system and not cocoa.found()) +if not get_option('gtk').auto() or have_system gtk =3D dependency('gtk+-3.0', version: '>=3D3.22.0', method: 'pkg-config', required: get_option('gtk'), --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267508; cv=none; d=zohomail.com; s=zohoarc; b=NfKAXcVi6fqci/vxtn99WVrYZYa9qJenMeWwLKREDxCKTmeBjm0Ai5xaixmkGreo+eBD2na8dNw5uRoI62vDqqPryIMwyniR7cpepj/y+sq/1a+2YR9Lj5C1Nyz73y2Lpds8MVYdbdM3+1ULtDa/4vXVPWKqKp/oBAeCYxb26YQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1lkEzdjW1YeSTjXm2o8kRYkVOAn224fd2T365fiA4EU=; b=eX5VM/eHYKFwxgeEyYJZFkfQSbbIOIuH2eZbmtcPRb4gDGZZ7+74nCeBn8/2g8mQ4MW4Ek9vDf3sBgEwvSiwUNcSqtEQ6pMJ2kCdv2l6eVPOGTjYGHrET9pML84lMxfXHViMdUN/PiXine2j1bQ+7pP+M9q1uwBetGE8Pt/94N8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267508519340.45058834597216; Tue, 27 Sep 2022 01:31:48 -0700 (PDT) Received: from localhost ([::1]:57576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od60J-0004DN-3X for importer@patchew.org; Tue, 27 Sep 2022 04:31:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oN-0005Ek-7x for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oK-0000IF-Ja for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:26 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-323-41Pe0pNuORq8sC8Xjmcisw-1; Tue, 27 Sep 2022 04:19:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88F75101E14E; Tue, 27 Sep 2022 08:19:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24D782087440; Tue, 27 Sep 2022 08:19:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2CE261800929; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1lkEzdjW1YeSTjXm2o8kRYkVOAn224fd2T365fiA4EU=; b=ELajVITjVnGvb3l8uwGBUtdKbCy2mt0IZV3lV7xG5geCDHinO6rpUdGXdFagTOUd6rKSdN wiKFes677hy9BAwUghty47KcmtHTmM2rJrGvj65tHqO+gozYjHOReB1jaCOB99GDpyh6+P 3qfC8z27COeDMSWgcIV9LVOboNCGGUk= X-MC-Unique: 41Pe0pNuORq8sC8Xjmcisw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 05/24] ui: add some vdagent related traces Date: Tue, 27 Sep 2022 10:18:53 +0200 Message-Id: <20220927081912.180983-6-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267509591100001 From: Marc-Andr=C3=A9 Lureau This helps debugging clipboard serial sync issues. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-2-marcandre.lureau@redhat.com> [ kraxel: code style fix ] Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 11 +++++++++-- ui/vdagent.c | 4 ++++ ui/trace-events | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index 9079ef829b51..cd5382fcb0c1 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "ui/clipboard.h" +#include "trace.h" =20 static NotifierList clipboard_notifiers =3D NOTIFIER_LIST_INITIALIZER(clipboard_notifiers); @@ -43,17 +44,23 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *pee= r, =20 bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client) { + bool ok; + if (!info->has_serial || !cbinfo[info->selection] || !cbinfo[info->selection]->has_serial) { + trace_clipboard_check_serial(-1, -1, true); return true; } =20 if (client) { - return cbinfo[info->selection]->serial >=3D info->serial; + ok =3D cbinfo[info->selection]->serial >=3D info->serial; } else { - return cbinfo[info->selection]->serial > info->serial; + ok =3D cbinfo[info->selection]->serial > info->serial; } + + trace_clipboard_check_serial(cbinfo[info->selection]->serial, info->se= rial, ok); + return ok; } =20 void qemu_clipboard_update(QemuClipboardInfo *info) diff --git a/ui/vdagent.c b/ui/vdagent.c index a899eed195d3..58ce7507fddc 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -533,6 +533,8 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev = *vd, uint8_t s, uint32_t info->has_serial =3D true; info->serial =3D *(uint32_t *)data; if (info->serial < vd->last_serial[s]) { + trace_vdagent_cb_grab_discard(GET_NAME(sel_name, s), + vd->last_serial[s], info->serial= ); /* discard lower-ordering guest grab */ return; } @@ -853,6 +855,8 @@ static void vdagent_chr_accept_input(Chardev *chr) =20 static void vdagent_disconnect(VDAgentChardev *vd) { + trace_vdagent_disconnect(); + buffer_reset(&vd->outbuf); vdagent_reset_bufs(vd); vd->caps =3D 0; diff --git a/ui/trace-events b/ui/trace-events index a922f00e10b4..977577fbba58 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -127,15 +127,20 @@ xkeymap_vendor(const char *name) "vendor '%s'" xkeymap_keycodes(const char *name) "keycodes '%s'" xkeymap_keymap(const char *name) "keymap '%s'" =20 +# clipboard.c +clipboard_check_serial(int cur, int recv, bool ok) "cur:%d recv:%d %d" + # vdagent.c vdagent_open(void) "" vdagent_close(void) "" +vdagent_disconnect(void) "" vdagent_send(const char *name) "msg %s" vdagent_send_empty_clipboard(void) "" vdagent_recv_chunk(uint32_t size) "size %d" vdagent_recv_msg(const char *name, uint32_t size) "msg %s, size %d" vdagent_peer_cap(const char *name) "cap %s" vdagent_cb_grab_selection(const char *name) "selection %s" +vdagent_cb_grab_discard(const char *name, int cur, int recv) "selection %s= , cur:%d recv:%d" vdagent_cb_grab_type(const char *name) "type %s" vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=3D= %u, received=3D%u" =20 --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664269563; cv=none; d=zohomail.com; s=zohoarc; b=b/LCjFmS824l+11FVjuH67SkjxIozoW3VD+WPx1a3X5vXTYBFGWJEDrrR5bCMn4Xe/iGi+mqaRcUAbrK/O/fAUrHC65NodGWDgwXrP7EGuvexUNWYA16RVM4XtBmgm7oKlxEJIFyrw65wDkhfNUsb0K3x4Z6Z6gIO2DLwrfXCVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664269563; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X8MB6qewQt3dNDFWmIT6gK9a8vJJkApS1O6Zso0beBQ=; b=iQjMOA15QLB5SWWZXlu/P1EJ4YUnpD2ypDqbXhJ4RCvjlVw3alCl04CD5Km5ubFFOZbvRD7loMI2/XM+YL6C33iZqSyBnCDyjI9//cckOluUNxp12Lu2foWWOirZcvXRRNQwv2k/aNwzWq7cb9nxcgYJ8FYX036OlU1ZjtlzXuE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664269563301594.6493134343064; Tue, 27 Sep 2022 02:06:03 -0700 (PDT) Received: from localhost ([::1]:45550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6XQ-0002Y8-AV for importer@patchew.org; Tue, 27 Sep 2022 05:06:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oO-0005KV-Qj for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oJ-0000Hz-EG for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-164-Kks5Mo1UPEmvWbMj-CTwRA-1; Tue, 27 Sep 2022 04:19:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED4E8185A78F; Tue, 27 Sep 2022 08:19:20 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 87A8017582; Tue, 27 Sep 2022 08:19:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 39E67180092D; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X8MB6qewQt3dNDFWmIT6gK9a8vJJkApS1O6Zso0beBQ=; b=F5fReayrsWRncLyQlLqC4uzzjlzMezU2o6W0Qykjm5hjDvY7zk+b+5K+Yp2y8dgQ1CXISz JqkMAYvnNE1Jtg02HrxOT4PU5T5ExXQ+HeXw6oBYUs9BthwraTHgW+1Cv+WIruPPNGOLh3 Al55Tj1NhEI6CPyY5tUOE4G/fl13lKI= X-MC-Unique: Kks5Mo1UPEmvWbMj-CTwRA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 06/24] ui/clipboard: fix serial priority Date: Tue, 27 Sep 2022 10:18:54 +0200 Message-Id: <20220927081912.180983-7-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664269563785100001 From: Marc-Andr=C3=A9 Lureau The incoming grab event should have a higher serial. See also "vdagent: introduce VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL": https://gitlab.freedesktop.org/spice/spice-protocol/-/commit/045a6978d6dbbf= 7046affc5c321fa8177c8cce56 This is only a relevant fix for the -display dbus, only user of that function. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-3-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index cd5382fcb0c1..3e2d02d5490c 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -54,9 +54,9 @@ bool qemu_clipboard_check_serial(QemuClipboardInfo *info,= bool client) } =20 if (client) { - ok =3D cbinfo[info->selection]->serial >=3D info->serial; + ok =3D info->serial >=3D cbinfo[info->selection]->serial; } else { - ok =3D cbinfo[info->selection]->serial > info->serial; + ok =3D info->serial > cbinfo[info->selection]->serial; } =20 trace_clipboard_check_serial(cbinfo[info->selection]->serial, info->se= rial, ok); --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267113; cv=none; d=zohomail.com; s=zohoarc; b=HOMQ4tTcGaqWCML7rOqCejzfvlw+glDy+7asWJ4ayhOx7DoQb0E9cZoBD2M0w99OL1lWTd3jvtJe5VKUNXs/KA3iup3KANWgTgF/ffvVYgDROaYGh5X82FT/AarFpGL18R2LTCD2Aj8GrLgEtWtwhpBUCKHCgGsUPEzjaqWKujw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267113; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y0j2Aqtnv13FSXqrmRMEFPQ/3l4+enM7Zc2eriMcTAk=; b=eWHbDjRMsD4geFQst2LuSA58sVI4z393mf0nLHD4cqci8wCTQOllnVJvIl17PsEvx1u8c8OYTDnw3D5U5FGiyC0SwYqlQBSdDimhv+Dj68SwbogM3ysloaSiB+G19JyQLCeA1QkE2JnPKiM5UygsI8R0TnfXQ6QNPuKLxvqju6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267113789154.12772041946243; Tue, 27 Sep 2022 01:25:13 -0700 (PDT) Received: from localhost ([::1]:52508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5tv-0005Fz-JH for importer@patchew.org; Tue, 27 Sep 2022 04:25:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oN-0005BE-4z for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oJ-0000Hw-58 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:25 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-aP_39PgwMAOjr_8adY7xwQ-1; Tue, 27 Sep 2022 04:19:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2DFE38173C0; Tue, 27 Sep 2022 08:19:20 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7DA12087440; Tue, 27 Sep 2022 08:19:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 46DEB1800937; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y0j2Aqtnv13FSXqrmRMEFPQ/3l4+enM7Zc2eriMcTAk=; b=C+Fs1K+Q7TYofp+6RdOUOvumabOg/XMPgED50mlDi8ALZH3ZagdSJMBaK3DNPdCCqI/x4q 3/wbamfBJupSz4cc3P1as7zUb736VUB8JCOovXsD5Kq0f6vGgSTvzj3vkzshMNqZxOUBgh Emr29dC3/kNcZ1zlIimV+exMo2whJCk= X-MC-Unique: aP_39PgwMAOjr_8adY7xwQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 07/24] ui/vdagent: always reset the clipboard serial on caps Date: Tue, 27 Sep 2022 10:18:55 +0200 Message-Id: <20220927081912.180983-8-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267114125100001 From: Marc-Andr=C3=A9 Lureau The guest agent doesn't know what is the current serial state. Reset the serial value whenever a new agent connection is established. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2124446 Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-4-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/vdagent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 58ce7507fddc..819e0dc1435b 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -719,8 +719,10 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, = VDAgentMessage *msg) if (have_mouse(vd) && vd->mouse_hs) { qemu_input_handler_activate(vd->mouse_hs); } + + memset(vd->last_serial, 0, sizeof(vd->last_serial)); + if (have_clipboard(vd) && vd->cbpeer.notifier.notify =3D=3D NULL) { - memset(vd->last_serial, 0, sizeof(vd->last_serial)); vd->cbpeer.name =3D "vdagent"; vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify; vd->cbpeer.request =3D vdagent_clipboard_request; --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664269239; cv=none; d=zohomail.com; s=zohoarc; b=gsXyXN8qHHAo3NO9IpHfjlCQPR/GN68QQDvL0zMKcacyRuupLidzHRTSb1AAjzhut3twSNTQYYOyoHoDYC7Xm2qbs80G2Zbri6lcVNElwOaIt0yzeM06+kiCNt9IGvY86+Jc3Kv7/TUc5bgOK9CtEFCGSELfGn8gX89mkCjCc1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664269239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8FOzTXJOVlAuEoG61vZulT59fd8k9A6AOrx8I9fMOQc=; b=OHvy3eHCfbsVTxUvJwlgdbZRxpdtj83FZOc1SW3imxjlTykDPrXVCacfeFtVvxfXq0LLmN+i047Fg8w7caKhY0CrnKGpM78YqhLZJ+e42jkeYwg0Trmw6ibsv72jcW1J1Wfer0WKR0eOLXt9oJlESlVWPdG6VXTs/TxxvTd65t8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664269239873832.8861197358482; Tue, 27 Sep 2022 02:00:39 -0700 (PDT) Received: from localhost ([::1]:40870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6SE-0005JI-MQ for importer@patchew.org; Tue, 27 Sep 2022 05:00:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oN-0005HU-Vo for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oM-0000Io-GX for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:27 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-108-n-oG2E5-OLq2tlHAdZ2H3A-1; Tue, 27 Sep 2022 04:19:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C370299E75B; Tue, 27 Sep 2022 08:19:22 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23C6617582; Tue, 27 Sep 2022 08:19:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 53B5D1800939; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8FOzTXJOVlAuEoG61vZulT59fd8k9A6AOrx8I9fMOQc=; b=KCMlktidZhtC4MCpga2+Eg3JrsX9r9Zrq9WSdcuAp9x3M6sZroqDVSjg49gmYi/kXSbD1N 8CmhGwGeGDIbz+OWlKWdc405Uydz5kwHjoZ5DqhWqupTYsddnSoK24BcBga4n7xizCP+DD THKBqqm4ODmKyRKsoI53hnAEKowvyT4= X-MC-Unique: n-oG2E5-OLq2tlHAdZ2H3A-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 08/24] ui/clipboard: reset the serial state on reset Date: Tue, 27 Sep 2022 10:18:56 +0200 Message-Id: <20220927081912.180983-9-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664269241793100001 From: Marc-Andr=C3=A9 Lureau Not only we have to reset the vdagent clipboards serial state, but also the current QEMU clipboards info serial (the value is currently used by qemu_clipboard_check_serial, only used by -display dbus). Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-5-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/clipboard.c b/ui/clipboard.c index 3e2d02d5490c..3d14bffaf80f 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -139,7 +139,14 @@ void qemu_clipboard_request(QemuClipboardInfo *info, void qemu_clipboard_reset_serial(void) { QemuClipboardNotify notify =3D { .type =3D QEMU_CLIPBOARD_RESET_SERIAL= }; + int i; =20 + for (i =3D 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { + QemuClipboardInfo *info =3D qemu_clipboard_info(i); + if (info) { + info->serial =3D 0; + } + } notifier_list_notify(&clipboard_notifiers, ¬ify); } =20 --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267876; cv=none; d=zohomail.com; s=zohoarc; b=SYWl98OE0Kj6BaBbMSQIYg0o2vBifpYsGvora/VBj6Y5LcTRGBFG7ov2XVD+SdmNZgTOUDSAejk5fGGUOzA8L2aopYtHmxiwBN59xXl+50tTZhFMCM8RFjU1CgreQLAv9SSqANa4dqIRBgmkK+fZGX0Zs4A+23T2DssIsVDNZH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267876; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L5PZAgDZ0Zk8jlRJBwRHM6yfmEwxC0P3PBdvK/bzC34=; b=S+jz7zI1TdAxXR62vZCh7nzOvG3m9cHDpabBOnjjRwuYc7Hr9eXJ2EjzmiRve49uE7fsoAFSWGq7bLUaBflA6c6jwpAoB9QNT2aRr1714hEcvkpokI888gqQhCyDkk5iGDyII2SB9Upyb8yOAnouiSnZjz653o2ooRTLT28amKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267876329718.3669102405426; Tue, 27 Sep 2022 01:37:56 -0700 (PDT) Received: from localhost ([::1]:38540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od66E-0001tl-Tq for importer@patchew.org; Tue, 27 Sep 2022 04:37:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oP-0005Kh-1c for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oN-0000Iw-Gg for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-HqC502HuOCy6Cm6G6YP_7Q-1; Tue, 27 Sep 2022 04:19:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 764DD86C048; Tue, 27 Sep 2022 08:19:22 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25FA32087440; Tue, 27 Sep 2022 08:19:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 60812180093F; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L5PZAgDZ0Zk8jlRJBwRHM6yfmEwxC0P3PBdvK/bzC34=; b=ZIwlofEeeKSShQOdjhUkEdYg+s8j3aUqmxnfPH7VX3rCDHMOFmYabgK2WvQy1rFFVDB9UC R1Q3DR+rlbGB30g6hCuafrqCbBvmyF7QOj6VOGVYTD3dk+hOe6XssTrfmUKWYAihQZQsnz Y6mOMzi4PUW930TeH46ZEOs0x92nbzI= X-MC-Unique: HqC502HuOCy6Cm6G6YP_7Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 09/24] ui/vdagent: fix serial reset of guest agent Date: Tue, 27 Sep 2022 10:18:57 +0200 Message-Id: <20220927081912.180983-10-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267878246100001 From: Marc-Andr=C3=A9 Lureau In order to reset the guest agent, we send CLOSED & OPENED events. They are correctly received by the guest kernel. However, they might not be noticed by the guest agent process, as the IO task (poll() for example) might be wake up after both CLOSED & OPENED have been processed. Wait until the guest agent is disconnected to re-open our side. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-6-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/vdagent.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 819e0dc1435b..4bf50f0c4d88 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -471,7 +471,7 @@ static void vdagent_clipboard_reset_serial(VDAgentChard= ev *vd) =20 /* reopen the agent connection to reset the serial state */ qemu_chr_be_event(chr, CHR_EVENT_CLOSED); - qemu_chr_be_event(chr, CHR_EVENT_OPENED); + /* OPENED again after the guest disconnected, see set_fe_open */ } =20 static void vdagent_clipboard_notify(Notifier *notifier, void *data) @@ -875,6 +875,9 @@ static void vdagent_chr_set_fe_open(struct Chardev *chr= , int fe_open) { if (!fe_open) { trace_vdagent_close(); + /* To reset_serial, we CLOSED our side. Make sure the other end kn= ows we + * are ready again. */ + qemu_chr_be_event(chr, CHR_EVENT_OPENED); return; } =20 --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267803; cv=none; d=zohomail.com; s=zohoarc; b=kQ85BPyfVhH2w+VBRi2OhRj4E+AKjWHt1fBssZ/7/v+FG5T2dPGPMtrJUy0E+jvhtdQ8H+vAsffqUQJHAVC7m1rXLxeIqoVocxu9rdBTIZh7ZS9u8t8As0ZjiKdgL+ohca302FCNxz/Z7dOMOz91Q7rDK4zylp5eP655+XyD3gE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267803; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HKhagRLCEtkmOiTdXQ0adfpQ5bj5UXG4kN9vlU05MwI=; b=Na0FNBfj41DPtTsroZ+i0kRb1R3grKLvFNTTZlkYHZYrsC3tOaSvP9j2mHYOrD2RzL7FdBsceohY15JtMnuUXINmGP6nFDKAeLH02tL75Bron6qZlFpwjvKkgjODNh0t4dsi7RjrZCvVh1MgP9GQlbCL6uwp6jS+mMmCYF2jgdU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267803710838.5048081170107; Tue, 27 Sep 2022 01:36:43 -0700 (PDT) Received: from localhost ([::1]:54832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od653-0008T3-6p for importer@patchew.org; Tue, 27 Sep 2022 04:36:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oU-0005QD-2K for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oO-0000JA-J2 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-61-gDKPxj-bMRuwVYe5VOGbpg-1; Tue, 27 Sep 2022 04:19:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CB71185A794; Tue, 27 Sep 2022 08:19:24 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F3E739D6A; Tue, 27 Sep 2022 08:19:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6DFB31800980; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HKhagRLCEtkmOiTdXQ0adfpQ5bj5UXG4kN9vlU05MwI=; b=LW+CdkNZHetMRFhQjNJDTckIjKR3RO7QQufF0xjoji/b1cubIWNhF+7p70Xc5zbxDDKeM3 bgKACfeRHBuXd3NGTG6E3O//OmzZzaBMDhEZn5SY9Iw7Q9kVOzo77tvYcb0MAmq3/qplgl sjKnnQ0z8rPREtkUrzIaz4nndMBKz60= X-MC-Unique: gDKPxj-bMRuwVYe5VOGbpg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 10/24] ui/console: fix three double frees in png_save() Date: Tue, 27 Sep 2022 10:18:58 +0200 Message-Id: <20220927081912.180983-11-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267805591100001 From: Volker R=C3=BCmelin The png_destroy_write_struct() function frees all memory used by libpng. Don't use the glib auto cleanup mechanism to free the memory allocated by libpng again. For the pixman image, use only the auto cleanup mechanism and remove the qemu_pixman_image_unref() function call to prevent another double free. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1210 Fixes: 9a0a119a38 ("Added parameter to take screenshot with screendump as P= NG") Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220919061956.30929-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- ui/console.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/console.c b/ui/console.c index 243f2f6e64ae..49da6a91df6f 100644 --- a/ui/console.c +++ b/ui/console.c @@ -304,8 +304,8 @@ static bool png_save(int fd, pixman_image_t *image, Err= or **errp) { int width =3D pixman_image_get_width(image); int height =3D pixman_image_get_height(image); - g_autofree png_struct *png_ptr =3D NULL; - g_autofree png_info *info_ptr =3D NULL; + png_struct *png_ptr; + png_info *info_ptr; g_autoptr(pixman_image_t) linebuf =3D qemu_pixman_linebuf_create(PIXMAN_a8r8g8b8, wi= dth); uint8_t *buf =3D (uint8_t *)pixman_image_get_data(linebuf); @@ -346,7 +346,6 @@ static bool png_save(int fd, pixman_image_t *image, Err= or **errp) qemu_pixman_linebuf_fill(linebuf, image, width, 0, y); png_write_row(png_ptr, buf); } - qemu_pixman_image_unref(linebuf); =20 png_write_end(png_ptr, NULL); =20 --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267379; cv=none; d=zohomail.com; s=zohoarc; b=Ts8RLmdviMVWtVLihLjYDLow+tfetGSa+8ONH/u/yPDeQF7WNUO/YOFY20mR5HVxhAZggkGMulJ3vaqN2/wK+FF8SBG1zz6hF295RFJoof+9VfDXbvIqDkT5qyGLc8Qj6ddpMczGhxQQ19ySvbe1/+IBI5EhULCTpfFjoPCERfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267379; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5nyN9zf4XTCE2tFR3Vt7TfVm0hv0qRla4YlTg9dQiCI=; b=cYHDLONuw6B0IAYqFk9hhWR0fOAWkGwNkIhTYup205FU07WAS7D0gN5+a27KED8r58/JgZwd4slTR6ZKWrHUeNfVOsRPJBjGhr6bXbV4e9CO6T6GOmynZl36BXYYCy9ylxQ5WCR37GDRQtcwgco7pbami6qF6rUByiRCGItzTwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267379770845.0227507856507; Tue, 27 Sep 2022 01:29:39 -0700 (PDT) Received: from localhost ([::1]:55784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5yE-0002eJ-KH for importer@patchew.org; Tue, 27 Sep 2022 04:29:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oQ-0005Os-7a for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oO-0000J8-G5 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-KSadr7CxNomHjU5Vjv264Q-1; Tue, 27 Sep 2022 04:19:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 235AA101A528; Tue, 27 Sep 2022 08:19:24 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABE532087440; Tue, 27 Sep 2022 08:19:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7BB3A1800996; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5nyN9zf4XTCE2tFR3Vt7TfVm0hv0qRla4YlTg9dQiCI=; b=a1n7qII9h/3dGdagKpCAsiwLcIMd6qSzEnRQW4eQL6+1oc/hpgWyddt/Q0/Snd642KKQCN awYKFQeowYxFY+lO7c8eletmqzXnAnW5jUib01ukvnPiPws9yBXa0JeIEp7TKs8+TmyIn2 j3fETCOGXH3kkrAhP9cdvDsPXPKuBks= X-MC-Unique: KSadr7CxNomHjU5Vjv264Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell Subject: [PULL 11/24] hw/usb/hcd-xhci: Check whether DMA accesses fail Date: Tue, 27 Sep 2022 10:18:59 +0200 Message-Id: <20220927081912.180983-12-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267381007100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth If a guest sets up bad descriptors, it could force QEMU to access non-existing memory regions. Thus we should check the return value of dma_memory_read/write() to make sure that these errors don't go unnoticed. Signed-off-by: Thomas Huth Message-Id: <20220817160016.49752-1-thuth@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 64 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 3c48b58ddeb5..acd60b1a4904 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -463,6 +463,12 @@ static void xhci_mfwrap_timer(void *opaque) xhci_mfwrap_update(xhci); } =20 +static void xhci_die(XHCIState *xhci) +{ + xhci->usbsts |=3D USBSTS_HCE; + DPRINTF("xhci: asserted controller error\n"); +} + static inline dma_addr_t xhci_addr64(uint32_t low, uint32_t high) { if (sizeof(dma_addr_t) =3D=3D 4) { @@ -488,7 +494,14 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci,= dma_addr_t addr, =20 assert((len % sizeof(uint32_t)) =3D=3D 0); =20 - dma_memory_read(xhci->as, addr, buf, len, MEMTXATTRS_UNSPECIFIED); + if (dma_memory_read(xhci->as, addr, buf, len, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + memset(buf, 0xff, len); + xhci_die(xhci); + return; + } =20 for (i =3D 0; i < (len / sizeof(uint32_t)); i++) { buf[i] =3D le32_to_cpu(buf[i]); @@ -496,7 +509,7 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci, = dma_addr_t addr, } =20 static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr, - uint32_t *buf, size_t len) + const uint32_t *buf, size_t len) { int i; uint32_t tmp[5]; @@ -508,7 +521,13 @@ static inline void xhci_dma_write_u32s(XHCIState *xhci= , dma_addr_t addr, for (i =3D 0; i < n; i++) { tmp[i] =3D cpu_to_le32(buf[i]); } - dma_memory_write(xhci->as, addr, tmp, len, MEMTXATTRS_UNSPECIFIED); + if (dma_memory_write(xhci->as, addr, tmp, len, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + xhci_die(xhci); + return; + } } =20 static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport) @@ -593,12 +612,6 @@ static inline int xhci_running(XHCIState *xhci) return !(xhci->usbsts & USBSTS_HCH); } =20 -static void xhci_die(XHCIState *xhci) -{ - xhci->usbsts |=3D USBSTS_HCE; - DPRINTF("xhci: asserted controller error\n"); -} - static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v) { XHCIInterrupter *intr =3D &xhci->intr[v]; @@ -619,7 +632,12 @@ static void xhci_write_event(XHCIState *xhci, XHCIEven= t *event, int v) ev_trb.status, ev_trb.control); =20 addr =3D intr->er_start + TRB_SIZE*intr->er_ep_idx; - dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE, MEMTXATTRS_UNSPECI= FIED); + if (dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + xhci_die(xhci); + } =20 intr->er_ep_idx++; if (intr->er_ep_idx >=3D intr->er_size) { @@ -680,8 +698,12 @@ static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRi= ng *ring, XHCITRB *trb, =20 while (1) { TRBType type; - dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE, - MEMTXATTRS_UNSPECIFIED); + if (dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\= n", + __func__); + return 0; + } trb->addr =3D ring->dequeue; trb->ccs =3D ring->ccs; le64_to_cpus(&trb->parameter); @@ -798,8 +820,14 @@ static void xhci_er_reset(XHCIState *xhci, int v) xhci_die(xhci); return; } - dma_memory_read(xhci->as, erstba, &seg, sizeof(seg), - MEMTXATTRS_UNSPECIFIED); + if (dma_memory_read(xhci->as, erstba, &seg, sizeof(seg), + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + xhci_die(xhci); + return; + } + le32_to_cpus(&seg.addr_low); le32_to_cpus(&seg.addr_high); le32_to_cpus(&seg.size); @@ -2415,8 +2443,12 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *x= hci, uint64_t pctx) /* TODO: actually implement real values here */ bw_ctx[0] =3D 0; memset(&bw_ctx[1], 80, xhci->numports); /* 80% */ - dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx), - MEMTXATTRS_UNSPECIFIED); + if (dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx), + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory write failed!\n", + __func__); + return CC_TRB_ERROR; + } =20 return CC_SUCCESS; } --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268341; cv=none; d=zohomail.com; s=zohoarc; b=LDrewnhNpDYhrcJ1HexBN9E9i2xZqMYjMvIfGOEADu0sYJht6lDafFvuiJ9hnedTenzhEicytwXp2X3SUDs4dkp+eQks7HvQJsiUnRM0W+rvDMKM6OrcMm6QOnfGLqxF5H8afKikA6HaYSv+m1BOMVrpSRqUbzbYbgNReozrwEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268341; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=At+dbiBtzojIId+CkWfr7mFw/GiOsUbaxmGmx4H6iSE=; b=Nlr/kGC1gjRvwDY6d88PPBV1Bvtddup34aqbr+b0KaA7upwTZnY0Nmxk4HG03QOZQ/IQqA/wEUY8v2K48rOIlCL2W0PQ8SVoVLvftLEieJvPKdGD+L6ml+/F66FZJZzJbIY5/E7G2A4ajLJIplmvbfZeVmCRJ+0rHd/dKSzR6ZQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268341905396.03644623909076; Tue, 27 Sep 2022 01:45:41 -0700 (PDT) Received: from localhost ([::1]:51262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6Dk-0004kN-QB for importer@patchew.org; Tue, 27 Sep 2022 04:45:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oV-0005WA-LN for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oT-0000Jm-QU for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-_vDPRKVsPFCNpEoD_mG3AA-1; Tue, 27 Sep 2022 04:19:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22DAF858282; Tue, 27 Sep 2022 08:19:26 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56BF9404102C; Tue, 27 Sep 2022 08:19:25 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 892741800999; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=At+dbiBtzojIId+CkWfr7mFw/GiOsUbaxmGmx4H6iSE=; b=UA59lVAbxXI14S0Zjt9YzdZMNzwkyErjyBmjasCr5sIDA3BClHfWrR0h7fM/I6BJPsJd+P IMIS2vuL/UinZHWvwH8JSMYKZ9WYvOY9ih6pbujNACeWuGhuPUHwwA8xuD/rtt+c25QBjx CSfPDpjnqFdONIpS1hNBXoEDLJfTV/U= X-MC-Unique: _vDPRKVsPFCNpEoD_mG3AA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Qiang Liu , Gaoning Pan Subject: [PULL 12/24] hcd-ohci: Drop ohci_service_iso_td() if ed->head & OHCI_DPTR_MASK is zero Date: Tue, 27 Sep 2022 10:19:00 +0200 Message-Id: <20220927081912.180983-13-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268342423100001 Content-Type: text/plain; charset="utf-8" From: Qiang Liu An abort happens in ohci_frame_boundary() when ohci->done is 0 [1]. ``` c static void ohci_frame_boundary(void *opaque) { // ... if (ohci->done_count =3D=3D 0 && !(ohci->intr_status & OHCI_INTR_WD)) { if (!ohci->done) abort(); <----------------------------------------- [1] ``` This was reported in https://bugs.launchpad.net/qemu/+bug/1911216/, https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg03613.html, and https://gitlab.com/qemu-project/qemu/-/issues/545. I can still reproduce it= with the latest QEMU. This happends due to crafted ED with putting ISO_TD at physical address 0. Suppose ed->head & OHCI_DPTR_MASK is 0 [2], and we memset 0 to the phyiscal memory from 0 to sizeof(ohci_iso_td). Then, starting_frame [3] and frame_co= unt [4] are both 0. As we can control the value of ohci->frame_number (0 to 0x1= f, suppose 1), we then control the value of relative_frame_number to be 1 [6].= The control flow goes to [7] where ohci->done is 0. Have returned from ohci_service_iso_td(), ohci_frame_boundary() will abort() [1]. ``` c static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed) { // ... addr =3D ed->head & OHCI_DPTR_MASK; // <--------------------- [2] if (ohci_read_iso_td(ohci, addr, &iso_td)) { // <-------- [3] // ... starting_frame =3D OHCI_BM(iso_td.flags, TD_SF); // <-------- [4] frame_count =3D OHCI_BM(iso_td.flags, TD_FC); // <-------- [5] relative_frame_number =3D USUB(ohci->frame_number, starting_frame); // <-------- [6] if (relative_frame_number < 0) { return 1; } else if (relative_frame_number > frame_count) { // ... ohci->done =3D addr; // <-------- [7] // ... } ``` As only (afaik) a guest root user can manipulate ED, TD and the physical me= mory, this assertion failure is not a security bug. The idea to fix this issue is to drop ohci_service_iso_td() if ed->head & OHCI_DPTR_MASK is 0, which is similar to the drop operation for ohci_service_ed_list() when head is 0. Probably, a similar issue is in ohci_service_td(). I drop ohci_service_td() if ed->head & OHCI_DPTR_MASK is= 0. Fixes: 7bfe577702 ("OHCI USB isochronous transfers support (Arnon Gilboa)") Reported-by: Gaoning Pan Reported-by: Alexander Bulekov Reported-by: Qiang Liu Resolves: https://gitlab.com/qemu-project/qemu/-/issues/545 Buglink: https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg03613.html Buglink: https://bugs.launchpad.net/qemu/+bug/1911216 Signed-off-by: Qiang Liu Message-Id: <20220826051557.119570-1-cyruscyliu@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 895b29fb8657..72bdde92617c 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -571,6 +571,11 @@ static int ohci_service_iso_td(OHCIState *ohci, struct= ohci_ed *ed) =20 addr =3D ed->head & OHCI_DPTR_MASK; =20 + if (addr =3D=3D 0) { + ohci_die(ohci); + return 1; + } + if (ohci_read_iso_td(ohci, addr, &iso_td)) { trace_usb_ohci_iso_td_read_failed(addr); ohci_die(ohci); @@ -858,6 +863,11 @@ static int ohci_service_td(OHCIState *ohci, struct ohc= i_ed *ed) int completion; =20 addr =3D ed->head & OHCI_DPTR_MASK; + if (addr =3D=3D 0) { + ohci_die(ohci); + return 1; + } + /* See if this TD has already been submitted to the device. */ completion =3D (addr =3D=3D ohci->async_td); if (completion && !ohci->async_complete) { --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664270627; cv=none; d=zohomail.com; s=zohoarc; b=WQD/A9bfFhagpzMmE86eI2jV1D4bhF1dvH3vf2ZXGBjo9PPzT5q9ufr+oLOCJbhjVhnZBa/rhQ7xIYrD4RlOIL1FQkKvLr/eoib6HspZ18Q/JZiXNFnd0xjcZkvXhDlPUh8b5ynp2+/CoU25Xn1K4L6swhceDtIzyg41lOBpECw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664270627; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0m00e7GaD8cqnM2csAfgTfw2hXblEpsI8UlNCemk+ag=; b=nagV7ROo5PiDuHK1nDFkBZi7UsIyOZcKnaWBA45axjURwUdabhlQ46xy+DnpD1TFK9TIuRC5sNMrbBwVosoZHRUFDcZgEP1W6ZWJ3EZpG5U2vi8DHznZi7O8gaqfgZZ9fBUo5FM9ZZVSSSa81U2N0xiZp03Ko1xGo3iUlvvuV38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664270627887895.2321156640154; Tue, 27 Sep 2022 02:23:47 -0700 (PDT) Received: from localhost ([::1]:50452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6oY-0006xN-Hx for importer@patchew.org; Tue, 27 Sep 2022 05:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oa-0005iW-0h for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57166) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oY-0000Kv-Ef for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:39 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-390-S3uAArm3PHqIY8Wn1h4NeA-1; Tue, 27 Sep 2022 04:19:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C26E862FDF; Tue, 27 Sep 2022 08:19:25 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58BAA17582; Tue, 27 Sep 2022 08:19:25 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 964D6180099A; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0m00e7GaD8cqnM2csAfgTfw2hXblEpsI8UlNCemk+ag=; b=cwm0DSQZfwNiACnGLAx9JKcV0pZfZSkasbt/7jryBnt4oBrGH/WbYqAGbXeKRItpdXlrWK +K/eR4DeKNJiDbiBNsU7dylvhtnsi5uLZ22Dan1QF42is0SVy8+SQgK2hyPtnRpuGEr/Ql Z4kFcKVLCQCW+03yWYw4rCkcXDcfu9Y= X-MC-Unique: S3uAArm3PHqIY8Wn1h4NeA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell Subject: [PULL 13/24] usb/msd: move usb_msd_packet_complete() Date: Tue, 27 Sep 2022 10:19:01 +0200 Message-Id: <20220927081912.180983-14-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664270630572100001 Content-Type: text/plain; charset="utf-8" Change ordering to avoid adding forward declarations in following patches. Fix comment code style while being at it. No functional change. Signed-off-by: Gerd Hoffmann Message-Id: <20220830063827.813053-2-kraxel@redhat.com> --- hw/usb/dev-storage.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 98639696e6d8..140ef2aeaa80 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -177,6 +177,20 @@ static const USBDesc desc =3D { .str =3D desc_strings, }; =20 +static void usb_msd_packet_complete(MSDState *s) +{ + USBPacket *p =3D s->packet; + + /* + * Set s->packet to NULL before calling usb_packet_complete + * because another request may be issued before + * usb_packet_complete returns. + */ + trace_usb_msd_packet_complete(); + s->packet =3D NULL; + usb_packet_complete(&s->dev, p); +} + static void usb_msd_copy_data(MSDState *s, USBPacket *p) { uint32_t len; @@ -208,18 +222,6 @@ static void usb_msd_send_status(MSDState *s, USBPacket= *p) memset(&s->csw, 0, sizeof(s->csw)); } =20 -static void usb_msd_packet_complete(MSDState *s) -{ - USBPacket *p =3D s->packet; - - /* Set s->packet to NULL before calling usb_packet_complete - because another request may be issued before - usb_packet_complete returns. */ - trace_usb_msd_packet_complete(); - s->packet =3D NULL; - usb_packet_complete(&s->dev, p); -} - void usb_msd_transfer_data(SCSIRequest *req, uint32_t len) { MSDState *s =3D DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664270302; cv=none; d=zohomail.com; s=zohoarc; b=erpbULEDlA1k1h3L00d++XFIrSb8g28LPhEzW7h+JuyadawV6cvgKboTcMKJ3Xkm1io26oPW+gHX7wNrjIRzAQm0BZ4nZ8SoggNPiMsiOz4fmHJLt26b2pUcobLUtjQJvdNroPzVh2rBPJOBKryPzO7y5BSRgAntZlSsAN+6YOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664270302; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1/bz0ZvfMImJCS6WH5kQCYHFBHl/aO5fDf5KXRDm0YE=; b=jTWX8WipKIifXOgT6vHM+kWsWhKyw0GszUxtOMnGe3ZYaVRsA5nOGjhBq8+Knb9TfLXoZvGJRvpwFs1k78o0bbea71TtsAmQdCmZX4hNHLv2ti9CK8GRFeHqbEcvFaqp+yAglqu3pixypTbUfojpIUGOS6d8BLEH0F49BQAbOR8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664270302355275.3025818290424; Tue, 27 Sep 2022 02:18:22 -0700 (PDT) Received: from localhost ([::1]:60076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6jM-00013l-7Q for importer@patchew.org; Tue, 27 Sep 2022 05:18:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oV-0005Wd-OV for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oT-0000Jv-Qh for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-245-NgBXk3BLPJmU17-imvproA-1; Tue, 27 Sep 2022 04:19:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BD54185A794; Tue, 27 Sep 2022 08:19:27 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1F80111E414; Tue, 27 Sep 2022 08:19:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A77AA180099B; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1/bz0ZvfMImJCS6WH5kQCYHFBHl/aO5fDf5KXRDm0YE=; b=SLE/xsuUJEdGt/eIF/OQSZwJMp4tLrb7XcI8bGSUFy6aMTFVpQnAM7m4VLNC6gg6z88K58 8a5bpcCAiGp0AZjJxfgsHCxP9TaJHLU6aQeP+HbxDZwGYjUyPJ7zgDLWkfwoEC4vl/Cx4S lCOKmuQAE5TEQEK1FiNiN7e4H/Er1Fc= X-MC-Unique: NgBXk3BLPJmU17-imvproA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Qiang Liu Subject: [PULL 14/24] usb/msd: add usb_msd_fatal_error() and fix guest-triggerable assert Date: Tue, 27 Sep 2022 10:19:02 +0200 Message-Id: <20220927081912.180983-15-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664270303717100001 Content-Type: text/plain; charset="utf-8" Add handler for fatal errors. Moves device into error state where it stops responding until the guest resets it. Guest can send illegal requests where scsi command and usb packet transfer directions are inconsistent. Use the new usb_msd_fatal_error() function instead of assert() in that case. Reported-by: Qiang Liu Signed-off-by: Gerd Hoffmann Tested-by: Qiang Liu Message-Id: <20220830063827.813053-3-kraxel@redhat.com> --- include/hw/usb/msd.h | 1 + hw/usb/dev-storage.c | 30 +++++++++++++++++++++++++++++- hw/usb/trace-events | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/hw/usb/msd.h b/include/hw/usb/msd.h index 54e9f38bda46..f9fd862b529a 100644 --- a/include/hw/usb/msd.h +++ b/include/hw/usb/msd.h @@ -40,6 +40,7 @@ struct MSDState { bool removable; bool commandlog; SCSIDevice *scsi_dev; + bool needs_reset; }; =20 typedef struct MSDState MSDState; diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 140ef2aeaa80..e3bcffb3e0d7 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -191,6 +191,23 @@ static void usb_msd_packet_complete(MSDState *s) usb_packet_complete(&s->dev, p); } =20 +static void usb_msd_fatal_error(MSDState *s) +{ + trace_usb_msd_fatal_error(); + + if (s->packet) { + s->packet->status =3D USB_RET_STALL; + usb_msd_packet_complete(s); + } + + /* + * Guest messed up up device state with illegal requests. Go + * ignore any requests until the guests resets the device (and + * brings it into a known state that way). + */ + s->needs_reset =3D true; +} + static void usb_msd_copy_data(MSDState *s, USBPacket *p) { uint32_t len; @@ -227,7 +244,11 @@ void usb_msd_transfer_data(SCSIRequest *req, uint32_t = len) MSDState *s =3D DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); USBPacket *p =3D s->packet; =20 - assert((s->mode =3D=3D USB_MSDM_DATAOUT) =3D=3D (req->cmd.mode =3D=3D = SCSI_XFER_TO_DEV)); + if ((s->mode =3D=3D USB_MSDM_DATAOUT) !=3D (req->cmd.mode =3D=3D SCSI_= XFER_TO_DEV)) { + usb_msd_fatal_error(s); + return; + } + s->scsi_len =3D len; s->scsi_off =3D 0; if (p) { @@ -317,6 +338,8 @@ void usb_msd_handle_reset(USBDevice *dev) =20 memset(&s->csw, 0, sizeof(s->csw)); s->mode =3D USB_MSDM_CBW; + + s->needs_reset =3D false; } =20 static void usb_msd_handle_control(USBDevice *dev, USBPacket *p, @@ -382,6 +405,11 @@ static void usb_msd_handle_data(USBDevice *dev, USBPac= ket *p) SCSIDevice *scsi_dev; uint32_t len; =20 + if (s->needs_reset) { + p->status =3D USB_RET_STALL; + return; + } + switch (p->pid) { case USB_TOKEN_OUT: if (devep !=3D 2) diff --git a/hw/usb/trace-events b/hw/usb/trace-events index 914ca7166829..b65269892c5e 100644 --- a/hw/usb/trace-events +++ b/hw/usb/trace-events @@ -263,6 +263,7 @@ usb_msd_packet_complete(void) "" usb_msd_cmd_submit(unsigned lun, unsigned tag, unsigned flags, unsigned le= n, unsigned data_len) "lun %u, tag 0x%x, flags 0x%08x, len %d, data-len %d" usb_msd_cmd_complete(unsigned status, unsigned tag) "status %d, tag 0x%x" usb_msd_cmd_cancel(unsigned tag) "tag 0x%x" +usb_msd_fatal_error(void) "" =20 # dev-uas.c usb_uas_reset(int addr) "dev %d" --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664270075; cv=none; d=zohomail.com; s=zohoarc; b=mrFqv/4Z5NOymcAjmlzln37L/fTdGKmY4xO9s/yuIJNi/DEL1W3OXWFw4EJEN01RHTiisCVVJaOym6A0vdW5YOy6ZlTjXtmg8wPW01PGLfZMe0vXW1vUgw760c4xoyfeofeg+2uRs7KFbTx8jkJGWLKEg/1D0K2IyBSdiyIFeQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664270075; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fIdR0vI29oZeRCFZBp8CQiXoR7cYaIYvZ9xzZVFSJ94=; b=Cs8TUgQRWuffTMnQWSBsqQ6EZdhDY6CHRxR5ww+reqhtcNMntIUbDhx4tMa4usINP9g0ySAQo5f2U00seUXtz25Ih03fmVyemlliXNM9tS6c2H6KUHCgPJqvl9/R96ZvjRvyDHcXR47kEAdTUPKFAUwRBElo4Oho1N92p0yrHQ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664270075598462.5856180141154; Tue, 27 Sep 2022 02:14:35 -0700 (PDT) Received: from localhost ([::1]:49418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6fh-0003ud-BY for importer@patchew.org; Tue, 27 Sep 2022 05:14:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oV-0005Ua-8N for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oP-0000JV-VY for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-59-xyPk2uJbMoWNxEez66wYJA-1; Tue, 27 Sep 2022 04:19:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94CC585A583; Tue, 27 Sep 2022 08:19:27 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4469A1402BDE; Tue, 27 Sep 2022 08:19:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B6F8C180099C; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fIdR0vI29oZeRCFZBp8CQiXoR7cYaIYvZ9xzZVFSJ94=; b=TQty7XSZx+vhNYlTAn90J57aTXXfk99bQBFBRhW+TusEHoc5zCzyRWU+Wuz7cNG9QBee1o gwskmxcdvyk7SiUa6kcBgRUm8kjO0+dOEWId135jgyS0/aXyxeHyKpXtHcdr1xlynbiVpZ RJREE+bWEgMWnz7HV+281IfUFPuk5Ys= X-MC-Unique: xyPk2uJbMoWNxEez66wYJA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Qiang Liu Subject: [PULL 15/24] hcd-xhci: drop operation with secondary stream arrays enabled Date: Tue, 27 Sep 2022 10:19:03 +0200 Message-Id: <20220927081912.180983-16-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664270077453100001 Content-Type: text/plain; charset="utf-8" From: Qiang Liu The abort() in xhci_find_stream() can be triggered via enabling the seconda= ry stream arrays by setting linear stream array (LSA) bit (in endpoint context= ) to 0. We may show warnings and drop this operation. Fixes: 024426acc0a2 ("usb-xhci: usb3 streams") Reported-by: Qiang Liu Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1192 Signed-off-by: Qiang Liu Message-Id: <20220904125926.2141607-1-cyruscyliu@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index acd60b1a4904..8299f35e6695 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1020,7 +1020,9 @@ static XHCIStreamContext *xhci_find_stream(XHCIEPCont= ext *epctx, } sctx =3D epctx->pstreams + streamid; } else { - FIXME("secondary streams not implemented yet"); + fprintf(stderr, "xhci: FIXME: secondary streams not implemented ye= t"); + *cc_error =3D CC_INVALID_STREAM_TYPE_ERROR; + return NULL; } =20 if (sctx->sct =3D=3D -1) { --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268094; cv=none; d=zohomail.com; s=zohoarc; b=Y9ONcrDqKnZgHzSsns0nGMGU1JR1RupUMEP/StD82KWaF6c4gJdPkvU0q8OtGEb9DsgIyGDUm459Ic8+fzWocTqe5H1YcCINSCjMHcK2puvpsb25aQ+LOJhWLX959IQCnFIcHrj1NQZWGFsCDuJ5jWpndZF2LqGb8hAuSk/gdVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268094; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xsE9VkekNKZPttOpoOonLuBUJbPWi32PC/I2Jy8KiYE=; b=dv6Ld45ojEhg8yzXPryZEi+VTafJ+fvZ2LU1YiqjwPFiUrI7IRwBPDOv1wManxAwcwjOc1leqBTIQkS75YkwjPgtHfPQhj5S6F2fA1Wfn72U3bIFGvxBg1wjqD0nkL9fD3RCWaZJryajLcdeckY6Zqs9JMOqE0vkH9PVgqJYqAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268094391701.8064845583305; Tue, 27 Sep 2022 01:41:34 -0700 (PDT) Received: from localhost ([::1]:47506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od69l-0007Re-C5 for importer@patchew.org; Tue, 27 Sep 2022 04:41:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oV-0005WL-MO for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oT-0000K3-R7 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-dOc8XnuPMmmYDtQSkAE68w-1; Tue, 27 Sep 2022 04:19:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD877811E87; Tue, 27 Sep 2022 08:19:28 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E3954029A7C; Tue, 27 Sep 2022 08:19:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C42BC180099F; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xsE9VkekNKZPttOpoOonLuBUJbPWi32PC/I2Jy8KiYE=; b=f4ZB57qKvcru2Gy3iqbnlVOue94mIBGyRl+EdSs/OHiqmLFD9CdO2FyHyH2VRhHXo5t4L3 4mc350rZOem7SA02s1Edqi+EECN5Gic1pwnJBkxA+3F3t3vV+gpqcoFlqqFL3aarz6Mr6w pnur0rkDv8w2iTsS3TxbbEuGILLnPok= X-MC-Unique: dOc8XnuPMmmYDtQSkAE68w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Michael Brown Subject: [PULL 16/24] usbnet: Add missing usb_wakeup() call in usbnet_receive() Date: Tue, 27 Sep 2022 10:19:04 +0200 Message-Id: <20220927081912.180983-17-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268096402100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown usbnet_receive() does not currently wake up the USB endpoint, leading to a dead RX datapath when used with a host controller such as xHCI that relies on being woken up. Fix by adding a call to usb_wakeup() at the end of usbnet_receive(). Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-2-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 6c49c16015e0..61bf598870cb 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -647,6 +647,7 @@ struct USBNetState { uint8_t in_buf[2048]; =20 USBEndpoint *intr; + USBEndpoint *bulk_in; =20 char usbstring_mac[13]; NICState *nic; @@ -1317,6 +1318,7 @@ static ssize_t usbnet_receive(NetClientState *nc, con= st uint8_t *buf, size_t siz memcpy(in_buf, buf, size); s->in_len =3D total_size; s->in_ptr =3D 0; + usb_wakeup(s->bulk_in, 0); return size; } =20 @@ -1359,6 +1361,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) s->filter =3D 0; s->vendorid =3D 0x1234; s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); + s->bulk_in =3D usb_ep_get(dev, USB_TOKEN_IN, 2); =20 qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_usbnet_info, &s->conf, --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268436; cv=none; d=zohomail.com; s=zohoarc; b=j/ZIeRaeQtqvFMfdRNRItuZDaggjm2pTAnb+Yx9yUbey5/OO+N3cIHEzZ1U9hR9bY2tj0t09/durL/lpUsFv2Bad4hvnm/uhsQx3iZO09/INk+no3t4mn6emddoFmDriCbRFNvJ2xp8JwOTImzryW45O438/QZOtMaSRt1kXLGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268436; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RHygAolE6RYOc4/xbnRCU9F7GebT834or/LJsscBmN0=; b=gnZhMKqtZItCkg+QCfHHAwTlUMcbMpHjIki9cT9YA3/P5NbyxxcH/GzBaQXEPn46b7uui9rxRf5kHtAOF+RIS6xwmpuceqDVTnJp2mUUcvcXGaWEhfKTO+cbIxSRx/OfO3dDMNcZ9fos4tvCAhmkDgpBQD3W+589dH6nDlZ7QMM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268436677320.55141882544774; Tue, 27 Sep 2022 01:47:16 -0700 (PDT) Received: from localhost ([::1]:58354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6FG-0005H2-Jn for importer@patchew.org; Tue, 27 Sep 2022 04:47:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5p8-0006Kv-Mx for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5p7-0000Ze-Ag for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:14 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-j3sHi4HkMFq-RZaklqgowQ-1; Tue, 27 Sep 2022 04:20:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B478D1E68194; Tue, 27 Sep 2022 08:20:07 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6BB4111E414; Tue, 27 Sep 2022 08:19:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D0CB818009A4; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RHygAolE6RYOc4/xbnRCU9F7GebT834or/LJsscBmN0=; b=FxdtbkarLRNKXuHnRJxk3FNWw8TdFC30SVuDQTdIHLpyKSfD/g9mSydQ3gUMdp9X4SRQf9 gooh9azeb/p1Bi9ER8rz8SMzr7qHM01eaDAmEZXD1dF0fCeCF3fINkEAkovGPVdEBSC5// +6CfCrY6IkfUCPmou5nAS2Ja/03ienw= X-MC-Unique: j3sHi4HkMFq-RZaklqgowQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Michael Brown Subject: [PULL 17/24] usbnet: Accept mandatory USB_CDC_SET_ETHERNET_PACKET_FILTER request Date: Tue, 27 Sep 2022 10:19:05 +0200 Message-Id: <20220927081912.180983-18-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268438016100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown The USB_CDC_SET_ETHERNET_PACKET_FILTER request is mandatory for CDC-ECM devices. Accept this request, ignoring the actual filter value (to match the existing behaviour for RNDIS). Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-3-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 61bf598870cb..155df935cd68 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1122,6 +1122,12 @@ static void usb_net_handle_control(USBDevice *dev, U= SBPacket *p, #endif break; =20 + case ClassInterfaceOutRequest | USB_CDC_SET_ETHERNET_PACKET_FILTER: + if (is_rndis(s)) { + goto fail; + } + break; + default: fail: fprintf(stderr, "usbnet: failed control transaction: " --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664270918; cv=none; d=zohomail.com; s=zohoarc; b=DDfo0UvOTZS4NIOie5INmAR6vlTp6LzQgDLjj0lubH5x5xLqz3fEi44A3zR1bgJiXXgT7s27c4Fv0Dq5fhOPXoqjHPibn6oOfqMyd8SBN1rEGgu3jernlZK2BVHzy5TqxqDJzObUIWkDNlg0HBUXEaMIz2lm5GjLROgR1dVts7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664270918; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MQSZ3YegllO8gYugV2LwNog3NGPPlbl9W71LJ6tpgkc=; b=n5OQ+8J7EcaevMixUG2jQLd0cmQNZaFFNiZTC6V5158F41XgwnYD2vEoQwEhDoJM8SodY4NQxIrhw4ZwnOpGapB0y4r9CaRK1YcKD3BK5zwSKvV20lWGx3FxoCmU1AtQZOICqqubaJUtDFEEQ2d1cg32n400odIVlYz7YX/vzB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664270918305695.2214187621097; Tue, 27 Sep 2022 02:28:38 -0700 (PDT) Received: from localhost ([::1]:33906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6tI-0004Vh-Tz for importer@patchew.org; Tue, 27 Sep 2022 05:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oa-0005kk-Fy for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oZ-0000L5-0C for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:40 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-NoODQLMfOF2E7mSn3E7gRA-1; Tue, 27 Sep 2022 04:19:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E1553C10224; Tue, 27 Sep 2022 08:19:30 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEC122087440; Tue, 27 Sep 2022 08:19:29 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DD7E218009A8; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MQSZ3YegllO8gYugV2LwNog3NGPPlbl9W71LJ6tpgkc=; b=Buo+7k55djmmSgmYHXhHFoDmD/MHeK/Ko73P6s6KvGsrFLBsf+b6nuWX5dZ3ckgqEOcP5Y lGQaBWcH2wONQxJMfyIMGEiXAvUtRYy1S4DvnWinBhkGbjfznnVLZb1z+PTkWK8hj25pJc 6nNR7Irb4B37o+b/evqhUZiPN+FyZiQ= X-MC-Unique: NoODQLMfOF2E7mSn3E7gRA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Michael Brown Subject: [PULL 18/24] usbnet: Detect short packets as sent by the xHCI controller Date: Tue, 27 Sep 2022 10:19:06 +0200 Message-Id: <20220927081912.180983-19-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664270919069100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown The xHCI controller will ignore the endpoint MTU and so may deliver packets of any length. Detect short packets as being any packet that has a length of zero or a length that is not a multiple of the MTU. Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-4-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 155df935cd68..9d83974ec9f0 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1211,7 +1211,7 @@ static void usb_net_handle_dataout(USBNetState *s, US= BPacket *p) s->out_ptr +=3D sz; =20 if (!is_rndis(s)) { - if (p->iov.size < 64) { + if (p->iov.size % 64 || p->iov.size =3D=3D 0) { qemu_send_packet(qemu_get_queue(s->nic), s->out_buf, s->out_pt= r); s->out_ptr =3D 0; } --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268858; cv=none; d=zohomail.com; s=zohoarc; b=O+/nxukDiuKBlXv1lY/riQOA5aMmXIr1BLlyazmussPfg5SP2llKrmc9dCTzMBZ1bl8+KvlZtkMCB3ZeHjZ1nIiEdXMxlSyuTvtqWoHknzWAYVC2dmy+HfrUVPTZ6ypvmtKh0DqSjY0fhslhz+tlRSbcAdmkuXx1eOgKrPpM6jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268858; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TwMBwWhUCObCQODSt2PE3geZjaDC55CP59MmTESi1FE=; b=GPF/3g9GXKcht7eRf6xKFU7bgcJ+tE0zhjRSFcnEoPZgVN/1VhIWL9PzDlr2aWHo/Jkrgqr0d0wBoeSHTENNHmGvhAwYJKy7fxnjDdDp1clkIgIheGtC5voJSPZ5gCZyNXcyDA7KYFnNNhBr7T2QAlmi4ToNY2Qo6NpUp7JXDk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268858105615.235556360608; Tue, 27 Sep 2022 01:54:18 -0700 (PDT) Received: from localhost ([::1]:53876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6M4-0005ny-2w for importer@patchew.org; Tue, 27 Sep 2022 04:54:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oY-0005cf-L2 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5oX-0000Kq-5c for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:19:38 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-4WZjYfBGMwGF8uEaKDpRgg-1; Tue, 27 Sep 2022 04:19:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFDEA811E81; Tue, 27 Sep 2022 08:19:31 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B4D318EB3; Tue, 27 Sep 2022 08:19:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EA7EF18009AA; Tue, 27 Sep 2022 10:19:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TwMBwWhUCObCQODSt2PE3geZjaDC55CP59MmTESi1FE=; b=F7I7ortHsi9AV+jex3TfTI3BqtSQa2SVx6iHUFZXXl4q73SCdoG42j/ZqcUi1fTI04ASob 9tnlxz5ANf2uV+NdGcZpRzttX2XewWrR0ZsBtz5P9oMgIqbw5mXI2Zt0ArJcXCpxHX5Q8b cCrrgQIuLUSZgbKjzwSiuVkULNNSG8s= X-MC-Unique: 4WZjYfBGMwGF8uEaKDpRgg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Michael Brown Subject: [PULL 19/24] usbnet: Report link-up via interrupt endpoint in CDC-ECM mode Date: Tue, 27 Sep 2022 10:19:07 +0200 Message-Id: <20220927081912.180983-20-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268859327100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-5-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 9d83974ec9f0..ac1adca54355 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -91,6 +91,8 @@ enum usbstring_idx { #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 #define USB_CDC_GET_ETHERNET_STATISTIC 0x44 =20 +#define USB_CDC_NETWORK_CONNECTION 0x00 + #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 =3D=3D 32 msec */ #define STATUS_BYTECOUNT 16 /* 8 byte header + data */ =20 @@ -640,6 +642,8 @@ struct USBNetState { uint16_t filter; uint32_t vendorid; =20 + uint16_t connection; + unsigned int out_ptr; uint8_t out_buf[2048]; =20 @@ -1140,18 +1144,28 @@ static void usb_net_handle_control(USBDevice *dev, = USBPacket *p, =20 static void usb_net_handle_statusin(USBNetState *s, USBPacket *p) { - le32 buf[2]; + le32 rbuf[2]; + uint16_t ebuf[4]; =20 if (p->iov.size < 8) { p->status =3D USB_RET_STALL; return; } =20 - buf[0] =3D cpu_to_le32(1); - buf[1] =3D cpu_to_le32(0); - usb_packet_copy(p, buf, 8); - if (!s->rndis_resp.tqh_first) { - p->status =3D USB_RET_NAK; + if (is_rndis(s)) { + rbuf[0] =3D cpu_to_le32(1); + rbuf[1] =3D cpu_to_le32(0); + usb_packet_copy(p, rbuf, 8); + if (!s->rndis_resp.tqh_first) { + p->status =3D USB_RET_NAK; + } + } else { + ebuf[0] =3D + cpu_to_be16(ClassInterfaceRequest | USB_CDC_NETWORK_CONNECTION= ); + ebuf[1] =3D cpu_to_le16(s->connection); + ebuf[2] =3D cpu_to_le16(1); + ebuf[3] =3D cpu_to_le16(0); + usb_packet_copy(p, ebuf, 8); } =20 #ifdef TRAFFIC_DEBUG @@ -1366,6 +1380,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) s->media_state =3D 0; /* NDIS_MEDIA_STATE_CONNECTED */; s->filter =3D 0; s->vendorid =3D 0x1234; + s->connection =3D 1; /* Connected */ s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); s->bulk_in =3D usb_ep_get(dev, USB_TOKEN_IN, 2); =20 --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664269216; cv=none; d=zohomail.com; s=zohoarc; b=LnmYSt7BzXzNrd94hAJNACZT8TWCjQuTIFsK8mpa6PMTElZJG1xMPpgJLvA4tPLYs05hlxB7+P+nbA+KCnXk6PXj7eg9zgwHNLg83Fc5As7t+miMnRznDpoxGvY7RNPDUItYEDxgYK1z/ksFJ7EhZcxidg01Y2+mXsQikDC599c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664269216; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IaAIzLnv6j0oElP8sw877kHAdtnTXggNHIKJP/nbolc=; b=l9uFnWzRgiQAW6pp+tHzrRLgX88Buc6us6d5sL6gOlK42/Su0rzVIk9qlodTC/h2zZ+Ifg/JFzku+5sRgYywV6P120iGxnAdzY9iOzmyJX+T2Smmn1M8KvEYumLVddBEJN76JY8Ipboudf+vXlgBx5qZi9m1byb1qMKh/WIbISQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664269216139930.0355015900274; Tue, 27 Sep 2022 02:00:16 -0700 (PDT) Received: from localhost ([::1]:33858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6Ro-0004zP-63 for importer@patchew.org; Tue, 27 Sep 2022 05:00:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pK-0006Rv-GR for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pE-0000aM-R5 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:24 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-22YGV06oOUWJmmAORQd38w-1; Tue, 27 Sep 2022 04:20:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8DE13C10234; Tue, 27 Sep 2022 08:20:16 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D220918EB3; Tue, 27 Sep 2022 08:19:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1A6BD18009AB; Tue, 27 Sep 2022 10:19:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IaAIzLnv6j0oElP8sw877kHAdtnTXggNHIKJP/nbolc=; b=YLH/tg7khT2FZtqn1W5y1Go+Z4Ynzmd1S0oDmO6p8Y/nDCGZJH5swfeOEQE/5eKurZkv4h zttw15HrVSFuQ5KFWzL9abXMD0nwh76s7Gqn9dtXqwUqTq3fcx6jPqwuTc3xIGqSn+hrj/ xN0G2B9RMtoXSYOSbhZjthbWUeROhmw= X-MC-Unique: 22YGV06oOUWJmmAORQd38w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Brad Smith , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 20/24] audio: Add sndio backend Date: Tue, 27 Sep 2022 10:19:08 +0200 Message-Id: <20220927081912.180983-21-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664269217699100001 From: Alexandre Ratchov sndio is the native API used by OpenBSD, although it has been ported to other *BSD's and Linux (packages for Ubuntu, Debian, Void, Arch, etc.). Signed-off-by: Brad Smith Signed-off-by: Alexandre Ratchov Reviewed-by: Volker R=C3=BCmelin Tested-by: Volker R=C3=BCmelin Message-Id: Signed-off-by: Gerd Hoffmann --- meson_options.txt | 4 +- audio/audio_template.h | 2 + audio/audio.c | 1 + audio/sndioaudio.c | 565 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 7 + audio/meson.build | 1 + meson.build | 9 +- qapi/audio.json | 25 +- qemu-options.hx | 16 + scripts/meson-buildoptions.sh | 7 +- 10 files changed, 632 insertions(+), 5 deletions(-) create mode 100644 audio/sndioaudio.c diff --git a/meson_options.txt b/meson_options.txt index 63f072517427..9df9e86d7d35 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -21,7 +21,7 @@ option('tls_priority', type : 'string', value : 'NORMAL', option('default_devices', type : 'boolean', value : true, description: 'Include a default selection of devices in emulators') option('audio_drv_list', type: 'array', value: ['default'], - choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', = 'pa', 'sdl'], + choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', = 'pa', 'sdl', 'sndio'], description: 'Set audio driver list') option('block_drv_rw_whitelist', type : 'string', value : '', description: 'set block driver read-write whitelist (by default aff= ects only QEMU, not tools like qemu-img)') @@ -240,6 +240,8 @@ option('oss', type: 'feature', value: 'auto', description: 'OSS sound support') option('pa', type: 'feature', value: 'auto', description: 'PulseAudio sound support') +option('sndio', type: 'feature', value: 'auto', + description: 'sndio sound support') =20 option('vhost_kernel', type: 'feature', value: 'auto', description: 'vhost kernel backend support') diff --git a/audio/audio_template.h b/audio/audio_template.h index 7192b19e7390..81860cea6202 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -336,6 +336,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)= (Audiodev *dev) return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE); case AUDIODEV_DRIVER_SDL: return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE); + case AUDIODEV_DRIVER_SNDIO: + return dev->u.sndio.TYPE; case AUDIODEV_DRIVER_SPICE: return dev->u.spice.TYPE; case AUDIODEV_DRIVER_WAV: diff --git a/audio/audio.c b/audio/audio.c index cfa4119c0598..5600593da043 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2030,6 +2030,7 @@ void audio_create_pdos(Audiodev *dev) CASE(OSS, oss, Oss); CASE(PA, pa, Pa); CASE(SDL, sdl, Sdl); + CASE(SNDIO, sndio, ); CASE(SPICE, spice, ); CASE(WAV, wav, ); =20 diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c new file mode 100644 index 000000000000..7c45276d36ce --- /dev/null +++ b/audio/sndioaudio.c @@ -0,0 +1,565 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2019 Alexandre Ratchov + */ + +/* + * TODO : + * + * Use a single device and open it in full-duplex rather than + * opening it twice (once for playback once for recording). + * + * This is the only way to ensure that playback doesn't drift with respect + * to recording, which is what guest systems expect. + */ + +#include +#include +#include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "audio.h" +#include "trace.h" + +#define AUDIO_CAP "sndio" +#include "audio_int.h" + +/* default latency in microseconds if no option is set */ +#define SNDIO_LATENCY_US 50000 + +typedef struct SndioVoice { + union { + HWVoiceOut out; + HWVoiceIn in; + } hw; + struct sio_par par; + struct sio_hdl *hdl; + struct pollfd *pfds; + struct pollindex { + struct SndioVoice *self; + int index; + } *pindexes; + unsigned char *buf; + size_t buf_size; + size_t sndio_pos; + size_t qemu_pos; + unsigned int mode; + unsigned int nfds; + bool enabled; +} SndioVoice; + +typedef struct SndioConf { + const char *devname; + unsigned int latency; +} SndioConf; + +/* needed for forward reference */ +static void sndio_poll_in(void *arg); +static void sndio_poll_out(void *arg); + +/* + * stop polling descriptors + */ +static void sndio_poll_clear(SndioVoice *self) +{ + struct pollfd *pfd; + int i; + + for (i =3D 0; i < self->nfds; i++) { + pfd =3D &self->pfds[i]; + qemu_set_fd_handler(pfd->fd, NULL, NULL, NULL); + } + + self->nfds =3D 0; +} + +/* + * write data to the device until it blocks or + * all of our buffered data is written + */ +static void sndio_write(SndioVoice *self) +{ + size_t todo, n; + + todo =3D self->qemu_pos - self->sndio_pos; + + /* + * transfer data to device, until it blocks + */ + while (todo > 0) { + n =3D sio_write(self->hdl, self->buf + self->sndio_pos, todo); + if (n =3D=3D 0) { + break; + } + self->sndio_pos +=3D n; + todo -=3D n; + } + + if (self->sndio_pos =3D=3D self->buf_size) { + /* + * we complete the block + */ + self->sndio_pos =3D 0; + self->qemu_pos =3D 0; + } +} + +/* + * read data from the device until it blocks or + * there no room any longer + */ +static void sndio_read(SndioVoice *self) +{ + size_t todo, n; + + todo =3D self->buf_size - self->sndio_pos; + + /* + * transfer data from the device, until it blocks + */ + while (todo > 0) { + n =3D sio_read(self->hdl, self->buf + self->sndio_pos, todo); + if (n =3D=3D 0) { + break; + } + self->sndio_pos +=3D n; + todo -=3D n; + } +} + +/* + * Set handlers for all descriptors libsndio needs to + * poll + */ +static void sndio_poll_wait(SndioVoice *self) +{ + struct pollfd *pfd; + int events, i; + + events =3D 0; + if (self->mode =3D=3D SIO_PLAY) { + if (self->sndio_pos < self->qemu_pos) { + events |=3D POLLOUT; + } + } else { + if (self->sndio_pos < self->buf_size) { + events |=3D POLLIN; + } + } + + /* + * fill the given array of descriptors with the events sndio + * wants, they are different from our 'event' variable because + * sndio may use descriptors internally. + */ + self->nfds =3D sio_pollfd(self->hdl, self->pfds, events); + + for (i =3D 0; i < self->nfds; i++) { + pfd =3D &self->pfds[i]; + if (pfd->fd < 0) { + continue; + } + qemu_set_fd_handler(pfd->fd, + (pfd->events & POLLIN) ? sndio_poll_in : NULL, + (pfd->events & POLLOUT) ? sndio_poll_out : NULL, + &self->pindexes[i]); + pfd->revents =3D 0; + } +} + +/* + * call-back called when one of the descriptors + * became readable or writable + */ +static void sndio_poll_event(SndioVoice *self, int index, int event) +{ + int revents; + + /* + * ensure we're not called twice this cycle + */ + sndio_poll_clear(self); + + /* + * make self->pfds[] look as we're returning from poll syscal, + * this is how sio_revents expects events to be. + */ + self->pfds[index].revents =3D event; + + /* + * tell sndio to handle events and return whether we can read or + * write without blocking. + */ + revents =3D sio_revents(self->hdl, self->pfds); + if (self->mode =3D=3D SIO_PLAY) { + if (revents & POLLOUT) { + sndio_write(self); + } + + if (self->qemu_pos < self->buf_size) { + audio_run(self->hw.out.s, "sndio_out"); + } + } else { + if (revents & POLLIN) { + sndio_read(self); + } + + if (self->qemu_pos < self->sndio_pos) { + audio_run(self->hw.in.s, "sndio_in"); + } + } + + /* + * audio_run() may have changed state + */ + if (self->enabled) { + sndio_poll_wait(self); + } +} + +/* + * return the upper limit of the amount of free play buffer space + */ +static size_t sndio_buffer_get_free(HWVoiceOut *hw) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + return self->buf_size - self->qemu_pos; +} + +/* + * return a buffer where data to play can be stored, + * its size is stored in the location pointed by the size argument. + */ +static void *sndio_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + *size =3D self->buf_size - self->qemu_pos; + return self->buf + self->qemu_pos; +} + +/* + * put back to sndio back-end a buffer returned by sndio_get_buffer_out() + */ +static size_t sndio_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + self->qemu_pos +=3D size; + sndio_poll_wait(self); + return size; +} + +/* + * return a buffer from where recorded data is available, + * its size is stored in the location pointed by the size argument. + * it may not exceed the initial value of "*size". + */ +static void *sndio_get_buffer_in(HWVoiceIn *hw, size_t *size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + size_t todo, max_todo; + + /* + * unlike the get_buffer_out() method, get_buffer_in() + * must return a buffer of at most the given size, see audio.c + */ + max_todo =3D *size; + + todo =3D self->sndio_pos - self->qemu_pos; + if (todo > max_todo) { + todo =3D max_todo; + } + + *size =3D todo; + return self->buf + self->qemu_pos; +} + +/* + * discard the given amount of recorded data + */ +static void sndio_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + self->qemu_pos +=3D size; + if (self->qemu_pos =3D=3D self->buf_size) { + self->qemu_pos =3D 0; + self->sndio_pos =3D 0; + } + sndio_poll_wait(self); +} + +/* + * call-back called when one of our descriptors becomes writable + */ +static void sndio_poll_out(void *arg) +{ + struct pollindex *pindex =3D (struct pollindex *) arg; + + sndio_poll_event(pindex->self, pindex->index, POLLOUT); +} + +/* + * call-back called when one of our descriptors becomes readable + */ +static void sndio_poll_in(void *arg) +{ + struct pollindex *pindex =3D (struct pollindex *) arg; + + sndio_poll_event(pindex->self, pindex->index, POLLIN); +} + +static void sndio_fini(SndioVoice *self) +{ + if (self->hdl) { + sio_close(self->hdl); + self->hdl =3D NULL; + } + + g_free(self->pfds); + g_free(self->pindexes); + g_free(self->buf); +} + +static int sndio_init(SndioVoice *self, + struct audsettings *as, int mode, Audiodev *dev) +{ + AudiodevSndioOptions *opts =3D &dev->u.sndio; + unsigned long long latency; + const char *dev_name; + struct sio_par req; + unsigned int nch; + int i, nfds; + + dev_name =3D opts->has_dev ? opts->dev : SIO_DEVANY; + latency =3D opts->has_latency ? opts->latency : SNDIO_LATENCY_US; + + /* open the device in non-blocking mode */ + self->hdl =3D sio_open(dev_name, mode, 1); + if (self->hdl =3D=3D NULL) { + dolog("failed to open device\n"); + return -1; + } + + self->mode =3D mode; + + sio_initpar(&req); + + switch (as->fmt) { + case AUDIO_FORMAT_S8: + req.bits =3D 8; + req.sig =3D 1; + break; + case AUDIO_FORMAT_U8: + req.bits =3D 8; + req.sig =3D 0; + break; + case AUDIO_FORMAT_S16: + req.bits =3D 16; + req.sig =3D 1; + break; + case AUDIO_FORMAT_U16: + req.bits =3D 16; + req.sig =3D 0; + break; + case AUDIO_FORMAT_S32: + req.bits =3D 32; + req.sig =3D 1; + break; + case AUDIO_FORMAT_U32: + req.bits =3D 32; + req.sig =3D 0; + break; + default: + dolog("unknown audio sample format\n"); + return -1; + } + + if (req.bits > 8) { + req.le =3D as->endianness ? 0 : 1; + } + + req.rate =3D as->freq; + if (mode =3D=3D SIO_PLAY) { + req.pchan =3D as->nchannels; + } else { + req.rchan =3D as->nchannels; + } + + /* set on-device buffer size */ + req.appbufsz =3D req.rate * latency / 1000000; + + if (!sio_setpar(self->hdl, &req)) { + dolog("failed set audio params\n"); + goto fail; + } + + if (!sio_getpar(self->hdl, &self->par)) { + dolog("failed get audio params\n"); + goto fail; + } + + nch =3D (mode =3D=3D SIO_PLAY) ? self->par.pchan : self->par.rchan; + + /* + * With the default setup, sndio supports any combination of parameters + * so these checks are mostly to catch configuration errors. + */ + if (self->par.bits !=3D req.bits || self->par.bps !=3D req.bits / 8 || + self->par.sig !=3D req.sig || (req.bits > 8 && self->par.le !=3D r= eq.le) || + self->par.rate !=3D as->freq || nch !=3D as->nchannels) { + dolog("unsupported audio params\n"); + goto fail; + } + + /* + * we use one block as buffer size; this is how + * transfers get well aligned + */ + self->buf_size =3D self->par.round * self->par.bps * nch; + + self->buf =3D g_malloc(self->buf_size); + if (self->buf =3D=3D NULL) { + dolog("failed to allocate audio buffer\n"); + goto fail; + } + + nfds =3D sio_nfds(self->hdl); + + self->pfds =3D g_malloc_n(nfds, sizeof(struct pollfd)); + if (self->pfds =3D=3D NULL) { + dolog("failed to allocate pollfd structures\n"); + goto fail; + } + + self->pindexes =3D g_malloc_n(nfds, sizeof(struct pollindex)); + if (self->pindexes =3D=3D NULL) { + dolog("failed to allocate pollindex structures\n"); + goto fail; + } + + for (i =3D 0; i < nfds; i++) { + self->pindexes[i].self =3D self; + self->pindexes[i].index =3D i; + } + + return 0; +fail: + sndio_fini(self); + return -1; +} + +static void sndio_enable(SndioVoice *self, bool enable) +{ + if (enable) { + sio_start(self->hdl); + self->enabled =3D true; + sndio_poll_wait(self); + } else { + self->enabled =3D false; + sndio_poll_clear(self); + sio_stop(self->hdl); + } +} + +static void sndio_enable_out(HWVoiceOut *hw, bool enable) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_enable(self, enable); +} + +static void sndio_enable_in(HWVoiceIn *hw, bool enable) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_enable(self, enable); +} + +static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *op= aque) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + if (sndio_init(self, as, SIO_PLAY, opaque) =3D=3D -1) { + return -1; + } + + audio_pcm_init_info(&hw->info, as); + hw->samples =3D self->par.round; + return 0; +} + +static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as, void *opaq= ue) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + if (sndio_init(self, as, SIO_REC, opaque) =3D=3D -1) { + return -1; + } + + audio_pcm_init_info(&hw->info, as); + hw->samples =3D self->par.round; + return 0; +} + +static void sndio_fini_out(HWVoiceOut *hw) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_fini(self); +} + +static void sndio_fini_in(HWVoiceIn *hw) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_fini(self); +} + +static void *sndio_audio_init(Audiodev *dev) +{ + assert(dev->driver =3D=3D AUDIODEV_DRIVER_SNDIO); + return dev; +} + +static void sndio_audio_fini(void *opaque) +{ +} + +static struct audio_pcm_ops sndio_pcm_ops =3D { + .init_out =3D sndio_init_out, + .fini_out =3D sndio_fini_out, + .enable_out =3D sndio_enable_out, + .write =3D audio_generic_write, + .buffer_get_free =3D sndio_buffer_get_free, + .get_buffer_out =3D sndio_get_buffer_out, + .put_buffer_out =3D sndio_put_buffer_out, + .init_in =3D sndio_init_in, + .fini_in =3D sndio_fini_in, + .read =3D audio_generic_read, + .enable_in =3D sndio_enable_in, + .get_buffer_in =3D sndio_get_buffer_in, + .put_buffer_in =3D sndio_put_buffer_in, +}; + +static struct audio_driver sndio_audio_driver =3D { + .name =3D "sndio", + .descr =3D "sndio https://sndio.org", + .init =3D sndio_audio_init, + .fini =3D sndio_audio_fini, + .pcm_ops =3D &sndio_pcm_ops, + .can_be_default =3D 1, + .max_voices_out =3D INT_MAX, + .max_voices_in =3D INT_MAX, + .voice_size_out =3D sizeof(SndioVoice), + .voice_size_in =3D sizeof(SndioVoice) +}; + +static void register_audio_sndio(void) +{ + audio_driver_register(&sndio_audio_driver); +} + +type_init(register_audio_sndio); diff --git a/MAINTAINERS b/MAINTAINERS index 738c4eb647c8..269e07cf4777 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2438,6 +2438,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndioaudio.c X: audio/spiceaudio.c F: qapi/audio.json =20 @@ -2482,6 +2483,12 @@ R: Thomas Huth S: Odd Fixes F: audio/sdlaudio.c =20 +Sndio Audio backend +M: Gerd Hoffmann +R: Alexandre Ratchov +S: Odd Fixes +F: audio/sndioaudio.c + Block layer core M: Kevin Wolf M: Hanna Reitz diff --git a/audio/meson.build b/audio/meson.build index 3abee908602a..34aed7834223 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -17,6 +17,7 @@ foreach m : [ ['pa', pulse, files('paaudio.c')], ['sdl', sdl, files('sdlaudio.c')], ['jack', jack, files('jackaudio.c')], + ['sndio', sndio, files('sndioaudio.c')], ['spice', spice, files('spiceaudio.c')] ] if m[1].found() diff --git a/meson.build b/meson.build index d9ac91ff3659..13db89c65af1 100644 --- a/meson.build +++ b/meson.build @@ -675,6 +675,11 @@ if not get_option('jack').auto() or have_system jack =3D dependency('jack', required: get_option('jack'), method: 'pkg-config', kwargs: static_kwargs) endif +sndio =3D not_found +if not get_option('sndio').auto() or have_system + sndio =3D dependency('sndio', required: get_option('sndio'), + method: 'pkg-config', kwargs: static_kwargs) +endif =20 spice_protocol =3D not_found if not get_option('spice_protocol').auto() or have_system @@ -1591,6 +1596,7 @@ if have_system 'oss': oss.found(), 'pa': pulse.found(), 'sdl': sdl.found(), + 'sndio': sndio.found(), } foreach k, v: audio_drivers_available config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v) @@ -1598,7 +1604,7 @@ if have_system =20 # Default to native drivers first, OSS second, SDL third audio_drivers_priority =3D \ - [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \ + [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \ (targetos =3D=3D 'linux' ? [] : [ 'sdl' ]) audio_drivers_default =3D [] foreach k: audio_drivers_priority @@ -3922,6 +3928,7 @@ if vnc.found() endif if targetos not in ['darwin', 'haiku', 'windows'] summary_info +=3D {'OSS support': oss} + summary_info +=3D {'sndio support': sndio} elif targetos =3D=3D 'darwin' summary_info +=3D {'CoreAudio support': coreaudio} elif targetos =3D=3D 'windows' diff --git a/qapi/audio.json b/qapi/audio.json index 8099e3d7f13b..1e0a24bdfc40 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -106,6 +106,28 @@ '*out': 'AudiodevAlsaPerDirectionOptions', '*threshold': 'uint32' } } =20 +## +# @AudiodevSndioOptions: +# +# Options of the sndio audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @dev: the name of the sndio device to use (default 'default') +# +# @latency: play buffer size (in microseconds) +# +# Since: 7.2 +## +{ 'struct': 'AudiodevSndioOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*dev': 'str', + '*latency': 'uint32'} } + ## # @AudiodevCoreaudioPerDirectionOptions: # @@ -387,7 +409,7 @@ ## { 'enum': 'AudiodevDriver', 'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', = 'pa', - 'sdl', 'spice', 'wav' ] } + 'sdl', 'sndio', 'spice', 'wav' ] } =20 ## # @Audiodev: @@ -418,5 +440,6 @@ 'oss': 'AudiodevOssOptions', 'pa': 'AudiodevPaOptions', 'sdl': 'AudiodevSdlOptions', + 'sndio': 'AudiodevSndioOptions', 'spice': 'AudiodevGenericOptions', 'wav': 'AudiodevWavOptions' } } diff --git a/qemu-options.hx b/qemu-options.hx index d8b5ce5b4354..2ff06884f42d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -769,6 +769,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, "-audiodev sdl,id=3Did[,prop[=3Dvalue][,...]]\n" " in|out.buffer-count=3D number of buffers\n" #endif +#ifdef CONFIG_AUDIO_SNDIO + "-audiodev sndio,id=3Did[,prop[=3Dvalue][,...]]\n" +#endif #ifdef CONFIG_SPICE "-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]\n" #endif @@ -935,6 +938,19 @@ SRST ``in|out.buffer-count=3Dcount`` Sets the count of the buffers. =20 +``-audiodev sndio,id=3Did[,prop[=3Dvalue][,...]]`` + Creates a backend using SNDIO. This backend is available on + OpenBSD and most other Unix-like systems. + + Sndio specific options are: + + ``in|out.dev=3Ddevice`` + Specify the sndio device to use for input and/or output. Default + is ``default``. + + ``in|out.latency=3Dusecs`` + Sets the desired period length in microseconds. + ``-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]`` Creates a backend that sends audio through SPICE. This backend requires ``-spice`` and automatically selected in that case, so diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 359b04e0e6d3..f08e3a8a7e02 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -1,7 +1,7 @@ # This file is generated by meson-buildoptions.py, do not edit! meson_options_help() { - printf "%s\n" ' --audio-drv-list=3DCHOICES Set audio driver list [defau= lt] (choices:' - printf "%s\n" ' alsa/coreaudio/default/dsound/= jack/oss/pa/sdl)' + printf "%s\n" ' --audio-drv-list=3DCHOICES Set audio driver list [defau= lt] (choices: alsa/co' + printf "%s\n" ' reaudio/default/dsound/jack/os= s/pa/sdl/sndio)' printf "%s\n" ' --block-drv-ro-whitelist=3DVALUE' printf "%s\n" ' set block driver read-only whi= telist (by default' printf "%s\n" ' affects only QEMU, not tools l= ike qemu-img)' @@ -144,6 +144,7 @@ meson_options_help() { printf "%s\n" ' slirp-smbd use smbd (at path --smbd=3D*) in slirp = networking' printf "%s\n" ' smartcard CA smartcard emulation support' printf "%s\n" ' snappy snappy compression support' + printf "%s\n" ' sndio sndio sound support' printf "%s\n" ' sparse sparse checker' printf "%s\n" ' spice Spice server support' printf "%s\n" ' spice-protocol Spice protocol support' @@ -393,6 +394,8 @@ _meson_option_parse() { --disable-smartcard) printf "%s" -Dsmartcard=3Ddisabled ;; --enable-snappy) printf "%s" -Dsnappy=3Denabled ;; --disable-snappy) printf "%s" -Dsnappy=3Ddisabled ;; + --enable-sndio) printf "%s" -Dsndio=3Denabled ;; + --disable-sndio) printf "%s" -Dsndio=3Ddisabled ;; --enable-sparse) printf "%s" -Dsparse=3Denabled ;; --disable-sparse) printf "%s" -Dsparse=3Ddisabled ;; --sphinx-build=3D*) quote_sh "-Dsphinx_build=3D$2" ;; --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268991; cv=none; d=zohomail.com; s=zohoarc; b=E+wa8DwpxzvTPCwob3q48TGNHMhNP2uJ0K+pWIAeUy3KRb+iTQfH6sgwjPOqKTubdeeLLT6yvTno/BI6tn0ogCB80WuxGrjVW2wWOl2LusU07zbQT6cSieRNaFmL+6szKgkYlfwlEcGWrZ+zsab5/x18QYhRbpKlAf/kzDg0HFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268991; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TJpHQZVHvsstAM7uMbP+gvvt8yEVZkMarUyInSA1C80=; b=kBjOKHgC/ky46SKknlhUP+0x53Ko1S8ME/T0i70EC1C9rxXrmOQJK/5LxDM7kaC7HcTNa8W0c4vpkiQQTwCKm8Y1iYjrCLkmouU8I8hQ60va2TeoMJnvGzbSkHL/Msv4cq3VHetNGLoT0YCipNgwur9Qmk7CL3iZPzf1ex918xk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268991459271.2093022297943; Tue, 27 Sep 2022 01:56:31 -0700 (PDT) Received: from localhost ([::1]:55040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6OE-00080q-Du for importer@patchew.org; Tue, 27 Sep 2022 04:56:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pB-0006MR-Vf for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5p9-0000Zx-QV for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:17 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-356-ZkUXjyMfO4C5daSd0lqRVQ-1; Tue, 27 Sep 2022 04:20:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C65A3C10224; Tue, 27 Sep 2022 08:20:09 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 014582011566; Tue, 27 Sep 2022 08:20:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2A7A018009B9; Tue, 27 Sep 2022 10:19:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TJpHQZVHvsstAM7uMbP+gvvt8yEVZkMarUyInSA1C80=; b=Sx/94nlAu2k4C48I8W7p5g1J5830GH2lA1DIWir+z7WLoofabIUVYq95O/bQbRVCRrUAeT kFjPy9birG4rQaFk208VnYNSpjzf0/l8b+da+V1fZ5AVx66tthhZQACr1z+tgpDlvQKPvs 2Ijvyk+MKeIEzNsxgE186Dw8ZlGxYuQ= X-MC-Unique: ZkUXjyMfO4C5daSd0lqRVQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 21/24] Revert "audio: Log context for audio bug" Date: Tue, 27 Sep 2022 10:19:09 +0200 Message-Id: <20220927081912.180983-22-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268992046100001 From: Volker R=C3=BCmelin This reverts commit 8e30d39bade3010387177ca23dbc2244352ed4a3. Revert commit 8e30d39bad "audio: Log context for audio bug" to make error propagation work again. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220917131626.7521-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio_template.h | 27 +++++++++++++++------------ audio/audio.c | 25 +++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 81860cea6202..98ab557684d8 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -59,13 +59,12 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioStat= e *s, if (audio_bug(__func__, !voice_size && max_voices)) { dolog ("drv=3D`%s' voice_size=3D0 max_voices=3D%d\n", drv->name, max_voices); - abort(); + glue (s->nb_hw_voices_, TYPE) =3D 0; } =20 if (audio_bug(__func__, voice_size && !max_voices)) { dolog ("drv=3D`%s' voice_size=3D%d max_voices=3D0\n", drv->name, voice_size); - abort(); } } =20 @@ -82,7 +81,6 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW = *hw) size_t samples =3D hw->samples; if (audio_bug(__func__, samples =3D=3D 0)) { dolog("Attempted to allocate empty buffer\n"); - abort(); } =20 HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * s= amples); @@ -254,12 +252,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioSta= te *s, =20 if (audio_bug(__func__, !drv)) { dolog ("No host audio driver\n"); - abort(); + return NULL; } =20 if (audio_bug(__func__, !drv->pcm_ops)) { dolog ("Host audio driver without pcm_ops\n"); - abort(); + return NULL; } =20 hw =3D audio_calloc(__func__, 1, glue(drv->voice_size_, TYPE)); @@ -277,13 +275,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioSta= te *s, QLIST_INIT (&hw->cap_head); #endif if (glue (hw->pcm_ops->init_, TYPE) (hw, as, s->drv_opaque)) { - g_free(hw); - return NULL; + goto err0; } =20 if (audio_bug(__func__, hw->samples <=3D 0)) { dolog("hw->samples=3D%zd\n", hw->samples); - abort(); + goto err1; } =20 if (hw->info.is_float) { @@ -312,6 +309,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioStat= e *s, audio_attach_capture (hw); #endif return hw; + + err1: + glue (hw->pcm_ops->fini_, TYPE) (hw); + err0: + g_free (hw); + return NULL; } =20 AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev) @@ -434,7 +437,7 @@ void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *= sw) if (sw) { if (audio_bug(__func__, !card)) { dolog ("card=3D%p\n", card); - abort(); + return; } =20 glue (audio_close_, TYPE) (sw); @@ -456,7 +459,7 @@ SW *glue (AUD_open_, TYPE) ( if (audio_bug(__func__, !card || !name || !callback_fn || !as)) { dolog ("card=3D%p name=3D%p callback_fn=3D%p as=3D%p\n", card, name, callback_fn, as); - abort(); + goto fail; } =20 s =3D card->state; @@ -467,12 +470,12 @@ SW *glue (AUD_open_, TYPE) ( =20 if (audio_bug(__func__, audio_validate_settings(as))) { audio_print_settings (as); - abort(); + goto fail; } =20 if (audio_bug(__func__, !s->drv)) { dolog ("Can not open `%s' (no host audio driver)\n", name); - abort(); + goto fail; } =20 if (sw && audio_pcm_info_eq (&sw->info, as)) { diff --git a/audio/audio.c b/audio/audio.c index 5600593da043..d96a13055940 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -118,6 +118,7 @@ int audio_bug (const char *funcname, int cond) AUD_log (NULL, "I am sorry\n"); } AUD_log (NULL, "Context:\n"); + abort(); } =20 return cond; @@ -138,7 +139,7 @@ static inline int audio_bits_to_index (int bits) default: audio_bug ("bits_to_index", 1); AUD_log (NULL, "invalid bits %d\n", bits); - abort(); + return 0; } } =20 @@ -156,7 +157,7 @@ void *audio_calloc (const char *funcname, int nmemb, si= ze_t size) AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n", funcname); AUD_log (NULL, "nmemb=3D%d size=3D%zu (len=3D%zu)\n", nmemb, size,= len); - abort(); + return NULL; } =20 return g_malloc0 (len); @@ -543,7 +544,7 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) size_t live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in = (hw); if (audio_bug(__func__, live > hw->conv_buf->size)) { dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); - abort(); + return 0; } return live; } @@ -581,7 +582,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) } if (audio_bug(__func__, live > hw->conv_buf->size)) { dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); - abort(); + return 0; } =20 rpos =3D audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); @@ -656,7 +657,7 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw= , int *nb_live) =20 if (audio_bug(__func__, live > hw->mix_buf->size)) { dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hw->mix_bu= f->size); - abort(); + return 0; } return live; } @@ -706,7 +707,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) live =3D sw->total_hw_samples_mixed; if (audio_bug(__func__, live > hwsamples)) { dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hwsamples); - abort(); + return 0; } =20 if (live =3D=3D hwsamples) { @@ -998,7 +999,7 @@ static size_t audio_get_avail (SWVoiceIn *sw) if (audio_bug(__func__, live > sw->hw->conv_buf->size)) { dolog("live=3D%zu sw->hw->conv_buf->size=3D%zu\n", live, sw->hw->conv_buf->size); - abort(); + return 0; } =20 ldebug ( @@ -1028,7 +1029,7 @@ static size_t audio_get_free(SWVoiceOut *sw) if (audio_bug(__func__, live > sw->hw->mix_buf->size)) { dolog("live=3D%zu sw->hw->mix_buf->size=3D%zu\n", live, sw->hw->mix_buf->size); - abort(); + return 0; } =20 dead =3D sw->hw->mix_buf->size - live; @@ -1170,7 +1171,7 @@ static void audio_run_out (AudioState *s) =20 if (audio_bug(__func__, live > hw->mix_buf->size)) { dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hw->mix_bu= f->size); - abort(); + continue; } =20 if (hw->pending_disable && !nb_live) { @@ -1203,7 +1204,7 @@ static void audio_run_out (AudioState *s) if (audio_bug(__func__, hw->mix_buf->pos >=3D hw->mix_buf->size)) { dolog("hw->mix_buf->pos=3D%zu hw->mix_buf->size=3D%zu played= =3D%zu\n", hw->mix_buf->pos, hw->mix_buf->size, played); - abort(); + hw->mix_buf->pos =3D 0; } =20 #ifdef DEBUG_OUT @@ -1223,7 +1224,7 @@ static void audio_run_out (AudioState *s) if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) { dolog("played=3D%zu sw->total_hw_samples_mixed=3D%zu\n", played, sw->total_hw_samples_mixed); - abort(); + played =3D sw->total_hw_samples_mixed; } =20 sw->total_hw_samples_mixed -=3D played; @@ -1346,7 +1347,7 @@ static void audio_run_capture (AudioState *s) if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)= ) { dolog("captured=3D%zu sw->total_hw_samples_mixed=3D%zu\n", captured, sw->total_hw_samples_mixed); - abort(); + captured =3D sw->total_hw_samples_mixed; } =20 sw->total_hw_samples_mixed -=3D captured; --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268744; cv=none; d=zohomail.com; s=zohoarc; b=Cx6/zR0kShR9Llqc4Pa0wzL9yIPssWZKe0r0twmLM+v6ll0AUjmSbKFDcmYrEXGJ6BgChuqz/b+mVSxRqs+pY3puL0VBY5ajG+a8UXLMEqQaQ0Gq33RURa/K1U5vXvU2DcryinFqlFs9BirW1QYvQkv1ZiU9T7xgXyALhl1djxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VdNGq6hWlpuhjkU34UysDLKoPOaBocYG/ganxIELqNM=; b=npp/w3pNRCAGXfoUT979QkCKDB/1sBpPgZ02xR96J2B2EW8Id4QTomOzdpz7H/+tij8gS12S36gA7bxabKVY2wdnJUAeqZnWouH+SK2f9kYMWMAIpPi4lcwfUw29AqWuwNISUY2W3XM5iK63E3hg25VWS2gH5T5EiJc+EHH96Yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268744819488.37659582782885; Tue, 27 Sep 2022 01:52:24 -0700 (PDT) Received: from localhost ([::1]:43892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6KF-0002Jr-96 for importer@patchew.org; Tue, 27 Sep 2022 04:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pB-0006MQ-6u for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5p9-0000Zr-20 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-hY-4SkWOMk6cGdxy4hiCGg-1; Tue, 27 Sep 2022 04:20:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DFDE3803D4B; Tue, 27 Sep 2022 08:20:10 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C720200E1E5; Tue, 27 Sep 2022 08:20:10 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 378BE18009BE; Tue, 27 Sep 2022 10:19:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VdNGq6hWlpuhjkU34UysDLKoPOaBocYG/ganxIELqNM=; b=ONe1WS2DYKQzAt5lfBA43QoWdJFMRktrMWpR3hDaXXKmPu9Pj5H8fmwMOhP0THH9BAI52S 0jGYDBzTCutv/AIB5jr1YYas/VX0lnr5ujSL+h0f8y2FDUSBT7Dc7sLXgohhzrOy0d7oic 5rdp63uVUVv1ALY8ZNa/6UgBbZpbHl4= X-MC-Unique: hY-4SkWOMk6cGdxy4hiCGg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 22/24] audio: remove abort() in audio_bug() Date: Tue, 27 Sep 2022 10:19:10 +0200 Message-Id: <20220927081912.180983-23-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268747137100001 From: Volker R=C3=BCmelin Commit ab32b78cd1 "audio: Simplify audio_bug() removing old code" introduced abort() in audio_bug() for regular builds. audio_bug() was never meant to abort QEMU for the following reasons. - There's code in audio_bug() that expects audio_bug() gets called more than once with error condition true. The variable 'shown' is only 0 on first error. - All call sites test the return code of audio_bug(), print an error context message and handle the errror. - The abort() in audio_bug() enables a class of guest-triggered aborts similar to the Launchpad Bug #1910603 at https://bugs.launchpad.net/bugs/1910603. Fixes: ab32b78cd1 "audio: Simplify audio_bug() removing old code" Buglink: https://bugs.launchpad.net/bugs/1910603 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220917131626.7521-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index d96a13055940..df6818ed5598 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -118,7 +118,6 @@ int audio_bug (const char *funcname, int cond) AUD_log (NULL, "I am sorry\n"); } AUD_log (NULL, "Context:\n"); - abort(); } =20 return cond; --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664268753; cv=none; d=zohomail.com; s=zohoarc; b=R2jDNyheCFYl0XwCk5UJf8j4bmiSC+dXLAaToUkxZ0Ebl/k4NDWatUAO/k2aRzU8pxnRvLQ6woHjIxCOTFKyE3/FHbS82vbexpXw7kQ2D4bB/t37IUxWzjzv1uqXQ+jJ8w0/PjrDxXzuDXrD21X8L4h4eG6Z4VYZk6mtb1upweA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664268753; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tbw9W7pPdJJ3uWnYTKdZaKFVJP/G2X2I0succO0vGcQ=; b=J3JQl5PiPKT/K4f82y02gv8CCzcT33BXnSTL4UEb7pL8O0XWYY/r4nByG8L1/njIA1K8OBV3RsIsTqHigeEJIrjmXFTPvo/D2iwrk21QHrIE2yX/m9w4Lk3cW/aFOObXhQo3fvnQr9+fu25mq/z3raB76aUet0zkAVHDVOvw2Z8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664268753565534.9945164986584; Tue, 27 Sep 2022 01:52:33 -0700 (PDT) Received: from localhost ([::1]:33452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6KO-0002k8-8p for importer@patchew.org; Tue, 27 Sep 2022 04:52:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pE-0006N0-Lj for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pC-0000aC-2e for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:19 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-CL-FyslxPT-fc1e-sTZuAQ-1; Tue, 27 Sep 2022 04:20:13 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BC8538173C3; Tue, 27 Sep 2022 08:20:12 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B536492B04; Tue, 27 Sep 2022 08:20:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 449DB18009BF; Tue, 27 Sep 2022 10:19:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tbw9W7pPdJJ3uWnYTKdZaKFVJP/G2X2I0succO0vGcQ=; b=hmH0JccdPy8vJy79//U+8WdKS3ffE4ujpyoQNJLjgrTQULGbVBwBIYzZxAHzSMaJ7s/igk 8fovmQaJt7SeF91vvEGcjlgNi+kZoJYRnNEjpwW/zDaQ97lKjtxJ325bYvQQaqFwWAakUd QeIJUEtRDPLuOP7ltY4ax7k77moXwKU= X-MC-Unique: CL-FyslxPT-fc1e-sTZuAQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Qiang Liu , Mauro Matteo Cascella Subject: [PULL 23/24] hw/display/ati_2d: Fix buffer overflow in ati_2d_blt (CVE-2021-3638) Date: Tue, 27 Sep 2022 10:19:11 +0200 Message-Id: <20220927081912.180983-24-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664268755268100001 From: Philippe Mathieu-Daud=C3=A9 When building QEMU with DEBUG_ATI defined then running with '-device ati-vga,romfile=3D"" -d unimp,guest_errors -trace ati\*' we get: ati_mm_write 4 0x16c0 DP_CNTL <- 0x1 ati_mm_write 4 0x146c DP_GUI_MASTER_CNTL <- 0x2 ati_mm_write 4 0x16c8 DP_MIX <- 0xff0000 ati_mm_write 4 0x16c4 DP_DATATYPE <- 0x2 ati_mm_write 4 0x224 CRTC_OFFSET <- 0x0 ati_mm_write 4 0x142c DST_PITCH_OFFSET <- 0xfe00000 ati_mm_write 4 0x1420 DST_Y <- 0x3fff ati_mm_write 4 0x1410 DST_HEIGHT <- 0x3fff ati_mm_write 4 0x1588 DST_WIDTH_X <- 0x3fff3fff ati_2d_blt: vram:0x7fff5fa00000 addr:0 ds:0x7fff61273800 stride:2560 bpp:= 32 rop:0xff ati_2d_blt: 0 0 0, 0 127 0, (0,0) -> (16383,16383) 16383x16383 > ^ ati_2d_blt: pixman_fill(dst:0x7fff5fa00000, stride:254, bpp:8, x:16383, y= :16383, w:16383, h:16383, xor:0xff000000) Thread 3 "qemu-system-i38" received signal SIGSEGV, Segmentation fault. (gdb) bt #0 0x00007ffff7f62ce0 in sse2_fill.lto_priv () at /lib64/libpixman-1.so.0 #1 0x00007ffff7f09278 in pixman_fill () at /lib64/libpixman-1.so.0 #2 0x0000555557b5a9af in ati_2d_blt (s=3D0x631000028800) at hw/display/a= ti_2d.c:196 #3 0x0000555557b4b5a2 in ati_mm_write (opaque=3D0x631000028800, addr=3D5= 512, data=3D1073692671, size=3D4) at hw/display/ati.c:843 #4 0x0000555558b90ec4 in memory_region_write_accessor (mr=3D0x631000039c= c0, addr=3D5512, ..., size=3D4, ...) at softmmu/memory.c:492 Commit 584acf34cb0 ("ati-vga: Fix reverse bit blts") introduced the local dst_x and dst_y which adjust the (x, y) coordinates depending on the direction in the SRCCOPY ROP3 operation, but forgot to address the same issue for the PATCOPY, BLACKNESS and WHITENESS operations, which also call pixman_fill(). Fix that now by using the adjusted coordinates in the pixman_fill call, and update the related debug printf(). Reported-by: Qiang Liu Fixes: 584acf34cb0 ("ati-vga: Fix reverse bit blts") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Mauro Matteo Cascella Message-Id: <20210906153103.1661195-1-philmd@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/display/ati_2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 4dc10ea79529..692bec91de45 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -84,7 +84,7 @@ void ati_2d_blt(ATIVGAState *s) DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n", s->regs.src_offset, s->regs.dst_offset, s->regs.default_offset, s->regs.src_pitch, s->regs.dst_pitch, s->regs.default_pitch, - s->regs.src_x, s->regs.src_y, s->regs.dst_x, s->regs.dst_y, + s->regs.src_x, s->regs.src_y, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? '>' : '<'), (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? 'v' : '^')); @@ -180,11 +180,11 @@ void ati_2d_blt(ATIVGAState *s) dst_stride /=3D sizeof(uint32_t); DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", dst_bits, dst_stride, bpp, - s->regs.dst_x, s->regs.dst_y, + dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, filler); pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, - s->regs.dst_x, s->regs.dst_y, + dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, filler); if (dst_bits >=3D s->vga.vram_ptr + s->vga.vbe_start_addr && --=20 2.37.3 From nobody Mon May 20 21:31:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664269122; cv=none; d=zohomail.com; s=zohoarc; b=WE6bUYet2WAvGBVAo/eERkhGT71lSnM3b5vFJQHxfghwb4rpiazurholsG5MMy/SXtptd3G1rw+FVcNqKGbXyOd8Tnl6Yc6ujq+d47BLb8tp4e58F3YUde1HjoStg3tdoR4FJo3K3GMpWOosldp+ql4VqWyYGIY/L2o2cH977vY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664269122; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wap4bE3M153XlNUESFRpL6QFaSZ1Y/NXM6sOa6Kq+is=; b=Rn7dHZktDXA1QwuIsxOwmoRTQcRD7GpOHPJAw6ZoO4PWL5NXKHU0HsbA7IBPYf4uSaqJaaSsvEAtkqh6bd6M1RH0sC3B6B/g8+SgXbyV+9LfNzp3isvVvBFdGFE0UWelYZCKTSnfOzLhGXUMz/WumM8wVST/GlJS+gnpDOFw5ww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664269122813881.3766231368254; Tue, 27 Sep 2022 01:58:42 -0700 (PDT) Received: from localhost ([::1]:59692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od6QL-000248-Hl for importer@patchew.org; Tue, 27 Sep 2022 04:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pI-0006Qk-GV for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55941) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od5pE-0000aO-S7 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 04:20:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-HK9T0suaNLeg4jL08XQ1RQ-1; Tue, 27 Sep 2022 04:20:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 106BA85A5A6; Tue, 27 Sep 2022 08:20:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5F4540C6EC2; Tue, 27 Sep 2022 08:20:13 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 533AD18009CC; Tue, 27 Sep 2022 10:19:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664266820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wap4bE3M153XlNUESFRpL6QFaSZ1Y/NXM6sOa6Kq+is=; b=XSbBt7uJeNilmbDQZLdv7ZfA/WkISg+9XwGgu3Gsd04ER3ZwB8TqGfpn98dIHyyLk0Wb9P y3Wa9Q6trnWmFWjS4jduMh6ZFgDAt93IOxfTww2wG7xIotIAXE5wcsDdjxqad3F80vsisC ax95MgheajfbXi7p80p2URjpmGYGUiw= X-MC-Unique: HK9T0suaNLeg4jL08XQ1RQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Qiuhao Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake , Darren Kenny , Bandan Das , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Akihiko Odaki , Alexandre Ratchov , Laurent Vivier , Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell , Dongwon Kim , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 24/24] virtio-gpu: update scanout if there is any area covered by the rect Date: Tue, 27 Sep 2022 10:19:12 +0200 Message-Id: <20220927081912.180983-25-kraxel@redhat.com> In-Reply-To: <20220927081912.180983-1-kraxel@redhat.com> References: <20220927081912.180983-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664269124935100001 From: Dongwon Kim The scanout is currently updated only if the whole rect is inside the scanout space. This is not a correct condition because the scanout should be updated even a small area in the scanout space is covered by the rect. Cc: Gerd Hoffmann Signed-off-by: Dongwon Kim Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220909014052.7297-1-dongwon.kim@intel.com> Signed-off-by: Gerd Hoffmann --- hw/display/virtio-gpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 20cc703dcc6e..5e15c79b94a5 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -515,9 +515,10 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { scanout =3D &g->parent_obj.scanout[i]; if (scanout->resource_id =3D=3D res->resource_id && - rf.r.x >=3D scanout->x && rf.r.y >=3D scanout->y && - rf.r.x + rf.r.width <=3D scanout->x + scanout->width && - rf.r.y + rf.r.height <=3D scanout->y + scanout->height && + rf.r.x < scanout->x + scanout->width && + rf.r.x + rf.r.width >=3D scanout->x && + rf.r.y < scanout->y + scanout->height && + rf.r.y + rf.r.height >=3D scanout->y && console_has_gl(scanout->con)) { dpy_gl_update(scanout->con, 0, 0, scanout->width, scanout->height); --=20 2.37.3