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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F668C4332F for ; Thu, 9 Nov 2023 15:55:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343598AbjKIPzw (ORCPT ); Thu, 9 Nov 2023 10:55:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234424AbjKIPzu (ORCPT ); Thu, 9 Nov 2023 10:55:50 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A7FD5A for ; Thu, 9 Nov 2023 07:55:48 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5af592fed43so13397847b3.2 for ; Thu, 09 Nov 2023 07:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699545347; x=1700150147; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LIV0OIBtO/qEXjcwFa8rlo/bkTpqYyvIzQur9Hu2Qhs=; b=elmMbCuHGjmMGTYLrs9pdF/CJ9097pLAy+R7TYoStB/mA5LnEMcQqefeUu+cR4DaDw dNIDJpPIkqFORFySnj2KZ0bpmw8AdWdCuq9IK8VSLikNaNApOr9XzMCVFrbwFMlrYOyb d8afeYo0We9B/Jt6gVOQDGQ9JpNt/imEEezhIEcFfYXi8Pyv45NCN2qapcAYPXOnrK+Q g8cERphO/Jp20EYPeOlfKaexzJysIg0OlfexqhaFLWwdHNlAeHaCE0E9ZsoqBZ/IunC8 dxH0pAiPycB3Z7IOEiMbGar/gpMascpfsM13FZCkvMD0zPVIw9N9Ym7RuMQYdWuo/70I Q1gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699545347; x=1700150147; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LIV0OIBtO/qEXjcwFa8rlo/bkTpqYyvIzQur9Hu2Qhs=; b=eHu1UdkyRkxI1J/y4GHDQl2cLha0JKWp352gcjXipQT21EM93T6V1SytHu4vHP0u3R /suabVT2JeF39iGnsvNxaWeX0g/98KkAEcWCCfh/EhvENvfMohxfMU1vwcXK3PxLug1y OtGMHg43rxwo0rEWxxkVbunYdKEkq7DxjtNrqBMIwYMvS73/dI40roOPobto4kM+j/3i lw2Ej+N3Sz/9N99jjb+/fyBsS7QmtwMkJ6mmB0kTIYNeHfrnkTBrE9dKUubNsR3Ez6p9 D5/VQuNok5r4dOz4dEVtIjarY3tR1dtvtVF9t7uXBRBVbKuLJCav38N0Fj0hkwYYra43 cC4w== X-Gm-Message-State: AOJu0YxqSWiy+0iCws5WHH3I1oUAQOccwducR3tHgKGRswuS0iSP6nEA FKNFOyhovgxX8THiwff9jdsW5ahXq7w= X-Google-Smtp-Source: AGHT+IEMEShf0mykk0aG8QQsdHk7vwrzkzv/Ox7kVvv3Xl7bbuRdh2hiw2H6Gx6DhoX5AbdU/WOx4VMJWVk= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:310:b0:5bf:6098:58dc with SMTP id bg16-20020a05690c031000b005bf609858dcmr88627ywb.9.1699545347576; Thu, 09 Nov 2023 07:55:47 -0800 (PST) Date: Thu, 9 Nov 2023 07:55:45 -0800 In-Reply-To: <20231108235456.GB1132821@ls.amr.corp.intel.com> Mime-Version: 1.0 References: <20231107192933.GA1102144@ls.amr.corp.intel.com> <20231108235456.GB1132821@ls.amr.corp.intel.com> Message-ID: Subject: Re: KVM: X86: Make bus clock frequency for vapic timer (bus lock -> bus clock) (was Re: [PATCH 0/2] KVM: X86: Make bus lock frequency for vapic timer) configurable From: Sean Christopherson To: Isaku Yamahata Cc: Jim Mattson , isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Vishal Annapurve Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 08, 2023, Isaku Yamahata wrote: > On Tue, Nov 07, 2023 at 12:03:35PM -0800, Jim Mattson wrote: > > I think I know the answer, but do you have any tests for this new feature? > > If you mean kvm kselftest, no. > I have > - TDX patched qemu > - kvm-unit-tests: test_apic_timer_one_shot() @ kvm-unit-tests/x86/apic.c > TDX version is found at https://github.com/intel/kvm-unit-tests-tdx > We're planning to upstream the changes for TDX > > How far do we want to go? > - Run kvm-unit-tests with TDX. What I have right now. > - kvm-unit-tests: extend qemu for default VM case and update > test_apic_timer_one_host() Hrm, I'm not sure that we can do a whole lot for test_apic_timer_one_shot(). Or rather, I'm not sure it's worth the effort to try and add coverage beyond what's already there. As for TDX, *if* we extend KUT, please don't make it depend on TDX. Very few people have access to TDX platforms and anything CoCo is pretty much guaranteed to be harder to debug. > - kselftest > Right now kvm kselftest doesn't have test cases even for in-kernel IRQCHIP > creation. Selftests always create an in-kernel APIC. And I think selftests are perfectly suited to complement the coverage provided by KUT. Specifically, the failure scenario for this is that KVM emulates at 1Ghz whereas TDX advertises 25Mhz, i.e. the test case we want is to verify that the APIC timer doesn't expire early. There's no need for any APIC infrastructure, e.g. a selftest doesn't even need to handle an interrupt. Get the TSC frequency from KVM, program up an arbitrary APIC bus clock frequency, set TMICT such that it expires waaaay in the future, and then verify that the APIC timer counts reasonably close to the programmed frequency. E.g. if the test sets the bus clock to 25Mhz, the "drift" due to KVM counting at 1Ghz should be super obvious. LOL, side topic, KUT has this: /* * For LVT Timer clock, SDM vol 3 10.5.4 says it should be * derived from processor's bus clock (IIUC which is the same <====== * as TSC), however QEMU seems to be using nanosecond. In all * cases, the following should satisfy on all modern * processors. */ report((lvtt_counter == 1) && (tsc2 - tsc1 >= interval), "APIC LVT timer one shot");