Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2959683pxj; Mon, 17 May 2021 14:09:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxzDNBdyJUy3jJwWVOhLfzdkuCWQRvgWuQA3tnEkbj6AfT/XYDAEfjuUiebFPEh4BGW+sD X-Received: by 2002:a17:906:2ac5:: with SMTP id m5mr1905382eje.517.1621285779483; Mon, 17 May 2021 14:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621285779; cv=none; d=google.com; s=arc-20160816; b=knL7zxWGQhmkYB/sDtcavW4LZJmrnZbZw8sa2YnKHhpHo0K9KWQJIIz+yoMYis5dWA FVT6tK4R6piysCGaXrmAAUDf6yeHGzWwVEiqqF5z8Kscyj+bQn/hQCRZs4YCVDWcO5la MVHqYrVX3vMdONPVh52Eak7OjX3OK+AP2Bbs66557NPHS7vcVNppzjozUUHEnYUzXfAW J9Ks6qtotcmFhG1nJLGCCat/ihk8XGXmgBUi/sKbVf3Vfx55E4Kn35VtcKvtOG9rq/at 90Y/yDHd65OaBXVoWNDXk8PpDo4mWa8EQ2poTg3cc+2qJ7nPcTy/JI4LQ+V+896hR5Lt cGJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=/2GPjTLQ/YR+wnuKsns5/Hi1QLal2y1jDQCRlyJhbRk=; b=nXxDjum1gs2/0L7VJDJeBzfrSVZTokniXJwaHk/jlcxn0Tqbzul+Nj0mZBRFeyGTIp 4aprGvpNX2piQ3uR4ZL0GJ0HgAOGZzve8EraR0Ud2LBx4SoaTg4chHz6EI7AYeF14ozD Y5/zC/f2NNT3PfxTWki3e/jLqNWc78Msv6I5zi6tALNYcrJZcf5LDYLgLZ3rBwrWVGO6 X2nu/qgYNODu0jzLNXWilwntoqU7bm5A1oHFqT/c9wiF18ZBSpX/t7r5+4W7cX+v9neE tN7ndXeYb4lFKm9AY14WA5hvzq30xM8ttFneIGSMxDfNYZNgbBcbuz+TxzMHh+KTuFD7 s/0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m78vKY4I; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gq26si8056660ejb.113.2021.05.17.14.08.30; Mon, 17 May 2021 14:09:39 -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=@gmail.com header.s=20161025 header.b=m78vKY4I; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237668AbhEQOCz (ORCPT + 99 others); Mon, 17 May 2021 10:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237574AbhEQOCn (ORCPT ); Mon, 17 May 2021 10:02:43 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACE7C061573; Mon, 17 May 2021 07:01:27 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so3765502pjv.1; Mon, 17 May 2021 07:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/2GPjTLQ/YR+wnuKsns5/Hi1QLal2y1jDQCRlyJhbRk=; b=m78vKY4Ils3Zka2LHxaL7/u8+Ux75+b2P5JcA51NnA/mOemelC6vljDXQ+wiyyhvCj JcjTebx//vYgWfEddx+4wvQUX1l7NeyFbhAH3MOb85xrYr/KeMFbUGJY7jhAj3QsUWqa Z6idJdQmlCCZ11B9YyUIFVhbybDaPahq0a8NVz/nVkumfpLeikq53mrI198nC7ujuGCT Cogu7jTwppj9IZ3sh48PkLyHT+42fOsBnPkjyLMzJmam9bpe9gqLeEqpZ1l08W//h4XJ 4UAwQtoURr7VZfMLg2KuYO2WNphH7/SD7nw9RoaemRDr4C21vW2+X2i7LfF1/mWAclO7 qSRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/2GPjTLQ/YR+wnuKsns5/Hi1QLal2y1jDQCRlyJhbRk=; b=k6G5HSWZBpeFC3c5o5B8zeDl5S9l3gVnt7spPcyYBMgnbAkksYo43tYzdc2fnfxdn5 wRWW+CAEacRwk9GDLNlU2E4TLNwk4A3bCz9pCQF6rgjL+25Wm6oWyOl0QxlE2xBO18jX TvTEXwTuhneyEjEh3IFvUNVe/2+G9vZr8u9KXCaGOJ4OB9pM2sxys25V1p8zDIOmf4u1 sM9lSf17x8jZJKbSS5bR3hhXJ5uu3eLxqC8UZhNaTRY37YMx5AtoGH9t+h/cbX3trrA+ Avusii+NSLMbM0jDNcmI9X6kABaGQzVNyEbu+kX2bZa5rx86cv67nvHDCnpmEK+zfscG hwJg== X-Gm-Message-State: AOAM5333rs8yO9h5ZkTyvepiYM9dfvDFTLP6LYe+80fNK6oOUMY3S9JU XrY4ToHGgCk78aouwiUBmW0fMRnO/tM= X-Received: by 2002:a17:90a:4a0e:: with SMTP id e14mr58581pjh.209.1621260086511; Mon, 17 May 2021 07:01:26 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.61]) by smtp.googlemail.com with ESMTPSA id k10sm3074229pfu.175.2021.05.17.07.01.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 May 2021 07:01:26 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , stable@vger.kernel.org Subject: [PATCH v3 3/5] KVM: X86: Fix vCPU preempted state from guest's point of view Date: Mon, 17 May 2021 07:00:26 -0700 Message-Id: <1621260028-6467-3-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1621260028-6467-1-git-send-email-wanpengli@tencent.com> References: <1621260028-6467-1-git-send-email-wanpengli@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li 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 --- v1 -> v2: * add curly braces arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index dfb7c320581f..bed7b5348c0e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3105,6 +3105,8 @@ static void record_steal_time(struct kvm_vcpu *vcpu) 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; -- 2.25.1