Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1116910lqo; Fri, 17 May 2024 11:07:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwne0Shd1HluA1Cso0b4eY2SX8zz1sMdKZO7D8/O/eRyPmxuB7YKu8cewRt5uXt5ptUzce0EnxhtDPB/+9cwOnooMfCeDvf+vtE2uxlQ== X-Google-Smtp-Source: AGHT+IEbEdGObFeoA0nfayRGZ7VBxjbhXZjsY4zxENGfsUm+y6UI/4tCWjDC/3P5HrAfmqGvnf4o X-Received: by 2002:a50:8e1b:0:b0:574:ebf4:f78c with SMTP id 4fb4d7f45d1cf-574ebf4f8fdmr7761185a12.7.1715969279788; Fri, 17 May 2024 11:07:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715969279; cv=pass; d=google.com; s=arc-20160816; b=k3C0/RzFbBETVfxSpHBye2P3Npvg5gVw4r8Krbu69JvtTMe+0WiJCuWl5zHxSJMC8x ORBOUmJBdQHAKfLUEl0GHtGoCWZubbCpHqQQLclLTfwaUiMtfdjfWLj0G/I42oHYm0Od xty4+JHzUH0rSMM5hxQ8ovPwTP9mASqHWWycuB3cP3/6Wnb8CbUk4jbn0Ne/t70Rfp8q FtP0QTpYMF3QKgKh4gpwSgtMH7KMY7+XOPcE98MxEnGNa2m5k9wOo71o5XqBFR3dmSrB UMncOBjFBXHxS70SGJfi2HOFWw+xy/EJs8RGVZEy6l7oGjq6Mg4dl2VCNBBkdZj4eymy qVUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Me9x3IUsC1z+bCQEZVRKdGqYAG/0M8JKwxm1DyG55YY=; fh=s2DhTh5fDa9tQCtqKiwXVRZ45CXn4OXZhKF6rJS4wIA=; b=mKm/U5yvEeqDw13N6tndJTIB6+QYA2ns9Z5NSiv1Rt/gGXcRbAb0uGnmsQ/WjNaz6T gdYO45EsiWpqmfPDLrgNJ2Uei8RRzp7yBacwhJZDoUDAXFmswHYi9PiNKdqnHQJLnnXg mk5ZlK3spGLX9did/05NCBc0z7iF3weRq/253D+c0DCFD93wdRrzH40egCZBiD52gvEI ToYdq6PO/6tBInX27/VeQW9FpK0WVl5NRcbc9ryr6AmUe1ohzg3Bf2pGyzkjB9hLtHt6 Zcw2NsB7gocm1LwjxdM5W8gJfZvZP+LRL3E7XvH1o5n1FaMetisKrYC1Zgjqs5g4IS7k kyKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eXH8b6kX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-182495-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574eb264f9fsi4218896a12.520.2024.05.17.11.07.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 11:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182495-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eXH8b6kX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-182495-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 494CC1F29363 for ; Fri, 17 May 2024 17:58:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 135E5143C42; Fri, 17 May 2024 17:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eXH8b6kX" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFB8813FD9A for ; Fri, 17 May 2024 17:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715968458; cv=none; b=JO/Lmwnw67EjFux70p9F+K5Hx5vAVg5QKflXbpXMA5XM+BBrdxNYYb0fN3IIfGVvvciblDfMCHK3G81/1Lut2ENAHz/X0/AYXUdC9QypWwvvPniPA0/U2bhNPqUoQfBUhWTIXoOO7n7OOo6yKoZkACb/PDlkvsWhEiZNbeVYGAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715968458; c=relaxed/simple; bh=fIE6oholh89hcyn+Mle9O7jrGtzYqHfvDqdxqhyIcuI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YvxUUIVcgkYC+y0ywlqszgstTiBNgN6c7Ma40q3ptQPOpBE7+ueGhfXYnWQsXh4MNrNffLW8+sFo0LNQW3+vw2rC62aenG6F2Po3GRBp2LMHYjpPKxQMMr8aQVf6BKyGks5DifY1/hBGM5NWcTrQJM8SyTZcQ/TX1PXNcjaiC8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eXH8b6kX; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715968455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Me9x3IUsC1z+bCQEZVRKdGqYAG/0M8JKwxm1DyG55YY=; b=eXH8b6kXGHUYlpalRTDr0y9SdiBZhblmeds34a4Zg/WMubJm7XDu/fMZ5aMZHy77lYQPGK jnUqZtQe44zBpvckmXxx8BQni71CucKg70jNz0O2AsJqlnhULX06HYxiHVcnZxkev9vv8P qOg+/X1W9yBpaiXOO4q9Dttc01YEXBI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-s610DBGjNHqfu8Z9etiwOQ-1; Fri, 17 May 2024 13:54:14 -0400 X-MC-Unique: s610DBGjNHqfu8Z9etiwOQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-34f1b148725so4310499f8f.2 for ; Fri, 17 May 2024 10:54:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715968453; x=1716573253; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Me9x3IUsC1z+bCQEZVRKdGqYAG/0M8JKwxm1DyG55YY=; b=EsUREq6IAP8NWZab5LSLVFyj6D8C5OtQ0EE08+JOlH/UP0d2SnMPzfwvOYtbwABkyC Xgjd2egUKJ8IIv2lTUYXeibb0cZwsXd9GsWw1036X9p5jJfeiOjpnKzHmQH9gultL5yF 4XopbQsdBoJEtWqf4MUuJL5BY5LoiMz1zqYHWO2IvH70fmKNtpbz28kv1WXEeFd7C4RZ Uon5ttTlrI4LOq+0CDjvpaf0UKFOwZoug4soGhJkT7tbt/HVu8Y33jxV3UDpcdWXgmkF gEH1iHcWBP742foJiYhnza+J5CLBgs6rIh7gkUfNOI7gCdtc5/FXfWjnokgJJHt8YOYy YaQw== X-Forwarded-Encrypted: i=1; AJvYcCXz4zrPQGF/dYRk+x9gNxruAvFXi8ZnYxJAWpASJ1ItKQbBmcRN1M8773tb/HJ46lmwn0VF3AXL/xVlu61b32wT8IguVLr4swGgQKay X-Gm-Message-State: AOJu0YxXwjfrTHtW46iTQghm1pj+MiqnHMKAa50y2hYeisSMYh3bl+Jo DxmzFVzxnSURL3mywMTzaHRBnky/z+g5mHZc0MOgw1pQpe1Aj1b7+vRvsS1VbpO7UlzRIofoeiZ sOn6vOYyWOf3RooniVthd588XERqyV0j+cPWuI4ZR5uCQyisan7f+wazvVf94vg4Goa3XawfO+B flEWYzgKZmyOGJS+YXhZE/sVsypy4czNYeryLt X-Received: by 2002:adf:f683:0:b0:351:d2e6:9296 with SMTP id ffacd0b85a97d-351d2e69673mr5014787f8f.41.1715968452885; Fri, 17 May 2024 10:54:12 -0700 (PDT) X-Received: by 2002:adf:f683:0:b0:351:d2e6:9296 with SMTP id ffacd0b85a97d-351d2e69673mr5014770f8f.41.1715968452489; Fri, 17 May 2024 10:54:12 -0700 (PDT) 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> In-Reply-To: <20240517173926.965351-1-seanjc@google.com> From: Paolo Bonzini Date: Fri, 17 May 2024 19:54:00 +0200 Message-ID: Subject: Re: [PATCH v2 00/49] KVM: x86: CPUID overhaul, fixes, and caching To: Sean Christopherson Cc: Vitaly Kuznetsov , 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" Content-Transfer-Encoding: quoted-printable On Fri, May 17, 2024 at 7:39=E2=80=AFPM Sean Christopherson wrote: > * Disallow KVM_CAP_X86_DISABLE_EXITS after vCPU creation > * Reject disabling of MWAIT/HLT interception when not allowed > * Advertise TSC_DEADLINE_TIMER in KVM_GET_SUPPORTED_CPUID. This is technically a breaking change, and it's even documented in api.rst under "KVM_GET_SUPPORTED_CPUID issues": --- CPU[EAX=3D1]:ECX[21] (X2APIC) is reported by ``KVM_GET_SUPPORTED_CPUID``, but it can only be enabled if ``KVM_CREATE_IRQCHIP`` or ``KVM_ENABLE_CAP(KVM_CAP_IRQCHIP_SPLIT)`` are used to enable in-kernel emulation of the local APIC. The same is true for the ``KVM_FEATURE_PV_UNHALT`` paravirtualized feature. CPU[EAX=3D1]:ECX[24] (TSC_DEADLINE) is not reported by ``KVM_GET_SUPPORTED_CPUID``. It can be enabled if ``KVM_CAP_TSC_DEADLINE_TIMER`` is present and the kernel has enabled in-kernel emulation of the local APIC. --- However I think we can get away with it. QEMU source code on one hand does /* tsc-deadline flag is not returned by GET_SUPPORTED_CPUID, but it * can be enabled if the kernel has KVM_CAP_TSC_DEADLINE_TIMER, * and the irqchip is in the kernel. */ if (kvm_irqchip_in_kernel() && kvm_check_extension(s, KVM_CAP_TSC_DEADLINE_TIMER)) { ret |=3D CPUID_EXT_TSC_DEADLINE_TIMER; } /* x2apic is reported by GET_SUPPORTED_CPUID, but it can't be enabl= ed * without the in-kernel irqchip */ if (!kvm_irqchip_in_kernel()) { ret &=3D ~CPUID_EXT_X2APIC; } so it has to cope with existing mess but it's not expecting the opposite mess (understandable). However, in practice userspace APIC has always been utterly broken and even deprecated in QEMU, so we might get away with it. I don't see why one would use no kernel APIC unless the guest has no APIC whatsoever. And no guest that doesn't find an APIC is going to use the TSC deadline timer (sure the MSR is outside x2APIC space but how in the world would you configure LVTT), likewise for X2APIC since you need to turn it on at 0xFEE0_0000 first. Paolo