From nobody Mon Feb 9 10:52:08 2026 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; 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; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1768104755; cv=none; d=zohomail.com; s=zohoarc; b=hQ1XIyoThIJrKPrpDFXpX8+CNPqi0ZeHNW7D2PQ+WJD/wfcDLJptHmmDvdPQdQI3Zp+Sm6dqMeJsp4m14OISpet63Iy0pfjZV2Guc9aaqVj7pjJKe7SFNikiX07J7dheXwGutp8b/lvPUXFJeGHuYryK1j3bRQA5YUldo1BIAdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768104755; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/m1LF2NtAIDgbIpy2Al8n60LY4uT2dvKj7zYoQhSDbo=; b=V8X3r8sgEKdRqVQwpk7rQczFroquvf1ql4TePHQe/vKAQ3UOR5rEdiLnz1lCmoyWES7yl9YOMNWFKxH68EzQ3TEdTK3DjdT847t6Gx2s0W85Aw6dQu20Vjdx2SN4AZe1wl2HRvYq974Itkadp1pOJl7qR9KqHg4gXQ4QBPC/ptI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1768104755964872.3946839545982; Sat, 10 Jan 2026 20:12:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1199668.1515895 (Exim 4.92) (envelope-from ) id 1vemo5-0004kw-NO; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (output) from mailman id 1199668.1515895; Sun, 11 Jan 2026 04:12:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo5-0004jX-JR; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (input) for mailman id 1199668; Sun, 11 Jan 2026 04:12:00 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo4-0004c9-U8 for xen-devel@lists.xenproject.org; Sun, 11 Jan 2026 04:12:00 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1vemo2-001xog-19; Sun, 11 Jan 2026 04:11:58 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vemo2-000Y62-1F; Sun, 11 Jan 2026 04:11:58 +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 Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=/m1LF2NtAIDgbIpy2Al8n60LY4uT2dvKj7zYoQhSDbo=; b=CUAl6W3UatzdFdEXzrnO6uITi1 5AaHssv4pclOCF7xrV739auHVlzo7QXZP3AkfWJe3PQGhlAo3Zwf6WwumunB3OH8Xwi9QyUR3t/ik nxBAHU9gzsS34J+fbJigMuALA9Mf9MgLuYxPyCXCXoIG7xq60dr7IlVhCSf+WJYXmZXQ=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2 1/4] tests: fixup domid make fragment Date: Sat, 10 Jan 2026 20:11:42 -0800 Message-ID: <20260111041145.553673-2-dmukhin@ford.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260111041145.553673-1-dmukhin@ford.com> References: <20260111041145.553673-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1768104756455158500 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 There can be multiple test harnesses per one test target (e.g. harness.h and harness2.h). Account for that by further parametrizing existing emit-harness-nested-rule(). Add guard against HOSTCC !=3D CC (similarly to how its done in PDX unit tes= t). Account for multiple test targets in install and uninstall make targets. Introduce CFLAGS dedicated for find-next-bit.c only to avoid contaminating global CFLAGS. Honor mocked hypervisor header over tools/include/xen symlinks. Finally, add some clarifications for the functions. Amends: 2d5065060710 ("xen/domain: unify domain ID allocation") Signed-off-by: Denis Mukhin --- Changes since v1: - updated commentaries - added ability to select the harness header filename - fixup for picking up mocked header files --- tools/tests/domid/Makefile | 63 ++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile index 753129029ed9..dd22a25b038a 100644 --- a/tools/tests/domid/Makefile +++ b/tools/tests/domid/Makefile @@ -4,36 +4,55 @@ # # Copyright 2025 Ford Motor Company =20 -XEN_ROOT=3D$(CURDIR)/../../.. -include $(XEN_ROOT)/tools/Rules.mk - TESTS :=3D test-domid =20 +XEN_ROOT =3D $(CURDIR)/../../.. +include $(XEN_ROOT)/tools/Rules.mk + define list-c-headers $(shell sed -n \ 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) endef =20 -# NB: $1 cannot be a list +# Generate mock environment by replicating header file hierarchy; +# each header file will point to a harness header. +# +# $1 target +# $2 list of test harnesses define emit-harness-nested-rule -$(1): $(CURDIR)/harness.h - mkdir -p $$(@D); - ln -sf $$< $$@; +$(1): $(2) + set -e; \ + mkdir -p $$(@D); \ + for i in $(2); do [ -e $$@ ] || ln -s $$$$i $$@; done =20 endef =20 +# Helper function to emit mocked hypervisor code dependencies. +# +# $1 Harness file name. +# $2 Mocked hypervisor file name. +# $3 List of dependencies to mock. define emit-harness-rules -$(foreach x,$(2),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(x))) -$(1:.c=3D.o): $(addprefix $(CURDIR)/generated/,$(2)) +$(foreach x,$(3),$(call emit-harness-nested-rule,\ + $(CURDIR)/generated/$(x),\ + $(addprefix $(CURDIR)/,$(1)))) +$(2:.c=3D.o): $(addprefix $(CURDIR)/generated/,$(3)) endef =20 define emit-harness-deps -$(if $(strip $(2)),$(call emit-harness-rules,$1,$2),) +$(if $(strip $(3)),$(call emit-harness-rules,$1,$2,$3),) endef =20 +# Emit dependencies for mocked hypervisor code. +# +# $1 Hypervisor file name. +# $2 Hypervisor source path. +# $3 Harness header file name (optional). define vpath-with-harness-deps vpath $(1) $(2) -$(call emit-harness-deps,$(1),$(call list-c-headers,$(2)$(1))) +$(call emit-harness-deps,$(or $(strip $(3)),harness.h),\ + $(1),\ + $(call list-c-headers,$(2)$(1))) endef =20 .PHONY: all @@ -41,7 +60,11 @@ all: $(TESTS) =20 .PHONY: run run: $(TESTS) +ifeq ($(CC),$(HOSTCC)) set -e; $(foreach t,$(TESTS),./$(t);) +else + $(warning HOSTCC !=3D CC, will not run test) +endif =20 .PHONY: clean clean: @@ -55,25 +78,27 @@ distclean: clean .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests - $(INSTALL_PROG) test-domid $(DESTDIR)$(LIBEXEC)/tests + set -e; $(foreach t,$(TESTS),$(INSTALL_PROG) $t $(DESTDIR)$(LIBEXEC)/test= s;) =20 .PHONY: uninstall uninstall: - $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/test-domid + set -e; $(foreach t,$(TESTS),$(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$t;) =20 CFLAGS +=3D -D__XEN_TOOLS__ + # find-next-bit.c -CFLAGS +=3D '-DEXPORT_SYMBOL(x)=3D' \ +CFLAGS-find-next-bit.c +=3D '-DEXPORT_SYMBOL(x)=3D' \ -Dfind_first_bit \ -Dfind_first_zero_bit \ -Dfind_next_bit \ -Dfind_next_bit_le \ -Dfind_next_zero_bit_le -CFLAGS +=3D $(APPEND_CFLAGS) -CFLAGS +=3D $(CFLAGS_xeninclude) -CFLAGS +=3D -I./generated/ =20 -LDFLAGS +=3D $(APPEND_LDFLAGS) +find-next-bit.o: CFLAGS +=3D $(CFLAGS-find-next-bit.c) + +# Honor mocked hypervisor header over tools/include/xen symlinks +CFLAGS +=3D -I$(CURDIR)/generated/ +CFLAGS +=3D $(CFLAGS_xeninclude) =20 vpath find-next-bit.c $(XEN_ROOT)/xen/lib/ =20 @@ -83,6 +108,6 @@ vpath find-next-bit.c $(XEN_ROOT)/xen/lib/ $(eval $(call vpath-with-harness-deps,domid.c,$(XEN_ROOT)/xen/common/)) =20 test-domid: domid.o find-next-bit.o test-domid.o - $(CC) $^ -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ =20 -include $(DEPS_INCLUDE) --=20 2.52.0 From nobody Mon Feb 9 10:52:08 2026 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; 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; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1768104751; cv=none; d=zohomail.com; s=zohoarc; b=RyusAw4q9Gr+aUCpLNUBkEAKyQpENUWTgv6ZeNX6FDLKLDVqfWzkSZXxI2hGRO6QRIeCiNlnQ+xbSM+n8aCbWBb5QhQg40ydKj5pJA/wm7dwwUSc/8k6bvVR9qrByYxpEWUzCLN7ipCEdHLKvBzkCaC2dNAxVq/2QrHwxNXAns0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768104751; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z0BRzvSQDE7UJZD2daLQhudqHPC6UC9KqBQjEA1pAzs=; b=MXM2MoXoPKRpRi91RDwbJUgSWMYMoeVTQzrYGKsV/HeRJGosXkqKUiEtHs9gx5detOIfBWW9hMGFXAhlDVYy+4KZeaBXuBcfCnqhGPAKHKo32lt08tOpwwnWfUV8fh3Izsj2vIiRj6Djd+QydDVrd8OXZZSRiRIXEfsR+/zsj0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1768104751370857.3544224635384; Sat, 10 Jan 2026 20:12:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1199667.1515890 (Exim 4.92) (envelope-from ) id 1vemo5-0004gc-Ew; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (output) from mailman id 1199667.1515890; Sun, 11 Jan 2026 04:12:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo5-0004gS-Ba; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (input) for mailman id 1199667; Sun, 11 Jan 2026 04:12:00 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo4-0004US-7N for xen-devel@lists.xenproject.org; Sun, 11 Jan 2026 04:12:00 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1vemo3-001xp0-1P; Sun, 11 Jan 2026 04:11:59 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vemo3-000Y66-1a; Sun, 11 Jan 2026 04:11:59 +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 Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=Z0BRzvSQDE7UJZD2daLQhudqHPC6UC9KqBQjEA1pAzs=; b=mgyg3C6YsbCXZFaBrHz+riy+N+ HfIJurtobX+6Bmy5GAepH2bL2pzL1w43IVmaRJjdhkZd5qykQt2+JKl++bgtD8ZoGC+1S/prDcxfV zNLa+VTOJEGIRwNCDR+u2EYptnEb1m7ivYyyD/rRCrEtVRpDm2Ye21+SK6MRx0/AmA/0=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2 2/4] tests: introduce common fragment for unit tests Date: Sat, 10 Jan 2026 20:11:43 -0800 Message-ID: <20260111041145.553673-3-dmukhin@ford.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260111041145.553673-1-dmukhin@ford.com> References: <20260111041145.553673-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1768104752474158500 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Move test harness generation into a new shared make fragment so that it can be reused by other unit tests. Signed-off-by: Denis Mukhin Reviewed-by: Stefano Stabellini --- Changes from v1: - moved fragment to tools/tests/ --- tools/tests/Rules.mk | 91 ++++++++++++++++++++++++++++++++++++++ tools/tests/domid/Makefile | 85 +---------------------------------- 2 files changed, 92 insertions(+), 84 deletions(-) create mode 100644 tools/tests/Rules.mk diff --git a/tools/tests/Rules.mk b/tools/tests/Rules.mk new file mode 100644 index 000000000000..daa9e69301e4 --- /dev/null +++ b/tools/tests/Rules.mk @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Common unit test fragment. +# +# Copyright 2025 Ford Motor Company + +include $(XEN_ROOT)/tools/Rules.mk + +define list-c-headers +$(shell sed -n \ + 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) +endef + +# Generate mock environment by replicating header file hierarchy; +# each header file will point to a harness header. +# +# $1 target +# $2 list of test harnesses +define emit-harness-nested-rule +$(1): $(2) + set -e; \ + mkdir -p $$(@D); \ + for i in $(2); do [ -e $$@ ] || ln -s $$$$i $$@; done + +endef + +# Helper function to emit mocked hypervisor code dependencies. +# +# $1 Harness file name. +# $2 Mocked hypervisor file name. +# $3 List of dependencies to mock. +define emit-harness-rules +$(foreach x,$(3),$(call emit-harness-nested-rule,\ + $(CURDIR)/generated/$(x),\ + $(addprefix $(CURDIR)/,$(1)))) +$(2:.c=3D.o): $(addprefix $(CURDIR)/generated/,$(3)) +endef + +define emit-harness-deps +$(if $(strip $(3)),$(call emit-harness-rules,$1,$2,$3),) +endef + +# Emit dependencies for mocked hypervisor code. +# +# $1 Hypervisor file name. +# $2 Hypervisor source path. +# $3 Harness header file name (optional). +define vpath-with-harness-deps +vpath $(1) $(2) +$(call emit-harness-deps,$(or $(strip $(3)),harness.h),\ + $(1),\ + $(call list-c-headers,$(2)$(1))) +endef + +.PHONY: all +all: $(TESTS) + +.PHONY: run +run: $(TESTS) +ifeq ($(CC),$(HOSTCC)) + set -e; $(foreach t,$(TESTS),./$(t);) +else + $(warning HOSTCC !=3D CC, will not run test) +endif + +.PHONY: clean +clean: + $(RM) -r generated + $(RM) -- *.o $(TESTS) $(DEPS_RM) + +.PHONY: distclean +distclean: clean + $(RM) -- *~ + +.PHONY: install +install: all + $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests + set -e; $(foreach t,$(TESTS),$(INSTALL_PROG) $t $(DESTDIR)$(LIBEXEC)/test= s;) + +.PHONY: uninstall +uninstall: + set -e; $(foreach t,$(TESTS),$(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$t;) + +CFLAGS +=3D -D__XEN_TOOLS__ +# Honor mocked hypervisor header over tools/include/xen symlinks +CFLAGS +=3D -I$(CURDIR)/generated/ +CFLAGS +=3D $(CFLAGS_xeninclude) + +ifeq ($(filter clean distclean,$(MAKECMDGOALS)),) +-include $(DEPS_INCLUDE) +endif diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile index dd22a25b038a..2f8cc5380462 100644 --- a/tools/tests/domid/Makefile +++ b/tools/tests/domid/Makefile @@ -7,84 +7,7 @@ TESTS :=3D test-domid =20 XEN_ROOT =3D $(CURDIR)/../../.. -include $(XEN_ROOT)/tools/Rules.mk - -define list-c-headers -$(shell sed -n \ - 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) -endef - -# Generate mock environment by replicating header file hierarchy; -# each header file will point to a harness header. -# -# $1 target -# $2 list of test harnesses -define emit-harness-nested-rule -$(1): $(2) - set -e; \ - mkdir -p $$(@D); \ - for i in $(2); do [ -e $$@ ] || ln -s $$$$i $$@; done - -endef - -# Helper function to emit mocked hypervisor code dependencies. -# -# $1 Harness file name. -# $2 Mocked hypervisor file name. -# $3 List of dependencies to mock. -define emit-harness-rules -$(foreach x,$(3),$(call emit-harness-nested-rule,\ - $(CURDIR)/generated/$(x),\ - $(addprefix $(CURDIR)/,$(1)))) -$(2:.c=3D.o): $(addprefix $(CURDIR)/generated/,$(3)) -endef - -define emit-harness-deps -$(if $(strip $(3)),$(call emit-harness-rules,$1,$2,$3),) -endef - -# Emit dependencies for mocked hypervisor code. -# -# $1 Hypervisor file name. -# $2 Hypervisor source path. -# $3 Harness header file name (optional). -define vpath-with-harness-deps -vpath $(1) $(2) -$(call emit-harness-deps,$(or $(strip $(3)),harness.h),\ - $(1),\ - $(call list-c-headers,$(2)$(1))) -endef - -.PHONY: all -all: $(TESTS) - -.PHONY: run -run: $(TESTS) -ifeq ($(CC),$(HOSTCC)) - set -e; $(foreach t,$(TESTS),./$(t);) -else - $(warning HOSTCC !=3D CC, will not run test) -endif - -.PHONY: clean -clean: - $(RM) -r generated - $(RM) -- *.o $(TESTS) $(DEPS_RM) - -.PHONY: distclean -distclean: clean - $(RM) -- *~ - -.PHONY: install -install: all - $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests - set -e; $(foreach t,$(TESTS),$(INSTALL_PROG) $t $(DESTDIR)$(LIBEXEC)/test= s;) - -.PHONY: uninstall -uninstall: - set -e; $(foreach t,$(TESTS),$(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$t;) - -CFLAGS +=3D -D__XEN_TOOLS__ +include $(XEN_ROOT)/tools/tests/Rules.mk =20 # find-next-bit.c CFLAGS-find-next-bit.c +=3D '-DEXPORT_SYMBOL(x)=3D' \ @@ -96,10 +19,6 @@ CFLAGS-find-next-bit.c +=3D '-DEXPORT_SYMBOL(x)=3D' \ =20 find-next-bit.o: CFLAGS +=3D $(CFLAGS-find-next-bit.c) =20 -# Honor mocked hypervisor header over tools/include/xen symlinks -CFLAGS +=3D -I$(CURDIR)/generated/ -CFLAGS +=3D $(CFLAGS_xeninclude) - vpath find-next-bit.c $(XEN_ROOT)/xen/lib/ =20 # Point to the hypervisor code and generate test harness dependencies @@ -109,5 +28,3 @@ $(eval $(call vpath-with-harness-deps,domid.c,$(XEN_ROOT= )/xen/common/)) =20 test-domid: domid.o find-next-bit.o test-domid.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ - --include $(DEPS_INCLUDE) --=20 2.52.0 From nobody Mon Feb 9 10:52:08 2026 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; 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; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1768104751; cv=none; d=zohomail.com; s=zohoarc; b=m+eoIDpqDyWlkHCsFqjUox66GL79g5qxNIfDMD3OZHXxgekakbS6PKaCHqO4cmRMhBguOrxSTqbMwn4daYn542UicHoI+O4by4CsOor3vOCC6emBL79P+kKo2/ZuLZCpSAau31gXQ5h5JVlQDstOYk8o6Ad/HU/tkEwvoBclPAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768104751; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I1QkihUJOTF7JtgRUB5yX7oCjGpry5xRBIdICxe+gYk=; b=DOpw+vaZft3k27uXT5oT3MQcIqwtWJ6i1ZHE57Nz74ZaWvzbRbnTKa4v12HOolMHKBKi1weyv5HhQvt5dkEPoIU79VVXDfMZizVeO+kKXuUy/xwC84NJVujS6M/RVDb2W1vUFjJv/hP7yk6Z0vEv6R6A9cu2Ym75PhwXyKT0izM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1768104751673959.4808611632917; Sat, 10 Jan 2026 20:12:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1199669.1515901 (Exim 4.92) (envelope-from ) id 1vemo6-0004pg-1h; Sun, 11 Jan 2026 04:12:02 +0000 Received: by outflank-mailman (output) from mailman id 1199669.1515901; Sun, 11 Jan 2026 04:12:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo5-0004ny-RZ; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (input) for mailman id 1199669; Sun, 11 Jan 2026 04:12:01 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo5-0004eg-53 for xen-devel@lists.xenproject.org; Sun, 11 Jan 2026 04:12:01 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1vemo4-001xp8-1k; Sun, 11 Jan 2026 04:12:00 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vemo4-000Y6C-1v; Sun, 11 Jan 2026 04:12:00 +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 Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=I1QkihUJOTF7JtgRUB5yX7oCjGpry5xRBIdICxe+gYk=; b=MxyA8O4DxFbU3PEJIfevcftBz+ Rzphjx6t27+g4MdrzScdGOpFv+c3gLxD9h/a2cZUjSFv+qvYVfLkd0+1LqtkJO0DGhOI0AVVjFYFV NAI2/NpQk2PfSOuT104fQRvc5YqiSmChOylympOMKQoQGCUippF+bDSQwudQqkCqiAdI=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2 3/4] tests: use unit test fragment in PDX test Date: Sat, 10 Jan 2026 20:11:44 -0800 Message-ID: <20260111041145.553673-4-dmukhin@ford.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260111041145.553673-1-dmukhin@ford.com> References: <20260111041145.553673-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1768104752431158500 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Use the new make fragment to generate test harness code for the PDX unit te= st. Move earlier in xen/common/pdx.c to ensure harness.h is included before triggering the #ifndef MAX_PFN_RANGES check when building a unit test. Additionally, use real in harness.h instead of a locally copied version. Update .gitignore to exclude generated test build-time dependencies. Not a functional change. Signed-off-by: Denis Mukhin --- Changes since v1: - new patch --- tools/tests/pdx/.gitignore | 2 +- tools/tests/pdx/Makefile | 55 +++++++++----------------------------- tools/tests/pdx/harness.h | 2 +- tools/tests/pdx/test-pdx.c | 2 -- xen/common/pdx.c | 3 ++- 5 files changed, 16 insertions(+), 48 deletions(-) diff --git a/tools/tests/pdx/.gitignore b/tools/tests/pdx/.gitignore index 1202a531a7fd..1bf9c05985c4 100644 --- a/tools/tests/pdx/.gitignore +++ b/tools/tests/pdx/.gitignore @@ -1,3 +1,3 @@ -/pdx.h +/generated /test-pdx-mask /test-pdx-offset diff --git a/tools/tests/pdx/Makefile b/tools/tests/pdx/Makefile index 3c431d7c7822..178b451cb611 100644 --- a/tools/tests/pdx/Makefile +++ b/tools/tests/pdx/Makefile @@ -1,50 +1,19 @@ -XEN_ROOT=3D$(CURDIR)/../../.. -include $(XEN_ROOT)/tools/Rules.mk +# SPDX-License-Identifier: GPL-2.0-only +# +# Unit tests for PDX (Page inDeX). +# =20 -TARGETS :=3D test-pdx-mask test-pdx-offset +TESTS :=3D test-pdx-mask test-pdx-offset =20 -.PHONY: all -all: $(TARGETS) +XEN_ROOT =3D $(CURDIR)/../../.. =20 -.PHONY: run -run: $(TARGETS) -ifeq ($(CC),$(HOSTCC)) - set -e; \ - for test in $? ; do \ - ./$$test ; \ - done -else - $(warning HOSTCC !=3D CC, will not run test) -endif +CFLAGS +=3D -DCONFIG_PDX_MASK_COMPRESSION =20 -.PHONY: clean -clean: - $(RM) -- *.o $(TARGETS) $(DEPS_RM) pdx.h +include $(XEN_ROOT)/tools/tests/Rules.mk =20 -.PHONY: distclean -distclean: clean - $(RM) -- *~ +CFLAGS +=3D -I $(XEN_ROOT)/xen/include/ =20 -.PHONY: install -install: all - $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests - $(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(LIBEXEC)/tests +$(eval $(call vpath-with-harness-deps,pdx.c,$(XEN_ROOT)/xen/common/)) =20 -.PHONY: uninstall -uninstall: - $(RM) -- $(patsubst %,$(DESTDIR)$(LIBEXEC)/tests/%,$(TARGETS)) - -pdx.h: $(XEN_ROOT)/xen/include/xen/pdx.h - sed -e '/^#[[:space:]]*include/d' <$< >$@ - -CFLAGS +=3D -D__XEN_TOOLS__ -CFLAGS +=3D $(APPEND_CFLAGS) -CFLAGS +=3D $(CFLAGS_xeninclude) - -test-pdx-mask: CFLAGS +=3D -DCONFIG_PDX_MASK_COMPRESSION -test-pdx-offset: CFLAGS +=3D -DCONFIG_PDX_OFFSET_COMPRESSION - -test-pdx-%: test-pdx.c pdx.h - $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -o $@ $< $(APPEND_CFLAGS) - --include $(DEPS_INCLUDE) +test-pdx-%: test-pdx.o pdx.o + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ diff --git a/tools/tests/pdx/harness.h b/tools/tests/pdx/harness.h index e49d6bcf92c2..4cdda931feb2 100644 --- a/tools/tests/pdx/harness.h +++ b/tools/tests/pdx/harness.h @@ -84,7 +84,7 @@ typedef uint64_t paddr_t; qsort(elem, nr, size, cmp); \ }) =20 -#include "pdx.h" +#include =20 #endif =20 diff --git a/tools/tests/pdx/test-pdx.c b/tools/tests/pdx/test-pdx.c index eefd54c76815..3633c231abaa 100644 --- a/tools/tests/pdx/test-pdx.c +++ b/tools/tests/pdx/test-pdx.c @@ -7,8 +7,6 @@ =20 #include "harness.h" =20 -#include "../../xen/common/pdx.c" - struct range { /* Ranges are defined as [start, end). */ unsigned long start, end; diff --git a/xen/common/pdx.c b/xen/common/pdx.c index 7e070ff962e8..068a2098b41b 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -15,11 +15,12 @@ * along with this program; If not, see . */ =20 +#include + /* Trim content when built for the test harness. */ #ifdef __XEN__ #include #include -#include #include #include #include --=20 2.52.0 From nobody Mon Feb 9 10:52:08 2026 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; 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; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1768104753; cv=none; d=zohomail.com; s=zohoarc; b=RM2A9gah+5Y/2lDgBlH54LxhiuU3/Quk/FYZtOurwH82AJIgzpd3jHIjjjQjOA2OvSE+L6WJtaicUX8/HB1Py/dsWm05ikSSErLFWx67mipqvK8lZIfd7KNLhTVBnsPfQTeTIGL9/fRnnMFCzP92ecuCi4/zahIBEBzDqotbPpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768104753; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=foxDb3geIou8JW8wuomGx2/i1qOo8eC7hBk0Ml/97QE=; b=VW1PNE35jMXk6hlgVsU9O7AwiVfmEcqLTWlcbPQMkElU11H8uE498sZnsdkQ1leZoNVHfcw7ttDQhawxyP9201ULG8xQ9e3OjiiOkXtxig5GYq7CVN4gzvh1bcldA8ShCbsxtK54gnsJ1CD2pu66FMu+stqODWzwpyBcc8UU0W0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1768104753519707.9770128560098; Sat, 10 Jan 2026 20:12:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1199670.1515921 (Exim 4.92) (envelope-from ) id 1vemo8-0005NY-84; Sun, 11 Jan 2026 04:12:04 +0000 Received: by outflank-mailman (output) from mailman id 1199670.1515921; Sun, 11 Jan 2026 04:12:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo8-0005NR-4z; Sun, 11 Jan 2026 04:12:04 +0000 Received: by outflank-mailman (input) for mailman id 1199670; Sun, 11 Jan 2026 04:12:02 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo6-00056N-G8 for xen-devel@lists.xenproject.org; Sun, 11 Jan 2026 04:12:02 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1vemo5-001xpY-21; Sun, 11 Jan 2026 04:12:01 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vemo5-000Y6K-2F; Sun, 11 Jan 2026 04:12:01 +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 Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=foxDb3geIou8JW8wuomGx2/i1qOo8eC7hBk0Ml/97QE=; b=U7mKRMHeM/Nu8OcpI71xY6D1sK hjbmlC8XouXkW3q6JlNMFecLWP/1Shj1wCzHf8W96hWwTr/UfrST5S8ZnlBpPvoX1YlZWsboOjPvL Oo7nhKw8JxSZ3zRpEvwY1Rwko1nmaJ0VecAjWog1NXw2PHlSU0u0Vwz/XD9vJemkrKKk=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2 4/4] tests: use unit test fragment in vPCI test Date: Sat, 10 Jan 2026 20:11:45 -0800 Message-ID: <20260111041145.553673-5-dmukhin@ford.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260111041145.553673-1-dmukhin@ford.com> References: <20260111041145.553673-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1768104754385158500 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Use the new make fragment to generate test harness code for the vPCI unit test. Add new prepare-harness target to tests/Rules.mk as an optional step for setting up mocked environment for building a test. Fix hypervisor headers used to compile vpci.c against host environment where necessary. Fixup emul.h by adding missing mocks to account for new unit test infra. Update .gitignore to exclude generated test build-time dependencies. Not a functional change. Signed-off-by: Denis Mukhin --- Changes since v1: - new patch --- tools/tests/Rules.mk | 5 +++- tools/tests/vpci/.gitignore | 2 ++ tools/tests/vpci/Makefile | 52 ++++++++++++------------------------- tools/tests/vpci/emul.h | 50 +++++++++++++---------------------- tools/tests/vpci/main.c | 2 -- xen/include/xen/irq.h | 2 ++ xen/include/xen/list.h | 2 ++ xen/include/xen/numa.h | 2 ++ xen/include/xen/pci.h | 2 ++ xen/include/xen/pfn.h | 2 ++ xen/include/xen/spinlock.h | 2 ++ xen/include/xen/types.h | 4 +++ 12 files changed, 56 insertions(+), 71 deletions(-) create mode 100644 tools/tests/vpci/.gitignore diff --git a/tools/tests/Rules.mk b/tools/tests/Rules.mk index daa9e69301e4..26f3d00b5fb9 100644 --- a/tools/tests/Rules.mk +++ b/tools/tests/Rules.mk @@ -11,13 +11,16 @@ $(shell sed -n \ 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) endef =20 +.PHONY: prepare-harness +prepare-harness: + # Generate mock environment by replicating header file hierarchy; # each header file will point to a harness header. # # $1 target # $2 list of test harnesses define emit-harness-nested-rule -$(1): $(2) +$(1): prepare-harness $(2) set -e; \ mkdir -p $$(@D); \ for i in $(2); do [ -e $$@ ] || ln -s $$$$i $$@; done diff --git a/tools/tests/vpci/.gitignore b/tools/tests/vpci/.gitignore new file mode 100644 index 000000000000..d66c2cd56be6 --- /dev/null +++ b/tools/tests/vpci/.gitignore @@ -0,0 +1,2 @@ +/generated +test-vpci diff --git a/tools/tests/vpci/Makefile b/tools/tests/vpci/Makefile index 97359ff67f86..695a275675f8 100644 --- a/tools/tests/vpci/Makefile +++ b/tools/tests/vpci/Makefile @@ -1,43 +1,23 @@ -XEN_ROOT=3D$(CURDIR)/../../.. -include $(XEN_ROOT)/tools/Rules.mk +# SPDX-License-Identifier: GPL-2.0-only +# +# Unit tests for vPCI. +# =20 -TARGET :=3D test_vpci +TESTS :=3D test-vpci =20 -.PHONY: all -all: $(TARGET) +XEN_ROOT =3D $(CURDIR)/../../.. +CFLAGS +=3D -DCONFIG_HAS_VPCI =20 -.PHONY: run -run: $(TARGET) -ifeq ($(CC),$(HOSTCC)) - ./$(TARGET) -else - $(warning HOSTCC !=3D CC, will not run test) -endif +include $(XEN_ROOT)/tools/tests/Rules.mk =20 -$(TARGET): vpci.c vpci.h list.h main.c emul.h - $(CC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c +# Do not mock xen/vpci.h header for the test +prepare-harness: + set -e; mkdir -p $(CURDIR)/generated/xen; \ + ln -sf $(XEN_ROOT)/xen/include/xen/vpci.h $(CURDIR)/generated/xen =20 -.PHONY: clean -clean: - rm -rf $(TARGET) *.o *~ vpci.h vpci.c list.h +CFLAGS +=3D -I $(XEN_ROOT)/xen/include/ =20 -.PHONY: distclean -distclean: clean +$(eval $(call vpath-with-harness-deps,vpci.c,$(XEN_ROOT)/xen/drivers/vpci/= ,emul.h)) =20 -.PHONY: install -install: all - $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests - $(INSTALL_PROG) $(TARGET) $(DESTDIR)$(LIBEXEC)/tests - -.PHONY: uninstall -uninstall: - $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$(TARGET) - -vpci.c: $(XEN_ROOT)/xen/drivers/vpci/vpci.c - # Remove includes and add the test harness header - sed -e '/#include/d' -e '1s/^/#include "emul.h"/' <$< >$@ - -list.h: $(XEN_ROOT)/xen/include/xen/list.h -vpci.h: $(XEN_ROOT)/xen/include/xen/vpci.h -list.h vpci.h: - sed -e '/#include/d' <$< >$@ +test-vpci: vpci.o main.o + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h index dd048cffbf9d..979e86e2692e 100644 --- a/tools/tests/vpci/emul.h +++ b/tools/tests/vpci/emul.h @@ -34,8 +34,16 @@ #define ASSERT(x) assert(x) #define __must_check __attribute__((__warn_unused_result__)) #define cf_check +#define always_inline inline =20 -#include "list.h" +typedef int64_t s_time_t; +typedef uint8_t nodeid_t; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +#include =20 typedef bool rwlock_t; =20 @@ -43,10 +51,6 @@ struct domain { rwlock_t pci_lock; }; =20 -struct pci_dev { - struct vpci *vpci; -}; - struct vcpu { struct domain *domain; @@ -57,35 +61,17 @@ extern const struct pci_dev test_pdev; =20 typedef bool spinlock_t; #define spin_lock_init(l) (*(l) =3D false) -#define spin_lock(l) (*(l) =3D true) -#define spin_unlock(l) (*(l) =3D false) -#define read_lock(l) (*(l) =3D true) -#define read_unlock(l) (*(l) =3D false) -#define write_lock(l) (*(l) =3D true) -#define write_unlock(l) (*(l) =3D false) +#define spin_lock(l) (assert(!*(l)), *(l) =3D true) +#define spin_unlock(l) (assert(*(l)), *(l) =3D false) +#define read_lock(l) (assert(!*(l)), *(l) =3D true) +#define read_unlock(l) (assert(*(l)), *(l) =3D false) +#define write_lock(l) (assert(!*(l)), *(l) =3D true) +#define write_unlock(l) (assert(*(l)), *(l) =3D false) =20 -typedef union { - uint32_t sbdf; - struct { - union { - uint16_t bdf; - struct { - union { - struct { - uint8_t func : 3, - dev : 5; - }; - uint8_t extfunc; - }; - uint8_t bus; - }; - }; - uint16_t seg; - }; -} pci_sbdf_t; +#define lock_evaluate_nospec(l) (l) +#define block_lock_speculation() =20 -#define CONFIG_HAS_VPCI -#include "vpci.h" +#include =20 #define __hwdom_init =20 diff --git a/tools/tests/vpci/main.c b/tools/tests/vpci/main.c index 2ef8d4e03f1d..3753417e866d 100644 --- a/tools/tests/vpci/main.c +++ b/tools/tests/vpci/main.c @@ -189,8 +189,6 @@ main(int argc, char **argv) uint32_t r24 =3D 0; uint8_t r28, r30; struct mask_data r32; - unsigned int i; - int rc; =20 INIT_LIST_HEAD(&vpci.handlers); spin_lock_init(&vpci.lock); diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 6071b00f621e..f7fa1d0fa29b 100644 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -1,5 +1,6 @@ #ifndef __XEN_IRQ_H__ #define __XEN_IRQ_H__ +#ifdef __XEN__ =20 #include #include @@ -208,4 +209,5 @@ unsigned int arch_hwdom_irqs(const struct domain *d); void arch_evtchn_bind_pirq(struct domain *d, int pirq); #endif =20 +#endif /* __XEN__ */ #endif /* __XEN_IRQ_H__ */ diff --git a/xen/include/xen/list.h b/xen/include/xen/list.h index 98d8482daba1..06d2fa3aed15 100644 --- a/xen/include/xen/list.h +++ b/xen/include/xen/list.h @@ -7,8 +7,10 @@ #ifndef __XEN_LIST_H__ #define __XEN_LIST_H__ =20 +#ifdef __XEN__ #include #include +#endif =20 /* * These are non-NULL pointers that will result in faults under normal diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index f6c1f27ca105..80d60fd49178 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -1,5 +1,6 @@ #ifndef _XEN_NUMA_H #define _XEN_NUMA_H +#ifdef __XEN__ =20 #include =20 @@ -152,4 +153,5 @@ static inline nodeid_t mfn_to_nid(mfn_t mfn) =20 #define page_to_nid(pg) mfn_to_nid(page_to_mfn(pg)) =20 +#endif /* __XEN__ */ #endif /* _XEN_NUMA_H */ diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index 130c2a8c1a65..f5965a68ae33 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -14,7 +14,9 @@ #include #include #include +#ifdef __XEN__ #include +#endif =20 /* * The PCI interface treats multi-function devices as independent diff --git a/xen/include/xen/pfn.h b/xen/include/xen/pfn.h index 1ca9b095e0df..98ff669d7def 100644 --- a/xen/include/xen/pfn.h +++ b/xen/include/xen/pfn.h @@ -1,7 +1,9 @@ #ifndef __XEN_PFN_H__ #define __XEN_PFN_H__ =20 +#ifdef __XEN__ #include +#endif =20 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h index ca9d8c7ec0a1..ad5094c4eb92 100644 --- a/xen/include/xen/spinlock.h +++ b/xen/include/xen/spinlock.h @@ -1,5 +1,6 @@ #ifndef __SPINLOCK_H__ #define __SPINLOCK_H__ +#ifdef __XEN__ =20 #include #include @@ -360,4 +361,5 @@ static always_inline void nrspin_lock_irq(rspinlock_t *= l) #define nrspin_unlock_irqrestore(l, f) _nrspin_unlock_irqrestore(l, f) #define nrspin_unlock_irq(l) _nrspin_unlock_irq(l) =20 +#endif /* __XEN__ */ #endif /* __SPINLOCK_H__ */ diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 73ddccbbd5dc..e5d702b48ac0 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -4,6 +4,7 @@ #include #include =20 +#ifdef __XEN__ /* Linux inherited types which are being phased out */ typedef uint8_t u8; typedef uint16_t u16; @@ -15,6 +16,7 @@ typedef uint64_t u64; typedef __SIZE_TYPE__ size_t; =20 typedef signed long ssize_t; +#endif /* __XEN__ */ =20 typedef __PTRDIFF_TYPE__ ptrdiff_t; typedef __UINTPTR_TYPE__ uintptr_t; @@ -33,6 +35,7 @@ typedef __UINTPTR_TYPE__ uintptr_t; #define NULL ((void*)0) #endif =20 +#ifdef __XEN__ #define INT8_MIN (-127-1) #define INT16_MIN (-32767-1) #define INT32_MIN (-2147483647-1) @@ -52,6 +55,7 @@ typedef __UINTPTR_TYPE__ uintptr_t; #define LONG_MAX ((long)(~0UL>>1)) #define LONG_MIN (-LONG_MAX - 1) #define ULONG_MAX (~0UL) +#endif /* __XEN__ */ =20 typedef uint16_t __le16; typedef uint16_t __be16; --=20 2.52.0