From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 83C8B224AE0 for ; Tue, 2 Dec 2025 01:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764640254; cv=none; b=ZZqCD6SDUFKrgLehrVpNV12T1Q/Z4gbnOT9iayKr5V5/iG8r/PRBLd1tPI1GTvk+xTXP2g10eRPp6tUS/6MWClfF47xHCUJjRmPG10GOZ/qPeD2KfcTafBR1/87WHWcB46e0+/6Rxu81mZ2owg+cuzIsqHZJgYbWW6yAXbqzo60= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764640254; c=relaxed/simple; bh=GJsgJE42hahCrSlO6ruVXUTJwUaytLSg/1t0nBGUr3I=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=axUDVbb/5NeDDs3SYCBAzJDEusSRHnelJ07x/z3uF994WzU2kHVVCZYp19VPJvz9Bc2VCir/6zLXOUQKWwWHcuKWf7q7/TcXyfIL0Ah968Q9RtdlbmrfaRYHPyEcOF+v4xJvQu+jl3lDIbuiNocfKRftSwv9Z9RbqmkZYrQ6/aQ= 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=z0CpjkuC; arc=none smtp.client-ip=209.85.210.202 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="z0CpjkuC" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7be94e1a073so8530433b3a.2 for ; Mon, 01 Dec 2025 17:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764640253; x=1765245053; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=3D61cNh0yfwOk/9cHtCVfA9iuP9LEn/jtfYiGihcV+g=; b=z0CpjkuCyftl8akL/zUwGs9pJnsYe4KX118+6ubRSTzw83NhLZN1MM88eecZWhoJ0u P5Cr8GTgbFRAIAwne1Jxpruf8/KQ/DyUrc8j1v1dw7UuHTME5rbVTXJhmCF04BoxYOIP OUl5/I7eOnuawHukhuf1e4W+HKyI4T7HVtOTM1uU+/yZnzoO2nFV/gzFSzxp3bupbHJ2 H+coIlySwCSVA5JYZgpej9LznNnSgfcmZDmeb2Ngq+fyTTWPTXifSBYwt1YTrd39Dm+7 tixB2JqZplKHhq9HSRAhtQqP7g1OceQCvBO0z2voC7RMrp3r2Y5+Tkz3qF46vWvCNdZ+ uDJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764640253; x=1765245053; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3D61cNh0yfwOk/9cHtCVfA9iuP9LEn/jtfYiGihcV+g=; b=koPF6+NDiQHP+gS/je1JqbZ2a2e3SQZeuMteXUgIUdfmOuM5PjSgE0pgPwWRpciAyN q7Wes5rGPwPXJQ5ZZTYXHvqRTCfhvPXlFxTm3ENmOZzeT1gei8FWaDJuL2bPnimR1xUv NJor3E7omlz6PFkt55QD79kYX/BRWnFZohy9D3k7UYIbdrBJlscZoIKTngovgWiwC7L7 56Y5ffdKGO5enYlFaKtC/ImVn6B7TKZj/UHkDmSqpQLHj6uK/WF+blMD3T4EctLLV/Ce CwlSvtu+29zqfx9pMuDG8NURN30ZWrVIpSDyNybkmirUeOzuBCJGLZcuPVLgW5oBniBi 9h8w== X-Forwarded-Encrypted: i=1; AJvYcCUkF+UyfoYOZe6B71z+FFU54ImSVFnnIvX9+x0K3GImWZfGwHRJdwRPPikT6WOz7hS2GW3SY8MwStTkuMw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzfc1tnEK3XGqtRfrZSq7yQ7xYZOCh1rG5CEqZTv6Ym3tz5CN9x oeSeOYIvh2XC+lHWrpbPA0YT/jlIbYChuWjRxh8nTPVEhzDYr6s7M6G9+P2diUvVV+boTC7VMeX 1qwgxJQ== X-Google-Smtp-Source: AGHT+IF29RfNiVdWAFTFzDpzMXQokkiwTYtIrFtwKcAMTTVB94hBWPhw+A9w4nZaJ56IxiONDOrTIxVJyvs= X-Received: from pggg22.prod.google.com ([2002:a63:2016:0:b0:bc3:57f1:bc8e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7f86:b0:35e:1a80:464 with SMTP id adf61e73a8af0-3614ed95c93mr43581424637.46.1764640252659; Mon, 01 Dec 2025 17:50:52 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 1 Dec 2025 17:50:47 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.107.ga0afd4fd5b-goog Message-ID: <20251202015049.1167490-1-seanjc@google.com> Subject: [PATCH 0/2] KVM: x86: Do runtime updates during KVM_SET_CPUID2 From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Mammedov Content-Type: text/plain; charset="UTF-8" Do runtime updates (if necessary) when userspace sets CPUID to fix a bug where KVM drops a pending update (KVM will clear the dirty flag when doing updates on the new/incoming CPUID). The bug most visibly manifests as an -EINVAL failure on KVM_SET_CPUID{,2} due to the old/current CPUID not matching the new/incoming CPUID, but if userspace were to continue running past the failure, the vCPU would run with stale CPUID/caps. Sean Christopherson (2): KVM: x86: Apply runtime updates to current CPUID during KVM_SET_CPUID{,2} KVM: selftests: Add a CPUID testcase for KVM_SET_CPUID2 with runtime updates arch/x86/kvm/cpuid.c | 11 +++++++++-- tools/testing/selftests/kvm/x86/cpuid_test.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) base-commit: 115d5de2eef32ac5cd488404b44b38789362dbe6 -- 2.52.0.107.ga0afd4fd5b-goog