From nobody Wed Apr 10 15:19:26 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VF61q1Gzhz5HHR0; Wed, 10 Apr 2024 15:19:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VF61p6fBfz4nWy; Wed, 10 Apr 2024 15:19:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tOFqO4THPDr+ARebVebBBe4NrOG5k1DfmCyvBw7IBCg=; b=gKk9zveADhdJceGuGUK3G6uj7e5fNS/j6sQFjNrBKKFJne3O/qUH92OgZVXyLIE+M1R/Q8 FKmAUWO79nC2CsWOorBRcJ+zHC/sgXBamNDWxxx3Jpvl5ELZLnv5Su6O9BHFWf0bI6LSui u31nKrhsO0A0HvWnS9TUWa7hM8s83aZDBIuclIpPIy40U7emuMmPZyfS4N3ZBXaBQkzBiu 3rFLKKNS0qFOVoabQN3FiHi9ON7PcVpYwU8EC980HNDU3ws04IGnr4uQo/aXEuxc2fuIGO w5nyaDf9ybF4o/hpJxGNnNUlE9Pprr8qVwBId/9GmmCpWJVTLjH5duoJbK7xPA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712762366; a=rsa-sha256; cv=none; b=Sf7VjLS5q2Az0dS+OsX1PgEc61tfkRN1Y0RZW/nS6/SbDkc9+l2JOVNGL3l82N4TnqJA2l 8UXclP2akdsBKGcRuULwAlS3yUsZGjLEPu2zgSLTDGrOnwxsz1ayGOm488oC3P0zhmADdC yjVxC+2AzIwp1fOlFxNk4x7JbbLivGrGh6jNVTLcybLx4DicYO1f67t7TEo3/mFzInvF0K DSeTvbDFxxcWSpuHM0m/69XtqtKkxbG1MQiYrZ5uNkl4Ej/jSM7Jk++OpURW5xbGe9FOwc hmfQ75tRKg2BR6cBqQRYsQBCYY5vkNDojTSmClOh6h/Qibu1+X12Gb9/mV40Sg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tOFqO4THPDr+ARebVebBBe4NrOG5k1DfmCyvBw7IBCg=; b=SJ7eLGbkWzupkhK/hBRxsmMHYelNlxT2NbIKbl/PVobVBJyB9Xshe6NbhBZ87b1GoBbmDc LT7iZuIJrOL979Ycxi5PrQfin2l8L/7vXlP9Egtu2dMnPl8tZqVPu/uCyN3GbHbUh7kLha N6lYYc3osWhe9ZZKkyIzsErcKDFLd4uRyjvF3GnppCg203wzKm+WcOri/ClmJBR1RJomdV lVdG6lZkx+HhlsRankSPjLpBPsQLvWSWXyRdPvOXbf1Nnz77XtmQtmMoBBWN/nRw4kDnkx H425TGJJ+ozJe8wU5GI2ueJ82XWsYCW4RFslehKRqB8EVLhgzH4cOMrrZFOo+A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VF61p6DFLzjjd; Wed, 10 Apr 2024 15:19:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43AFJQq5093776; Wed, 10 Apr 2024 15:19:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43AFJQO5093773; Wed, 10 Apr 2024 15:19:26 GMT (envelope-from git) Date: Wed, 10 Apr 2024 15:19:26 GMT Message-Id: <202404101519.43AFJQO5093773@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4dfa329f4861 - main - bhyve: Extend mevent to support updating timers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: dev-commits-src-all+owner@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4dfa329f48618d30e0c32529f874c1d0cc7beb00 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4dfa329f48618d30e0c32529f874c1d0cc7beb00 commit 4dfa329f48618d30e0c32529f874c1d0cc7beb00 Author: Jessica Clarke AuthorDate: 2024-02-21 22:42:19 +0000 Commit: Mark Johnston CommitDate: 2024-04-10 15:17:56 +0000 bhyve: Extend mevent to support updating timers This will be used by a new PL031 implementation to provide an RTC for arm64 guests. Reviewed by: jhb MFC after: 2 weeks Obtained from: CheriBSD --- usr.sbin/bhyve/mevent.c | 34 ++++++++++++++++++++++++---------- usr.sbin/bhyve/mevent.h | 1 + 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bhyve/mevent.c b/usr.sbin/bhyve/mevent.c index ce272ce87f3d..dbcc39148ca1 100644 --- a/usr.sbin/bhyve/mevent.c +++ b/usr.sbin/bhyve/mevent.c @@ -80,6 +80,12 @@ struct mevent { LIST_ENTRY(mevent) me_list; }; +enum mevent_update_type { + UPDATE_ENABLE, + UPDATE_DISABLE, + UPDATE_TIMER, +}; + static LIST_HEAD(listhead, mevent) global_head, change_head; static void @@ -237,7 +243,6 @@ mevent_build(struct kevent *kev) */ close(mevp->me_fd); } else { - assert((mevp->me_state & EV_ADD) == 0); mevent_populate(mevp, &kev[i]); i++; } @@ -375,30 +380,35 @@ mevent_add_disabled(int tfd, enum ev_type type, } static int -mevent_update(struct mevent *evp, bool enable) +mevent_update(struct mevent *evp, enum mevent_update_type type, int msecs) { int newstate; mevent_qlock(); /* - * It's not possible to enable/disable a deleted event + * It's not possible to update a deleted event */ assert((evp->me_state & EV_DELETE) == 0); newstate = evp->me_state; - if (enable) { + if (type == UPDATE_ENABLE) { newstate |= EV_ENABLE; newstate &= ~EV_DISABLE; - } else { + } else if (type == UPDATE_DISABLE) { newstate |= EV_DISABLE; newstate &= ~EV_ENABLE; + } else { + assert(type == UPDATE_TIMER); + assert(evp->me_type == EVF_TIMER); + newstate |= EV_ADD; + evp->me_msecs = msecs; } /* - * No update needed if state isn't changing + * No update needed if enable/disable had no effect */ - if (evp->me_state != newstate) { + if (evp->me_state != newstate || type == UPDATE_TIMER) { evp->me_state = newstate; /* @@ -421,15 +431,19 @@ mevent_update(struct mevent *evp, bool enable) int mevent_enable(struct mevent *evp) { - - return (mevent_update(evp, true)); + return (mevent_update(evp, UPDATE_ENABLE, -1)); } int mevent_disable(struct mevent *evp) { + return (mevent_update(evp, UPDATE_DISABLE, -1)); +} - return (mevent_update(evp, false)); +int +mevent_timer_update(struct mevent *evp, int msecs) +{ + return (mevent_update(evp, UPDATE_TIMER, msecs)); } static int diff --git a/usr.sbin/bhyve/mevent.h b/usr.sbin/bhyve/mevent.h index de70361059bd..23107fc55982 100644 --- a/usr.sbin/bhyve/mevent.h +++ b/usr.sbin/bhyve/mevent.h @@ -55,6 +55,7 @@ int mevent_enable(struct mevent *evp); int mevent_disable(struct mevent *evp); int mevent_delete(struct mevent *evp); int mevent_delete_close(struct mevent *evp); +int mevent_timer_update(struct mevent *evp, int msecs); void mevent_dispatch(void);