From nobody Wed Nov 27 13:01:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16992813488821023.3989727001033; Mon, 6 Nov 2023 06:35:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.628047.979064 (Exim 4.92) (envelope-from ) id 1r00hI-0008M8-Rh; Mon, 06 Nov 2023 14:35:24 +0000 Received: by outflank-mailman (output) from mailman id 628047.979064; Mon, 06 Nov 2023 14:35:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r00hI-0008M1-PA; Mon, 06 Nov 2023 14:35:24 +0000 Received: by outflank-mailman (input) for mailman id 628047; Mon, 06 Nov 2023 14:35:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r00hH-0008Lv-Fk for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 14:35:23 +0000 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b6b29fda-7cb1-11ee-98da-6d05b1d4d9a1; Mon, 06 Nov 2023 15:35:22 +0100 (CET) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-189d700f.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 14:35:19 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (pdx2-ws-svc-p26-lb5-vlan3.pdx.amazon.com [10.39.38.70]) by email-inbound-relay-pdx-2b-m6i4x-189d700f.us-west-2.amazon.com (Postfix) with ESMTPS id 85A1640D84; Mon, 6 Nov 2023 14:35:16 +0000 (UTC) Received: from EX19MTAUWC001.ant.amazon.com [10.0.38.20:34329] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.34.186:2525] with esmtp (Farcaster) id 76d34537-32d9-44b2-b563-58d436590f5f; Mon, 6 Nov 2023 14:35:16 +0000 (UTC) Received: from EX19MTAUWB001.ant.amazon.com (10.250.64.248) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Mon, 6 Nov 2023 14:35:15 +0000 Received: from u3832b3a9db3152.ant.amazon.com (10.106.83.6) by mail-relay.amazon.com (10.250.64.254) with Microsoft SMTP Server id 15.2.1118.39 via Frontend Transport; Mon, 6 Nov 2023 14:35:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Inumbo-ID: b6b29fda-7cb1-11ee-98da-6d05b1d4d9a1 X-IronPort-AV: E=Sophos;i="6.03,281,1694736000"; d="scan'208";a="361122546" X-Farcaster-Flow-ID: 76d34537-32d9-44b2-b563-58d436590f5f From: David Woodhouse To: CC: Kevin Wolf , Hanna Reitz , Peter Maydell , Stefano Stabellini , Anthony Perard , Paul Durrant , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Jason Wang , Marcelo Tosatti , , , Subject: [PATCH v4 01/17] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer() Date: Mon, 6 Nov 2023 14:34:51 +0000 Message-ID: <20231106143507.1060610-2-dwmw2@infradead.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106143507.1060610-1-dwmw2@infradead.org> References: <20231106143507.1060610-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: Bulk X-ZM-MESSAGEID: 1699281433264100001 From: David Woodhouse Upstream Xen now ignores this flag=C2=B9, since the only guest kernel ever = to use it was buggy. =C2=B9 https://xenbits.xen.org/gitweb/?p=3Dxen.git;a=3Dcommitdiff;h=3D19c6c= bd909 Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 75b2c557b9..1dc9ab0d91 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -1077,17 +1077,13 @@ static int vcpuop_stop_periodic_timer(CPUState *tar= get) * Must always be called with xen_timers_lock held. */ static int do_set_singleshot_timer(CPUState *cs, uint64_t timeout_abs, - bool future, bool linux_wa) + bool linux_wa) { CPUX86State *env =3D &X86_CPU(cs)->env; int64_t now =3D kvm_get_current_ns(); int64_t qemu_now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); int64_t delta =3D timeout_abs - now; =20 - if (future && timeout_abs < now) { - return -ETIME; - } - if (linux_wa && unlikely((int64_t)timeout_abs < 0 || (delta > 0 && (uint32_t)(delta >> 50) !=3D 0)= )) { /* @@ -1129,9 +1125,13 @@ static int vcpuop_set_singleshot_timer(CPUState *cs,= uint64_t arg) } =20 QEMU_LOCK_GUARD(&X86_CPU(cs)->env.xen_timers_lock); - return do_set_singleshot_timer(cs, sst.timeout_abs_ns, - !!(sst.flags & VCPU_SSHOTTMR_future), - false); + + /* + * We ignore the VCPU_SSHOTTMR_future flag, just as Xen now does. + * The only guest that ever used it, got it wrong. + * https://xenbits.xen.org/gitweb/?p=3Dxen.git;a=3Dcommitdiff;h=3D19c6= cbd909 + */ + return do_set_singleshot_timer(cs, sst.timeout_abs_ns, false); } =20 static int vcpuop_stop_singleshot_timer(CPUState *cs) @@ -1156,7 +1156,7 @@ static bool kvm_xen_hcall_set_timer_op(struct kvm_xen= _exit *exit, X86CPU *cpu, err =3D vcpuop_stop_singleshot_timer(CPU(cpu)); } else { QEMU_LOCK_GUARD(&X86_CPU(cpu)->env.xen_timers_lock); - err =3D do_set_singleshot_timer(CPU(cpu), timeout, false, true); + err =3D do_set_singleshot_timer(CPU(cpu), timeout, true); } exit->u.hcall.result =3D err; return true; @@ -1844,7 +1844,7 @@ int kvm_put_xen_state(CPUState *cs) QEMU_LOCK_GUARD(&env->xen_timers_lock); if (env->xen_singleshot_timer_ns) { ret =3D do_set_singleshot_timer(cs, env->xen_singleshot_timer_= ns, - false, false); + false); if (ret < 0) { return ret; } --=20 2.34.1