Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1107279lqo; Fri, 17 May 2024 10:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUV0WgoKYeXOjIQ3s5grDDRtV7KWdYF7Pb7u1tWDNPYSFz6qV4JyoH/YYUVKt+qaazRypD1qAVP43rk/hfg5r4u+wSx1FO1p5S9GSnXlQ== X-Google-Smtp-Source: AGHT+IGfc8gHHISNXdoHhv9xLawST1g5yS3Bu50Rk2L2zrHpxngAheKgP7QQ2FeDo+8cP6KUEgj1 X-Received: by 2002:a05:620a:22b6:b0:792:bc03:8ca2 with SMTP id af79cd13be357-792c759aef8mr2351108985a.28.1715968215220; Fri, 17 May 2024 10:50:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968215; cv=pass; d=google.com; s=arc-20160816; b=YmPUFYT3Ae5K+VIPoyVx4/tgd/FCV1y2wy6hRu7ghv/viUQbAZohVBL19RujkVCOz6 J3jKi8xNeCiv6lS8ecjPYVL5e4op3Y8sDaPjDr5HhrQYdgLa3nYQ2ITClZziOpDu8M8Y csBpnBTOc3C2P5j8R/zjlGVKydMzBI2Pha8nppH7l6LHDJxWu/A8cz5LW8gyHGSR2ryG fsqK+nsvLeLsi0bv+a7EDA2uEgC3lyd8st+tsuW2M1wY1sQyYnb4Hf2xkG+cvt/cXN7+ +cm6ibesIad23RW46Im2zV8j3prn/dK4sOxJqtcK/OFyXms1I0huMtDbbegdC4P7iVow jbZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=nreJM2bt6oXkxkEymPqKgBXxGBAexzLG9b/YnglUi3Q=; fh=M/k82yhSXAMrEs9r/KMNk2nOSLV5oDgTKFCA6EyHr60=; b=TCLuSR60Ls8aFl8BBjO3guNZ2D6ruzVocEYX95xH79UzL3s90D6mB66V8HzSpHORKR rFG0qyVv3wey6jFTYKr9JVKAJwvAj8dg2HzU0ahecC8yQTmkrYQSY+zXcBfSmJoTos9f DBkvfZhnr6H5lYDun+0LNseqB7BadRXlXIKIkaNh1urVjOwj4WBGjuAUGrYkGxaeJZib yOUTl0JXxytwbOqEGUHQY6/3nBm/0ml+tt1Us4oCyBuQDBJluRYcghQVVNPKsp4xuO1W 4pmC4QLpu0Kfp5Kep9Z/qiDQLCJYIsCjC+LhtHDG9xtqA12Zk0YQyazvcP0MB487bdUr /0jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dUseT+B7; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182466-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792e8eb72f8si461061885a.683.2024.05.17.10.50.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dUseT+B7; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182466-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DDF7D1C212CF for ; Fri, 17 May 2024 17:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24B78155398; Fri, 17 May 2024 17:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dUseT+B7" Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 9FC4E1552FE for ; Fri, 17 May 2024 17:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967648; cv=none; b=YNC+HR5nD6ux6pxfFfqbGxTukwdwRp7FMNiMYnBjlsM3GPf5H0Jz1dIzeGyRR7CcvIyRUko9XCvJrbloVR9TNhi9HcDpVKNATH8Y/8hHb/sXsvFKo+lCx35aFNixfZQajf9z5iRs45TrgsmAxC/f0+6AuGzNzCNdbC6bHCnC8h4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967648; c=relaxed/simple; bh=6O5zygWVSQQH/nffvcjVp4lF6K9NInxF8jIHE/Q/ytY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pu4GJ5zmM83lfPyyvCdnKTSrtcaHP+8r9qjPx8ewN29mlh28CVE/Im5xC0VbDC3sxXHZ6qhWXJ3ZTXhtA7LcDoEoaSsqk8k65QnC4caP3oNg+oupJ/mKhje9Um1KDLtyrBKjjmOJ4LDjGHyxij2pfWUv21aaCF3VIM2b40gV8gg= 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=dUseT+B7; arc=none smtp.client-ip=209.85.210.201 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 Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-6f44dcb8eb0so5528143b3a.1 for ; Fri, 17 May 2024 10:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967646; x=1716572446; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=nreJM2bt6oXkxkEymPqKgBXxGBAexzLG9b/YnglUi3Q=; b=dUseT+B7XR84r1jQ+wkrwg1K71NkU8A0tZnSZbHZp751Tg4fkttp6YsS3REdyMKTdm 1tZahKe7yGDPt1hvwt/dypen7cr0IQxyIRBKMsOZ9s9qiaEPduQxxQAEuLto9NltiksK DD6vl8SqcaDnCd+exLliL3PF58rOfkS4y+buAu48ACgUXREQpb5wHuKZs3DPm9JmEPJO qZpeJbOv3fF88s4zDkaWXJtQYiJtaAyQ8dRoxePv6YIaSPF9K6O9RcFN0kI1nRUYi5GL s9C7EZHPO762fg3fea8LrBQ2BRauvnh80ZBlaPkZ3VMIPNTNGQ4CQz+o2syCboQtkpc6 eCcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967646; x=1716572446; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nreJM2bt6oXkxkEymPqKgBXxGBAexzLG9b/YnglUi3Q=; b=bnKM+qJMwnv+5E0u+cOPx6UQeBH3rK12F9L8Thq/Xi7IbQj6RpSfVJboQcevXq9NxZ dvs5SM6grzCNyb+Le5H2M2OjLPAddHGSShGpE1lJ6W1zCrvHY7hlbAneCgTweRmrjR4J +ecHtPlvR76DTNEQr26dOmQrFB3BwBQ1PatmB9T1NI1E6AHHisLXVFLvVy42tVHRKNnP 3NsLVQn3S9EWMTAbvm9jtQmDJtJJrkoc5VPWPwRrZrx9t6CEJ+mXPz03tVg7f8IXKaIK lMboaen8cIuRUnj5HoadK05TsxIwtqURoNh71cpI5seZD+B8HltTTTev/PLljygiCB+U z84g== X-Forwarded-Encrypted: i=1; AJvYcCUuI5PqLOGkTIZbeMmCeHUmZYQValTlc5kPsmTCMaXW17foL4fh7nVQMFLgNZxoSI0n/NrtLNrYGlFUh7JBbhMxYtHAEwEnRYKu0IFv X-Gm-Message-State: AOJu0YwgcKZq1QciyLI3Ct+qjuUD/gZW/mcbM8jNnhyfiha4PEnasaq2 c54LeTlhAxbm0wzvSaCyRF4i1FLSuqdzl+eW1H6gDmys9Hs52G9WVKFi1cErkunht3Xr8Ug2F5s q0w== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:17a4:b0:6ea:b073:bf40 with SMTP id d2e1a72fcca58-6f4e03374bemr1037250b3a.4.1715967645992; Fri, 17 May 2024 10:40:45 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:39:10 -0700 In-Reply-To: <20240517173926.965351-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240517173926.965351-1-seanjc@google.com> X-Mailer: git-send-email 2.45.0.215.g3402c0e53f-goog Message-ID: <20240517173926.965351-34-seanjc@google.com> Subject: [PATCH v2 33/49] KVM: x86: Advertise TSC_DEADLINE_TIMER in KVM_GET_SUPPORTED_CPUID From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Hou Wenlong , Kechen Lu , Oliver Upton , Maxim Levitsky , Binbin Wu , Yang Weijiang , Robert Hoo Content-Type: text/plain; charset="UTF-8" Advertise TSC_DEADLINE_TIMER via KVM_GET_SUPPORTED_CPUID when it's supported in hardware, as the odds of a VMM emulating the local APIC in userspace, not emulating the TSC deadline timer, _and_ reflecting KVM_GET_SUPPORTED_CPUID back into KVM_SET_CPUID2 are extremely low. KVM has _unconditionally_ advertised X2APIC via CPUID since commit 0d1de2d901f4 ("KVM: Always report x2apic as supported feature"), and it is completely impossible for userspace to emulate X2APIC as KVM doesn't support forwarding the MSR accesses to userspace. I.e. KVM has relied on userspace VMMs to not misreport local APIC capabilities for nearly 13 years. Signed-off-by: Sean Christopherson --- Documentation/virt/kvm/api.rst | 9 ++++++--- arch/x86/kvm/cpuid.c | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 884846282d06..cb744a646de6 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -1804,15 +1804,18 @@ emulate them efficiently. The fields in each entry are defined as follows: the values returned by the cpuid instruction for this function/index combination -The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned -as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC -support. Instead it is reported via:: +x2APIC (CPUID leaf 1, ecx[21) and TSC deadline timer (CPUID leaf 1, ecx[24]) +may be returned as true, but they depend on KVM_CREATE_IRQCHIP for in-kernel +emulation of the local APIC. TSC deadline timer support is also reported via:: ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the feature in userspace, then you can enable the feature for KVM_SET_CPUID2. +Enabling x2APIC in KVM_SET_CPUID2 requires KVM_CREATE_IRQCHIP as KVM doesn't +support forwarding x2APIC MSR accesses to userspace, i.e. KVM does not support +emulating x2APIC in userspace. 4.47 KVM_PPC_GET_PVINFO ----------------------- diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 699ce4261e9c..d1f427284ccc 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -680,8 +680,8 @@ void kvm_set_cpu_caps(void) F(FMA) | F(CX16) | 0 /* xTPR Update */ | F(PDCM) | F(PCID) | 0 /* Reserved, DCA */ | F(XMM4_1) | F(XMM4_2) | EMUL_F(X2APIC) | F(MOVBE) | F(POPCNT) | - 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) | - F(F16C) | F(RDRAND) + EMUL_F(TSC_DEADLINE_TIMER) | F(AES) | F(XSAVE) | + 0 /* OSXSAVE */ | F(AVX) | F(F16C) | F(RDRAND) ); kvm_cpu_cap_init(CPUID_1_EDX, -- 2.45.0.215.g3402c0e53f-goog