Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp695766pxj; Thu, 3 Jun 2021 17:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMicXeOv0m7vovL+5IOkH+kP9cFWEtC1IBnW7HZMN1Eu8pNKbX7jc/9Nbine0XTO5U5RzU X-Received: by 2002:aa7:cc97:: with SMTP id p23mr1938497edt.372.1622767126737; Thu, 03 Jun 2021 17:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622767126; cv=none; d=google.com; s=arc-20160816; b=r0xkWmOemYPlQNb5ban1OkVFs/TrFcpg6344wmWvH1qGTC+BT9lVQ/BNqwtyIl0AgW QnyaQt++D9HLwEvZpxeWC2WQ2KHMzT8v1LSpFpVEcR2RNgRhryPMXqNlOHo3/nh3h3eB rwwv/AxX2cuaXEcFa8eD3YLCIMMvL0bFuQyEiUa5eSgJ+gF7eEqfXvZ9WLsBjMGLBvDg /ug846RDhh0eQj3D7/jf728uHc8kcY1yRiF9C1kyEUHnzcNnEffocKSZF4Uev4EAi3Y9 LC57qC4gypOpNreawz6fyxdSy+cpTAks6oFUC2euqz7VDFZwowSbAMRnfMu+BXrVywwk UBwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dM61mylJ53YidPBEu1MqfzVtHPvSltpQP4lAmiQnPxc=; b=pO5fFGTGBAitGGKkpG4qS5GHshMXz3IiecHj2B5aSj780XbxsuF8LwDhfCXwQ+I09A brhqJX3OWr2iia5cv9wLaHA3kPLLJS624xo+RWNdperWHG6ofIqXbU2wW7Swk3eIFDta J4Ipyc1a6tHTp1fPYxJOn+eY1jbyZgZJ3sEjx6EZsLz6ztVvbRjYt05ev2dUWVhaQ6yi om285wCUUIj+OAy2zP0O2mMEcctA/cRW/Z+YNOw0UKqbWBF8s49Pm86vcVXjpxnRVVDJ nHYTglCuwuEqRm+Rxi4ka22fuN28HDTZiTcvfNAaKjXKurv+8Xl1piQelKct0DpGHV0e ErwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tlltf3pk; 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 h12si1844438ejx.506.2021.06.03.17.38.22; Thu, 03 Jun 2021 17:38:46 -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=Tlltf3pk; 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 S229825AbhFDAgI (ORCPT + 99 others); Thu, 3 Jun 2021 20:36:08 -0400 Received: from mail-ot1-f53.google.com ([209.85.210.53]:43540 "EHLO mail-ot1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFDAgH (ORCPT ); Thu, 3 Jun 2021 20:36:07 -0400 Received: by mail-ot1-f53.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso7512167otu.10; Thu, 03 Jun 2021 17:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dM61mylJ53YidPBEu1MqfzVtHPvSltpQP4lAmiQnPxc=; b=Tlltf3pkZ2IWrWaATPbV6DEJsQBCoEP7CfKwGY8DnRl7EyaKdnzUUCArywEnpW6ZKk SeDhT6w1BGJQM3VLqWXInbqM9GIDCeturhx06Z8Zl70YF4aEUJYZp/GM7OzVPcbzb40i 1TYeU4bNsVo5LeG77wcvJItrTPvYtyYTxqMw4V7fUdpTgVjFhnwbY4AlP6t7QUTaA7WO ++lWDevRC1UQIGd2azKxnkG6aopQDCPDflbUIt5YTaCyyjzUffIJtu2s2TTTIqYHtX32 9d/YLBxfaOnvKenpXlo8kIlAhsZQtLrU5fvj60VptVjlTaifxSCecwcQbSfqaK9/Sh3W 3lQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dM61mylJ53YidPBEu1MqfzVtHPvSltpQP4lAmiQnPxc=; b=HztWZqxw6Pktk0jq68i22uV8Qqu+zKF/pVu3UKIDEEaEsa1YLmorQjiv+4/94HNE6a 72yNnLe+FOyRaLzwjg5R2kAeYtFjRxrZSjlohkiRG5iVVfAP7sjTmfTHsK15Q//ovxY7 Thl8T7KEchfaRXUtx3zY8WiPhJeuVDlVpRR1aLfkRc9VgTuJ8j7nE88LCSFJWUMDAvWT 9WwHZ+smQyic9Lv3bJzdC88ScUPFwVbQNqcv8q+9QXxubkxFVaCHdOfo/S6bxAqA8TE3 1IEjUQZTiJaSM379EfG5JTd2K3kcxr6F1fsdxzmFdeSICW7rPZM69V3Oc5iZGulbosTx 6yUg== X-Gm-Message-State: AOAM531zkKp7hRB/eU+LropOZyM2GVjRGOnZYDX8TB7byqtcB909J1Jm N8fBJWcwXjBmdgMDAzDlvru2LZ1M0QnNIqS+Oew= X-Received: by 2002:a9d:4b0e:: with SMTP id q14mr1577750otf.254.1622766789119; Thu, 03 Jun 2021 17:33:09 -0700 (PDT) MIME-Version: 1.0 References: <1622710841-76604-1-git-send-email-wanpengli@tencent.com> In-Reply-To: From: Wanpeng Li Date: Fri, 4 Jun 2021 08:32:57 +0800 Message-ID: Subject: Re: [PATCH 1/2] KVM: LAPIC: write 0 to TMICT should also cancel vmx-preemption timer To: David Matlack Cc: LKML , kvm list , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Jun 2021 at 07:02, David Matlack wrote: > > On Thu, Jun 3, 2021 at 2:04 AM Wanpeng Li wrote: > > > > From: Wanpeng Li > > > > According to the SDM 10.5.4.1: > > > > A write of 0 to the initial-count register effectively stops the local > > APIC timer, in both one-shot and periodic mode. > > If KVM is not correctly emulating this behavior then could you also > add a kvm-unit-test to test for the correct behavior? A simple test here, the test will hang after the patch since it will not receive the spurious interrupt any more. diff --git a/x86/apic.c b/x86/apic.c index a7681fe..947d018 100644 --- a/x86/apic.c +++ b/x86/apic.c @@ -488,6 +488,14 @@ static void test_apic_timer_one_shot(void) */ report((lvtt_counter == 1) && (tsc2 - tsc1 >= interval), "APIC LVT timer one shot"); + + lvtt_counter = 0; + apic_write(APIC_TMICT, interval); + apic_write(APIC_TMICT, 0); + while (!lvtt_counter); + + report((lvtt_counter == 1), + "APIC LVT timer one shot spurious interrupt"); }