From: isaku.yamahata@intel.com
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com,
Paolo Bonzini <pbonzini@redhat.com>,
erdemaktas@google.com, Sean Christopherson <seanjc@google.com>,
Vishal Annapurve <vannapurve@google.com>,
Jim Mattson <jmattson@google.com>
Subject: [PATCH v2 0/3] KVM: X86: Make bus clock frequency for vapic timer configurable
Date: Mon, 13 Nov 2023 20:35:01 -0800 [thread overview]
Message-ID: <cover.1699936040.git.isaku.yamahata@intel.com> (raw)
From: Isaku Yamahata <isaku.yamahata@intel.com>
Changes from v1:
https://lore.kernel.org/all/cover.1699383993.git.isaku.yamahata@intel.com/
- Added a test case
- Fix a build error for i386 platform
- Add check if vcpu isn't created.
- Add check if lapic chip is in-kernel emulation.
- Updated api.rst
Add KVM_CAP_X86_BUS_FREQUENCY_CONTROL capability to configure the core
crystal clock (or processor's bus clock) for APIC timer emulation. Allow
KVM_ENABLE_CAPABILITY(KVM_CAP_X86_BUS_FREUQNCY_CONTROL) to set the
frequency. When using this capability, the user space VMM should configure
CPUID[0x15] to advertise the frequency.
TDX virtualizes CPUID[0x15] for the core crystal clock to be 25MHz. The
x86 KVM hardcodes its freuqncy for APIC timer to be 1GHz. This mismatch
causes the vAPIC timer to fire earlier than the guest expects. [1] The KVM
APIC timer emulation uses hrtimer, whose unit is nanosecond.
There are options to reconcile the mismatch. 1) Make apic bus clock frequency
configurable (this patch). 2) TDX KVM code adjusts TMICT value. This is hacky
and it results in losing MSB bits from 32 bit width to 30 bit width. 3). Make
the guest kernel use tsc deadline timer instead of acpi oneshot/periodic timer.
This is guest kernel choice. It's out of control of VMM.
[1] https://lore.kernel.org/lkml/20231006011255.4163884-1-vannapurve@google.com/
Isaku Yamahata (3):
KVM: x86: Make the hardcoded APIC bus frequency vm variable
KVM: X86: Add a capability to configure bus frequency for APIC timer
KVM: selftests: Add test case for x86 apic_bus_clock_frequency
Documentation/virt/kvm/api.rst | 14 ++
arch/x86/include/asm/kvm_host.h | 2 +
arch/x86/kvm/hyperv.c | 2 +-
arch/x86/kvm/lapic.c | 6 +-
arch/x86/kvm/lapic.h | 4 +-
arch/x86/kvm/x86.c | 37 +++++
include/uapi/linux/kvm.h | 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../selftests/kvm/include/x86_64/apic.h | 7 +
.../kvm/x86_64/apic_bus_clock_test.c | 132 ++++++++++++++++++
10 files changed, 201 insertions(+), 5 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
base-commit: be3ca57cfb777ad820c6659d52e60bbdd36bf5ff
--
2.25.1
next reply other threads:[~2023-11-14 4:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 4:35 isaku.yamahata [this message]
2023-11-14 4:35 ` [PATCH v2 1/3] KVM: x86: Make the hardcoded APIC bus frequency vm variable isaku.yamahata
2023-12-13 22:39 ` Maxim Levitsky
2023-12-13 23:10 ` Sean Christopherson
2023-12-13 23:18 ` Jim Mattson
2023-12-14 9:31 ` Maxim Levitsky
2023-12-14 16:41 ` Sean Christopherson
2023-12-19 1:40 ` Isaku Yamahata
2023-12-19 3:53 ` Jim Mattson
2023-12-19 7:56 ` Xiaoyao Li
2023-12-19 8:11 ` Isaku Yamahata
2023-12-20 22:07 ` Sean Christopherson
2023-12-20 22:22 ` Jim Mattson
2023-12-21 5:44 ` Xiaoyao Li
2023-12-21 14:39 ` Jim Mattson
2023-12-21 17:01 ` Maxim Levitsky
2023-11-14 4:35 ` [PATCH v2 2/3] KVM: X86: Add a capability to configure bus frequency for APIC timer isaku.yamahata
2023-12-13 22:40 ` Maxim Levitsky
2023-11-14 4:35 ` [PATCH v2 3/3] KVM: selftests: Add test case for x86 apic_bus_clock_frequency isaku.yamahata
2023-12-13 22:41 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1699936040.git.isaku.yamahata@intel.com \
--to=isaku.yamahata@intel.com \
--cc=erdemaktas@google.com \
--cc=isaku.yamahata@gmail.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vannapurve@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox