* [tip:x86/msr 5/19] drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations
@ 2025-05-07 16:41 kernel test robot
2025-05-07 18:40 ` [tip: x86/msr] accel/habanalabs: Add explicit include of <asm/tsc.h> to pick up the rdtsc() definition tip-bot2 for Ingo Molnar
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: kernel test robot @ 2025-05-07 16:41 UTC (permalink / raw)
To: Xin Li (Intel); +Cc: llvm, oe-kbuild-all, linux-kernel, x86, Ingo Molnar
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/msr
head: 570d58b12fbf7bae0ba72d929ccf914a4df5ca7c
commit: efef7f184f2eaf29a1ca676712d0e6e851cd0191 [5/19] x86/msr: Add explicit includes of <asm/msr.h>
config: um-allmodconfig (https://download.01.org/0day-ci/archive/20250508/202505080003.0t7ewxGp-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250508/202505080003.0t7ewxGp-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505080003.0t7ewxGp-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/accel/habanalabs/common/habanalabs_ioctl.c:11:
In file included from drivers/accel/habanalabs/common/habanalabs.h:11:
In file included from include/linux/habanalabs/cpucp_if.h:12:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:12:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:549:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
549 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:567:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
567 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/accel/habanalabs/common/habanalabs_ioctl.c:11:
In file included from drivers/accel/habanalabs/common/habanalabs.h:11:
In file included from include/linux/habanalabs/cpucp_if.h:12:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:12:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:585:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/accel/habanalabs/common/habanalabs_ioctl.c:11:
In file included from drivers/accel/habanalabs/common/habanalabs.h:11:
In file included from include/linux/habanalabs/cpucp_if.h:12:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:12:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:601:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
601 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:616:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
616 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:631:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
631 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:724:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
724 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:737:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
737 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:750:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
750 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:764:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
764 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:778:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
778 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:792:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
792 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
326 | time_sync.tsc_time = rdtsc();
| ^
12 warnings and 1 error generated.
vim +/rdtsc +326 drivers/accel/habanalabs/common/habanalabs_ioctl.c
52c01b0137193ab drivers/misc/habanalabs/habanalabs_ioctl.c Moti Haimovski 2019-11-03 314
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 315 static int time_sync_info(struct hl_device *hdev, struct hl_info_args *args)
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 316 {
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 317 struct hl_info_time_sync time_sync = {0};
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 318 u32 max_size = args->return_size;
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 319 void __user *out = (void __user *) (uintptr_t) args->return_pointer;
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 320
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 321 if ((!max_size) || (!out))
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 322 return -EINVAL;
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 323
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 324 time_sync.device_time = hdev->asic_funcs->get_device_time(hdev);
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 325 time_sync.host_time = ktime_get_raw_ns();
0648c4d0806fe16 drivers/accel/habanalabs/common/habanalabs_ioctl.c Hen Alon 2023-08-09 @326 time_sync.tsc_time = rdtsc();
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 327
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 328 return copy_to_user(out, &time_sync,
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 329 min((size_t) max_size, sizeof(time_sync))) ? -EFAULT : 0;
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 330 }
25e7aeba601c177 drivers/misc/habanalabs/habanalabs_ioctl.c Tomer Tayar 2020-03-31 331
:::::: The code at line 326 was first introduced by commit
:::::: 0648c4d0806fe167fe699299573100507ae99502 accel/habanalabs: add tsc clock sampling to clock sync info
:::::: TO: Hen Alon <halon@habana.ai>
:::::: CC: Oded Gabbay <ogabbay@kernel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread* [tip: x86/msr] accel/habanalabs: Add explicit include of <asm/tsc.h> to pick up the rdtsc() definition
2025-05-07 16:41 [tip:x86/msr 5/19] drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations kernel test robot
@ 2025-05-07 18:40 ` tip-bot2 for Ingo Molnar
2025-05-07 18:40 ` [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc() tip-bot2 for Ingo Molnar
2025-05-08 9:09 ` [tip: x86/msr] " tip-bot2 for Ingo Molnar
2 siblings, 0 replies; 9+ messages in thread
From: tip-bot2 for Ingo Molnar @ 2025-05-07 18:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Ingo Molnar, Johannes Berg, Ofir Bitton,
Oded Gabbay, x86, linux-kernel
The following commit has been merged into the x86/msr branch of tip:
Commit-ID: b1d1720321a0fb90c918fcbb3aa15649c116130a
Gitweb: https://git.kernel.org/tip/b1d1720321a0fb90c918fcbb3aa15649c116130a
Author: Ingo Molnar <mingo@kernel.org>
AuthorDate: Wed, 07 May 2025 20:25:59 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 07 May 2025 20:30:53 +02:00
accel/habanalabs: Add explicit include of <asm/tsc.h> to pick up the rdtsc() definition
The following commit:
288a4ff0ad29 ("x86/msr: Move rdtsc{,_ordered}() to <asm/tsc.h>")
removed the <asm/msr.h> include from the accel/habanalabs driver, which broke
the build on UML:
drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
Add an explicit <asm/tsc.h> include, now that it works on UML too.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Ofir Bitton <obitton@habana.ai>
Cc: Oded Gabbay <ogabbay@kernel.org>
Link: https://lore.kernel.org/r/202505080003.0t7ewxGp-lkp@intel.com
---
drivers/accel/habanalabs/common/habanalabs_ioctl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
index dc80ca9..af23001 100644
--- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c
+++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
@@ -17,6 +17,8 @@
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
+#include <asm/tsc.h>
+
/* make sure there is space for all the signed info */
static_assert(sizeof(struct cpucp_info) <= SEC_DEV_INFO_BUF_SZ);
^ permalink raw reply related [flat|nested] 9+ messages in thread* [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc()
2025-05-07 16:41 [tip:x86/msr 5/19] drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations kernel test robot
2025-05-07 18:40 ` [tip: x86/msr] accel/habanalabs: Add explicit include of <asm/tsc.h> to pick up the rdtsc() definition tip-bot2 for Ingo Molnar
@ 2025-05-07 18:40 ` tip-bot2 for Ingo Molnar
2025-05-07 18:47 ` Ingo Molnar
2025-05-07 20:36 ` Johannes Berg
2025-05-08 9:09 ` [tip: x86/msr] " tip-bot2 for Ingo Molnar
2 siblings, 2 replies; 9+ messages in thread
From: tip-bot2 for Ingo Molnar @ 2025-05-07 18:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Ingo Molnar, Johannes Berg, x86, linux-kernel
The following commit has been merged into the x86/msr branch of tip:
Commit-ID: 24b58adaa7508d9d2cdb6bca44803954baf24459
Gitweb: https://git.kernel.org/tip/24b58adaa7508d9d2cdb6bca44803954baf24459
Author: Ingo Molnar <mingo@kernel.org>
AuthorDate: Wed, 07 May 2025 20:18:22 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 07 May 2025 20:30:39 +02:00
um: Add UML version of <asm/tsc.h> to define rdtsc()
In the x86 tree rdtsc() methods got moved out of <asm/msr.h>, but this
broke UML, as the x86 version of <asm/tsc.h> cannot be used by UML as-is:
CC [M] drivers/accel/habanalabs/common/habanalabs_ioctl.o
In file included from drivers/accel/habanalabs/common/habanalabs_ioctl.c:20:
./arch/x86/include/asm/tsc.h:70:28: error: conflicting types for ‘cycles_t’; have ‘long long unsigned int’
70 | typedef unsigned long long cycles_t;
| ^~~~~~~~
In file included from ./arch/um/include/asm/timex.h:7,
from ./include/linux/timex.h:67,
from ./include/linux/time32.h:13,
from ./include/linux/time.h:60,
from ./include/linux/skbuff.h:15,
from ./include/linux/if_ether.h:19,
from ./include/linux/habanalabs/cpucp_if.h:12,
from drivers/accel/habanalabs/common/habanalabs.h:11,
from drivers/accel/habanalabs/common/habanalabs_ioctl.c:11:
./include/asm-generic/timex.h:8:23: note: previous declaration of ‘cycles_t’ with type ‘cycles_t’ {aka ‘long unsigned int’}
8 | typedef unsigned long cycles_t;
| ^~~~~~~~
To resolve these kinds of problems and to allow <asm/tsc.h> to be included on UML,
add a simplified version of <asm/tsc.h>, which only adds the rdtsc() definition.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/202505080003.0t7ewxGp-lkp@intel.com
---
arch/um/include/asm/tsc.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 arch/um/include/asm/tsc.h
diff --git a/arch/um/include/asm/tsc.h b/arch/um/include/asm/tsc.h
new file mode 100644
index 0000000..a52b0e4
--- /dev/null
+++ b/arch/um/include/asm/tsc.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_UM_TSC_H
+#define _ASM_UM_TSC_H
+
+#include <asm/asm.h>
+
+/**
+ * rdtsc() - returns the current TSC without ordering constraints
+ *
+ * rdtsc() returns the result of RDTSC as a 64-bit integer. The
+ * only ordering constraint it supplies is the ordering implied by
+ * "asm volatile": it will put the RDTSC in the place you expect. The
+ * CPU can and will speculatively execute that RDTSC, though, so the
+ * results can be non-monotonic if compared on different CPUs.
+ */
+static __always_inline u64 rdtsc(void)
+{
+ EAX_EDX_DECLARE_ARGS(val, low, high);
+
+ asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
+
+ return EAX_EDX_VAL(val, low, high);
+}
+
+#endif /* _ASM_UM_TSC_H */
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc()
2025-05-07 18:40 ` [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc() tip-bot2 for Ingo Molnar
@ 2025-05-07 18:47 ` Ingo Molnar
2025-05-07 20:36 ` Johannes Berg
1 sibling, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2025-05-07 18:47 UTC (permalink / raw)
To: linux-kernel, Johannes Berg
Cc: linux-tip-commits, kernel test robot, Johannes Berg, x86
Johannes: this is basically an RFC, not a final commit, will add your
Reviewed-by if it's fine to you, or will change the patch if it's not.
Thanks,
Ingo
* tip-bot2 for Ingo Molnar <tip-bot2@linutronix.de> wrote:
> The following commit has been merged into the x86/msr branch of tip:
>
> Commit-ID: 24b58adaa7508d9d2cdb6bca44803954baf24459
> Gitweb: https://git.kernel.org/tip/24b58adaa7508d9d2cdb6bca44803954baf24459
> Author: Ingo Molnar <mingo@kernel.org>
> AuthorDate: Wed, 07 May 2025 20:18:22 +02:00
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitterDate: Wed, 07 May 2025 20:30:39 +02:00
>
> um: Add UML version of <asm/tsc.h> to define rdtsc()
>
> In the x86 tree rdtsc() methods got moved out of <asm/msr.h>, but this
> broke UML, as the x86 version of <asm/tsc.h> cannot be used by UML as-is:
>
> CC [M] drivers/accel/habanalabs/common/habanalabs_ioctl.o
> In file included from drivers/accel/habanalabs/common/habanalabs_ioctl.c:20:
> ./arch/x86/include/asm/tsc.h:70:28: error: conflicting types for ‘cycles_t’; have ‘long long unsigned int’
> 70 | typedef unsigned long long cycles_t;
> | ^~~~~~~~
> In file included from ./arch/um/include/asm/timex.h:7,
> from ./include/linux/timex.h:67,
> from ./include/linux/time32.h:13,
> from ./include/linux/time.h:60,
> from ./include/linux/skbuff.h:15,
> from ./include/linux/if_ether.h:19,
> from ./include/linux/habanalabs/cpucp_if.h:12,
> from drivers/accel/habanalabs/common/habanalabs.h:11,
> from drivers/accel/habanalabs/common/habanalabs_ioctl.c:11:
> ./include/asm-generic/timex.h:8:23: note: previous declaration of ‘cycles_t’ with type ‘cycles_t’ {aka ‘long unsigned int’}
> 8 | typedef unsigned long cycles_t;
> | ^~~~~~~~
>
> To resolve these kinds of problems and to allow <asm/tsc.h> to be included on UML,
> add a simplified version of <asm/tsc.h>, which only adds the rdtsc() definition.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Cc: Johannes Berg <johannes.berg@intel.com>
> Link: https://lore.kernel.org/r/202505080003.0t7ewxGp-lkp@intel.com
> ---
> arch/um/include/asm/tsc.h | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> create mode 100644 arch/um/include/asm/tsc.h
>
> diff --git a/arch/um/include/asm/tsc.h b/arch/um/include/asm/tsc.h
> new file mode 100644
> index 0000000..a52b0e4
> --- /dev/null
> +++ b/arch/um/include/asm/tsc.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_UM_TSC_H
> +#define _ASM_UM_TSC_H
> +
> +#include <asm/asm.h>
> +
> +/**
> + * rdtsc() - returns the current TSC without ordering constraints
> + *
> + * rdtsc() returns the result of RDTSC as a 64-bit integer. The
> + * only ordering constraint it supplies is the ordering implied by
> + * "asm volatile": it will put the RDTSC in the place you expect. The
> + * CPU can and will speculatively execute that RDTSC, though, so the
> + * results can be non-monotonic if compared on different CPUs.
> + */
> +static __always_inline u64 rdtsc(void)
> +{
> + EAX_EDX_DECLARE_ARGS(val, low, high);
> +
> + asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
> +
> + return EAX_EDX_VAL(val, low, high);
> +}
> +
> +#endif /* _ASM_UM_TSC_H */
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc()
2025-05-07 18:40 ` [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc() tip-bot2 for Ingo Molnar
2025-05-07 18:47 ` Ingo Molnar
@ 2025-05-07 20:36 ` Johannes Berg
2025-05-08 8:57 ` [PATCH -v2] accel/habanalabs: Don't build the driver on UML Ingo Molnar
1 sibling, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2025-05-07 20:36 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org
Cc: lkp, Ingo Molnar, x86@kernel.org, linux-um
+linux-um
On Wed, 2025-05-07 at 18:40 +0000, tip-bot2 for Ingo Molnar wrote:
>
> To resolve these kinds of problems and to allow <asm/tsc.h> to be included on UML,
> add a simplified version of <asm/tsc.h>, which only adds the rdtsc() definition.
OK, weird, why would that be needed - UM isn't really X86.
> arch/um/include/asm/tsc.h | 25 +++++++++++++++++++++++++
Feels that should be in arch/x86/um/asm/ instead, which I believe is
also included but then at least pretends to keep the notion that UML
could be ported to other architectures ;-)
> +static __always_inline u64 rdtsc(void)
> +{
> + EAX_EDX_DECLARE_ARGS(val, low, high);
> +
> + asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
> +
> + return EAX_EDX_VAL(val, low, high);
> +}
Though I also wonder where this is called at all that would be relevant
for UML? If it's not then perhaps we should just make using it
unbuildable, a la
u64 __um_has_no_rdtsc(void);
#define rdtsc() __um_has_no_rdtsc()
or something like that... (and then of course keep it in the current
location). But looking at the 0-day report that'd probably break
building the driver on UML; while the driver doesn't seem important we
wouldn't really want that...
Actually, that's just because of the stupid quirk in UML/X86:
config DRM_ACCEL_HABANALABS
tristate "HabanaLabs AI accelerators"
depends on DRM_ACCEL
depends on X86_64
that last line should almost certainly be "depends on X86 && X86_64"
because ARCH=um will set UM and X86_64, but not X86 since the arch
Kconfig symbols are X86 and UM respectively, but the UML subarch still
selects X86_64 ...
I dunno. I guess we can put rdtsc() into UML on x86 as I suggested about
the file placement, or we can also just fix the Kconfig there.
johannes
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH -v2] accel/habanalabs: Don't build the driver on UML
2025-05-07 20:36 ` Johannes Berg
@ 2025-05-08 8:57 ` Ingo Molnar
2025-05-08 9:02 ` Johannes Berg
0 siblings, 1 reply; 9+ messages in thread
From: Ingo Molnar @ 2025-05-08 8:57 UTC (permalink / raw)
To: Johannes Berg
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
lkp, x86@kernel.org, linux-um
* Johannes Berg <johannes@sipsolutions.net> wrote:
> +linux-um
>
> On Wed, 2025-05-07 at 18:40 +0000, tip-bot2 for Ingo Molnar wrote:
> >
> > To resolve these kinds of problems and to allow <asm/tsc.h> to be included on UML,
> > add a simplified version of <asm/tsc.h>, which only adds the rdtsc() definition.
>
> OK, weird, why would that be needed - UM isn't really X86.
>
> > arch/um/include/asm/tsc.h | 25 +++++++++++++++++++++++++
>
> Feels that should be in arch/x86/um/asm/ instead, which I believe is
> also included but then at least pretends to keep the notion that UML
> could be ported to other architectures ;-)
>
> > +static __always_inline u64 rdtsc(void)
> > +{
> > + EAX_EDX_DECLARE_ARGS(val, low, high);
> > +
> > + asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
> > +
> > + return EAX_EDX_VAL(val, low, high);
> > +}
>
> Though I also wonder where this is called at all that would be relevant
> for UML? If it's not then perhaps we should just make using it
> unbuildable, a la
>
> u64 __um_has_no_rdtsc(void);
> #define rdtsc() __um_has_no_rdtsc()
>
> or something like that... (and then of course keep it in the current
> location). But looking at the 0-day report that'd probably break
> building the driver on UML; while the driver doesn't seem important we
> wouldn't really want that...
>
> Actually, that's just because of the stupid quirk in UML/X86:
>
> config DRM_ACCEL_HABANALABS
> tristate "HabanaLabs AI accelerators"
> depends on DRM_ACCEL
> depends on X86_64
>
> that last line should almost certainly be "depends on X86 && X86_64"
> because ARCH=um will set UM and X86_64, but not X86 since the arch
> Kconfig symbols are X86 and UM respectively, but the UML subarch still
> selects X86_64 ...
>
>
> I dunno. I guess we can put rdtsc() into UML on x86 as I suggested about
> the file placement, or we can also just fix the Kconfig there.
The Kconfig solution looks much simpler to me too :)
Patch attached, does this look good to you?
Thanks,
Ingo
===================================>
From: Ingo Molnar <mingo@kernel.org>
Date: Wed, 7 May 2025 20:25:59 +0200
Subject: [PATCH] accel/habanalabs: Don't build the driver on UML
The following commit:
288a4ff0ad29 ("x86/msr: Move rdtsc{,_ordered}() to <asm/tsc.h>")
removed the <asm/msr.h> include from the accel/habanalabs driver, which broke
the build on UML:
drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
Make the driver depend on 'X86 && X86_64', instead of just 'X86_64',
thus it won't be built on UML.
Suggested-by: Johannes Berg <johannes.berg@intel.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Ofir Bitton <obitton@habana.ai>
Cc: Oded Gabbay <ogabbay@kernel.org>
Link: https://lore.kernel.org/r/202505080003.0t7ewxGp-lkp@intel.com
---
drivers/accel/habanalabs/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/accel/habanalabs/Kconfig b/drivers/accel/habanalabs/Kconfig
index be85336107f9..1919fbb169c7 100644
--- a/drivers/accel/habanalabs/Kconfig
+++ b/drivers/accel/habanalabs/Kconfig
@@ -6,7 +6,7 @@
config DRM_ACCEL_HABANALABS
tristate "HabanaLabs AI accelerators"
depends on DRM_ACCEL
- depends on X86_64
+ depends on X86 && X86_64
depends on PCI && HAS_IOMEM
select GENERIC_ALLOCATOR
select HWMON
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH -v2] accel/habanalabs: Don't build the driver on UML
2025-05-08 8:57 ` [PATCH -v2] accel/habanalabs: Don't build the driver on UML Ingo Molnar
@ 2025-05-08 9:02 ` Johannes Berg
2025-05-08 9:03 ` Ingo Molnar
0 siblings, 1 reply; 9+ messages in thread
From: Johannes Berg @ 2025-05-08 9:02 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
lkp, x86@kernel.org, linux-um
On Thu, 2025-05-08 at 10:57 +0200, Ingo Molnar wrote:
> >
> > I dunno. I guess we can put rdtsc() into UML on x86 as I suggested about
> > the file placement, or we can also just fix the Kconfig there.
>
> The Kconfig solution looks much simpler to me too :)
>
> Patch attached, does this look good to you?
Yeah looks good to me. Common gotcha really.
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
If anyone _really_ needs to have this driver built on UML (say for
simulations/testing, we do build iwlwifi for all the time), then they'd
probably want to replace the rdtsc() anyway with something else there.
johannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH -v2] accel/habanalabs: Don't build the driver on UML
2025-05-08 9:02 ` Johannes Berg
@ 2025-05-08 9:03 ` Ingo Molnar
0 siblings, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2025-05-08 9:03 UTC (permalink / raw)
To: Johannes Berg
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
lkp, x86@kernel.org, linux-um
* Johannes Berg <johannes@sipsolutions.net> wrote:
> On Thu, 2025-05-08 at 10:57 +0200, Ingo Molnar wrote:
> > >
> > > I dunno. I guess we can put rdtsc() into UML on x86 as I suggested about
> > > the file placement, or we can also just fix the Kconfig there.
> >
> > The Kconfig solution looks much simpler to me too :)
> >
> > Patch attached, does this look good to you?
>
> Yeah looks good to me. Common gotcha really.
>
> Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Thanks, applied to tip:x86/msr.
> If anyone _really_ needs to have this driver built on UML (say for
> simulations/testing, we do build iwlwifi for all the time), then
> they'd probably want to replace the rdtsc() anyway with something
> else there.
Yeah.
Ingo
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip: x86/msr] accel/habanalabs: Don't build the driver on UML
2025-05-07 16:41 [tip:x86/msr 5/19] drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations kernel test robot
2025-05-07 18:40 ` [tip: x86/msr] accel/habanalabs: Add explicit include of <asm/tsc.h> to pick up the rdtsc() definition tip-bot2 for Ingo Molnar
2025-05-07 18:40 ` [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc() tip-bot2 for Ingo Molnar
@ 2025-05-08 9:09 ` tip-bot2 for Ingo Molnar
2 siblings, 0 replies; 9+ messages in thread
From: tip-bot2 for Ingo Molnar @ 2025-05-08 9:09 UTC (permalink / raw)
To: linux-tip-commits
Cc: Johannes Berg, kernel test robot, Ingo Molnar, Johannes Berg,
Ofir Bitton, Oded Gabbay, x86, linux-kernel
The following commit has been merged into the x86/msr branch of tip:
Commit-ID: 9cf78722003178b09c409df9aafe9d79e5b9a74e
Gitweb: https://git.kernel.org/tip/9cf78722003178b09c409df9aafe9d79e5b9a74e
Author: Ingo Molnar <mingo@kernel.org>
AuthorDate: Wed, 07 May 2025 20:25:59 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 08 May 2025 11:02:46 +02:00
accel/habanalabs: Don't build the driver on UML
The following commit:
288a4ff0ad29 ("x86/msr: Move rdtsc{,_ordered}() to <asm/tsc.h>")
removed the <asm/msr.h> include from the accel/habanalabs driver, which broke
the build on UML:
drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
Make the driver depend on 'X86 && X86_64', instead of just 'X86_64',
thus it won't be built on UML.
Suggested-by: Johannes Berg <johannes.berg@intel.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Ofir Bitton <obitton@habana.ai>
Cc: Oded Gabbay <ogabbay@kernel.org>
Link: https://lore.kernel.org/r/202505080003.0t7ewxGp-lkp@intel.com
---
drivers/accel/habanalabs/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/accel/habanalabs/Kconfig b/drivers/accel/habanalabs/Kconfig
index be85336..1919fbb 100644
--- a/drivers/accel/habanalabs/Kconfig
+++ b/drivers/accel/habanalabs/Kconfig
@@ -6,7 +6,7 @@
config DRM_ACCEL_HABANALABS
tristate "HabanaLabs AI accelerators"
depends on DRM_ACCEL
- depends on X86_64
+ depends on X86 && X86_64
depends on PCI && HAS_IOMEM
select GENERIC_ALLOCATOR
select HWMON
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-05-08 9:09 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 16:41 [tip:x86/msr 5/19] drivers/accel/habanalabs/common/habanalabs_ioctl.c:326:23: error: call to undeclared function 'rdtsc'; ISO C99 and later do not support implicit function declarations kernel test robot
2025-05-07 18:40 ` [tip: x86/msr] accel/habanalabs: Add explicit include of <asm/tsc.h> to pick up the rdtsc() definition tip-bot2 for Ingo Molnar
2025-05-07 18:40 ` [tip: x86/msr] um: Add UML version of <asm/tsc.h> to define rdtsc() tip-bot2 for Ingo Molnar
2025-05-07 18:47 ` Ingo Molnar
2025-05-07 20:36 ` Johannes Berg
2025-05-08 8:57 ` [PATCH -v2] accel/habanalabs: Don't build the driver on UML Ingo Molnar
2025-05-08 9:02 ` Johannes Berg
2025-05-08 9:03 ` Ingo Molnar
2025-05-08 9:09 ` [tip: x86/msr] " tip-bot2 for Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox