Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2979275ybi; Mon, 1 Jul 2019 23:41:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/RMaTVb52LhrL4UbDFOsF/05l0dC+KKkEU8DBuaclxWzkJdjlRgibgJFY90lbG/85xQBK X-Received: by 2002:a17:90a:228b:: with SMTP id s11mr3658619pjc.23.1562049680361; Mon, 01 Jul 2019 23:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562049680; cv=none; d=google.com; s=arc-20160816; b=yuWu3qolejTJnMFVGL6X9KsQ3gXkcyKRK1WHobBfl/HEA9aePT3DKEyFBTGTSMc0Km u5bhcKe/Gi53ogCO5SEkEwDqG5gaEx8feSj+WyFF2ugvgYzCZPOpPufKt92cDvTtbKOT CZU6yMp3iqYCYYdGBKqORvHekxy7bXbqvoQv6vTdq/OyxMUwCkwWyaBAcI7//V9QtcYv 3PCFoevwix6OHp5nAzSlCsaH518HVXJcEnzR/SowoO8kNBwb2HFITgONQfEedhMvTGf4 +5cDoSYqQ9VqEJE2VLuNaQcfmKcuSZelBwj5/3Q7R8hj+TvByxWqCVCzGYRq/wdAxdeH rFjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=BnUlnj1ceYuZzRI8PODNrPstCaKhyEYdVcovHIorzgM=; b=K9uSTPqpdhuCIctmwk8cUPg6ql+xnrmotm3DZt4WEvVMHMeNMLEucZPk5v6QnbuDyg Ag8JdmgvAkbfD5AliNysjGaGR4vbhY0JJYpjSagNpBlt/MHJ7kDNJ5ezzXW+rwa2aTJH lXzbMYnBoXvAZTzDESXUQT5dwd7EIhffILk9dGj4USdo9vA4MV2Zwi70RVGuPn6JwRR2 XdPBKTX1q6MpW9WLhqiR3SxQz0YUjKrAGZDeL+ba1o5f64t3G4fborOkIUvqKG1Oy9+3 LK/mw+ihEJg+Z9VoOI3jorVm4Q41HRwDYVofXKik+jy2OdJmXYNc8E73VPF1b4NeoKji 9ReA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si11723664pgq.275.2019.07.01.23.41.05; Mon, 01 Jul 2019 23:41:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725923AbfGBGkp (ORCPT + 99 others); Tue, 2 Jul 2019 02:40:45 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43540 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725775AbfGBGkp (ORCPT ); Tue, 2 Jul 2019 02:40:45 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hiCSv-0007m3-QT; Tue, 02 Jul 2019 08:40:33 +0200 Date: Tue, 2 Jul 2019 08:40:32 +0200 (CEST) From: Thomas Gleixner To: Wanpeng Li cc: Rong Chen , Feng Tang , the arch/x86 maintainers , LKML , "H. Peter Anvin" , "tipbuild@zytor.com" , "lkp@01.org" , Ingo Molnar , kvm , Paolo Bonzini , =?ISO-8859-2?Q?Radim_Kr=E8m=E1=F8?= , Fenghua Yu Subject: Re: [BUG] kvm: APIC emulation problem - was Re: [LKP] [x86/hotplug] ... In-Reply-To: Message-ID: References: <20190628063231.GA7766@shbuild999.sh.intel.com> <20190630130347.GB93752@shbuild999.sh.intel.com> <20190701083654.GB12486@shbuild999.sh.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wanpeng, On Tue, 2 Jul 2019, Wanpeng Li wrote: > On Tue, 2 Jul 2019 at 06:44, Thomas Gleixner wrote: > > > > While that CPU0 hotplug test case is surely an esoteric issue, the APIC > > emulation is still wrong, Even if the play_dead() code would not enable > > interrupts then the pending IRR bit would turn into an ISR .. interrupt > > when the APIC is reenabled on startup. > > >From SDM 10.4.7.2 Local APIC State After It Has Been Software Disabled > * Pending interrupts in the IRR and ISR registers are held and require > masking or handling by the CPU. Correct. > In your testing, hardware cpu will not respect soft disable APIC when > IRR has already been set or APICv posted-interrupt is in flight, so we > can skip soft disable APIC checking when clearing IRR and set ISR, > continue to respect soft disable APIC when attempting to set IRR. > Could you try below fix? > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index 05d8934..f857a12 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -2376,7 +2376,7 @@ int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu) > struct kvm_lapic *apic = vcpu->arch.apic; > u32 ppr; > > - if (!apic_enabled(apic)) > + if (!kvm_apic_hw_enabled(apic)) > return -1; > > __apic_update_ppr(apic, &ppr); Yes. That fixes it and works as expected. Thanks for the quick resolution. I surely stared at that function, but was not sure how to fix it proper. Tested-by: Thomas Gleixner Please add a Cc: stable... tag when you post the patch. Thanks, tglx