aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-05-12 10:55:17 +0100
committerMichael Brown <mcb30@ipxe.org>2021-05-12 11:03:01 +0100
commita6a8bb1a9a58becb82dfacc7bc27cf645d0e216c (patch)
tree9e38c4c1d3508b6821a3f70a96f2fee03889876d
parent05fcf1a2f0809b8d87ca5affea1f1bfe0996235b (diff)
downloadipxe-a6a8bb1a9a58becb82dfacc7bc27cf645d0e216c.zip
ipxe-a6a8bb1a9a58becb82dfacc7bc27cf645d0e216c.tar.gz
ipxe-a6a8bb1a9a58becb82dfacc7bc27cf645d0e216c.tar.bz2
[undi] Read TSC only when profiling
Avoid using the "rdtsc" instruction unless profiling is enabled. This allows the non-debug build of the UNDI driver to be used on a CPU such as a 486 that does not support the TSC. Reported-by: Nikolai Zhubr <n-a-zhubr@yandex.ru> Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/arch/x86/drivers/net/undinet.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/arch/x86/drivers/net/undinet.c b/src/arch/x86/drivers/net/undinet.c
index 9b7d6d8..43cb18b 100644
--- a/src/arch/x86/drivers/net/undinet.c
+++ b/src/arch/x86/drivers/net/undinet.c
@@ -104,6 +104,13 @@ static union u_PXENV_ANY __bss16 ( undinet_params );
SEGOFF16_t __bss16 ( undinet_entry_point );
#define undinet_entry_point __use_data16 ( undinet_entry_point )
+/* Read TSC in real mode only when profiling */
+#if PROFILING
+#define RDTSC_IF_PROFILING "rdtsc\n\t"
+#else
+#define RDTSC_IF_PROFILING ""
+#endif
+
/** IRQ profiler */
static struct profiler undinet_irq_profiler __profiler =
{ .name = "undinet.irq" };
@@ -288,14 +295,14 @@ static int undinet_call ( struct undi_nic *undinic, unsigned int function,
*/
profile_start ( &profiler->total );
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
- "rdtsc\n\t"
+ RDTSC_IF_PROFILING
"pushl %%eax\n\t"
"pushw %%es\n\t"
"pushw %%di\n\t"
"pushw %%bx\n\t"
"lcall *undinet_entry_point\n\t"
"movw %%ax, %%bx\n\t"
- "rdtsc\n\t"
+ RDTSC_IF_PROFILING
"addw $6, %%sp\n\t"
"popl %%edx\n\t"
"popl %%ebp\n\t" /* gcc bug */ )