tools/virtio/linux/cpumask.h | 7 +++++++ tools/virtio/linux/gfp.h | 7 +++++++ tools/virtio/linux/kernel.h | 1 + tools/virtio/linux/kmsan.h | 12 ++++++++++++ tools/virtio/linux/log2.h | 11 +++++++++++ tools/virtio/linux/topology.h | 7 +++++++ 6 files changed, 45 insertions(+) create mode 100644 tools/virtio/linux/cpumask.h create mode 100644 tools/virtio/linux/gfp.h create mode 100644 tools/virtio/linux/kmsan.h create mode 100644 tools/virtio/linux/log2.h create mode 100644 tools/virtio/linux/topology.h
Fix the build caused by missing kmsan_handle_dma() and is_power_of_2() that
are used in drivers/virtio/virtio_ring.c.
Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
---
tools/virtio/linux/cpumask.h | 7 +++++++
tools/virtio/linux/gfp.h | 7 +++++++
tools/virtio/linux/kernel.h | 1 +
tools/virtio/linux/kmsan.h | 12 ++++++++++++
tools/virtio/linux/log2.h | 11 +++++++++++
tools/virtio/linux/topology.h | 7 +++++++
6 files changed, 45 insertions(+)
create mode 100644 tools/virtio/linux/cpumask.h
create mode 100644 tools/virtio/linux/gfp.h
create mode 100644 tools/virtio/linux/kmsan.h
create mode 100644 tools/virtio/linux/log2.h
create mode 100644 tools/virtio/linux/topology.h
diff --git a/tools/virtio/linux/cpumask.h b/tools/virtio/linux/cpumask.h
new file mode 100644
index 000000000000..307da69d6b26
--- /dev/null
+++ b/tools/virtio/linux/cpumask.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CPUMASK_H
+#define _LINUX_CPUMASK_H
+
+#include <linux/kernel.h>
+
+#endif /* _LINUX_CPUMASK_H */
diff --git a/tools/virtio/linux/gfp.h b/tools/virtio/linux/gfp.h
new file mode 100644
index 000000000000..43d146f236f1
--- /dev/null
+++ b/tools/virtio/linux/gfp.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_GFP_H
+#define __LINUX_GFP_H
+
+#include <linux/topology.h>
+
+#endif
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 21593bf97755..8b877167933d 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -10,6 +10,7 @@
#include <stdarg.h>
#include <linux/compiler.h>
+#include <linux/log2.h>
#include <linux/types.h>
#include <linux/overflow.h>
#include <linux/list.h>
diff --git a/tools/virtio/linux/kmsan.h b/tools/virtio/linux/kmsan.h
new file mode 100644
index 000000000000..272b5aa285d5
--- /dev/null
+++ b/tools/virtio/linux/kmsan.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_KMSAN_H
+#define _LINUX_KMSAN_H
+
+#include <linux/gfp.h>
+
+inline void kmsan_handle_dma(struct page *page, size_t offset, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+#endif /* _LINUX_KMSAN_H */
diff --git a/tools/virtio/linux/log2.h b/tools/virtio/linux/log2.h
new file mode 100644
index 000000000000..aa67bb21d8e2
--- /dev/null
+++ b/tools/virtio/linux/log2.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _LINUX_LOG2_H
+#define _LINUX_LOG2_H
+
+inline bool is_power_of_2(unsigned long n)
+{
+ return true;
+}
+
+#endif /* _LINUX_LOG2_H */
diff --git a/tools/virtio/linux/topology.h b/tools/virtio/linux/topology.h
new file mode 100644
index 000000000000..910794afb993
--- /dev/null
+++ b/tools/virtio/linux/topology.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_TOPOLOGY_H
+#define _LINUX_TOPOLOGY_H
+
+#include <linux/cpumask.h>
+
+#endif /* _LINUX_TOPOLOGY_H */
--
2.25.1
On Wed, Dec 21, 2022 at 04:55:06PM +0900, Shunsuke Mie wrote: >Fix the build caused by missing kmsan_handle_dma() and is_power_of_2() that >are used in drivers/virtio/virtio_ring.c. > >Signed-off-by: Shunsuke Mie <mie@igel.co.jp> >--- > tools/virtio/linux/cpumask.h | 7 +++++++ > tools/virtio/linux/gfp.h | 7 +++++++ > tools/virtio/linux/kernel.h | 1 + > tools/virtio/linux/kmsan.h | 12 ++++++++++++ > tools/virtio/linux/log2.h | 11 +++++++++++ > tools/virtio/linux/topology.h | 7 +++++++ > 6 files changed, 45 insertions(+) > create mode 100644 tools/virtio/linux/cpumask.h > create mode 100644 tools/virtio/linux/gfp.h > create mode 100644 tools/virtio/linux/kmsan.h > create mode 100644 tools/virtio/linux/log2.h > create mode 100644 tools/virtio/linux/topology.h > >diff --git a/tools/virtio/linux/cpumask.h b/tools/virtio/linux/cpumask.h >new file mode 100644 >index 000000000000..307da69d6b26 >--- /dev/null >+++ b/tools/virtio/linux/cpumask.h >@@ -0,0 +1,7 @@ >+/* SPDX-License-Identifier: GPL-2.0 */ >+#ifndef _LINUX_CPUMASK_H >+#define _LINUX_CPUMASK_H >+ >+#include <linux/kernel.h> >+ >+#endif /* _LINUX_CPUMASK_H */ >diff --git a/tools/virtio/linux/gfp.h b/tools/virtio/linux/gfp.h >new file mode 100644 >index 000000000000..43d146f236f1 >--- /dev/null >+++ b/tools/virtio/linux/gfp.h >@@ -0,0 +1,7 @@ >+/* SPDX-License-Identifier: GPL-2.0 */ >+#ifndef __LINUX_GFP_H >+#define __LINUX_GFP_H >+ >+#include <linux/topology.h> >+ >+#endif >diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h >index 21593bf97755..8b877167933d 100644 >--- a/tools/virtio/linux/kernel.h >+++ b/tools/virtio/linux/kernel.h >@@ -10,6 +10,7 @@ > #include <stdarg.h> > > #include <linux/compiler.h> >+#include <linux/log2.h> > #include <linux/types.h> > #include <linux/overflow.h> > #include <linux/list.h> >diff --git a/tools/virtio/linux/kmsan.h b/tools/virtio/linux/kmsan.h >new file mode 100644 >index 000000000000..272b5aa285d5 >--- /dev/null >+++ b/tools/virtio/linux/kmsan.h >@@ -0,0 +1,12 @@ >+/* SPDX-License-Identifier: GPL-2.0 */ >+#ifndef _LINUX_KMSAN_H >+#define _LINUX_KMSAN_H >+ >+#include <linux/gfp.h> >+ >+inline void kmsan_handle_dma(struct page *page, size_t offset, size_t size, >+ enum dma_data_direction dir) >+{ >+} >+ >+#endif /* _LINUX_KMSAN_H */ >diff --git a/tools/virtio/linux/log2.h b/tools/virtio/linux/log2.h >new file mode 100644 >index 000000000000..aa67bb21d8e2 >--- /dev/null >+++ b/tools/virtio/linux/log2.h >@@ -0,0 +1,11 @@ >+/* SPDX-License-Identifier: GPL-2.0 */ >+ >+#ifndef _LINUX_LOG2_H >+#define _LINUX_LOG2_H >+ >+inline bool is_power_of_2(unsigned long n) >+{ >+ return true; >+} is_power_of_2 seems defined in tools/include/linux/log2.h so `#include <linux/log2.h>` in tools/virtio/linux/kernel.h should be enough. If that's not the case, however, I think we should return true here only if n is really power of 2. Thanks, Stefano
Thank you for your quick response. On 2022/12/21 18:13, Stefano Garzarella wrote: > On Wed, Dec 21, 2022 at 04:55:06PM +0900, Shunsuke Mie wrote: >> Fix the build caused by missing kmsan_handle_dma() and >> is_power_of_2() that >> are used in drivers/virtio/virtio_ring.c. >> >> Signed-off-by: Shunsuke Mie <mie@igel.co.jp> >> --- >> tools/virtio/linux/cpumask.h | 7 +++++++ >> tools/virtio/linux/gfp.h | 7 +++++++ >> tools/virtio/linux/kernel.h | 1 + >> tools/virtio/linux/kmsan.h | 12 ++++++++++++ >> tools/virtio/linux/log2.h | 11 +++++++++++ >> tools/virtio/linux/topology.h | 7 +++++++ >> 6 files changed, 45 insertions(+) >> create mode 100644 tools/virtio/linux/cpumask.h >> create mode 100644 tools/virtio/linux/gfp.h >> create mode 100644 tools/virtio/linux/kmsan.h >> create mode 100644 tools/virtio/linux/log2.h >> create mode 100644 tools/virtio/linux/topology.h >> >> diff --git a/tools/virtio/linux/cpumask.h b/tools/virtio/linux/cpumask.h >> new file mode 100644 >> index 000000000000..307da69d6b26 >> --- /dev/null >> +++ b/tools/virtio/linux/cpumask.h >> @@ -0,0 +1,7 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +#ifndef _LINUX_CPUMASK_H >> +#define _LINUX_CPUMASK_H >> + >> +#include <linux/kernel.h> >> + >> +#endif /* _LINUX_CPUMASK_H */ >> diff --git a/tools/virtio/linux/gfp.h b/tools/virtio/linux/gfp.h >> new file mode 100644 >> index 000000000000..43d146f236f1 >> --- /dev/null >> +++ b/tools/virtio/linux/gfp.h >> @@ -0,0 +1,7 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +#ifndef __LINUX_GFP_H >> +#define __LINUX_GFP_H >> + >> +#include <linux/topology.h> >> + >> +#endif >> diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h >> index 21593bf97755..8b877167933d 100644 >> --- a/tools/virtio/linux/kernel.h >> +++ b/tools/virtio/linux/kernel.h >> @@ -10,6 +10,7 @@ >> #include <stdarg.h> >> >> #include <linux/compiler.h> >> +#include <linux/log2.h> >> #include <linux/types.h> >> #include <linux/overflow.h> >> #include <linux/list.h> >> diff --git a/tools/virtio/linux/kmsan.h b/tools/virtio/linux/kmsan.h >> new file mode 100644 >> index 000000000000..272b5aa285d5 >> --- /dev/null >> +++ b/tools/virtio/linux/kmsan.h >> @@ -0,0 +1,12 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +#ifndef _LINUX_KMSAN_H >> +#define _LINUX_KMSAN_H >> + >> +#include <linux/gfp.h> >> + >> +inline void kmsan_handle_dma(struct page *page, size_t offset, >> size_t size, >> + enum dma_data_direction dir) >> +{ >> +} >> + >> +#endif /* _LINUX_KMSAN_H */ >> diff --git a/tools/virtio/linux/log2.h b/tools/virtio/linux/log2.h >> new file mode 100644 >> index 000000000000..aa67bb21d8e2 >> --- /dev/null >> +++ b/tools/virtio/linux/log2.h >> @@ -0,0 +1,11 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> + >> +#ifndef _LINUX_LOG2_H >> +#define _LINUX_LOG2_H >> + >> +inline bool is_power_of_2(unsigned long n) >> +{ >> + return true; >> +} > > is_power_of_2 seems defined in tools/include/linux/log2.h so > `#include <linux/log2.h>` in tools/virtio/linux/kernel.h should be > enough. > > If that's not the case, however, I think we should return true here only > if n is really power of 2. I'm going to check and try those. > Thanks, > Stefano > Best, Shunsuke
© 2016 - 2025 Red Hat, Inc.