From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E85ACA1015 for ; Thu, 4 Sep 2025 12:52:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uu9Rd-0005Br-GV; Thu, 04 Sep 2025 08:52:06 -0400 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 1uu8m7-0008KF-2R for qemu-rust@nongnu.org; Thu, 04 Sep 2025 08:09:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uu8lv-0003xC-H7 for qemu-rust@nongnu.org; Thu, 04 Sep 2025 08:09:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756987734; 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=RGfsbECkN8yDi9zfYlQG8Tqcfjb7p7ijr5WocyCehHg=; b=XJ+Le8mjlcPUJz3CCcbGcAMjjQuatCONgfMyzvWAOp88xyK+Vna7nzXjCBwB5anzXmZ+x5 yBtWlN8Ro4Nad/wmFTlTj1bpZP9UWWBhhWuvjRjk7GABzHHEKwWv/5ESpKEg5eMDUmXRaC GBLdul+LaEn/ExGuewUjeaikO+0KtCY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-AM63JENsPI2nhNn2qfNDLw-1; Thu, 04 Sep 2025 08:08:50 -0400 X-MC-Unique: AM63JENsPI2nhNn2qfNDLw-1 X-Mimecast-MFC-AGG-ID: AM63JENsPI2nhNn2qfNDLw_1756987730 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45dd12d469cso4156055e9.2 for ; Thu, 04 Sep 2025 05:08:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756987729; x=1757592529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RGfsbECkN8yDi9zfYlQG8Tqcfjb7p7ijr5WocyCehHg=; b=plAekTnALlcMWwODfG2lOG5UeSqyMEY5WzW1pMGxiMIpVfKWC5afIiFP/bdA9SkcAS G9uB2IUEyzLkEXFx4i3LeYUCukiQB1RcosFQLgapGBffegcXu3GTFDYjOfAZ1iu4/b1e VXQcjm7nfG4EDxcapQ2VmecyeaEkfBk9esGhBPTptfuid8x+VHaR8qyA+yEDuPRXgGIX camPv1R6a544n49trSYlpLEOUB8nYAlerLmuYCZC1JSlMoChzxLWfUn/KLpJgrCZKRR7 1iir3ZUR8C1dGkLaGFwz3nrOBrlrOMcp1pTIS53SKfIit6xG5SthLdnyU0ItBpdtayn3 TxHg== X-Forwarded-Encrypted: i=1; AJvYcCWxvdGjXXFrDv7XEDR1ur5b7RcuSUceaJUQKySbL1FWJhCquJ4H+EW7yCJrD4kumsB/+0UncZohmds=@nongnu.org X-Gm-Message-State: AOJu0YzjqXztv37fyWFUDyWkuUkRTNh9B7UcHPHBKPL0rOIoBLDyrbyC eqxrYjQDk+YyIDfdd2gQ7I+9RphiA9b5H3MfsdtcIgaFIZ7kne5SAaqf42KM+QiIk/EBIe1pWgW VMNI8r0mGn78aLbaBCBpmVRbHouuvhHeJvGHdIACu2EYhBeNnkp4RWTY= X-Gm-Gg: ASbGncvA0ablOF9pV3vLipSL5MvHGFupw0r95fHZAPXclPnhY62kP9EvdHbd0yvxoNL qRFAUnLpg5yNEOE8THO2Y8kWjdkywtgyUAAo59AbQzkdK4/G8RzQ/XjKUUuMy+AwGzcE+xrH8Yp NcWlRmvWhsP4CNQX5iCa3CNDNr01wDJxAMY1B3Sv9ZW2N0Wh/z/zcV1ZIS06FK46eBHSvTTU5N2 rX1eFwPbl/Pe05ug+OjQpcphYiVcBoi29hKGnIU5Mqyv0L70p2ACmunlY+88407SvbQwWbS+vRw mSBWsNT4ib8En6mijmNvAFNqFE0aNg== X-Received: by 2002:a05:6000:2681:b0:3df:1a8b:ff40 with SMTP id ffacd0b85a97d-3df1a8c028amr3675207f8f.43.1756987729310; Thu, 04 Sep 2025 05:08:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGX0PPz3yh7ncUtLm/xW0ZxJtT+AldckvinW77LYH+EITFhgO23Jx24JW/wmCpN9gO6bSEhZg== X-Received: by 2002:a05:6000:2681:b0:3df:1a8b:ff40 with SMTP id ffacd0b85a97d-3df1a8c028amr3675186f8f.43.1756987728720; Thu, 04 Sep 2025 05:08:48 -0700 (PDT) Received: from fedora ([85.93.96.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d53fda847dsm18324880f8f.0.2025.09.04.05.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 05:08:48 -0700 (PDT) Date: Thu, 4 Sep 2025 14:08:44 +0200 From: Igor Mammedov To: Alex =?UTF-8?B?QmVubsOpZQ==?= , Peter Xu Cc: qemu-devel@nongnu.org, Reinoud Zandijk , =?UTF-8?B?Q8OpZHJpYw==?= Le Goater , Huacai Chen , Zhao Liu , Paolo Bonzini , Alistair Francis , qemu-arm@nongnu.org, Fam Zheng , Helge Deller , Matthew Rosato , Fabiano Rosas , qemu-rust@nongnu.org, Bibo Mao , qemu-riscv@nongnu.org, Thanos Makatos , Liu Zhiwei , Riku Voipio , Cameron Esfahani , Alexander Graf , Laurent Vivier , Harsh Prateek Bora , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?=" , qemu-ppc@nongnu.org, Stafford Horne , Sunil Muthuswamy , Jagannathan Raman , Brian Cain , Phil Dennis-Jordan , devel@lists.libvirt.org, Mads Ynddal , Elena Ufimtseva , Jason Herne , Michael Rolnik , Weiwei Li , Laurent Vivier , Ilya Leoshkevich , qemu-block@nongnu.org, Peter Maydell , Kostiantyn Kostiuk , Kyle Evans , David Hildenbrand , "Edgar E. Iglesias" , Warner Losh , Daniel Henrique Barboza , John Snow , Yoshinori Sato , Aleksandar Rikalo , Alistair Francis , Marcelo Tosatti , Yonggang Luo , Radoslaw Biernacki , Artyom Tarasenko , Yanan Wang , Eduardo Habkost , Aurelien Jarno , Richard Henderson , qemu-s390x@nongnu.org, Alex Williamson , "Michael S. Tsirkin" , Ani Sinha , Roman Bolshakov , Manos Pitsidianakis , Chinmay Rath , Thomas Huth , Cleber Rosa , kvm@vger.kernel.org, Song Gao , Philippe =?UTF-8?B?TWF0aGlldS1EYXVkw6k=?= , Halil Pasic , Eric Farman , Palmer Dabbelt , Leif Lindholm , Christian Borntraeger , Michael Roth , Mauro Carvalho Chehab , Jiaxun Yang , =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau , Mark Cave-Ayland , Marcel Apfelbaum , Nicholas Piggin , John Levon , Xin Wang Subject: Re: [PATCH v2 001/281] target/i386: Add support for save/load of exception error code Message-ID: <20250904140844.5b670290@fedora> In-Reply-To: <20250904081128.1942269-2-alex.bennee@linaro.org> References: <20250904081128.1942269-1-alex.bennee@linaro.org> <20250904081128.1942269-2-alex.bennee@linaro.org> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.49; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HuVa1TPBKCJ9ayilr_qfJL1zlJZBEHzsD0rdkj9mnrA_1756987730 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 04 Sep 2025 08:52:02 -0400 X-BeenThere: qemu-rust@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: QEMU Rust-related patches and discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-rust-bounces+qemu-rust=archiver.kernel.org@nongnu.org Sender: qemu-rust-bounces+qemu-rust=archiver.kernel.org@nongnu.org On Thu, 4 Sep 2025 09:06:35 +0100 Alex Benn=C3=A9e wrote: > From: Xin Wang >=20 > For now, qemu save/load CPU exception info(such as exception_nr and > has_error_code), while the exception error_code is ignored. This will > cause the dest hypervisor reinject a vCPU exception with error_code(0), > potentially causing a guest kernel panic. >=20 > For instance, if src VM stopped with an user-mode write #PF (error_code 6= ), > the dest hypervisor will reinject an #PF with error_code(0) when vCPU res= ume, > then guest kernel panic as: > BUG: unable to handle page fault for address: 00007f80319cb010 > #PF: supervisor read access in user mode > #PF: error_code(0x0000) - not-present page > RIP: 0033:0x40115d >=20 > To fix it, support save/load exception error_code. this potentially will break migration between new/old QEMU versions due to presence new subsection. But then according to commit message the guest might panic (on dst) when resumed anyways. So patch changes how guest will fail (panic: old =3D> old, old =3D> new vs migration error: new =3D> old ). Peter, do we care and do we need a compat knob to make existing machine type behave old way? >=20 > Signed-off-by: Xin Wang > Link: https://lore.kernel.org/r/20250819145834.3998-1-wangxinxin.wang@hua= wei.com > Signed-off-by: Paolo Bonzini > --- > target/i386/machine.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) >=20 > diff --git a/target/i386/machine.c b/target/i386/machine.c > index dd2dac1d443..45b7cea80aa 100644 > --- a/target/i386/machine.c > +++ b/target/i386/machine.c > @@ -462,6 +462,24 @@ static const VMStateDescription vmstate_exception_in= fo =3D { > } > }; > =20 > +static bool cpu_errcode_needed(void *opaque) > +{ > + X86CPU *cpu =3D opaque; > + > + return cpu->env.has_error_code !=3D 0; > +} > + > +static const VMStateDescription vmstate_error_code =3D { > + .name =3D "cpu/error_code", > + .version_id =3D 1, > + .minimum_version_id =3D 1, > + .needed =3D cpu_errcode_needed, > + .fields =3D (const VMStateField[]) { > + VMSTATE_INT32(env.error_code, X86CPU), > + VMSTATE_END_OF_LIST() > + } > +}; > + > /* Poll control MSR enabled by default */ > static bool poll_control_msr_needed(void *opaque) > { > @@ -1746,6 +1764,7 @@ const VMStateDescription vmstate_x86_cpu =3D { > }, > .subsections =3D (const VMStateDescription * const []) { > &vmstate_exception_info, > + &vmstate_error_code, > &vmstate_async_pf_msr, > &vmstate_async_pf_int_msr, > &vmstate_pv_eoi_msr,