mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"Nakajima, Jun" <jun.nakajima@intel.com>,
	"Annapurve, Vishal" <vannapurve@google.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"Aktas, Erdem" <erdemaktas@google.com>,
	"Yamahata, Isaku" <isaku.yamahata@intel.com>,
	"bp@alien8.de" <bp@alien8.de>, "Shahar, Sagi" <sagis@google.com>
Cc: "sathyanarayanan.kuppuswamy@linux.intel.com" 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>, "Christopherson,,
	Sean" <seanjc@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Jason@zx2c4.com" <Jason@zx2c4.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH] x86/tdx: Override the tsc calibration for TDX VMs
Date: Fri, 6 Oct 2023 10:43:29 +0000	[thread overview]
Message-ID: <0f97dc87e18fccbca6663225f11f47bc1a927ad4.camel@intel.com> (raw)
In-Reply-To: <20231006011255.4163884-1-vannapurve@google.com>


>  
> +/**
> + * Determine TSC frequency via CPUID, else return 0.
> + */

Nit: looks you don't need the k-doc style comment here?

> +static unsigned long tdx_calibrate_tsc(void)
> +{
> +	unsigned int eax_denominator = 0, ebx_numerator = 0, ecx_hz = 0, edx = 0;
> +	unsigned int crystal_khz;
> +
> +	/* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */
> +	cpuid(0x15, &eax_denominator, &ebx_numerator, &ecx_hz, &edx);
> +
> +	if (ebx_numerator == 0 || eax_denominator == 0)
> +		return 0;
> +
> +	crystal_khz = ecx_hz / 1000;
> +
> +	/*
> +	 * TSC frequency reported directly by CPUID is a "hardware reported"
> +	 * frequency and is the most accurate one so far we have. This
> +	 * is considered a known frequency.
> +	 */
> +	if (crystal_khz != 0)
> +		setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> +
> +	return crystal_khz * ebx_numerator / eax_denominator;
> +}
> +


  reply	other threads:[~2023-10-06 10:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06  1:12 Vishal Annapurve
2023-10-06 10:43 ` Huang, Kai [this message]
2023-10-06 15:29   ` Vishal Annapurve
2023-10-06 14:02 ` Dave Hansen
2023-10-06 15:27   ` Vishal Annapurve
2023-10-06 15:43     ` Dave Hansen
2023-10-13 22:43 ` Sean Christopherson
2023-10-13 23:02   ` Sean Christopherson
2023-10-21  1:54     ` Vishal Annapurve

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=0f97dc87e18fccbca6663225f11f47bc1a927ad4.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=Jason@zx2c4.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=erdemaktas@google.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=sagis@google.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vannapurve@google.com \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®