On Thu, 2021-05-06 at 17:48 +0000, Stamatis, Ilias wrote: > On Thu, 2021-05-06 at 10:16 -0700, Jim Mattson wrote: > > On Thu, May 6, 2021 at 3:34 AM <ilstam@xxxxxxxxxxx> wrote: > > > From: Ilias Stamatis <ilstam@xxxxxxxxxx> > > > > > > KVM currently supports hardware-assisted TSC scaling but only for L1 > > > and it > > > doesn't expose the feature to nested guests. This patch series adds > > > support for > > > nested TSC scaling and allows both L1 and L2 to be scaled with > > > different > > > scaling factors. > > > > > > When scaling and offsetting is applied, the TSC for the guest is > > > calculated as: > > > > > > (TSC * multiplier >> 48) + offset > > > > > > With nested scaling the values in VMCS01 and VMCS12 need to be > > > merged > > > together and stored in VMCS02. > > > > > > The VMCS02 values are calculated as follows: > > > > > > offset_02 = ((offset_01 * mult_12) >> 48) + offset_12 > > > mult_02 = (mult_01 * mult_12) >> 48 > > > > > > The last patch of the series adds a KVM selftest. > > > > Will you be doing the same for SVM? The last time I tried to add a > > nested virtualization feature for Intel only, Paolo rapped my knuckles > > with a ruler. > > Yes, I can try do this, if it's not much more complicated, once I get > access to AMD hardware. I have access to AMD hardware with regular TSC scaling, and nested TSC scaling IMHO won't be hard for me to implement so I volunteer for this task! Best regards, Maxim Levitsky > > But I suppose this series is standalone and could be merged separately? > By taking a quick look it seems that SVM exposes far less features to > nested guests than VMX does anyway. > > Ilias