diff mbox

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

Message ID 5128E8C9.1050000@web.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka Feb. 23, 2013, 4:05 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

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.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Should go to 3.8 as well, I presume.

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

Comments

Jan Kiszka Feb. 23, 2013, 4:20 p.m. UTC | #1
-----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

On 2013-02-23 17:05, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> 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.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> ---
> 
> Should go to 3.8 as well, I presume.
> 
> arch/x86/kernel/kvmclock.c |    9 ++++++++- 1 files changed, 8
> insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvmclock.c
> 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;
> 
> +	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();
> 

-----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-----
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcelo Tosatti Feb. 26, 2013, 2:22 a.m. UTC | #2
On Sat, Feb 23, 2013 at 05:05:29PM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> 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.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Should go to 3.8 as well, I presume.
> 
>  arch/x86/kernel/kvmclock.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvmclock.c 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;
>  
> +	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();
> -- 
> 1.7.3.4
> 

Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov Feb. 27, 2013, 11:19 a.m. UTC | #3
On Sat, Feb 23, 2013 at 05:05:29PM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> 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.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Applied, thanks.

> ---
> 
> Should go to 3.8 as well, I presume.
> 
>  arch/x86/kernel/kvmclock.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvmclock.c 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;
>  
> +	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();
> -- 
> 1.7.3.4
> 



--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kiszka April 7, 2013, 11:33 a.m. UTC | #4
On 2013-02-27 12:19, Gleb Natapov wrote:
> On Sat, Feb 23, 2013 at 05:05:29PM +0100, Jan Kiszka wrote:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> 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.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> 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

> 
>> ---
>>
>> Should go to 3.8 as well, I presume.
>>
>>  arch/x86/kernel/kvmclock.c |    9 ++++++++-
>>  1 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/x86/kernel/kvmclock.c 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;
>>  
>> +	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();
>> -- 
>> 1.7.3.4
>>
Gleb Natapov April 7, 2013, 11:37 a.m. UTC | #5
On Sun, Apr 07, 2013 at 01:33:05PM +0200, Jan Kiszka wrote:
> On 2013-02-27 12:19, Gleb Natapov wrote:
> > On Sat, Feb 23, 2013 at 05:05:29PM +0100, Jan Kiszka wrote:
> >> From: Jan Kiszka <jan.kiszka@siemens.com>
> >>
> >> 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.
> >>
> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> > 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.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kiszka April 7, 2013, 11:38 a.m. UTC | #6
On 2013-04-07 13:37, Gleb Natapov wrote:
> On Sun, Apr 07, 2013 at 01:33:05PM +0200, Jan Kiszka wrote:
>> On 2013-02-27 12:19, Gleb Natapov wrote:
>>> On Sat, Feb 23, 2013 at 05:05:29PM +0100, Jan Kiszka wrote:
>>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>>
>>>> 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.
>>>>
>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> 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
Gleb Natapov April 7, 2013, 11:45 a.m. UTC | #7
On Sun, Apr 07, 2013 at 01:38:48PM +0200, Jan Kiszka wrote:
> On 2013-04-07 13:37, Gleb Natapov wrote:
> > On Sun, Apr 07, 2013 at 01:33:05PM +0200, Jan Kiszka wrote:
> >> On 2013-02-27 12:19, Gleb Natapov wrote:
> >>> On Sat, Feb 23, 2013 at 05:05:29PM +0100, Jan Kiszka wrote:
> >>>> From: Jan Kiszka <jan.kiszka@siemens.com>
> >>>>
> >>>> 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.
> >>>>
> >>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> >>> 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...
> 
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.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kernel/kvmclock.c 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;
 
+	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();