From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 719FB2F3C01 for ; Thu, 4 Sep 2025 11:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756987199; cv=none; b=VlJfv9dOJwTtUXtDApsswfySptrye3FN7gp13US0jpyV1z8dp8UD3r9LA9udMKvUKOBnvbFMMYOj+duv5CRQ9oRRARIpzp337MbELLfWQFyO9x8/2aWsTgTbsnaaYWUD8fgdNxzRAbAo0WvJHMcYaQ/l7QcMxwZvpnHQK+kQ9ag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756987199; c=relaxed/simple; bh=ZXNn7I+rDr8GQnTPEyxX8hDMbjRGz6pxIO5JVjmS4wM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eZqTGP/Q25iJfWy4dd/DBs1d9flyjRRNnvYANwfg5bzfGN+lpgh61vJGqQGHWydGxw5bvhedWTB1w65jLbSvutOnWBccXum2LYKT2S1+ViTInp2XjjVByTWAslgV5eiO9sJRFLSDNf8j5UUyMVAkz/TL0G0cYYHfyiWfomkPqj8= 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=fR14sSbE; arc=none smtp.client-ip=209.85.216.74 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="fR14sSbE" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-32b51b26802so862395a91.2 for ; Thu, 04 Sep 2025 04:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756987198; x=1757591998; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Dto7K6eXvGSvhdBpztAXq5eWQrSsso/7rLd9mr1E24A=; b=fR14sSbEaJim7HvVIfltSd3dXGIVPlqzLZlXm+98fIZfCb7atRyJ9jURKHdti7cM9N V278HnrDVoN5Rowtj1GDcEA8T6l7PfWc5azsVXHksCEG1rqdtI4hTfxZdsU6CKu5Wf04 Ms0QB2xGwZC8WrJjuzxlYEBgVyKpyckcv9dWNn4a9Yw/GAdsLadKugmf2A8I0HYuPsaQ OzQq6CiSKVTfFXj5QPQd15w1ss0JHCFAQuRhHI6WMMdlo8N55L8ScLh8X7ZRjKqDRTlD d1givSFKeT4s67aQ8ZVuWZpc/J39V1gFxVIa/0iLAnWKUSmn5DvBvRbquGBSh69rP/ww 990Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756987198; x=1757591998; h=content-transfer-encoding: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=Dto7K6eXvGSvhdBpztAXq5eWQrSsso/7rLd9mr1E24A=; b=BTLXdmiNgWCIZRLGi/DJNA6wmmdSR3AiX2T0UxPqrKFCqfQAWgFPhpE1vIr6v+LCSA e1g9s1t7AzhsrnGL8qd+eOblQkidXG3QIMYsFXj5YPHQSd9B73+7+NmOc7E9x++2MXWt ppFQp26Up2ltdcTueGLhKgcrRmvzvY2UKERwF5ffDgn3RBN0qLiYvIE7Lg/b7CVrTLlB 9PeFMc73kGOeRZkaqsPK+UClZbie+ju9I8HZzy1CniGjNSb+sHqLfjcp8oAUT2M7MzLJ PS7OThpxHr0IvhZ6Te2JVj005KjStZut1qHcwDA2LWCAL3ccimGk6Jt0wvVBr/ca0Dzc K5rA== X-Forwarded-Encrypted: i=1; AJvYcCWMDP2mHiRqmZxHaXuNvSsC8HOZ+c0JWjvMXhFbeIpzVFk63LjK97enVvfXV3O14fJu/e3lBCVyr0moaTc=@vger.kernel.org X-Gm-Message-State: AOJu0YwXgJb7SmuqX2rjkBFi0KCL3yGeT8+lmZlQQtqL5nJ9SyudJPq9 OpHZB7yJewIsjwY243uwiNPOcF7kvIjUhxjN4bZMegs78/6Yi8eYyl4A9MT9JdH7ROqSv3Zbn4K zW54zuA== X-Google-Smtp-Source: AGHT+IHP6++Ieg1NxgcxEx/LfHzuEBAPAP8bF6XQFVaVCxfhu7J+bDNjZtW76Vo5/SjfbbqGGuwo3OTmXSY= X-Received: from pjh5.prod.google.com ([2002:a17:90b:3f85:b0:325:7c49:9cce]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1d03:b0:328:a89:71b8 with SMTP id 98e67ed59e1d1-328156e1238mr23720013a91.30.1756987197621; Thu, 04 Sep 2025 04:59:57 -0700 (PDT) Date: Thu, 4 Sep 2025 04:59:44 -0700 In-Reply-To: <3268e953e14004d1786bf07c76ae52d98d0f8259.camel@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <54BCC060-1C9B-4BE4-8057-0161E816A9A3@amazon.co.uk> <3268e953e14004d1786bf07c76ae52d98d0f8259.camel@infradead.org> Message-ID: Subject: Re: [PATCH v2 0/3] Support "generic" CPUID timing leaf as KVM guest and host From: Sean Christopherson To: David Woodhouse Cc: Paul Durrant , Fred Griffoul , Colin Percival , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "H. Peter Anvin" , Vitaly Kuznetsov , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Graf (AWS), Alexander" , Ajay Kaher , Alexey Makhalov Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tue, Sep 02, 2025, David Woodhouse wrote: > On Tue, 2025-09-02 at 10:49 -0700, Sean Christopherson wrote: > >=20 > > > So even if a VMM has set the TSC frequency VM-wide with KVM_SET_TSC_K= HZ > > > instead of doing it the old per- vCPU way, how can it get the results= for a > > > specific VM? > >=20 > > I don't see any need for userspace to query per-VM support.=C2=A0 What = I'm proposing > > is that KVM advertise the feature if the bare metal TSC is constant and= the CPU > > supports TSC scaling.=C2=A0 Beyond that, _KVM_ doesn't need to do anyth= ing to ensure > > the guest sees a constant frequency, it's userspace's responsibility to= provide > > a sane configuration. > >=20 > > And strictly speaking, CPUID is per-CPU, i.e. it's architecturally lega= l to set > > per-vCPU frequencies and then advertise a different frequency in CPUID = for each > > vCPU.=C2=A0 That's all but guaranteed to break guests as most/all kerne= ls assume that > > TSC operates at the same frequency on all CPUs, but as above, that's us= erspace's > > responsibility to not screw up. >=20 > Sure, but doesn't that make this whole thing orthogonal to the original > problem being solved? Because userspace still doesn't *know* the actual > effective TSC frequency, whether it's scaled or not. I thought the original problem being solved was that the _guest_ doesn't kn= ow the effective TSC frequency? Userspace can already get the effectively TSC fre= quency via KVM_GET_TSC_KHZ, why do we need another uAPI to provide that? (Honest = question, I feel like I'm missing something) > Or are you suggesting that we add the leaf (with unscaled values) in > KVM_GET_SUPPORTED_CPUID and *also* 'correct' the values if userspace > does pass that leaf to its guests, as I had originally proposed? The effective guest TSC frequency should be whatever is reported in KVM_GET= _TSC_KHZ when done on a vCPU, modulo temporarily skewed results without hardware sca= ling. If that doesn't hold true, we should fix that.