* [PATCH v7 0/2] introduce stub directory to storing empty/stub headers
@ 2023-09-07 15:15 Oleksii Kurochko
2023-09-07 15:15 ` [PATCH v7 1/2] xen: asm-generic support Oleksii Kurochko
2023-09-07 15:16 ` [PATCH v7 2/2] xen: move arm/include/asm/vm_event.h to asm-generic Oleksii Kurochko
0 siblings, 2 replies; 3+ messages in thread
From: Oleksii Kurochko @ 2023-09-07 15:15 UTC (permalink / raw)
To: xen-devel
Cc: Anthony PERARD, Tamas K Lengyel, Oleksii Kurochko, Andrew Cooper,
George Dunlap, Jan Beulich, Julien Grall, Stefano Stabellini,
Wei Liu, Bertrand Marquis, Volodymyr Babchuk
A lot of empty/stub headers should be introduced during the early steps of adding
support of new architecture.
An example can be found here:
1. https://lore.kernel.org/xen-devel/cover.1692181079.git.oleksii.kurochko@gmail.com/
2. https://lore.kernel.org/xen-devel/a92f99e8f697da99d77bfde562a549dbef3760ce.1692816595.git.sanastasio@raptorengineering.com/
As part of the patch series, asm/vm_event.h was moved to the stubs directory because
It is the same for ARM, PPC, and RISC-V.
---
Changes in V7:
- update warning message in Makefile.asm-generic
- add Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> for patch 1
- add Acked-by: Jan Beulich <jbeulich@suse.com> for patch 1
- update header guards in asm-generic/vm_event.h.
- add Acked-by: Tamas K Lengyel <tamas@tklengyel.com> for patch 2
---
Changes in V6:
- introduce $(asm-generic) macro in Kbuild.include.
- move "asm-generic" after the rule "__distclean".
- update the commit message.
---
Changes in V5:
- Update SPDX license.
- Remove code related to UML in Makefile.asm-generic.
- Include $(src)/Makefile instead of $(kbuild-file).
- Update comment message in Makefile.asm-generic.
- Update .gitignore.
- Update path to generated headers in CFLAGS.
- Use the latest version of Linux's Makefile.asm-generic.
- Introduce asm-generic's vm_event.h.
- Switch ARM to use asm-generic/vm_event.h.
---
Changes in V4:
- add asm-generic support
- update path of vm_event.h from include/asm-generic/asm to include/asm-generic
---
Changes in V3:
- add Acked-by: Stefano Stabellini <sstabellini@kernel.org> for "xen: move arm/include/asm/vm_event.h to asm-generic"
- update SPDX tag.
- move asm/vm_event.h to asm-generic.
- rename stubs dir to asm-generic.
---
Changes in V2:
- change public/domctl.h to public/vm_event.h.
- update commit message of [PATCH v2 2/2] xen: move arm/include/asm/vm_event.h to stubs
Oleksii Kurochko (2):
xen: asm-generic support
xen: move arm/include/asm/vm_event.h to asm-generic
.gitignore | 1 +
xen/Makefile | 9 +++-
xen/arch/arm/include/asm/Makefile | 2 +
xen/arch/arm/include/asm/vm_event.h | 66 -----------------------------
xen/include/asm-generic/vm_event.h | 55 ++++++++++++++++++++++++
xen/scripts/Kbuild.include | 6 +++
xen/scripts/Makefile.asm-generic | 53 +++++++++++++++++++++++
7 files changed, 125 insertions(+), 67 deletions(-)
create mode 100644 xen/arch/arm/include/asm/Makefile
delete mode 100644 xen/arch/arm/include/asm/vm_event.h
create mode 100644 xen/include/asm-generic/vm_event.h
create mode 100644 xen/scripts/Makefile.asm-generic
--
2.41.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v7 1/2] xen: asm-generic support
2023-09-07 15:15 [PATCH v7 0/2] introduce stub directory to storing empty/stub headers Oleksii Kurochko
@ 2023-09-07 15:15 ` Oleksii Kurochko
2023-09-07 15:16 ` [PATCH v7 2/2] xen: move arm/include/asm/vm_event.h to asm-generic Oleksii Kurochko
1 sibling, 0 replies; 3+ messages in thread
From: Oleksii Kurochko @ 2023-09-07 15:15 UTC (permalink / raw)
To: xen-devel
Cc: Anthony PERARD, Tamas K Lengyel, Oleksii Kurochko, Andrew Cooper,
George Dunlap, Jan Beulich, Julien Grall, Stefano Stabellini,
Wei Liu
Some headers are shared between individual architectures or are empty.
To avoid duplication of these headers, asm-generic is introduced.
With the following patch, an architecture uses generic headers
mentioned in the file arch/$(ARCH)/include/asm/Makefile
To use a generic header is needed to add to
arch/$(ARCH)/include/asm/Makefile :
generic-y += <name-of-header-file.h>
For each mentioned header in arch/$(ARCH)/include/asm/Makefile,
the necessary wrapper in arch/$(ARCH)/include/generated/asm will be
generated.
As the base Makefile.asm-generic from Linux kernel was taken.
( 06c2afb862f9da8 "Linux 6.5-rc1" ).
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes in V7:
- update warning message in Makefile.asm-generic
- add Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
- add Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes in V6:
- introduce $(asm-generic) macro in Kbuild.include.
- move "asm-generic" after the rule "__distclean".
---
Changes in V5:
- Update the commit message
- Update SPDX license in Makefile.
- Remove code related to UML
- Include $(src)/Makefile instead of $(kbuild-file)
- Update comment message in Makefile.asm-generic
- Update .gitignore
- Update path to generated headers in CFLAGS.
- Use the latest version of Linux's Makefile.asm-generic
---
Changes in V4:
- introduce asm-generic support
- update commit message
---
Changes in V3:
- Rename stubs dir to asm-generic
---
Changes in V2:
- Nothing changed.
---
.gitignore | 1 +
xen/Makefile | 9 +++++-
xen/scripts/Kbuild.include | 6 ++++
xen/scripts/Makefile.asm-generic | 53 ++++++++++++++++++++++++++++++++
4 files changed, 68 insertions(+), 1 deletion(-)
create mode 100644 xen/scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 50273adb8d..287166f8fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -267,6 +267,7 @@ xen/arch/*/efi/efi.h
xen/arch/*/efi/pe.c
xen/arch/*/efi/runtime.c
xen/arch/*/include/asm/asm-offsets.h
+xen/arch/*/include/generated
xen/build-dir-cppcheck/
xen/common/config_data.S
xen/common/config.gz
diff --git a/xen/Makefile b/xen/Makefile
index f57e5a596c..2dc5e3526d 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -438,6 +438,7 @@ ifdef building_out_of_srctree
endif
CFLAGS += -I$(srctree)/include
CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include
+CFLAGS += -I$(objtree)/arch/$(SRCARCH)/include/generated
# Note that link order matters!
ALL_OBJS-y := common/built_in.o
@@ -580,16 +581,22 @@ _clean:
rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf $(TARGET).efi.stripped
rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h
rm -f .banner .allconfig.tmp include/xen/compile.h
+ rm -rf $(objtree)/arch/*/include/generated
.PHONY: _distclean
_distclean: clean
rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS .config source
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm
+
$(TARGET).gz: $(TARGET)
gzip -n -f -9 < $< > $@.new
mv $@.new $@
-$(TARGET): outputmakefile FORCE
+$(TARGET): outputmakefile asm-generic FORCE
$(Q)$(MAKE) $(build)=tools
$(Q)$(MAKE) $(build)=. include/xen/compile.h
$(Q)$(MAKE) $(build)=include all
diff --git a/xen/scripts/Kbuild.include b/xen/scripts/Kbuild.include
index 785a32c32e..c2bd8498e1 100644
--- a/xen/scripts/Kbuild.include
+++ b/xen/scripts/Kbuild.include
@@ -91,6 +91,12 @@ cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || e
clang-ifversion = $(shell [ $(CONFIG_CLANG_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
+###
+# Shorthand for $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj
+# Usage:
+# $(Q)$(MAKE) $(asm-generic)=dir
+asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
+
###
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
# Usage:
diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic
new file mode 100644
index 0000000000..b0d356bfa3
--- /dev/null
+++ b/xen/scripts/Makefile.asm-generic
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Makefile
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in arch/$(SRCARCH)/include/generated/asm.
+
+PHONY := all
+all:
+
+src := $(subst /generated,,$(obj))
+
+include $(srctree)/scripts/Kbuild.include
+-include $(src)/Makefile
+
+redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
+redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
+redundant := $(sort $(redundant))
+$(if $(redundant),\
+ $(warning redundant generic-y found in $(src)/Makefile: $(redundant)))
+
+# If arch does not implement mandatory headers, fallback to asm-generic ones.
+mandatory-y := $(filter-out $(generated-y), $(mandatory-y))
+generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(srctree)/$(src)/$(f)),,$(f)))
+
+generic-y := $(addprefix $(obj)/, $(generic-y))
+generated-y := $(addprefix $(obj)/, $(generated-y))
+
+# Remove stale wrappers when the corresponding files are removed from generic-y
+old-headers := $(wildcard $(obj)/*.h)
+unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers))
+
+quiet_cmd_wrap = WRAP $@
+ cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@
+
+quiet_cmd_remove = REMOVE $(unwanted)
+ cmd_remove = rm -f $(unwanted)
+
+all: $(generic-y)
+ $(if $(unwanted),$(call cmd,remove))
+ @:
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
+# Create output directory. Skip it if at least one old header exists
+# since we know the output directory already exists.
+ifeq ($(old-headers),)
+$(shell mkdir -p $(obj))
+endif
+
+.PHONY: $(PHONY)
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v7 2/2] xen: move arm/include/asm/vm_event.h to asm-generic
2023-09-07 15:15 [PATCH v7 0/2] introduce stub directory to storing empty/stub headers Oleksii Kurochko
2023-09-07 15:15 ` [PATCH v7 1/2] xen: asm-generic support Oleksii Kurochko
@ 2023-09-07 15:16 ` Oleksii Kurochko
1 sibling, 0 replies; 3+ messages in thread
From: Oleksii Kurochko @ 2023-09-07 15:16 UTC (permalink / raw)
To: xen-devel
Cc: Anthony PERARD, Tamas K Lengyel, Oleksii Kurochko,
Stefano Stabellini, Julien Grall, Bertrand Marquis,
Volodymyr Babchuk, Andrew Cooper, George Dunlap, Jan Beulich,
Wei Liu
asm/vm_event.h is common for ARM and RISC-V so it will be moved to
asm-generic dir.
Original asm/vm_event.h from ARM was updated:
* use SPDX-License-Identifier.
* update comment messages of stubs.
* update #ifdef
* instead of "include <public/domctl.h>" -> "public/vm_event.h"
As vm_event.h was moved to asm-generic then it is needed to create
Makefile in arm/include/asm/ and add generated-y += vm_event.h to
it.
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
---
Changes in V7:
- update guards in asm-generic/vm_event.h.
- add Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
---
Changes in V6:
- update the commit message.
---
Changes in V5:
- Update the commit message
- Remove Acked-by:...
- Switch ARM to use asm-generic/vm_event.h
---
Changes in V4:
- update path of vm_event.h from include/asm-generic/asm to include/asm-generic
---
Changes in V3:
- add Acked-by: Stefano Stabellini <sstabellini@kernel.org> for "xen: move arm/include/asm/vm_event.h to asm-generic"
- update SPDX tag.
- move asm/vm_event.h to asm-generic.
---
Changes in V2:
- change public/domctl.h to public/vm_event.h.
- update commit message of [PATCH v2 2/2] xen: move arm/include/asm/vm_event.h to stubs
---
xen/arch/arm/include/asm/Makefile | 2 +
xen/arch/arm/include/asm/vm_event.h | 66 -----------------------------
xen/include/asm-generic/vm_event.h | 55 ++++++++++++++++++++++++
3 files changed, 57 insertions(+), 66 deletions(-)
create mode 100644 xen/arch/arm/include/asm/Makefile
delete mode 100644 xen/arch/arm/include/asm/vm_event.h
create mode 100644 xen/include/asm-generic/vm_event.h
diff --git a/xen/arch/arm/include/asm/Makefile b/xen/arch/arm/include/asm/Makefile
new file mode 100644
index 0000000000..821addb0bf
--- /dev/null
+++ b/xen/arch/arm/include/asm/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+generic-y += vm_event.h
diff --git a/xen/arch/arm/include/asm/vm_event.h b/xen/arch/arm/include/asm/vm_event.h
deleted file mode 100644
index 4d861373b3..0000000000
--- a/xen/arch/arm/include/asm/vm_event.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * vm_event.h: architecture specific vm_event handling routines
- *
- * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __ASM_ARM_VM_EVENT_H__
-#define __ASM_ARM_VM_EVENT_H__
-
-#include <xen/sched.h>
-#include <public/domctl.h>
-
-static inline int vm_event_init_domain(struct domain *d)
-{
- /* Nothing to do. */
- return 0;
-}
-
-static inline void vm_event_cleanup_domain(struct domain *d)
-{
- memset(&d->monitor, 0, sizeof(d->monitor));
-}
-
-static inline void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v,
- vm_event_response_t *rsp)
-{
- /* Not supported on ARM. */
-}
-
-static inline
-void vm_event_register_write_resume(struct vcpu *v, vm_event_response_t *rsp)
-{
- /* Not supported on ARM. */
-}
-
-static inline
-void vm_event_emulate_check(struct vcpu *v, vm_event_response_t *rsp)
-{
- /* Not supported on ARM. */
-}
-
-static inline
-void vm_event_sync_event(struct vcpu *v, bool value)
-{
- /* Not supported on ARM. */
-}
-
-static inline
-void vm_event_reset_vmtrace(struct vcpu *v)
-{
- /* Not supported on ARM. */
-}
-
-#endif /* __ASM_ARM_VM_EVENT_H__ */
diff --git a/xen/include/asm-generic/vm_event.h b/xen/include/asm-generic/vm_event.h
new file mode 100644
index 0000000000..620c7b971c
--- /dev/null
+++ b/xen/include/asm-generic/vm_event.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * vm_event.h: stubs for architecture specific vm_event handling routines
+ *
+ * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com)
+ */
+
+#ifndef __ASM_GENERIC_VM_EVENT_H__
+#define __ASM_GENERIC_VM_EVENT_H__
+
+#include <xen/sched.h>
+#include <public/vm_event.h>
+
+static inline int vm_event_init_domain(struct domain *d)
+{
+ /* Nothing to do. */
+ return 0;
+}
+
+static inline void vm_event_cleanup_domain(struct domain *d)
+{
+ memset(&d->monitor, 0, sizeof(d->monitor));
+}
+
+static inline void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v,
+ vm_event_response_t *rsp)
+{
+ /* Nothing to do. */
+}
+
+static inline
+void vm_event_register_write_resume(struct vcpu *v, vm_event_response_t *rsp)
+{
+ /* Nothing to do. */
+}
+
+static inline
+void vm_event_emulate_check(struct vcpu *v, vm_event_response_t *rsp)
+{
+ /* Nothing to do. */
+}
+
+static inline
+void vm_event_sync_event(struct vcpu *v, bool value)
+{
+ /* Nothing to do. */
+}
+
+static inline
+void vm_event_reset_vmtrace(struct vcpu *v)
+{
+ /* Nothing to do. */
+}
+
+#endif /* __ASM_GENERIC_VM_EVENT_H__ */
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-07 15:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-07 15:15 [PATCH v7 0/2] introduce stub directory to storing empty/stub headers Oleksii Kurochko
2023-09-07 15:15 ` [PATCH v7 1/2] xen: asm-generic support Oleksii Kurochko
2023-09-07 15:16 ` [PATCH v7 2/2] xen: move arm/include/asm/vm_event.h to asm-generic Oleksii Kurochko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.