From patchwork Tue Jul 21 09:24:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 11675253 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 7AD6E13A4 for ; Tue, 21 Jul 2020 09:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 638B620657 for ; Tue, 21 Jul 2020 09:24:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q9qnbLp1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728632AbgGUJYj (ORCPT ); Tue, 21 Jul 2020 05:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgGUJYj (ORCPT ); Tue, 21 Jul 2020 05:24:39 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51563C061794; Tue, 21 Jul 2020 02:24:39 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id o13so11687968pgf.0; Tue, 21 Jul 2020 02:24:39 -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=4CU667nkvV00ipZaKMgd7BNRAsDjboapT6L5BW02bj8=; b=Q9qnbLp1dDGcoPGLtm89abpod6WY1ZGMxNJ2YnnwmafnEDB9+Ylou2LL6Sluy7IeAL seq4i+lgqzmj2CoSnRIYqG/QoMRbCd1oaaAkau5NxIkmWJr509ttZoK1IxhVznPA/T0U iR9weCEMN2EL/H6S+cyazSbUBMUaRhQe297qRWAGmTahQcsgFOPuDpXP0wpr0uB5zzyj Ki1c+fQwdlYFdvTm50XHCc0IJ1AjnmXj9EIvrPzUyp/6f7mz9i56QqWODsV+/VpMhdMY XdUGRwa2C3RbbJ+Ern5Nh0S7F/6m4WdAWRg5Xij/cESF/FfeMhmas+XmfKO+xqnPpRDe urqg== 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=4CU667nkvV00ipZaKMgd7BNRAsDjboapT6L5BW02bj8=; b=gv60waYW88IKWITfujqsRkPog7aFO807NEbpGBpt+Qb0+9gVNPnYL6DRLl3ZFZzSD2 U0q8u0dJjUGwgnx/cuRqfwbg0C5BT9xZOLdqxTB3IxPaoDCOWlVLLkkk5QZ4P/OuqgG3 HvKr9768z5EE/BRDYFcimuJ2B2uMHRjbeR33zScqoWlR89HtoexuaxrWBIvL+HOXhByq eMpxL8iwd7ojXgfd6k4bVk/Fo9yO1pGC910XAv4wNnHqb0J9uZn0T9/gO2cQAYDok5dh MlaKX3eooo2V8DKPBI3YYEtZ6Wu3bR33ecHQouVljnxM37+CIWXYwOGLHkYAiCf2g/4y sAHA== X-Gm-Message-State: AOAM531l0AIZDmxgitnXPe68atI/U4/R+tciRPIM0LkB0GPitJzdD7wn BYGXW42V4X917MmTvDSqkLf3Eewu X-Google-Smtp-Source: ABdhPJwQ7uwVn4YaUJ0trVo3VulSj443x0CxxyZZktIAxMWDWRRi/5o9YakQzf2hxB1OlDyRceOZOQ== X-Received: by 2002:aa7:930b:: with SMTP id 11mr24277068pfj.320.1595323478678; Tue, 21 Jul 2020 02:24:38 -0700 (PDT) Received: from localhost.localdomain ([103.7.29.6]) by smtp.googlemail.com with ESMTPSA id l9sm2337685pjy.2.2020.07.21.02.24.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2020 02:24:38 -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 1/2] KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled Date: Tue, 21 Jul 2020 17:24:27 +0800 Message-Id: <1595323468-4380-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. Signed-off-by: Wanpeng Li --- 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 Tue Jul 21 09:24:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 11675255 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 12B5F13A4 for ; Tue, 21 Jul 2020 09:24:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF2D12072E for ; Tue, 21 Jul 2020 09:24:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ao56ZxaY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbgGUJYn (ORCPT ); Tue, 21 Jul 2020 05:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgGUJYm (ORCPT ); Tue, 21 Jul 2020 05:24:42 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0EF5C061794; Tue, 21 Jul 2020 02:24:41 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id u5so10453613pfn.7; Tue, 21 Jul 2020 02:24:41 -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=nCJ0wq1+iNIw82Rl5c0tpfz9VgbOLTbPvMTzVmJqTNI=; b=Ao56ZxaYpU6im+Me37kHpBMg7g3MdPOws9kUTJ42ld7wKg3qmsXiusthDnC2DURk+W 14novEz0jLbWc48DXVvyrr36ptVHF0BKRi/MIxROyWCX3xgzqrXLHTmM8S/byB4Ax4ed v0d6R+BXxevNGBDsjNXayJQkL0Jkwwo3VADBkgng4HK2ZO7xMfBAgMM1uQJsPGQz4fyd lwaSz92L81F/E7Ty9SGPqBmY/z5kCtzVOkepfe1CjjWFWvbDsOR9l66qkB6TtyLTDpys xgbrLpYkKzTarlzMEa8GgOysOFXqQxyW4sh4fE1zCWwYU2timfs9lSbeMrqDw1jkSW/i SL2g== 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=nCJ0wq1+iNIw82Rl5c0tpfz9VgbOLTbPvMTzVmJqTNI=; b=sHNybMybcWcZN3A8/X+JagqhjVeDRu6ORwwktiv0L8bL2UBNp1RF8FZxbD+iytJBLM sF+xYLXU75CRermRAhvPlr9wQnkVJC4D6SLFAvaoKgZOTY+V3MxAY7H1xR95bcZm9AB6 hMW9yVXU37V+EcgoGmMB6sIVJ3evlW1W6K1Gtb2uwqZUmQxrhAI32ptl+U3I9R863lml NzWsuFjeF44opUrNz5FXz9rKPoowmYPzjoHF+TcwWHSxPwGeLI6bH6M0QulOIwkaafrX hh+ujGRrJYzDT97r0HO01ZQIxv/o2B7qPyPtyInccv5q03Ztld7KMdvSXEOAdGmfRnBK e2dQ== X-Gm-Message-State: AOAM530SslSwl39ARqe7P4CY0bd+FYfEMmp6y8elpq3mq022gJZlP5cQ iOZzik86++FNf83USrM54wy1m6sc X-Google-Smtp-Source: ABdhPJxhQNBFSgIjZmbnWEGJNzFG3rBsfkcbCx4RCO1/lDF7jBAYo6N79YIjtTUSm3oQyKyZR8LQJg== X-Received: by 2002:aa7:9630:: with SMTP id r16mr24209002pfg.144.1595323481310; Tue, 21 Jul 2020 02:24:41 -0700 (PDT) Received: from localhost.localdomain ([103.7.29.6]) by smtp.googlemail.com with ESMTPSA id l9sm2337685pjy.2.2020.07.21.02.24.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2020 02:24:40 -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 2/2] KVM: LAPIC: Set the TDCR settable bits Date: Tue, 21 Jul 2020 17:24:28 +0800 Message-Id: <1595323468-4380-2-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595323468-4380-1-git-send-email-wanpengli@tencent.com> References: <1595323468-4380-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 Only bits 0, 1, and 3 are settable, others are reserved for APIC_TDCR. Let's record the settable value in the virtual apic page. Signed-off-by: Wanpeng Li --- 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 4ce2ddd..8f7a14d 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2068,7 +2068,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) case APIC_TDCR: { uint32_t old_divisor = apic->divide_count; - kvm_lapic_set_reg(apic, APIC_TDCR, val); + kvm_lapic_set_reg(apic, APIC_TDCR, val & 0xb); update_divide_count(apic); if (apic->divide_count != old_divisor && apic->lapic_timer.period) {