From nobody Fri Dec 15 13:59:47 2023 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 4Ss9nw1WRMz52rSp; Fri, 15 Dec 2023 13:59:48 +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 4Ss9nv4TcTz4J9d; Fri, 15 Dec 2023 13:59:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702648787; 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=DIJ4ZrwUnUuYQ1TuGb8klABIiJJSq4f9bb5ok3OVrOo=; b=GY+I9f6NAQJC5RsGSjQyX0Hv7hUL8zdJLQcp6Spzz99VQLpIbJV8q8IVR/xKzt+gwVzF+H Tp9jHEkMZZrrGt5eEADwBSL92zJbdXuooM+0Sjzittd205b4FqN+on+/QAO8yW+8BopB8O Qs8z0hCX1Tvd6kpZ0U9jgZE2Q4g055PveSFKh9+0gGDADo5D3vHY7EQarH6Bu9yoecpimN 9hCq2ajrOiOXmqak+ZgeDxaymZ5d8Nts9JwiM8QHUQRkymR1BnxmZI/B3am0bBlC2Fv3DW nUJVUzTNG/pB9Duz9WslJX1OyBTSKxuEgeTQ4nsbG1jLlJjQFOuUGlCojowiyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702648787; a=rsa-sha256; cv=none; b=VpndNLLYyZX8TzPR0t4QBnnd7X/65xO6l2ObtjyYG3apNUQa+aaXRG8pv5qGGH6jjqocC2 U59jiKCuiGP+W1TRq2NPxmpGpfG4lwwEQuT4jRQsO1XnLEkTqecNx43vpzvu7daSA1im+c BoXvCHg46aDhoQF2CwjVZMASyOpKo2+CAPRfYK2pVn5DfBf2I0NkdvACRBSgRLcAKBR70N tPPVPBSrFd1222aMRy5zFK9+fJzXuiC8Kg/BMipRqhUVDxnlSsFfUgiTWHGPvETCjINsYZ vW9clUtjq3S7AnngGsfl9qtV+4EQ14V1wurXTq6Foa6Pm3COarTX7PmlkY3stw== 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=1702648787; 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=DIJ4ZrwUnUuYQ1TuGb8klABIiJJSq4f9bb5ok3OVrOo=; b=FG8nN3yvCBzXtpQXSpRw4u+AKIoQE86Po825+nWuf8dofHOHFvSRS2KIp4PdqJ6Pgxtv8w AZN3gFnCQBIqbaS2RnFOFKwqbGRjEAhobs/ztmt7wY4NorVsLIxzmPEaWhWvjNpM2s0IIp bsGG2/OyGU7lZK3JNuuxiP5G6p6uVK6FHI0KYvw+4vaiCeAkomR7XPJDTT+lMr/kSJEkWX aZ8tyTAHno/LhcM7WK6zLCcFssUW9vgA80Bq0dNbTsJ0Te/D8alXMA9sxB7b0gihr6RJ7p gVhPlhmzorNznxMMMos55MltxjnwGkcfwKvfKE77mcw0u0COglILwVBOUVyNXA== 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 4Ss9nv3Y5sz1C03; Fri, 15 Dec 2023 13:59:47 +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 3BFDxlnF015694; Fri, 15 Dec 2023 13:59:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BFDxlBN015691; Fri, 15 Dec 2023 13:59:47 GMT (envelope-from git) Date: Fri, 15 Dec 2023 13:59:47 GMT Message-Id: <202312151359.3BFDxlBN015691@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Roger Pau =?utf-8?Q?Monn=C3=A9?= Subject: git: 4c9e6ad3205a - main - xen: add atomic #defines to accomodate differing xen_ulong_t sizes 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: owner-dev-commits-src-all@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: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c9e6ad3205a770a029cedc3056790258791e6ba Auto-Submitted: auto-generated The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=4c9e6ad3205a770a029cedc3056790258791e6ba commit 4c9e6ad3205a770a029cedc3056790258791e6ba Author: Elliott Mitchell AuthorDate: 2023-12-02 21:54:48 +0000 Commit: Roger Pau Monné CommitDate: 2023-12-15 13:59:26 +0000 xen: add atomic #defines to accomodate differing xen_ulong_t sizes Alas, ARM declared xen_ulong_t to be 64-bits long, unlike i386 where it matches the word size. As a result, compatibility wrappers are needed for Xen atomic operations. Reviewed by: royger --- sys/dev/xen/bus/xen_intr.c | 6 +++--- sys/x86/include/xen/xen-os.h | 10 ++++++++++ sys/xen/evtchn/evtchnvar.h | 6 +++--- sys/xen/xen-os.h | 12 ++++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sys/dev/xen/bus/xen_intr.c b/sys/dev/xen/bus/xen_intr.c index 3e44c05ceeb7..3fc8fb0fe83a 100644 --- a/sys/dev/xen/bus/xen_intr.c +++ b/sys/dev/xen/bus/xen_intr.c @@ -369,7 +369,7 @@ xen_intr_handle_upcall(void *unused __unused) /* Clear master flag /before/ clearing selector flag. */ wmb(); #endif - l1 = atomic_readandclear_long(&v->evtchn_pending_sel); + l1 = atomic_readandclear_xen_ulong(&v->evtchn_pending_sel); l1i = pc->last_processed_l1i; l2i = pc->last_processed_l2i; @@ -475,7 +475,7 @@ xen_intr_init(void *dummy __unused) } for (i = 0; i < nitems(s->evtchn_mask); i++) - atomic_store_rel_long(&s->evtchn_mask[i], ~0); + atomic_store_rel_xen_ulong(&s->evtchn_mask[i], ~0); xen_arch_intr_init(); @@ -582,7 +582,7 @@ xen_intr_resume(void) /* Mask all event channels. */ for (i = 0; i < nitems(s->evtchn_mask); i++) - atomic_store_rel_long(&s->evtchn_mask[i], ~0); + atomic_store_rel_xen_ulong(&s->evtchn_mask[i], ~0); /* Clear existing port mappings */ for (isrc_idx = 0; isrc_idx < NR_EVENT_CHANNELS; ++isrc_idx) diff --git a/sys/x86/include/xen/xen-os.h b/sys/x86/include/xen/xen-os.h index 6a3b82c0ba62..12942375be43 100644 --- a/sys/x86/include/xen/xen-os.h +++ b/sys/x86/include/xen/xen-os.h @@ -54,6 +54,16 @@ extern int xen_disable_pv_nics; extern uint32_t xen_cpuid_base; +/* compatibility for accessing xen_ulong_t with atomics */ +#define atomic_clear_xen_ulong atomic_clear_long +#define atomic_set_xen_ulong atomic_set_long +#define atomic_readandclear_xen_ulong atomic_readandclear_long +#define atomic_testandset_xen_ulong atomic_testandset_long +#define atomic_load_acq_xen_ulong atomic_load_acq_long +#define atomic_store_rel_xen_ulong atomic_store_rel_long +#define atomic_set_xen_ulong atomic_set_long +#define atomic_clear_xen_ulong atomic_clear_long + static inline u_int XEN_CPUID_TO_VCPUID(u_int cpuid) { diff --git a/sys/xen/evtchn/evtchnvar.h b/sys/xen/evtchn/evtchnvar.h index 10eed8434ebe..455f7bcbd620 100644 --- a/sys/xen/evtchn/evtchnvar.h +++ b/sys/xen/evtchn/evtchnvar.h @@ -54,7 +54,7 @@ static inline int evtchn_test_and_set_mask(evtchn_port_t port) { - return (atomic_testandset_long(EVTCHN_PTR(mask, port), + return (atomic_testandset_xen_ulong(EVTCHN_PTR(mask, port), EVTCHN_BIT(port))); } @@ -67,7 +67,7 @@ static inline void evtchn_clear_port(evtchn_port_t port) { - atomic_clear_long(EVTCHN_PTR(pending, port), EVTCHN_MASK(port)); + atomic_clear_xen_ulong(EVTCHN_PTR(pending, port), EVTCHN_MASK(port)); } /** @@ -79,7 +79,7 @@ static inline void evtchn_mask_port(evtchn_port_t port) { - atomic_set_long(EVTCHN_PTR(mask, port), EVTCHN_MASK(port)); + atomic_set_xen_ulong(EVTCHN_PTR(mask, port), EVTCHN_MASK(port)); } /** diff --git a/sys/xen/xen-os.h b/sys/xen/xen-os.h index d009b1af11fa..d7e9b3ca8632 100644 --- a/sys/xen/xen-os.h +++ b/sys/xen/xen-os.h @@ -120,23 +120,23 @@ xen_initial_domain(void) #define NBPL (NBBY * sizeof(long)) static inline bool -xen_test_bit(int bit, volatile long *addr) +xen_test_bit(int bit, volatile xen_ulong_t *addr) { unsigned long mask = 1UL << (bit % NBPL); - return !!(atomic_load_acq_long(&addr[bit / NBPL]) & mask); + return !!(atomic_load_acq_xen_ulong(&addr[bit / NBPL]) & mask); } static inline void -xen_set_bit(int bit, volatile long *addr) +xen_set_bit(int bit, volatile xen_ulong_t *addr) { - atomic_set_long(&addr[bit / NBPL], 1UL << (bit % NBPL)); + atomic_set_xen_ulong(&addr[bit / NBPL], 1UL << (bit % NBPL)); } static inline void -xen_clear_bit(int bit, volatile long *addr) +xen_clear_bit(int bit, volatile xen_ulong_t *addr) { - atomic_clear_long(&addr[bit / NBPL], 1UL << (bit % NBPL)); + atomic_clear_xen_ulong(&addr[bit / NBPL], 1UL << (bit % NBPL)); } #undef NBPL