Re: KVM Kernel 5.6+, BUG: stack guard page was hit at

Suravee Suthikulpanit
2020-04-23T11:55:06Z

Boris,

On 4/22/20 12:43 PM, Boris V. wrote:
> Hello,
>
> when running qemu with GPU passthrough it crashes with 5.6 and also 5.7-rc kernels, it works with 5.5 and lower.
> Without GPU passthrough I don't see this crash.
> With bisecting, I found commit that causes this BUG.
> It seems bad commit is f458d039db7e8518041db4169d657407e3217008, if I revert this patch it works.

Could you please try the following patch?

Thanks,
Suravee

--- BEGIN PATCH ---
commit 5a605d65a71583195f64d42f39a29c771e2c763a
Author: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Date: Thu Apr 23 06:40:11 2020 -0500

kvm: ioapic: Introduce arch-specific check for lazy update EOI mechanism

commit f458d039db7e ("kvm: ioapic: Lazy update IOAPIC EOI") introduces
a regression on Intel VMX APICv since it always force IOAPIC lazy update
EOI mechanism when APICv is activated, which is needed to support AMD
SVM AVIC.

Fixes by introducing struct kvm_arch.use_lazy_eoi variable to specify
whether the architecture needs lazy update EOI support.

Fixes: f458d039db7e ("kvm: ioapic: Lazy update IOAPIC EOI")
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
arch/x86/include/asm/kvm_host.h | 2 ++
arch/x86/kvm/ioapic.c | 3 +++
arch/x86/kvm/svm.c | 1 +
3 files changed, 6 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f15e5b3..a760ebd 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -980,6 +980,8 @@ struct kvm_arch {

struct kvm_pmu_event_filter *pmu_event_filter;
struct task_struct *nx_lpage_recovery_thread;
+
+ bool use_lazy_eoi;
};

struct kvm_vm_stat {
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 750ff0b..baee8793 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -188,6 +188,9 @@ static void ioapic_lazy_update_eoi(struct kvm_ioapic *ioapic, int irq)
struct kvm_vcpu *vcpu;
union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq];

+ if (!ioapic->kvm->arch.use_lazy_eoi)
+ return;
+
kvm_for_each_vcpu(i, vcpu, ioapic->kvm) {
if (!kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
entry->fields.dest_id,
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 13a5bb4..a3d45ec 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2267,6 +2267,7 @@ static int svm_create_vcpu(struct kvm_vcpu *vcpu)

svm_init_osvw(vcpu);
vcpu->arch.microcode_version = 0x01000065;
+ vcpu->kvm->arch.use_lazy_eoi = true;

return 0;

---- END PATCH ---