Received: by 10.223.185.116 with SMTP id b49csp1335089wrg; Fri, 23 Feb 2018 16:40:28 -0800 (PST) X-Google-Smtp-Source: AH8x225tpQjNbwCo55SCrM5NkZ37xKo1GldFMOMHr41XepJK4KJ5SsrbpO8ioac3NmHWiI6yjB6x X-Received: by 10.98.0.67 with SMTP id 64mr3373095pfa.63.1519432828701; Fri, 23 Feb 2018 16:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519432828; cv=none; d=google.com; s=arc-20160816; b=fdxBm+hgFYhZOR2hU9BHCGpB3XBh4E3dbJuHwOwQoossRrD/SfVY+nvlANt6rtYxxA A2k8uicr3d/h6uGem0k6IvJJIRNBIzkeQabEAr4/+hXVmH7bEKSswMwkHrqHmBP7EV9w HLQl3cAoWSILQC6EpW5SD0ieubl3A0YGL2HyPSlQVa+FDGgdtIbjkNhcwyNOR+7w+AW2 XNnKZktEFnGo6NqZvglj9ZAWzQbdjZo8S4bGXujqw/OH4RRXJqAjQh18xqWlMywi9hYU fCtNbfaW7gcV8Cy9ySW6DXaqk6b95O7uil8M5bR5Mogb6ZbVhpj5jhp9lzUFo259qh1l PJcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:subject:cc:to:from:date:message-id :mime-version:dkim-signature:arc-authentication-results; bh=c9nZ4az99cohh5CeRx49nBbADxoCpJoeJKRIAV+MGE8=; b=pPStLx/Se0TU7DOJj/q8nAhTddDTPpFlj/4dRXHyWVjfXFzBhvN6o9vZFl/Zcr3JWV 0v8BZtvxACElBCHrb2BMg8n1OCbQpbDfJTZ3ssl8EaS5rCEpmeUCU7ZlbELfu5fA4PzM wlhRTj0DWDnsxO44AhHau9Jy9ZZdPwUDPlfJiHBWSZwmx7X2DlyVBRaLG88E0PxkrdHq gtaxm2AlQGoBjpPC/vUfpPOXvCbpziPffOzTlZjdEEIlFiEoLghtZGOnoWNDpZgZ+KAu grtrN5DcBvmQREjIAi3fHG6HR0JufWccKXmzyfxsmtZZe/ABvXijeatLRUyBZVRU6cPK KqWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=V4zgu62p; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si2625698pff.308.2018.02.23.16.40.14; Fri, 23 Feb 2018 16:40:28 -0800 (PST) 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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=V4zgu62p; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbeBXAj0 (ORCPT + 99 others); Fri, 23 Feb 2018 19:39:26 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:50908 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbeBXAjY (ORCPT ); Fri, 23 Feb 2018 19:39:24 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1O0cm3v151817; Sat, 24 Feb 2018 00:39:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : to : cc : subject : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=c9nZ4az99cohh5CeRx49nBbADxoCpJoeJKRIAV+MGE8=; b=V4zgu62p/g9wjjJYCbDNqNOeXdaWWGXw2T9xgYrqIyvqjhzDYD/QViA8KPMaVnsY6rcC FQuV7IrMtpfcgdiYlOB2d3GXCDArUAKXlRNlPIfh0oUSwiAaEjbZ69U7FBACecGpYQZL uG9o2RVpxXwOZWTBHeD/FZcq5VC5KgBBc/NaJ24K4U+G8A323FCndxdZpG220pu2SOPH JJUkvMukMMLhdov12H+zqdGqlOzcchtbzhzl5s3DUmL+1xEALEtflfC/0IKVThDzOgtm HQZI6OazmgBeLAwbwsvsqvTZXOH6aRywpc7BaLOtHW5fSuaqkdom1MO1klgSxOl81WfE 2w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2gawjm80fu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Feb 2018 00:39:22 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1O0dLrK006499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 24 Feb 2018 00:39:21 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w1O0dL1u019568; Sat, 24 Feb 2018 00:39:21 GMT MIME-Version: 1.0 Message-ID: <764f4da9-2d0c-41cf-a4a4-d9b3bf3447c2@default> Date: Fri, 23 Feb 2018 16:39:21 -0800 (PST) From: Liran Alon To: Cc: , Subject: Re: [PATCH] KVM: x86: move LAPIC initialization after VMCS creation X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8813 signatures=668678 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802240006 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- pbonzini@redhat.com wrote: > The initial reset of the local APIC is performed before the VMCS has > been > created, but it tries to do a vmwrite: >=20 > vmwrite error: reg 810 value 4a00 (err 18944) > CPU: 54 PID: 38652 Comm: qemu-kvm Tainted: G W I =20 > 4.16.0-0.rc2.git0.1.fc28.x86_64 #1 > Hardware name: Intel Corporation S2600CW/S2600CW, BIOS > SE5C610.86B.01.01.0003.090520141303 09/05/2014 > Call Trace: > vmx_set_rvi [kvm_intel] > vmx_hwapic_irr_update [kvm_intel] > kvm_lapic_reset [kvm] > kvm_create_lapic [kvm] > kvm_arch_vcpu_init [kvm] > kvm_vcpu_init [kvm] > vmx_create_vcpu [kvm_intel] > kvm_vm_ioctl [kvm] >=20 > Move it later, after the VMCS has been created. >=20 > Fixes: 851c1a18c5412fd321e387cfe60739387cdbf37d > Cc: Liran Alon > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/lapic.c | 1 - > arch/x86/kvm/x86.c | 1 + > 2 files changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index 924ac8ce9d50..cc5fe7a50dde 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -2165,7 +2165,6 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) > =09 */ > =09vcpu->arch.apic_base =3D MSR_IA32_APICBASE_ENABLE; > =09static_key_slow_inc(&apic_sw_disabled.key); /* sw disabled at reset > */ > -=09kvm_lapic_reset(vcpu, false); > =09kvm_iodevice_init(&apic->dev, &apic_mmio_ops); > =20 > =09return 0; > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index c8a0b545ac20..ca90d9515137 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7975,6 +7975,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) > =09kvm_vcpu_mtrr_init(vcpu); > =09vcpu_load(vcpu); > =09kvm_vcpu_reset(vcpu, false); > +=09kvm_lapic_reset(vcpu, false); > =09kvm_mmu_setup(vcpu); > =09vcpu_put(vcpu); > =09return 0; > --=20 > 1.8.3.1 I agree with the bug and the fix. It makes sense to reset LAPIC in the same place other components are reset rather than in it's creation. However, I failed to understand why you mention it fixes commit: 851c1a18c541 ("KVM: nVMX: Fix injection to L2 when L1 don't intercept exter= nal-interrupts") Before and after that commit, vmx_hwapic_irr_update() did exactly the same because is_guest_mode(vcpu)=3D=3Dfalse at this point. Therefore, vmx_hwapic_irr_update() has always just called vmx_set_rvi() which has not changed in that commit. It seems to me that the commit which introduced this issue is actually: 4191db26b714 ("KVM: x86: Update APICv on APIC reset") What am I missing? -Liran