From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD4BE374756 for ; Thu, 21 May 2026 20:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779395668; cv=none; b=TqeyZ1eMuPtzeW8H7xTXdxffqZEqsAeesGhTf5WHpylVJPV7OnbH/X1jEeorXuamRD/OYjGrccIVqOlEDcJ1Wa/x9i6Q0//BRZKT2h26uhh55aWKhqOl4x10GU8ybyJE+/vbQXVKeh34ZQ+7gpl1MNjr1Q9L3dFUbIWtRYO+ZaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779395668; c=relaxed/simple; bh=Vidk3LDEKL2XnrVS0/5PJ+6dbEOeauOpV9iuOcmzzjI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qHTRBvwx57mbtYz2bZitfhR+tO/dy7rz5I/dNfr6SgHvBzyyDy714BAlI4SBbJsnHEeFJkq1IaH2KmnKoBITl3xo58zz7DHz7eh5537v6SmagOvNTCB7zXq0R/bIndXgmrq0jpIPII/QoIM7LQSAlemL/1hDyxr/nL3MnLYFqtM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=o+9WImWb; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="o+9WImWb" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bc763c7256so150496115ad.3 for ; Thu, 21 May 2026 13:34:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779395666; x=1780000466; 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=dIireasEnp8AQZjS+o0HC63+VEosuYCnO+TKDPQR05s=; b=o+9WImWbeAbOLztvLMTB+MdER7K+60tboDKwyKU9bSRbhkvTfZYUs0v4XkM2QeRety jTmwLKveG81OJBnWOQqPX8e/6+KmgGV5gzQRWwdmKRKP4oBsw7P0ibo1BzukWptlK0KA TScf/zDsLe1K02dtWTh/nt80ijybeo/UMrVrgzwhieF41ecwBQiNAS5VoLeLOz784tPR U3HMnH1xJnDX89cUe0SvelQAGIt4VC7yBZUvYbdoOUuWdWqJYDzAsN/G4+901+Hjc2qW /hZCQHQiSvMzfztTkUiIiX55aJ46HPK6tkLKWjODNb7O3xpcl/PPp/1351Xl/FPNQCkX 8mdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779395666; x=1780000466; 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=dIireasEnp8AQZjS+o0HC63+VEosuYCnO+TKDPQR05s=; b=r+xaLO63j71TRpOi8vDHI/Y7EHz5hpKOV1WZmI+ycJZTqdyLH6K7kq93rzK/gPp/yM aqKplsQ8F39mBEx4IArfyUpsWi/QkiNdG4GFDR+y59reV/qijbsF1N7/UhD8lSt1Ylv2 Q4lKmbic5qJWRm1G1POsONe6VT9GyAi7RJcZAaKHJAFnWH1CdMya53ZOW9PEdWUFcEzg TcSuL+TVW+CJeTSnmOXyEJ+Qy9OAr++RhDlvuunHTp9sAynAcVCEWJ+hVfUEjKIlFUXc UzActO11BDgI8WjhpQyBG+sdSiKA9vUR3au+dHMZO5+O06mjaxLe6BbGBdsfilIsRhUF aOnA== X-Forwarded-Encrypted: i=1; AFNElJ/f9j1mmE4RB1QgPmfw4+YgQmOSfZsakS2j7mgAoq4g10DYPHGkSvTZJo/J9v0u7rVF6W71dORX3X0L7rs=@vger.kernel.org X-Gm-Message-State: AOJu0YwY5I7YkNy7lRFq1Kezgc9Y4/wVIsx7Wvlo5eYrfrlewaWhsyvV i/HOHWmjjOFDavzmHo5xpjO+jTi2U9AkMZXS6ssq7w8NYwI3blDgw4RShCSCJTGeBmh/2wjTHPd Gr+PqKw== X-Received: from plip15.prod.google.com ([2002:a17:903:38cf:b0:2bc:ae06:63be]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:4405:b0:2b9:6458:1a2c with SMTP id d9443c01a7336-2beb06733bemr4530925ad.13.1779395665926; Thu, 21 May 2026 13:34:25 -0700 (PDT) Date: Thu, 21 May 2026 13:34:24 -0700 In-Reply-To: <7489ff3cc1ff402bf0ade38272fc52dcbcc75fc1.camel@amazon.co.uk> Precedence: bulk X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260515191942.1892718-1-seanjc@google.com> <20260515191942.1892718-37-seanjc@google.com> <7489ff3cc1ff402bf0ade38272fc52dcbcc75fc1.camel@amazon.co.uk> Message-ID: Subject: Re: [PATCH v3 36/41] x86/kvmclock: Get local APIC bus frequency from PV CPUID Timing Info From: Sean Christopherson To: David Woodhouse Cc: "tglx@kernel.org" , "longli@microsoft.com" , "luto@kernel.org" , "alexey.makhalov@broadcom.com" , "jstultz@google.com" , "dave.hansen@linux.intel.com" , "ajay.kaher@broadcom.com" , "jan.kiszka@siemens.com" , "haiyangz@microsoft.com" , "kas@kernel.org" , "pbonzini@redhat.com" , "kys@microsoft.com" , "decui@microsoft.com" , "daniel.lezcano@kernel.org" , "wei.liu@kernel.org" , "peterz@infradead.org" , "jgross@suse.com" , "boris.ostrovsky@oracle.com" , "linux-coco@lists.linux.dev" , "kvm@vger.kernel.org" , "mhklinux@outlook.com" , "thomas.lendacky@amd.com" , "linux-kernel@vger.kernel.org" , "bcm-kernel-feedback-list@broadcom.com" , "tglx@linutronix.de" , "nikunj@amd.com" , "xen-devel@lists.xenproject.org" , "linux-hyperv@vger.kernel.org" , "vkuznets@redhat.com" , "rick.p.edgecombe@intel.com" , "virtualization@lists.linux.dev" , "sboyd@kernel.org" , "x86@kernel.org" Content-Type: text/plain; charset="us-ascii" On Wed, May 20, 2026, David Woodhouse wrote: > On Fri, 2026-05-15 at 12:19 -0700, Sean Christopherson wrote: > > When running as a KVM guest with kvmclock support enabled, stuff the APIC > > timer period/frequency with the local APIC bus frequency reported in > > CPUID.0x40000010.EBX instead of trying to calibrate/guess the frequency. > > > > See Documentation/virt/kvm/x86/cpuid.rst for details. > > > > Signed-off-by: Sean Christopherson > > I still don't much like the way this is done inside kvm_get_tsc_khz(). Yeah, I don't like it either (understatement). Aha! native_calibrate_tsc() is the oddball, all of the PV flows stuff lapic_timer_period when parsing the initial timing info. I'll just do that. Blindly writing a global is all kinds of fugly, but that's a future problem to solve. > We also probably ought to be looking for the timing leaf on other > hypervisors including VMware VMware gets the frequency via hypercall. Why, I have no idea. I'll let the VMware folks deal with that. eax = vmware_hypercall3(VMWARE_CMD_GETHZ, UINT_MAX, &ebx, &ecx); > and probably Bhyve too. Should it be done somewhere else? I'm not opposed to that, though I don't know that it'd be a net positive. The "hard" part of getting the info is finding the CPUID base and checking if the leaf is available. Unlike the native CPUID leaf, no math is necessary, and so once the leaf is obtained, getting the frequency is trivial. Regardless, I definitely don't want to take it on in this series. :-)