Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2724948pxj; Mon, 31 May 2021 09:09:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU+5ZOSvLe0NJ94vtGOh6xEGLcR78WSujAC82beig02zutF5GVGekZuVFkQUUwJjLD+O6t X-Received: by 2002:a92:cd04:: with SMTP id z4mr16526529iln.39.1622477396764; Mon, 31 May 2021 09:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477396; cv=none; d=google.com; s=arc-20160816; b=hvW0i1m6SGmRvo3QuSM+LZrDpcAoWOpn2AuTFwU0WEhOZHNNaHJiwLXL2X5tR18w6/ Vqpz5+/IV9KRBIe3TUeKjQ/iXCXx77JaEIlEgUAkFF4DuevGe50pfbGo8AMtflvSdebe e8zjD//Mpz3HaT3cuNq2wQ76rytJBlmFpmiiCcCHcCOylIC9U0nrFGD3ebP59x5Xfvz5 Pbxnn8uDQPN+gjjr1D27XDzWKO3mo+zuUCxHQHkqqnQnEylg61dck7wKA3CWs87axXPQ 4iGJmwJvpwZU856QcZxbh16jcQfdUDbN+gZjLMzP0oH3+UJc04sW3MsaMHK1uM+nXFcF rjNg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ti/eZGEFsj5ijT+gQosZxVU6yQ7w8KSLeRWaY50T3ik=; b=XXVji1qr1re2Vz8450DppWGqa1YlSFOYtT/lR8q8R0DUN4M62k9eTCrgRizOG4fyAb 2Ui2Pj5Ra2rQFc+34CTTBNSToTOnhoOy7Cqfto1cExRzArXKSj882PGh97gieW8ZQ5aF 9+uv/iGVpKfKWe2TxvSL2U+4tJn/eEhJrL6xPPc7E+gugi5Na2aEi+eX+cZ6Xx29uWhj Xmz/fVZD6olsypVwM+gsDmAKrQnupBGLndYxbmr7HwAwWv5xgd7/7bYI64DuVPKRVJE+ Ub+uw/FMy6F5WNdCtSgS/nAiaSOyIkZuJjbxLykNOdYQ/c8hy1PuqoJEcMeLTx2Ry3bz 99BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nSK1g8Jg; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m30si14884928jav.6.2021.05.31.09.09.43; Mon, 31 May 2021 09:09:56 -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=@linuxfoundation.org header.s=korg header.b=nSK1g8Jg; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232740AbhEaQKn (ORCPT + 99 others); Mon, 31 May 2021 12:10:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:36376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233715AbhEaOha (ORCPT ); Mon, 31 May 2021 10:37:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 306A961C50; Mon, 31 May 2021 13:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469099; bh=F28ENUktMeBlIeqVNXhvaXUllT9A0puQItpPMb53VJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nSK1g8Jg01Fu72uVgO50T/jMf42Nx6GBam9Y2prITkwwipTcy5MhQybzxTzgAdqB+ YbKcJp/iNxq3TaifgkDvVBNoXfXjqw2YlVIuorlMeJro0RupECDnTilwQLw/y2NyoX elB1J5+6SaW6VRUt+CSqFKbjSNXfJ2MFblDxD/EI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Wanpeng Li , Paolo Bonzini Subject: [PATCH 5.12 070/296] KVM: X86: Fix vCPU preempted state from guests point of view Date: Mon, 31 May 2021 15:12:05 +0200 Message-Id: <20210531130706.200784834@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li commit 1eff0ada88b48e4ac1e3fe26483b3684fedecd27 upstream. Commit 66570e966dd9 (kvm: x86: only provide PV features if enabled in guest's CPUID) avoids to access pv tlb shootdown host side logic when this pv feature is not exposed to guest, however, kvm_steal_time.preempted not only leveraged by pv tlb shootdown logic but also mitigate the lock holder preemption issue. >From guest's point of view, vCPU is always preempted since we lose the reset of kvm_steal_time.preempted before vmentry if pv tlb shootdown feature is not exposed. This patch fixes it by clearing kvm_steal_time.preempted before vmentry. Fixes: 66570e966dd9 (kvm: x86: only provide PV features if enabled in guest's CPUID) Reviewed-by: Sean Christopherson Cc: stable@vger.kernel.org Signed-off-by: Wanpeng Li Message-Id: <1621339235-11131-3-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3015,6 +3015,8 @@ static void record_steal_time(struct kvm st->preempted & KVM_VCPU_FLUSH_TLB); if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB) kvm_vcpu_flush_tlb_guest(vcpu); + } else { + st->preempted = 0; } vcpu->arch.st.preempted = 0;