Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1106611lqo; Fri, 17 May 2024 10:48:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzHJo3XWspTca4khDdfvK0WGoQ3UP3HH34a+G8D8w/fpyBds1REL0CipDx4Ta8Ubov30wNzUGCEj9bX+qHc0dFxY3x/s6r7J7B5k+0/Q== X-Google-Smtp-Source: AGHT+IE8fEXPFgj1zDBnQ01IhUaJcZB0hwGyWv8yaIjegiEoMrY2RIWrk+yBJ0TYVcVXb7Ahpwf6 X-Received: by 2002:a05:6a20:5607:b0:1af:d206:e572 with SMTP id adf61e73a8af0-1afde0a9cb3mr22469207637.9.1715968121202; Fri, 17 May 2024 10:48:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968121; cv=pass; d=google.com; s=arc-20160816; b=tctyqLsf6ae+FXNYTsxFcvGcIYWsGUvFSAsLvXcQMtdrapajqiBltSlm4HyS1vi1TA QwD58YACSh7m+JrxXmvUZQ7vXm8jMuB7JoAEVJ4rP65krQhGX/UE1fjKJeenp8KPo8f7 WQaSRROqtJO/wWi5MF/VD/tFu9u2R4ojesqxplpmtbInvadxolTECSxAibgLRMbJxkhG FX0EcYFzbq5T6vGRsCqTkDznEC2gzF2FDt2DgoZZeozo/T6bPqy3KG+D7R0CclFz97Jz pNXckOYC3dgiD7thrk96zUhFD+StyzwMOHhMUYrIpEoa2z5Ne6Xf34gqMd548bZSpicm yClg== 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=+xzcZH1oX82o+qOCBsf3LxtdbYVe7tXAJ4CjGFkhZ1E=; fh=9wHzBMrIYyGWLm7KReGRTSCSq4g7HvtE7VB+Y/7Sc1k=; b=UIXrtPZh1O77u9irDwxWZCtHh+SGO6kc7cNc94h/JubxHzfZ7ggy+TwaYOaZUlkDqg +8ckAos45h0S2riB3Fa7aNEosnmZ+TmihvCosDYjFhUGMtpjRiGV+JjjJ6DQjRINCq22 SMmSCr1IpqrxOd8rEN0PpB9f+oWmZwBlQC7rkxfB/UqvIOM1pM4RIen1rSZ03c1tRT33 YGad5fkiPP6gND6LUaiQwinS+FM5SBFGO8fTxpymIXM1HXbbS/GQ7BgdxrDA964uAZxY 3Xcv7qooyN+i+pNGcXHxv7xxsen+RhCt4aOLMHR+hc0ewk0I6EU05YaNxkxRcvPJ79gL IZYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=s+9kuIVP; 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-182448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6538951d16csi118777a12.48.2024.05.17.10.48.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=s+9kuIVP; 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-182448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182448-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BF58FB22F97 for ; Fri, 17 May 2024 17:44:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3B7D143C76; Fri, 17 May 2024 17:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="s+9kuIVP" 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 C3D58143880 for ; Fri, 17 May 2024 17:40:12 +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=1715967614; cv=none; b=nhMRkD08O6JFp+nURh+wCTB3N9130FwoNzBHppy1gdl1yKd9cQhf/u/zl8Jbmc1aSQtMPI8yNXlaH/LsgrgUTaEveSKANfzQ3vFAWVwQI+cN+2Yx+6GzL9q0g2v0lvg+RDJSl2dYmxnpUI8jdv78o0hG7kQe1IYPWtA26j+OFoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967614; c=relaxed/simple; bh=JWFYm3hzYs3OhfFjHKQqDUvFKX5QGqdvk4KVBkOltW8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iJaHWle3/1JRNRUsF8aTD2nOYpNkXfLf0ltvSxqVvp6VepxJNojJcOAMqrEzFvYvY0UGYfepUOrQ8woLaD/PuwUtDrNxh+nOmNVptzaQVDIIKckZRQby8+L7R2KRcrZKJV50XYLBbn3KvMo/1KNy9lVrZGYyrnICwjfGB68mLD0= 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=s+9kuIVP; 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-6f44e0a2756so7724590b3a.1 for ; Fri, 17 May 2024 10:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967612; x=1716572412; 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=+xzcZH1oX82o+qOCBsf3LxtdbYVe7tXAJ4CjGFkhZ1E=; b=s+9kuIVPvj7qjbEf5NbiNyiqCOlCCPfuNSmvSaafb3/N/d9trIE9IsKqTxPGVBnf0B h9t2gVrPJDvnBATNw1Wvb7V0RzUPKrCM3wI6Q84jpeiVxHYgB8Xdv/k58HLvmjaMZJCb YHAsxhlB1RDJEznXSjEdrXFFzK+YeWX8A8fdLxSrfK5/7HYjo7o/KvX7j+idKeX3KRei 8vq8ijyGJbb1XUZHWNnAYSrP2ykBBBGu9xEfT6nyVIazzYnPILudcQYMosFlPfznbh7M Hf7h5ZDdhcF3C9/WjpdsPb8bAqF9aWDaqw1IB+2wpt4EfReiMQLJiiRE3SERNGkhAQvH oxgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967612; x=1716572412; 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=+xzcZH1oX82o+qOCBsf3LxtdbYVe7tXAJ4CjGFkhZ1E=; b=i6xYhvq/IIHqLJkq8WFcNPvjUvJf/1ughRfMDv/j72hIKat3dGdFyTil9zh8HHmb7B Tc4iVH/9Hdv9wyO33HCfeLvyJhJZqOk09DSZKBFnhLbzksrA7KPr4QIWecbOviN0X+ZN XHtAnuU30T6yko4QsViWPV044pagIA5Xh1CSJvWuSinyEfiIKlK2BqpUb/JxDBvMmj5k 8ic0wf6NgbtAnfftmrVMt5Z9cXWD8CWkEFjZNAQbSqOvskUtG81tv9E3mOl6p1mmtO0U np44H0GOpXHr4mVro8k/EiBQDbUNQdYDPhy9cH1h0kurQ9LwTxLpPjUZGZ8yDhzCHxT9 d5iw== X-Forwarded-Encrypted: i=1; AJvYcCXI0NoEBXVq11VuUWcSDQsJuZ1jtu2kru+NipAQQazM1zFkOVBz8LL/AVPlYxx93G73F8rOak+m3abWXyp9XwJ8cVAGp8k92nv5uk9A X-Gm-Message-State: AOJu0Yx5+fQh8sF+aps12GUeIaqmDzTsPvGMydDhPLvsx3r9nKAqhDq/ Edlpw3rSh782sTaGWLGXcTQ3VN/NnLqVwFwbpixfMPR6i/tXlQHcf8+a6/BTMH5FEmdBL5MzhYa Y/g== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:390d:b0:6eb:1d5:a3a with SMTP id d2e1a72fcca58-6f4df3b1c35mr975367b3a.1.1715967612089; Fri, 17 May 2024 10:40:12 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:38:52 -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-16-seanjc@google.com> Subject: [PATCH v2 15/49] KVM: x86: Zero out PV features cache when the CPUID leaf is not present 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" Clear KVM's PV feature cache prior when processing a new guest CPUID so that KVM doesn't keep a stale cache entry if userspace does KVM_SET_CPUID2 multiple times, once with a PV features entry, and a second time without. Fixes: 66570e966dd9 ("kvm: x86: only provide PV features if enabled in guest's CPUID") Cc: Oliver Upton Signed-off-by: Sean Christopherson --- arch/x86/kvm/cpuid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index f756a91a3f2f..be1c8f43e090 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -246,6 +246,8 @@ void kvm_update_pv_runtime(struct kvm_vcpu *vcpu) { struct kvm_cpuid_entry2 *best = kvm_find_kvm_cpuid_features(vcpu); + vcpu->arch.pv_cpuid.features = 0; + /* * save the feature bitmap to avoid cpuid lookup for every PV * operation -- 2.45.0.215.g3402c0e53f-goog