* [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off
@ 2016-08-03 4:04 Wanpeng Li
2016-08-03 4:04 ` [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC Wanpeng Li
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Wanpeng Li @ 2016-08-03 4:04 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Wanpeng Li, Paolo Bonzini, Radim Krčmář, Yunhong Jiang
From: Wanpeng Li <wanpeng.li@hotmail.com>
BUG: unable to handle kernel NULL pointer dereference at 000000000000008c
IP: [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
PGD 0
Oops: 0000 [#1] SMP
Call Trace:
kvm_arch_vcpu_load+0x86/0x260 [kvm]
vcpu_load+0x46/0x60 [kvm]
kvm_vcpu_ioctl+0x79/0x7c0 [kvm]
? __lock_is_held+0x54/0x70
do_vfs_ioctl+0x96/0x6a0
? __fget_light+0x2a/0x90
SyS_ioctl+0x79/0x90
do_syscall_64+0x7c/0x1e0
entry_SYSCALL64_slow_path+0x25/0x25
RIP [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
RSP <ffff8800db1f3d70>
CR2: 000000000000008c
---[ end trace a55fb79d2b3b4ee8 ]---
This can be reproduced steadily by kernel_irqchip=off.
We should not access preemption timer stuff if lapic is emulated in userspace.
This patch fix it by avoiding access preemption timer stuff when kernel_irqchip=off.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
arch/x86/kvm/lapic.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 6895fd2..0120a58 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1348,6 +1348,9 @@ static void start_sw_tscdeadline(struct kvm_lapic *apic)
bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu)
{
+ if (!lapic_in_kernel(vcpu))
+ return false;
+
return vcpu->arch.apic->lapic_timer.hv_timer_in_use;
}
EXPORT_SYMBOL_GPL(kvm_lapic_hv_timer_in_use);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC
2016-08-03 4:04 [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Wanpeng Li
@ 2016-08-03 4:04 ` Wanpeng Li
2016-08-03 9:57 ` Radim Krčmář
2016-08-03 9:55 ` [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Radim Krčmář
2016-08-04 12:20 ` Paolo Bonzini
2 siblings, 1 reply; 6+ messages in thread
From: Wanpeng Li @ 2016-08-03 4:04 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: Wanpeng Li, Paolo Bonzini, Radim Krčmář
From: Wanpeng Li <wanpeng.li@hotmail.com>
APIC map table is recalculated during reset APIC ID to the initial value
when enabling LAPIC. This patch move the recalculate_apic_map() to the
next branch since we don't need to recalculate apic map twice in current
codes.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
arch/x86/kvm/lapic.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 0120a58..d676f4b 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1760,9 +1760,10 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
if (value & MSR_IA32_APICBASE_ENABLE) {
kvm_apic_set_xapic_id(apic, vcpu->vcpu_id);
static_key_slow_dec_deferred(&apic_hw_disabled);
- } else
+ } else {
static_key_slow_inc(&apic_hw_disabled.key);
- recalculate_apic_map(vcpu->kvm);
+ recalculate_apic_map(vcpu->kvm);
+ }
}
if ((old_value ^ value) & X2APIC_ENABLE) {
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off
2016-08-03 4:04 [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Wanpeng Li
2016-08-03 4:04 ` [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC Wanpeng Li
@ 2016-08-03 9:55 ` Radim Krčmář
2016-08-03 10:03 ` Wanpeng Li
2016-08-04 12:20 ` Paolo Bonzini
2 siblings, 1 reply; 6+ messages in thread
From: Radim Krčmář @ 2016-08-03 9:55 UTC (permalink / raw)
To: Wanpeng Li; +Cc: linux-kernel, kvm, Wanpeng Li, Paolo Bonzini, Yunhong Jiang
2016-08-03 12:04+0800, Wanpeng Li:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> BUG: unable to handle kernel NULL pointer dereference at 000000000000008c
> IP: [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
> PGD 0
> Oops: 0000 [#1] SMP
> Call Trace:
> kvm_arch_vcpu_load+0x86/0x260 [kvm]
> vcpu_load+0x46/0x60 [kvm]
> kvm_vcpu_ioctl+0x79/0x7c0 [kvm]
> ? __lock_is_held+0x54/0x70
> do_vfs_ioctl+0x96/0x6a0
> ? __fget_light+0x2a/0x90
> SyS_ioctl+0x79/0x90
> do_syscall_64+0x7c/0x1e0
> entry_SYSCALL64_slow_path+0x25/0x25
> RIP [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
> RSP <ffff8800db1f3d70>
> CR2: 000000000000008c
> ---[ end trace a55fb79d2b3b4ee8 ]---
>
> This can be reproduced steadily by kernel_irqchip=off.
>
> We should not access preemption timer stuff if lapic is emulated in userspace.
> This patch fix it by avoiding access preemption timer stuff when kernel_irqchip=off.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Yunhong Jiang <yunhong.jiang@intel.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> @@ -1348,6 +1348,9 @@ static void start_sw_tscdeadline(struct kvm_lapic *apic)
>
> bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu)
Btw, the "hv" in makes it look like it has something to do with Hyper-V.
What does "hv" stand for anyway? Hardware Virtualized?
Thanks.
> {
> + if (!lapic_in_kernel(vcpu))
> + return false;
> +
> return vcpu->arch.apic->lapic_timer.hv_timer_in_use;
> }
> EXPORT_SYMBOL_GPL(kvm_lapic_hv_timer_in_use);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC
2016-08-03 4:04 ` [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC Wanpeng Li
@ 2016-08-03 9:57 ` Radim Krčmář
0 siblings, 0 replies; 6+ messages in thread
From: Radim Krčmář @ 2016-08-03 9:57 UTC (permalink / raw)
To: Wanpeng Li; +Cc: linux-kernel, kvm, Wanpeng Li, Paolo Bonzini
2016-08-03 12:04+0800, Wanpeng Li:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> APIC map table is recalculated during reset APIC ID to the initial value
> when enabling LAPIC. This patch move the recalculate_apic_map() to the
> next branch since we don't need to recalculate apic map twice in current
> codes.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> @@ -1760,9 +1760,10 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
> if (value & MSR_IA32_APICBASE_ENABLE) {
> kvm_apic_set_xapic_id(apic, vcpu->vcpu_id);
> static_key_slow_dec_deferred(&apic_hw_disabled);
> - } else
> + } else {
> static_key_slow_inc(&apic_hw_disabled.key);
> - recalculate_apic_map(vcpu->kvm);
> + recalculate_apic_map(vcpu->kvm);
> + }
> }
>
> if ((old_value ^ value) & X2APIC_ENABLE) {
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off
2016-08-03 9:55 ` [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Radim Krčmář
@ 2016-08-03 10:03 ` Wanpeng Li
0 siblings, 0 replies; 6+ messages in thread
From: Wanpeng Li @ 2016-08-03 10:03 UTC (permalink / raw)
To: Radim Krčmář
Cc: linux-kernel, kvm, Wanpeng Li, Paolo Bonzini, Yunhong Jiang
2016-08-03 17:55 GMT+08:00 Radim Krčmář <rkrcmar@redhat.com>:
> 2016-08-03 12:04+0800, Wanpeng Li:
>> From: Wanpeng Li <wanpeng.li@hotmail.com>
>>
>> BUG: unable to handle kernel NULL pointer dereference at 000000000000008c
>> IP: [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
>> PGD 0
>> Oops: 0000 [#1] SMP
>> Call Trace:
>> kvm_arch_vcpu_load+0x86/0x260 [kvm]
>> vcpu_load+0x46/0x60 [kvm]
>> kvm_vcpu_ioctl+0x79/0x7c0 [kvm]
>> ? __lock_is_held+0x54/0x70
>> do_vfs_ioctl+0x96/0x6a0
>> ? __fget_light+0x2a/0x90
>> SyS_ioctl+0x79/0x90
>> do_syscall_64+0x7c/0x1e0
>> entry_SYSCALL64_slow_path+0x25/0x25
>> RIP [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
>> RSP <ffff8800db1f3d70>
>> CR2: 000000000000008c
>> ---[ end trace a55fb79d2b3b4ee8 ]---
>>
>> This can be reproduced steadily by kernel_irqchip=off.
>>
>> We should not access preemption timer stuff if lapic is emulated in userspace.
>> This patch fix it by avoiding access preemption timer stuff when kernel_irqchip=off.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Radim Krčmář <rkrcmar@redhat.com>
>> Cc: Yunhong Jiang <yunhong.jiang@intel.com>
>> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
>> ---
>
> Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
>
>> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
>> @@ -1348,6 +1348,9 @@ static void start_sw_tscdeadline(struct kvm_lapic *apic)
>>
>> bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu)
>
> Btw, the "hv" in makes it look like it has something to do with Hyper-V.
> What does "hv" stand for anyway? Hardware Virtualized?
Hmm, yeah, hv_timer make people confusing.
http://www.spinics.net/lists/kvm/msg134205.html
Regards,
Wanpeng Li
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off
2016-08-03 4:04 [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Wanpeng Li
2016-08-03 4:04 ` [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC Wanpeng Li
2016-08-03 9:55 ` [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Radim Krčmář
@ 2016-08-04 12:20 ` Paolo Bonzini
2 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2016-08-04 12:20 UTC (permalink / raw)
To: Wanpeng Li, linux-kernel, kvm
Cc: Wanpeng Li, Radim Krčmář, Yunhong Jiang
On 03/08/2016 06:04, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> BUG: unable to handle kernel NULL pointer dereference at 000000000000008c
> IP: [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
> PGD 0
> Oops: 0000 [#1] SMP
> Call Trace:
> kvm_arch_vcpu_load+0x86/0x260 [kvm]
> vcpu_load+0x46/0x60 [kvm]
> kvm_vcpu_ioctl+0x79/0x7c0 [kvm]
> ? __lock_is_held+0x54/0x70
> do_vfs_ioctl+0x96/0x6a0
> ? __fget_light+0x2a/0x90
> SyS_ioctl+0x79/0x90
> do_syscall_64+0x7c/0x1e0
> entry_SYSCALL64_slow_path+0x25/0x25
> RIP [<ffffffffc04e0180>] kvm_lapic_hv_timer_in_use+0x10/0x20 [kvm]
> RSP <ffff8800db1f3d70>
> CR2: 000000000000008c
> ---[ end trace a55fb79d2b3b4ee8 ]---
>
> This can be reproduced steadily by kernel_irqchip=off.
>
> We should not access preemption timer stuff if lapic is emulated in userspace.
> This patch fix it by avoiding access preemption timer stuff when kernel_irqchip=off.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Yunhong Jiang <yunhong.jiang@intel.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/lapic.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 6895fd2..0120a58 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1348,6 +1348,9 @@ static void start_sw_tscdeadline(struct kvm_lapic *apic)
>
> bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu)
> {
> + if (!lapic_in_kernel(vcpu))
> + return false;
> +
> return vcpu->arch.apic->lapic_timer.hv_timer_in_use;
> }
> EXPORT_SYMBOL_GPL(kvm_lapic_hv_timer_in_use);
>
Applied patch 1, while 2 will wait for 4.9.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-08-04 12:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-03 4:04 [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Wanpeng Li
2016-08-03 4:04 ` [PATCH 2/2] KVM: lapic: don't recalculate apic map table twice when enabling LAPIC Wanpeng Li
2016-08-03 9:57 ` Radim Krčmář
2016-08-03 9:55 ` [PATCH 1/2] KVM: lapic: fix access preemption timer stuff even if kernel_irqchip=off Radim Krčmář
2016-08-03 10:03 ` Wanpeng Li
2016-08-04 12:20 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).