From patchwork Fri Jul 31 03:12:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 11693939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60B4713B1 for ; Fri, 31 Jul 2020 03:12:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48DE120829 for ; Fri, 31 Jul 2020 03:12:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UOtVTTaO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731268AbgGaDMj (ORCPT ); Thu, 30 Jul 2020 23:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730820AbgGaDMi (ORCPT ); Thu, 30 Jul 2020 23:12:38 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC49C061574; Thu, 30 Jul 2020 20:12:37 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id c10so3273825pjn.1; Thu, 30 Jul 2020 20:12:37 -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; bh=CmJxc+XhZero9r+6q4uoOOTuXV90dMxdt2faOFzAcdY=; b=UOtVTTaOgPUCZucic0rjP7R/0UCYE1hGM2DtZQAZkSvbYgH4aiIUe1RSWRYIuyiPRr 1bjNKVcYR6t8wIGGP/Yd/KsB1QZyAdmvYo0cxzRSMrXDs1YqOhOHbszlIls2r9wHBuqm 93NrCV2rM6xN8UyPzE8Qyf0Bx6nQY1MNffIHzBovXdY2TQDIg4GI12h1d6+iML5KcjEc IR6NmTB0skdQ5226ijlQvdU+e6j1Q7U9hJT+3pFOMQ/r+xuWBOo82Ak0Pu/KE8JwXbuv VaBybxme7S/k31A/nOZGHtsu2TOdc4PE+fOcNNiEqpF2TVCZmNdXOZzB8GxX0I10/tN0 HOyQ== 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; bh=CmJxc+XhZero9r+6q4uoOOTuXV90dMxdt2faOFzAcdY=; b=LZbVc3r/pC2rAT2cG/Y4aHtjMCjDvcz/+jIUraNlQ2HT4QFEoxQYfph8FLrnVir/lJ 8n5SFPWj0o3I461k/U+S5GWc2y4D1VevynqJpbVyTG/JzPzInzhtTwUgN8DuE2fxOJvg D41Q5jnhxByC+qCVzZAJYFPJ1IzaeFoDAZQXJFQAbK+hHa/sl47poSNurskfgFsXC4hR jl0JEhagxs+wQSuh1qWMGoay2MZ5zXHpWXNqLbPT/E3M6iBi3Kr19kWmL/+QPgg6Ow8/ 1WSIVbBggEwbshKQcD0mGTomjTOtQV/WaZ+hsIhwgN97S/AiknuL+bGBia5TrBLs/ah4 kjvg== X-Gm-Message-State: AOAM532vhBTM9ZIaDzm6XOBoF52OZSuOBZ+pkn8NU3Tl3D86RCBHZ4WI owGiVrglF/kEKDN38WctJe7ef5wy X-Google-Smtp-Source: ABdhPJxh16+judrCc9+W6BGiAb8rYYh+q1qUJ3nANGdE5Ei1cEQokwGhGm9lfoBfIcMMCZ8hy4g3dQ== X-Received: by 2002:a63:d446:: with SMTP id i6mr1696694pgj.438.1596165157234; Thu, 30 Jul 2020 20:12:37 -0700 (PDT) Received: from localhost.localdomain ([103.7.29.6]) by smtp.googlemail.com with ESMTPSA id t19sm8221961pfq.179.2020.07.30.20.12.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2020 20:12:36 -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 1/3] KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled Date: Fri, 31 Jul 2020 11:12:19 +0800 Message-Id: <1596165141-28874-1-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Wanpeng Li Prevent setting the tscdeadline timer if the lapic is hw disabled. Fixes: bce87cce88 (KVM: x86: consolidate different ways to test for in-kernel LAPIC) Cc: Signed-off-by: Wanpeng Li --- v1 -> v2: * add Fixes tag and cc stable arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 5bf72fc..4ce2ddd 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2195,7 +2195,7 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data) { struct kvm_lapic *apic = vcpu->arch.apic; - if (!lapic_in_kernel(vcpu) || apic_lvtt_oneshot(apic) || + if (!kvm_apic_present(vcpu) || apic_lvtt_oneshot(apic) || apic_lvtt_period(apic)) return; From patchwork Fri Jul 31 03:12:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 11693943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A771E14B7 for ; Fri, 31 Jul 2020 03:12:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84A7A208E4 for ; Fri, 31 Jul 2020 03:12:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mLD+hI5q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731304AbgGaDMr (ORCPT ); Thu, 30 Jul 2020 23:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731284AbgGaDMn (ORCPT ); Thu, 30 Jul 2020 23:12:43 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9F45C061574; Thu, 30 Jul 2020 20:12:42 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a9so6014623pjd.3; Thu, 30 Jul 2020 20:12:42 -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=tPJzt6hCr28nMvlRPeU7cuy9KZpdsuKpUl1/2Pv7MJo=; b=mLD+hI5qyhPWZAbK5CjoAHjrxXCA29ORK7oi4ZLY7vihruRs7sX/QL/AUBFIi3I5ka OEjuZC6ss/bbaEe/CHy3N6YC9k3fhFHAZaWBLzRLNE8vZq88+OIhbTuRyXFcolNncZVg 5c8JRsgyhNwEaNXvZ9QfGpWMKTYEEhEULmM6mZDNKEqHhgNQYIc6SdPBynbq+NOwRfDQ JFgOMjBEcSWpSESrhjfwdQrYvVCrmf2eRDIftNoZ44SNN/t3b895RhOPR6D5ulDAIkjg rFA34XgkYpbX9Gv6TN4v0YayoF7UzlIj7BZ6xDwyIiwcC+0/9hbIXwHoTc44Vd2lKqXT giTg== 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=tPJzt6hCr28nMvlRPeU7cuy9KZpdsuKpUl1/2Pv7MJo=; b=LmCO59sp3TjGgA6AyxzQUguCL8Wzt0tCKskRWG+zvirZ6owl8mUsqAeYEQadp26Bv9 Mm/4zCqSDTlvQ25jbJrKh7CoP0IgX1WuyA3HEL5FW5tC1eNj+Hij+mIVPORH+yYV6GKo XlN7SVcaAcwt1C336Or7gAkNil96ZxDr45icv7tV/dHNm9bdbfQEDSvmWyMIF7XnMnJq jnYKh+T76HwUURrWJ8GOQgFFoB4eU6EdzQSSn8srBQADJQ4BbJ34f6qD7xt9Q4ZlcqIi 9YMwABK7myrojCxUfapCbmI5KLPPonWyX+3z1CdX8wEPxDF1cKEtaLlbs7I1vglwKSBo D47w== X-Gm-Message-State: AOAM530VhnfNuL4XNUEed4TSI3Mxq3vgDRa4Mg2OE81zVH0MR7BJgBt0 0OD6hvCOgQctxTDHKFJ7s+jnwqTJ X-Google-Smtp-Source: ABdhPJz4SqGEyF0fKUXkl4NNUswbWn0leItPQBNpbUyN94kwgKwftMcOg4m9cQxjICJZw7R9qih0Ow== X-Received: by 2002:a17:90b:390f:: with SMTP id ob15mr2053196pjb.156.1596165162337; Thu, 30 Jul 2020 20:12:42 -0700 (PDT) Received: from localhost.localdomain ([103.7.29.6]) by smtp.googlemail.com with ESMTPSA id t19sm8221961pfq.179.2020.07.30.20.12.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2020 20:12:41 -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 Subject: [PATCH v3 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM Date: Fri, 31 Jul 2020 11:12:21 +0800 Message-Id: <1596165141-28874-3-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596165141-28874-1-git-send-email-wanpengli@tencent.com> References: <1596165141-28874-1-git-send-email-wanpengli@tencent.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Wanpeng Li 'Commit 8566ac8b8e7c ("KVM: SVM: Implement pause loop exit logic in SVM")' drops disable pause loop exit/pause filtering capability completely, I guess it is a merge fault by Radim since disable vmexits capabilities and pause loop exit for SVM patchsets are merged at the same time. This patch reintroduces the disable pause loop exit/pause filtering capability support. Reported-by: Haiwei Li Tested-by: Haiwei Li Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) Signed-off-by: Wanpeng Li --- v2 -> v3: * simplify the condition in init_vmcb() arch/x86/kvm/svm/svm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c0da4dd..bf77f90 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm) svm->nested.vmcb = 0; svm->vcpu.arch.hflags = 0; - if (pause_filter_count) { + if (!kvm_pause_in_guest(svm->vcpu.kvm)) { control->pause_filter_count = pause_filter_count; if (pause_filter_thresh) control->pause_filter_thresh = pause_filter_thresh; @@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm) struct kvm_vcpu *vcpu = &svm->vcpu; bool in_kernel = (svm_get_cpl(vcpu) == 0); - if (pause_filter_thresh) + if (!kvm_pause_in_guest(vcpu->kvm)) grow_ple_window(vcpu); kvm_vcpu_on_spin(vcpu, in_kernel); @@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu) static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu) { - if (pause_filter_thresh) + if (!kvm_pause_in_guest(vcpu->kvm)) shrink_ple_window(vcpu); } @@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm) static int svm_vm_init(struct kvm *kvm) { + if (!pause_filter_count || !pause_filter_thresh) + kvm->arch.pause_in_guest = true; + if (avic) { int ret = avic_vm_init(kvm); if (ret)