Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2650798pxj; Mon, 31 May 2021 07:24:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWCqJk6rtWrdyk4+vHSt5/PZSxp5igg8hr/M11vxps4xwfRH2rZL0ElpibayxNSdqqiqkE X-Received: by 2002:a05:6638:154:: with SMTP id y20mr8647102jao.118.1622471063865; Mon, 31 May 2021 07:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471063; cv=none; d=google.com; s=arc-20160816; b=NHZD1TNii0+axRXakbDCXAjw1xJaLDXgUWnTTxK8zo4pQWPD/rL/DHzMqdhgWofHeF vmaT1aVGk0ethT7GWt1hcjcUOoobpanICnMwUKDJTnnw4S7di23o76q2iSKdMEqvbRZp oUO8V1OZI9XVcTcoR13l7MNjDhceaf+mLB/+EX4bzFzWU/kf12t48QKHkDtOAnWX3P0t QZOWFsitlKdB5mZqzeu7yK1bwXCiTBgFE/41Y41OMN8n1MA9OFJzIVPM47K5AQt2ZMEX zoJAC1iLxnf12xMcH9lHrCAlQYSGr3LylHugGfV/7+6GaJalCbY6mCm069z2NaVF8O/n Fzow== 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=uYdCzygJR8/HmHH4UVns849NKePL9xTj8a9J8ja8vTo=; b=I+zYfMMR9zMkQHTXwynD3XtwZ3SJ5t/u/0GYTxAF2PA3Kv7eXJ9Ee0gQZPKUTcWDew +Uf1Q8z18UDTrSVyp/WVm5qjwRlxOGXNb+e7fx2ith7osNUHb0HwJRS08wYl/amC/Isv Nfo2Ul5eNRhzdrM5UQBtzfmZ7CCY0pkUrdFb3GjogDK+RACgc7M7anNOVPayLRjJ0IGz 0/Ie+ttXdWMzozcWn7zL7BHr5ioMa+LrgCj5JD9Subc91KphsCXt+IugFrmNSIV+TpqV 9PyFg8tEGbxcOIKbOxAIL2dmxuwNIMLnbwF9staHWse0I9Mv49NI8nbhIo6t5xFzS+qr QvKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yx1aN+EC; 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 l126si19106033iof.101.2021.05.31.07.24.11; Mon, 31 May 2021 07:24:23 -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=yx1aN+EC; 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 S232077AbhEaOZU (ORCPT + 99 others); Mon, 31 May 2021 10:25:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:55082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232307AbhEaNvO (ORCPT ); Mon, 31 May 2021 09:51:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A37EB613EA; Mon, 31 May 2021 13:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467938; bh=JZciasEvEPmMhPJ2Yltw5AYj7KSxC5rV+XIOgYsS43U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yx1aN+ECmWH84CDjMx3R4Ke2eMuzkYSrLThSeM5UyPAidaBVsAXUGHGt196NVtdyp 87/ZLETbAIxpEHFnvdPKVN7ER1TRPbHPqON9v6e5aDGPStlk9klpU2jA6aOBVRdhJ1 b39Rc2N5FmTg0eeSLds+ckx5jpuSX3ly7t11BAT0= 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.10 057/252] KVM: X86: Fix vCPU preempted state from guests point of view Date: Mon, 31 May 2021 15:12:02 +0200 Message-Id: <20210531130659.917507144@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 @@ -3006,6 +3006,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;