Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1225550pxj; Fri, 4 Jun 2021 09:02:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbK9Hs7lf9iWWjZDqm93J6LyNPyyghoD+D9VUA9dLuvnnIfiEBMX4BR43WznxGGYIjCobl X-Received: by 2002:a05:6402:c8:: with SMTP id i8mr5433495edu.380.1622822537481; Fri, 04 Jun 2021 09:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622822537; cv=none; d=google.com; s=arc-20160816; b=TU2uBQKuG8v0rMStm8+lMNJX6MdGUw5axBR4dxl2OOQqVcKc0s6qzORNT3QDlKewAC lrew3Lr72w1tD6hIE2kCmZ3y6ZawHkuhfbUo65ffe1jU5yznIlCrOzo6mMOG43h8zS/q 15b9ecr3DcVd9OU6cxvxBQ0rI+9z5QZ4ISL6pIS8P7vfEtsBVfgaEIPT+hnfwVB2xHiK jLV+QJFFgwIMzBn8jCdCS0chsZlXbA+qOrlUE2zSKN4dpuyvyigK9SB3ljliXV8P35qU 1k6W5Kc9+/IiM6R6/uWzv0zOlJ8rgAr4tk24DmyP19eVdUhpoyOR5bylJkF97MK0PjLO /8Hg== 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=r5ECTwCt3X6K4WKVYIKXRgYYaU+9MK7ZbJf7rcjA4iE=; b=XWawS+s53Mpc97Xkknh1JXg9593KfSTPPGx0FVIlrAsKXSOpL9QzyjwEW+Aeyp95o5 UVPCMCRInvnPGZrXK3xZgIqyGS8nyl/348Rfkss6quBHNIJ7nAzPYjyQpiXdV/Z+J9bQ KiJU0yGs4ZM7Y02wz3QfwamtofV1hotnWWPqK/VawHMgO3GX/BEWzjbnQFl4m5zpu951 6Wa4DK5TU8fnniYF3QQPEtJgDUtV931Nohqy9XE1rkOsHY/Z9Z6cCzN6lcobd1Ntz72G M1n3hMFVpOL+tLwqqfiBwxxCB3TErJMJ/GqXulN+1d1hD7xwsaRtT+gCwtbS3IuZbYCO fOkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HifdVuTQ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si4782207eje.396.2021.06.04.09.01.49; Fri, 04 Jun 2021 09:02:17 -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=@google.com header.s=20161025 header.b=HifdVuTQ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbhFDQCd (ORCPT + 99 others); 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-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"); > }