Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1333794ybb; Fri, 29 Mar 2019 02:21:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvaV7miJZfzIKq78ze6pi8ldyeDd04X1KmSo01synJ834B60oa+eO1qkr8DXFkibW3Q8bW X-Received: by 2002:a63:e653:: with SMTP id p19mr45631484pgj.284.1553851287178; Fri, 29 Mar 2019 02:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553851287; cv=none; d=google.com; s=arc-20160816; b=DaEibYYTjR4jLTDfzPePT9Ye75bzLmlgQ8E4QSu4ow0u6c3+yo8wvg3vJuTTZ+kNJ+ MLk4/tkZPIt8RJ86Bw8qo1+l5UagtnXZDeaS6H+kv+ImwSFyiC2ZH/zNhmF2Ga6cnOY4 i+2oRm+UcMg/VMcxszilY6XmsT2L6i/+RJlVBJGAI27+CskxkoGcDQn+6ROLlYs+ogpg K+dB/A9aHFAzXJItyAqiFYso4g6WFRawKkq5YHvo6mInmxhkoHRK8TAxr/8VvY+bMZTW bcotpKINFCfVjX7Zf/0zNwtmmWjNGB+z3Uo9KdXgYizI2SjWey9/92EAzst0HIWNDIVm a6Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=07DqJot8KQWyiNEQE86AYZBPetP0MIsnlI+IMIpptVg=; b=rles/5csVTnTwbllAhlv4vtIGE2Yn07T/1c90ATT2DFCTv8wq9+NkDWFQUy3gInKdI K5O3MMeaI4y3abQGi+eaI5uJwY7fRVR8km1RJrcSjSO/4z1yoTSQJwx4COZleOmFswJm sa2zg9IM0vHWqwWhzflQjPwL/gXy7hzk9y1YLWPptnEbDea8XugmEE2J7xN5viMJGvYv xPbaNZWFETaT385I55LAxyPEOCyCefwmFdwfcA8bo5PoozAp9Ymj/9hq09yUSI7ZyObD LKRhDi0dXTrCiVDsnv7jQFbZA/Re12T4FzwXD86RtAVqzf14CDXffSXZLx9qDks8cNHF /bjg== 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 o24si1366705pgk.41.2019.03.29.02.21.11; Fri, 29 Mar 2019 02:21:27 -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 S1729282AbfC2JUE (ORCPT + 99 others); Fri, 29 Mar 2019 05:20:04 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:39266 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728676AbfC2JUE (ORCPT ); Fri, 29 Mar 2019 05:20:04 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 22D916E25BE330483374; Fri, 29 Mar 2019 17:20:02 +0800 (CST) Received: from [127.0.0.1] (10.177.31.55) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Fri, 29 Mar 2019 17:19:52 +0800 Subject: Re: Unexpected interrupt received in Guest OS when booting after "system_reset" To: Marc Zyngier , Christoffer Dall References: <9a6ece7e-9984-dc9e-8fa2-df9736393dd2@arm.com> <9694b5f2-80bd-b85c-8fc5-bd1d917e1b33@huawei.com> CC: , , , wanghaibin 00208455 From: Heyi Guo Message-ID: <2e8f8bfb-4ae2-5fc6-4022-222a8f44e1f6@huawei.com> Date: Fri, 29 Mar 2019 17:19:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <9694b5f2-80bd-b85c-8fc5-bd1d917e1b33@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.31.55] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, The patch works. I tested for 1.5 hour and 52 VM resets. There were 16 times that a virtual LPI left in the ap_list (seen by an additional printk) during reset and we never saw "Unexpected interrupt received" any more. Just a minor comment: how about replacing /vcpu->arch.vgic_cpu./ with /vgic_cpu->/ in the lock/unlock code line, to reduce some words? Thanks, Heyi On 2019/3/29 9:19, Heyi Guo wrote: > > > On 2019/3/29 1:18, Marc Zyngier wrote: >> [Please do not send HTML emails] > Sorry; will keep in mind next time :) >> >> On 28/03/2019 15:44, Heyi Guo wrote: >>> Hi Marc and Christoffer, >>> >>> When we issue "system_reset" from qemu monitor to a running VM, guest >>> Linux will occasionally get "Unexpected interrupt" after rebooting, with >>> kernel message at the bottom. >>> >>> After some investigation, we found it might be caused by the >>> preservation of virtual LPI during system reset: it seems the virtual >>> LPI remains in the ap_list during VM reset, as well as its "enabled" and >>> "pending_latch" status, and this causes the virtual LPI to be injected >>> wrongly after VCPU reboots and enables interrupt. >>> >>> We propose to clear "enabled" flag of virtual LPI when PROPBASER (or >>> GICR_CTRL) of virtual GICR is written to 0, and update virtual LPI >>> properties when GICR_CTRL.enableLPIs is set to 1 again. >>> >>> Any advice? Or did we miss something? >> We're clearly missing a trick here, but I'm not convinced of your >> approach. > To be honest, we were not fully convinced by ourselves either. I was worrying about guest switching GICR_CTRL or GICR_PROPBASER at runtime which probably causes issue for our rough approach. > >> What should happend is that the redistributors should be reset >> as well, and that this should recall any LPI that has been made pending. >> Unfortunately, we don't seem to have such code in place, which is >> embarrassing. >> >> Can you give the following, untested patch a go? It isn't right either, >> but it should have the right effect. If you confirm that it solves your >> problem, we can look at adding the right hooks... > Thanks, I'll test this and get back to you. > Heyi > >> Thanks, >> >> M. >> >> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c >> index ab3f47745d9c..bd9a9250f323 100644 >> --- a/virt/kvm/arm/vgic/vgic-its.c >> +++ b/virt/kvm/arm/vgic/vgic-its.c >> @@ -2403,8 +2403,32 @@ static int vgic_its_commit_v0(struct vgic_its *its) >> return 0; >> } >> +static void vgic_nuke_pending_lpis(struct kvm_vcpu *vcpu) >> +{ >> + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; >> + struct vgic_irq *irq, *tmp; >> + unsigned long flags; >> + >> + raw_spin_lock_irqsave(&vcpu->arch.vgic_cpu.ap_list_lock, flags); >> + >> + list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) { >> + if (irq->intid >= VGIC_MIN_LPI) { >> + list_del(&irq->ap_list); >> + vgic_put_irq(vcpu->kvm, irq); >> + } >> + } >> + >> + raw_spin_unlock_irqrestore(&vcpu->arch.vgic_cpu.ap_list_lock, flags); >> +} >> + >> static void vgic_its_reset(struct kvm *kvm, struct vgic_its *its) >> { >> + struct kvm_vcpu *vcpu; >> + int c; >> + >> + kvm_for_each_vcpu(c, vcpu, kvm) >> + vgic_nuke_pending_lpis(vcpu); >> + >> /* We need to keep the ABI specific field values */ >> its->baser_coll_table &= ~GITS_BASER_VALID; >> its->baser_device_table &= ~GITS_BASER_VALID; >> > > > > . >