Skip to contentSkip to conversation

x86: kvmclock: Do not setup kvmclock vsyscall in the absence of that clock

PATCH Applied Jan Kiszka 3 participants 8 messages Feb 23, 2013 – Apr 7, 2013

Subsystems (3)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 x86: kvmclock: Do not setup kvmclock vsyscall in the absence of that clock

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

---

Should go to 3.8 as well, I presume.

 arch/x86/kernel/kvmclock.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/kvmclock.c +8 -1
index 5bedbdd..b730efa 100644
@@ -160,8 +160,12 @@ int kvm_register_clock(char *txt)
 {
 	int cpu = smp_processor_id();
 	int low, high, ret;
-	struct pvclock_vcpu_time_info *src = &hv_clock[cpu].pvti;
+	struct pvclock_vcpu_time_info *src;
+
+	if (!hv_clock)
+		return 0;
 
+	src = &hv_clock[cpu].pvti;
 	low = (int)__pa(src) | 1;
 	high = ((u64)__pa(src) >> 32);
 	ret = native_write_msr_safe(msr_kvm_system_time, low, high);
@@ -276,6 +280,9 @@ int __init kvm_setup_vsyscall_timeinfo(void)
 	struct pvclock_vcpu_time_info *vcpu_time;
 	unsigned int size;
 
+	if (!hv_clock)
+		return 0;
+
 	size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
 
 	preempt_disable();
Signature · 1 line
1.7.3.4
author
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sorry, $subject reflects only half of the fix (v0.1, when I thought hunk #2 would suffice). A better headline:

"x86: kvmclock: Fix boot with kvmclock disabled or not existing"

If you want me to resend, let me know.

Jan

Quoted 30 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

Should go to 3.8 as well, I presume.

arch/x86/kernel/kvmclock.c | 9 ++++++++- 1 files changed, 8
insertions(+), 1 deletions(-)

(quoted diff) +0 -0

b/arch/x86/kernel/kvmclock.c index 5bedbdd..b730efa 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -160,8 +160,12 @@ int kvm_register_clock(char *txt) { int cpu =
smp_processor_id(); int low, high, ret; - struct
pvclock_vcpu_time_info *src = &hv_clock[cpu].pvti; + struct
pvclock_vcpu_time_info *src; + + if (!hv_clock) + return 0;

(quoted diff) +1 -0
+	src = &hv_clock[cpu].pvti; low = (int)__pa(src) | 1; high =

((u64)__pa(src) >> 32); ret = native_write_msr_safe(msr_kvm_system_time, low, high); @@ -276,6 +280,9 @@ int __init kvm_setup_vsyscall_timeinfo(void) struct pvclock_vcpu_time_info *vcpu_time; unsigned int size;

(quoted diff) +1 -0
+	if (!hv_clock) +		return 0; + size = PAGE_ALIGN(sizeof(struct

pvclock_vsyscall_time_info)*NR_CPUS);

Quoted 2 lines

preempt_disable();

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlEo7DUACgkQitSsb3rl5xSZqACfX6CIIu4GtiAafeHAlDNAM1su v9UAniQcdE/gRhgoILKfEk/THLHB26T2
=aW5W
-----END PGP SIGNATURE-----

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jan Kiszka
Quoted 45 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

---

Should go to 3.8 as well, I presume.

 arch/x86/kernel/kvmclock.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/kvmclock.c +8 -1
index 5bedbdd..b730efa 100644
@@ -160,8 +160,12 @@ int kvm_register_clock(char *txt)
 {
 	int cpu = smp_processor_id();
 	int low, high, ret;
-	struct pvclock_vcpu_time_info *src = &hv_clock[cpu].pvti;
+	struct pvclock_vcpu_time_info *src;
+
+	if (!hv_clock)
+		return 0;
 
+	src = &hv_clock[cpu].pvti;
 	low = (int)__pa(src) | 1;
 	high = ((u64)__pa(src) >> 32);
 	ret = native_write_msr_safe(msr_kvm_system_time, low, high);
@@ -276,6 +280,9 @@ int __init kvm_setup_vsyscall_timeinfo(void)
 	struct pvclock_vcpu_time_info *vcpu_time;
 	unsigned int size;
 
+	if (!hv_clock)
+		return 0;
+
 	size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
 
 	preempt_disable();
Signature · 1 line
1.7.3.4
Applied
#3 lore raw
In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

Applied, thanks.

Quoted 38 lines

---

Should go to 3.8 as well, I presume.

 arch/x86/kernel/kvmclock.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/kvmclock.c +8 -1
index 5bedbdd..b730efa 100644
@@ -160,8 +160,12 @@ int kvm_register_clock(char *txt)
 {
 	int cpu = smp_processor_id();
 	int low, high, ret;
-	struct pvclock_vcpu_time_info *src = &hv_clock[cpu].pvti;
+	struct pvclock_vcpu_time_info *src;
+
+	if (!hv_clock)
+		return 0;
 
+	src = &hv_clock[cpu].pvti;
 	low = (int)__pa(src) | 1;
 	high = ((u64)__pa(src) >> 32);
 	ret = native_write_msr_safe(msr_kvm_system_time, low, high);
@@ -276,6 +280,9 @@ int __init kvm_setup_vsyscall_timeinfo(void)
 	struct pvclock_vcpu_time_info *vcpu_time;
 	unsigned int size;
 
+	if (!hv_clock)
+		return 0;
+
 	size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
 
 	preempt_disable();
Signature · 1 line
1.7.3.4

--
Gleb.

author
#4 lore raw
Quoted 9 lines · Gleb Natapov
Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

Applied, thanks.

Just noticed that this fix isn't in Linus tree yet, thus also not yet in 3.8.y. Which route does it take?

Jan

Quoted 39 lines
Quoted 39 lines

---

Should go to 3.8 as well, I presume.

 arch/x86/kernel/kvmclock.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/kvmclock.c +8 -1
index 5bedbdd..b730efa 100644
@@ -160,8 +160,12 @@ int kvm_register_clock(char *txt)
 {
 	int cpu = smp_processor_id();
 	int low, high, ret;
-	struct pvclock_vcpu_time_info *src = &hv_clock[cpu].pvti;
+	struct pvclock_vcpu_time_info *src;
+
+	if (!hv_clock)
+		return 0;
 
+	src = &hv_clock[cpu].pvti;
 	low = (int)__pa(src) | 1;
 	high = ((u64)__pa(src) >> 32);
 	ret = native_write_msr_safe(msr_kvm_system_time, low, high);
@@ -276,6 +280,9 @@ int __init kvm_setup_vsyscall_timeinfo(void)
 	struct pvclock_vcpu_time_info *vcpu_time;
 	unsigned int size;
 
+	if (!hv_clock)
+		return 0;
+
 	size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
 
 	preempt_disable();
Signature · 1 line
1.7.3.4
#5 lore raw
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Gleb Natapov
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

Applied, thanks.

Just noticed that this fix isn't in Linus tree yet, thus also not yet in 3.8.y. Which route does it take?

It is scheduled to go into 3.10. To get it into 3.8.y we need to send it to stable@.

--
Gleb.

author
#6 lore raw
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Gleb Natapov
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

Applied, thanks.

Just noticed that this fix isn't in Linus tree yet, thus also not yet in 3.8.y. Which route does it take?

It is scheduled to go into 3.10. To get it into 3.8.y we need to send it to stable@.

Hmm, it's a bug fix for an ugly early kernel crash...

Jan

#7 lore raw
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Gleb Natapov
Quoted 11 lines · Jan Kiszka
Quoted 9 lines · Gleb Natapov
Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This fixes boot lockups with "no-kvmclock", when the host is not exposing this particular feature (QEMU: -cpu ...,-kvmclock) or when the kvmclock initialization failed for whatever reason.

Applied, thanks.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Just noticed that this fix isn't in Linus tree yet, thus also not yet in 3.8.y. Which route does it take?

It is scheduled to go into 3.10. To get it into 3.8.y we need to send it to stable@.

Hmm, it's a bug fix for an ugly early kernel crash...

It was not a regression introduced in 3.9 and this usually means that fix is delayed to the next merge window. Severe bugs with simple fix could be exceptions, and I probably misjudged this one. Note that the patch is for 3.9 would have helped to avoid that. As it stands the patch will go to 3.9 via stable.

--
Gleb.