From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30F5EC433F5 for ; Tue, 1 Mar 2022 13:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235187AbiCAN4i (ORCPT ); Tue, 1 Mar 2022 08:56:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235176AbiCAN4c (ORCPT ); Tue, 1 Mar 2022 08:56:32 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 893589F6E1 for ; Tue, 1 Mar 2022 05:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646142949; 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=gSFeH1i77V/KkgawIUDjeRhR+3rBrHanlQxBcU1qMVM=; b=G5VMHrxqUDkIcxGLJZVuuccQI8SWMf0P9PnEa72SbAu+okvQ1nUqY2mFKOh/mxjRB5vKvx W0Q+QOiRjpUdCqGuAd1IURN2zAeS5QxAqwqlybMcmbraGRCKnAy8qOENUbYQgniuZChuQZ wQfOdFQ4ZAR4//dy3qvq7QpGQo/RmVo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-JLkAO0TqMSyP51vTULynBA-1; Tue, 01 Mar 2022 08:55:48 -0500 X-MC-Unique: JLkAO0TqMSyP51vTULynBA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39B8C800422; Tue, 1 Mar 2022 13:55:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98BF41057F7C; Tue, 1 Mar 2022 13:55:42 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Jim Mattson , "H. Peter Anvin" , linux-kernel@vger.kernel.org, Vitaly Kuznetsov , Paolo Bonzini , Joerg Roedel , Sean Christopherson , Thomas Gleixner , Dave Hansen , Wanpeng Li , Borislav Petkov , x86@kernel.org, Maxim Levitsky Subject: [PATCH 2/4] KVM: x86: SVM: disable preemption in avic_refresh_apicv_exec_ctrl Date: Tue, 1 Mar 2022 15:55:24 +0200 Message-Id: <20220301135526.136554-3-mlevitsk@redhat.com> In-Reply-To: <20220301135526.136554-1-mlevitsk@redhat.com> References: <20220301135526.136554-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org avic_refresh_apicv_exec_ctrl is called from vcpu_enter_guest, without preemption disabled, however avic_vcpu_load, and avic_vcpu_put expect preemption to be disabled. This issue was found by lockdep. Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/avic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index aea0b13773fd3..e23159f3a62ba 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -640,12 +640,16 @@ void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) } vmcb_mark_dirty(vmcb, VMCB_AVIC); + preempt_disable(); + if (activated) avic_vcpu_load(vcpu, vcpu->cpu); else avic_vcpu_put(vcpu); avic_set_pi_irte_mode(vcpu, activated); + + preempt_enable(); } static void svm_ir_list_del(struct vcpu_svm *svm, struct amd_iommu_pi_data *pi) -- 2.26.3