From nobody Thu Jul 10 19:33:41 2025 X-Original-To: dev-commits-src-main@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 4bdQ4j5xY5z61SSQ; Thu, 10 Jul 2025 19:33:41 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bdQ4j4qx6z3F17; Thu, 10 Jul 2025 19:33:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752176021; 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=Y0zVOs9hKnmS4o7DxwQfW8DNQdgAkyVi1gqqRYyHd3Q=; b=pYSH/gLo9OqrjSZtiOaLOgydIUXJ85w1+s5lfrbN1LhyH2+nqzhREAL+5v95RP8Dnnln/3 1rgbpMRhZUK7d2Erbn8NgUCM8S38E5CSVPyIlsPE2B31WcPLoDIE3ADxfC/3uIb2/LfDFE 4ZOgD94BeSVtWLd9GJ/CIu+BKWJgi2rtONeSd36j5gaQc01JNc0trjOHKtbaCCap9nbahN zHMpMRBiYO8540wazhAOB2r7/oOgJ/84mNcqnaxycvg/lItWKeG3xfNlT7Acu3axgEZJJ3 uyuqSMOM+mT/e7wkhK1X3lPnFc3IsilkiQxDazo7OQ2HDb2+NkNOBC4XOHl/rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752176021; 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=Y0zVOs9hKnmS4o7DxwQfW8DNQdgAkyVi1gqqRYyHd3Q=; b=oGO8xejzdUQR0oqwNTPRqINTJVCyQtFStwsjx06rs/9ycmkeRLPG2MXLK4M2HmXBbZOZni YSpbzuKEE9zlJp9DUej0LRzLDqXQ0z8vKfBNoePUkWPpRImAULn41rmQah7oXjNG/qzHi4 G/xmVYy/RFC2RXbrieQfkTHAvrBT4a4vChA3vCzdaZ/KkSzAn7CcaNIo1Er5fP68ZuUMpV bwZxhSbvJCBvWkBcgSQVNdwY7nOUbKRvNb+tKl/1G6pl6LKkZ0u59Kw317pERZR5fsuWOk rHsJLQ36Ex7/yaq5HdJTtJw+3JToV6u65UtJ5x1ZXN7luvCxqbHNEyyBtfuV+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752176021; a=rsa-sha256; cv=none; b=mdlRLi27e+zifTHJwLV+PzUTj4tVvL6RdGQDp6MOeoFNtJh1tWfjZJfvvdtBe+gAu6KSun MRhIepUIoO4wb+NUDXHf4UMQyBFOFbqCtxuVxGqPs+yv8cpRvhqkvhvX+3uUgXtSZJtxDc wozgi+7Ep2WeAMcryIJNtXLCIgHJ25pplTb+QBMQWUveiXe4bpXQkU5SjqeLn2oAnBnpJZ j0CoE2mTQPTIOZBHGBQu+E1BJtoQiAHlfJtlHetkrjoK3JG9QnXtEn2DES2ZfMXJ8SzFjw cDAcsYFNXkimKzePvf0DnFDcjVcjBoPGesKEyVkG879xOLXrGnOxUIrJZvNy7A== 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 4bdQ4j4QrYz1Kgw; Thu, 10 Jul 2025 19:33:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56AJXfwA059093; Thu, 10 Jul 2025 19:33:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56AJXfOn059090; Thu, 10 Jul 2025 19:33:41 GMT (envelope-from git) Date: Thu, 10 Jul 2025 19:33:41 GMT Message-Id: <202507101933.56AJXfOn059090@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: cb75bb51261b - main - vmbus: Avoid gratuitous ifdef and use more generic implementation instead List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cb75bb51261b13a49636befdee1c4a76f2e9013e Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=cb75bb51261b13a49636befdee1c4a76f2e9013e commit cb75bb51261b13a49636befdee1c4a76f2e9013e Author: Jessica Clarke AuthorDate: 2025-07-10 19:33:33 +0000 Commit: Jessica Clarke CommitDate: 2025-07-10 19:33:33 +0000 vmbus: Avoid gratuitous ifdef and use more generic implementation instead Checking for __LP64__ is non-portable as it assumes that ILP32 and LP64 are the only two ABIs that exist, but CheriBSD supports an additional ABI where long is still 64-bit but pointers are 128-bit capabilities, and thus __LP64__ is not defined. We could change this to check the value of __SIZEOF_LONG__, since the code here only cares about that aspect of the ABI, however in this instance, the only real reason an ifdef is used at all is to be able to get log2(sizeof(u_long)), but if we instead multiply and divide rather than shift, and let the compiler optimise that to a shift, we can just use sizeof(u_long) instead. Note also that VMBUS_EVTFLAGS_MAX could always just have been defined as VMBUS_EVTFLAGS_SIZE / sizeof(u_long). Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D50630 --- sys/dev/hyperv/vmbus/vmbus_chan.c | 6 +++--- sys/dev/hyperv/vmbus/vmbus_reg.h | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/sys/dev/hyperv/vmbus/vmbus_chan.c b/sys/dev/hyperv/vmbus/vmbus_chan.c index 189a3e66a039..7ea60a499c72 100644 --- a/sys/dev/hyperv/vmbus/vmbus_chan.c +++ b/sys/dev/hyperv/vmbus/vmbus_chan.c @@ -1555,7 +1555,7 @@ vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, continue; flags = atomic_swap_long(&event_flags[f], 0); - chid_base = f << VMBUS_EVTFLAG_SHIFT; + chid_base = f * VMBUS_EVTFLAG_LEN; while ((chid_ofs = ffsl(flags)) != 0) { struct vmbus_channel *chan; @@ -1599,7 +1599,7 @@ vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu) eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) { vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags, - VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT); + VMBUS_CHAN_MAX_COMPAT / VMBUS_EVTFLAG_LEN); } } @@ -1903,7 +1903,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_softc *sc, * Setup event flag. */ chan->ch_evtflag = - &sc->vmbus_tx_evtflags[chan->ch_id >> VMBUS_EVTFLAG_SHIFT]; + &sc->vmbus_tx_evtflags[chan->ch_id / VMBUS_EVTFLAG_LEN]; chan->ch_evtflag_mask = 1UL << (chan->ch_id & VMBUS_EVTFLAG_MASK); /* diff --git a/sys/dev/hyperv/vmbus/vmbus_reg.h b/sys/dev/hyperv/vmbus/vmbus_reg.h index 4aa729475b5d..76cdca0ebeb2 100644 --- a/sys/dev/hyperv/vmbus/vmbus_reg.h +++ b/sys/dev/hyperv/vmbus/vmbus_reg.h @@ -60,16 +60,10 @@ CTASSERT(sizeof(struct vmbus_message) == VMBUS_MSG_SIZE); * Hyper-V SynIC event flags */ -#ifdef __LP64__ -#define VMBUS_EVTFLAGS_MAX 32 -#define VMBUS_EVTFLAG_SHIFT 6 -#else -#define VMBUS_EVTFLAGS_MAX 64 -#define VMBUS_EVTFLAG_SHIFT 5 -#endif -#define VMBUS_EVTFLAG_LEN (1 << VMBUS_EVTFLAG_SHIFT) +#define VMBUS_EVTFLAG_LEN (sizeof(u_long) * 8) #define VMBUS_EVTFLAG_MASK (VMBUS_EVTFLAG_LEN - 1) #define VMBUS_EVTFLAGS_SIZE 256 +#define VMBUS_EVTFLAGS_MAX (VMBUS_EVTFLAGS_SIZE / sizeof(u_long)) struct vmbus_evtflags { u_long evt_flags[VMBUS_EVTFLAGS_MAX];