Skip to contentSkip to conversation

x86: make sure we really have an hpet mapping before using it

PATCH In review Jeremy Fitzhardinge 2 participants 4 messages Dec 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: make sure we really have an hpet mapping before using it

When booting in Xen dom0, the hpet isn't really accessible, so make sure the mapping is non-NULL before use.

---
arch/x86/kernel/hpet.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)

===================================================================

arch/x86/kernel/hpet.c +0 -0
@@ -818,9 +818,10 @@
 
		hpet_address = force_hpet_address;
		hpet_enable();
-		if (!hpet_virt_address)
-			return -ENODEV;
	}

+
+ if (!hpet_virt_address)
+ return -ENODEV;

	hpet_reserve_platform_timers(hpet_readl(HPET_ID));
#1 lore raw
Quoted 12 lines · Jeremy Fitzhardinge

When booting in Xen dom0, the hpet isn't really accessible, so make sure the mapping is non-NULL before use.

---
arch/x86/kernel/hpet.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)

===================================================================

arch/x86/kernel/hpet.c line 824

Quoted 9 lines
arch/x86/kernel/hpet.c +3 -2
@@ -818,9 +818,10 @@
 
 		hpet_address = force_hpet_address;
 		hpet_enable();
-		if (!hpet_virt_address)
-			return -ENODEV;
 	}
+
+	if (!hpet_virt_address)
+		return -ENODEV;

hm, how can hpet_virt_address become non-NULL if hpet_address is zero?

Ingo

#2 lore raw
Quoted 16 lines · Ingo Molnar
Quoted 13 lines · Jeremy Fitzhardinge

When booting in Xen dom0, the hpet isn't really accessible, so make sure the mapping is non-NULL before use.

---
arch/x86/kernel/hpet.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)

===================================================================

arch/x86/kernel/hpet.c +0 -0
@@ -818,9 +818,10 @@
 
Quoted 12 lines

arch/x86/kernel/hpet.c line 825

Quoted 9 lines
arch/x86/kernel/hpet.c +3 -2
 		hpet_address = force_hpet_address;
 		hpet_enable();
-		if (!hpet_virt_address)
-			return -ENODEV;
 	}
+
+	if (!hpet_virt_address)
+		return -ENODEV;
 

hm, how can hpet_virt_address become non-NULL if hpet_address is zero?

The mapping is normally created in (paravirt_ops.)time_init -> hpet_time_init -> hpet_enable -> hpet_set_mapping. However, under Xen, time_init points to the Xen time init function, and so hpet_time_init is never called.

hpet_time_late_init is always called because its an initfunc. In domU it doesn't matter because hpet_address is NULL and so it does nothing. In dom0, however, all the ACPI table parsing gets done as normal, so the hpet is discovered and its address found. But it is not available for the dom0 kernel's use, and it is never mapped.

J

#3 lore raw
Quoted 35 lines · Jeremy Fitzhardinge
Quoted 16 lines · Ingo Molnar
Quoted 13 lines · Jeremy Fitzhardinge

When booting in Xen dom0, the hpet isn't really accessible, so make sure the mapping is non-NULL before use.

---
arch/x86/kernel/hpet.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)

===================================================================

arch/x86/kernel/hpet.c +0 -0
@@ -818,9 +818,10 @@
 
Quoted 12 lines

arch/x86/kernel/hpet.c line 825

Quoted 9 lines
arch/x86/kernel/hpet.c +3 -2
 		hpet_address = force_hpet_address;
 		hpet_enable();
-		if (!hpet_virt_address)
-			return -ENODEV;
 	}
+
+	if (!hpet_virt_address)
+		return -ENODEV;
 

hm, how can hpet_virt_address become non-NULL if hpet_address is zero?

The mapping is normally created in (paravirt_ops.)time_init -> hpet_time_init -> hpet_enable -> hpet_set_mapping. However, under Xen, time_init points to the Xen time init function, and so hpet_time_init is never called.

Quoted 5 lines

hpet_time_late_init is always called because its an initfunc. In domU it doesn't matter because hpet_address is NULL and so it does nothing. In dom0, however, all the ACPI table parsing gets done as normal, so the hpet is discovered and its address found. But it is not available for the dom0 kernel's use, and it is never mapped.

ok - applied it to tip/timers/hpet.

Ingo