Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3940742pxv; Tue, 13 Jul 2021 07:21:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySHRQ25l2KsmFKc6uByqnkgrXMO2di5VBu2IUs8caCvoqXli+X0usSkoHucf4dgnOHlyo6 X-Received: by 2002:a6b:7948:: with SMTP id j8mr3355269iop.32.1626186113214; Tue, 13 Jul 2021 07:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626186113; cv=none; d=google.com; s=arc-20160816; b=AQrAw+o1aY3WsHRRt4eZnolzDhMRtNni1qJfZioOFcVZ22Tvmk4wtQGT1h6XBj8VDT CO+6ccRLnt6PSGtuLkyG3J+iUjbdvmeJ95kJ60D9zKbVJt92a+xiY42e3ZdBxV0TxnqY j36EJ9ENcNwe6pDzMySEOvXCEtAomSpJNBP6j3h6PQnF34ycwCS6kXKULQBun/70GvVK CX6pMqf9NEASYLdVS4/OEF8b31u38YUCajALT6sF/OCLig2iOnfYs1rI3NPRyuVq9PXC Iw0WgQfZ24OXSFDf10pdC/AG2ODK1BgFJyunOPyjGZ0hQwZIsyBSRQO8WJn+G/ME7soS 8mSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IsGkdcLUVDDRGPEUG9SeEQfNq5iOGQYqs/SNmiCeXhc=; b=acH2aOUGTp28eEQb+G15jxI61ewjw6qZhWp0NIFFZxQX+Bys21minmzmaY5IlICAHE 4qMGqHnwtl/0DXtKhMZgiIysvkthoksnQXkrRiRia7Z5N89d3iT4BzcMeaE9b7KzQg7d q+Dos2TJQxEoQCuuDTukpn0lhpAUlf+LOmPePs296mVTcgj3QwVUoGO0AkDkLgcc0/CL SWrE5fhu/yywx94Ab1xCYD1KgyQ6jyeg/J7O/F84eBuP3kEbgIeEBUz/CZHRFYs5BzYW 0Ir6ASlIucM0zQ/FNpL5U0IvZbxAY3b/1anvgk592A0JbRF2g7rrfngzQTInUpUEJ6zr nwfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bvnz9pO+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si4869425jad.51.2021.07.13.07.21.35; Tue, 13 Jul 2021 07:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bvnz9pO+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236869AbhGMOXj (ORCPT + 99 others); Tue, 13 Jul 2021 10:23:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31909 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236871AbhGMOXj (ORCPT ); Tue, 13 Jul 2021 10:23:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626186049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IsGkdcLUVDDRGPEUG9SeEQfNq5iOGQYqs/SNmiCeXhc=; b=Bvnz9pO+G9qSfv4ro8wOMPKFsdPiyPqsNfCwvaz3JOJU9ZqJXzspsOHM/lmhqtZlvCourt aWtZURmtoAA43PFtdzv+qpaYuBHf/vI/+4ZZvY+lQoK3pQDrbHauy2PrCzQSbz4UaTlV21 MIhR1pUGXOhNy5rQp1Zcf9R76LbZU+M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-81pWtNMCMBOCCSxgkTumGw-1; Tue, 13 Jul 2021 10:20:45 -0400 X-MC-Unique: 81pWtNMCMBOCCSxgkTumGw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8197101F000; Tue, 13 Jul 2021 14:20:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF2BC5D6AB; Tue, 13 Jul 2021 14:20:39 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Jim Mattson , Joerg Roedel , Borislav Petkov , Vitaly Kuznetsov , Wanpeng Li , Paolo Bonzini , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Sean Christopherson , Maxim Levitsky Subject: [PATCH v2 3/8] KVM: SVM: use vmcb01 in svm_refresh_apicv_exec_ctrl Date: Tue, 13 Jul 2021 17:20:18 +0300 Message-Id: <20210713142023.106183-4-mlevitsk@redhat.com> In-Reply-To: <20210713142023.106183-1-mlevitsk@redhat.com> References: <20210713142023.106183-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently when SVM is enabled in guest CPUID, AVIC is inhibited as soon as the guest CPUID is set. AVIC happens to be fully disabled on all vCPUs by the time any guest entry starts (if after migration the entry can be nested). The reason is that currently we disable avic right away on vCPU from which the kvm_request_apicv_update was called and for this case, it happens to be called on all vCPUs (by svm_vcpu_after_set_cpuid). After we stop doing this, AVIC will end up being disabled only when KVM_REQ_APICV_UPDATE is processed which is after we done switching to the nested guest. Fix this by just using vmcb01 in svm_refresh_apicv_exec_ctrl for avic (which is a right thing to do anyway). Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/avic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index a9abed054cd5..64d1e1b6a305 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -646,7 +646,7 @@ static int svm_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate) void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); - struct vmcb *vmcb = svm->vmcb; + struct vmcb *vmcb = svm->vmcb01.ptr; bool activated = kvm_vcpu_apicv_active(vcpu); if (!enable_apicv) -- 2.26.3