From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65BC7C07E94 for ; Fri, 4 Jun 2021 16:00:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 478D66108E for ; Fri, 4 Jun 2021 16:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbhFDQCd (ORCPT ); Fri, 4 Jun 2021 12:02:33 -0400 Received: from mail-lj1-f173.google.com ([209.85.208.173]:35642 "EHLO mail-lj1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbhFDQCc (ORCPT ); Fri, 4 Jun 2021 12:02:32 -0400 Received: by mail-lj1-f173.google.com with SMTP id f12so12229743ljp.2 for ; Fri, 04 Jun 2021 09:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r5ECTwCt3X6K4WKVYIKXRgYYaU+9MK7ZbJf7rcjA4iE=; b=HifdVuTQnhR4+K80b68InFXLYze8Xu/FLGPgzoOlov/poDI9RGW3f0NtS2mRiM640q 3m6hg0mrebX83/d49puBNJv+Zzd90qPogr212hDxehGRWMzXu2A7M7XGqYwqmfrQs4Vf yM4bDnf6Th9uPG+j3xC8f4UKuWuHI7Q/CYIFr4lq1ZNfKjpidx3/ZbLwBLZYTP+0byoZ 7K3YTifcfDoNdH6jzFNczQEf3UVKjrdcMLVVrIV88IXfjpxGUrZJ/vwBc27jk/T2Xdmt /zPgNR8KwCqu00YVx6cy9hEI2CT4Nb5fpLV0nv83Dvl4dGxAyRY4eEp8KeUw4zMcw6i8 7yNQ== 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=r5ECTwCt3X6K4WKVYIKXRgYYaU+9MK7ZbJf7rcjA4iE=; b=KTIq3TSwYXVyWMGRm+/wonONIVIJzQyMpS7k8Y+2WT668vKeaFoUfjEVTjNMKmCCBs Bh9dBKDyMNQ+AgnoB3LFGIwLAu7gbGlg4vwDLmaAzTdrg7dNyjk5QjDj8SvOy1zdCJBG dgEf+dyBuqwNRcm1GS1IfAS6A1egZKAnvYo2G3S1PHvaLva0ahUGTPn4ikKi/xdXgDP5 7H4gxjDWPnyZ3sQUC3yDLs2R2XLO35uH+dmhi84EgAhz3kREI36p+wlMnfj8wDJ6onfX MK7mLcTQ2uRXbqgQ5CZ9dCCSzzK+b48pcD8OFSXeKGOv+AYKf+XrcOmvIlIFvdUXm+mz RUxA== X-Gm-Message-State: AOAM531dslihCNQVnB0sbh92EWU/vT3O3qI4Loa1W9M+NC25mseuRVo1 d50QBE77UeaIDsI/hat+CgZ/k/wFIzoFLTQcYxPH6Q== X-Google-Smtp-Source: ABdhPJxZRTQjjun0mX2hIiYgdxaWogxrDk5FFPDWCFH0EbYYSXBYPWgC70xlfG/bYz+n7/Dle+sdvu65fdkchFecl9c= X-Received: by 2002:a2e:bc06:: with SMTP id b6mr3980338ljf.342.1622822372908; Fri, 04 Jun 2021 08:59:32 -0700 (PDT) MIME-Version: 1.0 References: <1622710841-76604-1-git-send-email-wanpengli@tencent.com> In-Reply-To: From: David Matlack Date: Fri, 4 Jun 2021 08:59:06 -0700 Message-ID: Subject: Re: [PATCH 1/2] KVM: LAPIC: write 0 to TMICT should also cancel vmx-preemption timer To: Wanpeng Li 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 Thu, Jun 3, 2021 at 5:33 PM Wanpeng Li wrote: > > 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. Thanks. Can you send this as a [PATCH]? I think it would be worthwhile so have a regression test for this bug. > > 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"); > }