From nobody Sun Jan 25 10:15:21 2026 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=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1769116431; cv=none; d=zohomail.com; s=zohoarc; b=BUCD7VVU3RxIlbhTh/QtUx9mI9OG3/m/kU+8dnBrvLqDxRzzOJOsk2deSgUS/Q+rROLtuKAe9gh/Gvkz5Z3cd9Q5Fy/42ejez7hiJlFHxyMng2ou9tSnsYO5/Y0wVp6H8sSXV7m1tMhRXx7Ds7z0UwQIvfWjPzqfOuHQmJvhxPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769116431; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Kj/7/II76qCnvHhgi4r8FVH9LGVK/+/wBOJAdlrkCxI=; b=DGqV/rFjiQR1kepoaVscua/QRgiN3FWWzv1FR8zhgd582BH/ZFM3HSkM4sPLoRWOMzvnYo1bgKORlCCSDqq45fXaGyG7KrZigqmruLoyY9m13bc0mybFFpC7FHuqycGvk1NcJAfAZy3+/Ycub24KH1dq+M7JptBTP5uqVhAdDXg= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176911643113884.81052604789363; Thu, 22 Jan 2026 13:13:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vj1zP-0003ti-AO; Thu, 22 Jan 2026 16:13:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vj0Tm-0006s9-6F for qemu-devel@nongnu.org; Thu, 22 Jan 2026 14:36:30 -0500 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vj0Tk-0000Ht-EM for qemu-devel@nongnu.org; Thu, 22 Jan 2026 14:36:29 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id E024160146; Thu, 22 Jan 2026 19:36:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49B40C116C6; Thu, 22 Jan 2026 19:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769110584; bh=CdsJZ+0bNqLv87Inc1EV8wPcun8YQax+psc0i3jYUXA=; h=From:To:Cc:Subject:Date:From; b=J235xgmXHyApsZ3okq43cgOXzPbVbvEJUVW3sAkufFCuVwrE8ruQ5QxUZk4gAiEcO 60l5/1q1U2wlSSmW4sL/9FjMlPC76RyC3zOX1BxxIEXk/SiGqUTZhPVYXlSwN+/afW NMbApv68kzNzR1QScrVdgk7GGGUQkIO/7XdbObOC5t4rv9mJKwW6Lp97nyJo2RwTQ6 Gt2Wp7GB6kHC+t8grtjlhDWNLCfK3zNKDUJWys6aSSyloc1j8Z2TuKD4K+fRnF+d++ ZvOLyAm781gBNNRuW2R2MKhwAeU27asgnH0UiNmhq3k0aNbh7cfdf0X4lYtA8prVGW HOx29HJh3QegA== From: Josh Poimboeuf To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Justin Forbes , Alexey Makhalov Subject: [PATCH] hw/i386/vmmouse: Fix hypercall clobbers Date: Thu, 22 Jan 2026 11:36:20 -0800 Message-ID: X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 (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=2600:3c04:e001:324:0:1991:8:25; envelope-from=jpoimboe@kernel.org; helo=tor.source.kernel.org 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.07, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 22 Jan 2026 16:13:09 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1769116434547154100 Content-Type: text/plain; charset="utf-8" Fedora QA reported the following panic: BUG: unable to handle page fault for address: 0000000040003e54 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 1082ec067 P4D 0 Oops: Oops: 0002 [#1] SMP NOPTI CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.19.0-0.rc4.260108gf0b9= d8eb98df.34.fc43.x86_64 #1 PREEMPT(lazy) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20251119-3.= fc43 11/19/2025 RIP: 0010:vmware_hypercall4.constprop.0+0x52/0x90 Code: 48 83 c4 20 5b e9 69 f0 fc fe 8b 05 a0 c1 b2 01 85 c0 74 23 b8 68 5= 8 4d 56 b9 27 00 00 00 31 d2 bb 04 00 00 00 66 ba 58 56 ed <89> 1f 89 0e 41= 89 10 5b e9 3c f0 fc fe 6a 00 49 89 f9 45 31 c0 31 RSP: 0018:ff5eeb3240003e40 EFLAGS: 00010046 RAX: 0000000000000000 RBX: 000000000000ffca RCX: 000000000000ffac RDX: 0000000000000000 RSI: 0000000040003e58 RDI: 0000000040003e54 RBP: ff1e05f3c1204800 R08: ff5eeb3240003e5c R09: 000000009d899c41 R10: 000000000000003d R11: ff5eeb3240003ff8 R12: 0000000000000000 R13: 00000000000000ff R14: ff1e05f3c02f9e00 R15: 000000000000000c FS: 0000000000000000(0000) GS:ff1e05f489e40000(0000) knlGS:0000000000000= 000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000040003e54 CR3: 000000010841d002 CR4: 0000000000771ef0 PKRU: 55555554 Call Trace: vmmouse_report_events+0x13e/0x1b0 psmouse_handle_byte+0x15/0x60 ps2_interrupt+0x8a/0xd0 ... The panic was triggered by dereferencing a bad pointer (RDI) immediately after a VMware hypercall for VMWARE_CMD_ABSPOINTER_DATA in the vmmouse driver: ffffffff82135070 : ... ffffffff821350ac: b8 68 58 4d 56 mov $0x564d5868,%eax ffffffff821350b1: b9 27 00 00 00 mov $0x27,%ecx ffffffff821350b6: 31 d2 xor %edx,%edx ffffffff821350b8: bb 04 00 00 00 mov $0x4,%ebx ffffffff821350bd: 66 ba 58 56 mov $0x5658,%dx ffffffff821350c1: ed in (%dx),%eax <-- hyp= ercall ffffffff821350c2: 89 1f mov %ebx,(%rdi) <-- cr= ash Reading the disassembly shows that RDI should contain the value of a valid kernel stack address here (0xff5eeb3240003e54). Instead it contains 0x40003e54, suggesting the hypervisor cleared the upper 32 bits. And indeed, Alexey discovered that QEMU's vmmouse_get_data() and vmmouse_set_data() are only saving/restoring the lower 32 bits, while clearing the upper 32. Fix that by changing the type of the saved data array from uint32_t to target_ulong. Fixes: 548df2acc6fc ("VMMouse Emulation, by Anthony Liguori.") Reported-by: Justin Forbes Debugged-by: Alexey Makhalov Signed-off-by: Josh Poimboeuf Acked-by: Alexey Makhalov --- hw/i386/vmmouse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 2ae7f3a242..3bba221d5f 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -72,7 +72,7 @@ struct VMMouseState { ISAKBDState *i8042; }; =20 -static void vmmouse_get_data(uint32_t *data) +static void vmmouse_get_data(target_ulong *data) { X86CPU *cpu =3D X86_CPU(current_cpu); CPUX86State *env =3D &cpu->env; @@ -82,7 +82,7 @@ static void vmmouse_get_data(uint32_t *data) data[4] =3D env->regs[R_ESI]; data[5] =3D env->regs[R_EDI]; } =20 -static void vmmouse_set_data(const uint32_t *data) +static void vmmouse_set_data(const target_ulong *data) { X86CPU *cpu =3D X86_CPU(current_cpu); CPUX86State *env =3D &cpu->env; @@ -197,7 +197,7 @@ static void vmmouse_disable(VMMouseState *s) vmmouse_remove_handler(s); } =20 -static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size) +static void vmmouse_data(VMMouseState *s, target_ulong *data, uint32_t siz= e) { int i; =20 @@ -221,7 +221,7 @@ static void vmmouse_data(VMMouseState *s, uint32_t *dat= a, uint32_t size) static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr) { VMMouseState *s =3D opaque; - uint32_t data[6]; + target_ulong data[6]; uint16_t command; =20 vmmouse_get_data(data); @@ -247,7 +247,7 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint3= 2_t addr) vmmouse_request_absolute(s); break; default: - printf("vmmouse: unknown command %x\n", data[1]); + printf("vmmouse: unknown command " TARGET_FMT_lx "\n", data[1]= ); break; } break; --=20 2.52.0