Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp787236rdb; Fri, 26 Jan 2024 10:33:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/SadXhPrw6P/Kdr4RCnyjJfLulZJgHbOV9COTaKudzRRnFOzUdmYsVsULqaRRSO6NCQuX X-Received: by 2002:a05:6a21:9994:b0:19c:900e:4a7e with SMTP id ve20-20020a056a21999400b0019c900e4a7emr199147pzb.47.1706294035745; Fri, 26 Jan 2024 10:33:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706294035; cv=pass; d=google.com; s=arc-20160816; b=UBbrSGFocuSnJqdj6DN4h/sZ7QMvUrXVM5tuaXAl33DKqiChyoJ1y+wHqPDJpNmqFc fXrDrvgYElfzBfPBfYOgIqXM3PcIAdECukzUsXIKiyXzIuls/ScQbARTu/CcnAhxeoJD EBPLB9jnPDb+n4qwxRnlgisWnHadK+rpukfi1blV6OpRfMIZNBj7mpoLftfYP4qDH4wg 8HzUlIBkhhmrW3PpYEebXFTPdHTxVNlmFFW+Dc/lZbez2/USyv+/QAiJVdIr3482AOyI cjLJg0VzupEc1jE23cLpNPvx1MctgBNfUw3FH+q7vPNEY2GDtKwxQAU6a9ONQXvmfTVj kVkg== 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 :dkim-signature; bh=6Dcc9LRXvpntKzSYVjpRtgdZNNstahDCXgoyjCxDxqY=; fh=74N/uh0EyHJgByDwAXdY1CE4jv/Wn6PHe+IIW4z7Krk=; b=ybVvwmWcowB3DDwd9ltz/Qenh+tc+QvTW+HQDdDRkHSv/82rkE8eSC5H6chGHloLju vcZ8nyGvoONLg7b0xsyTfbFHcfe6xQn2G7eXTnyhCovWfNG0wnbPJQhCEkT5dxfGeNzi hYBc1F7MzvN9BzZzuZFzU1CVCudYjNz2IUHmWHrcC2qdwrIkl/wcDwSDUuy5t3SCWvkR A7A67A2c8L04tUcjGZ7FBQjTWmwjX5TGYlsjoX7+tTTO43HLEC6igMkyk6bvr8WgTcqv Ey2YpA4hhQaNpEvwCCXyiHSBh85Nt988UH5ttGqEdsDhvzsIHRw0vM3h0C1WxAveIEVD KAtA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=utuHxNlP; 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-40495-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s19-20020a63af53000000b005d2eea210fesi1546075pgo.887.2024.01.26.10.33.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:33:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40495-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=utuHxNlP; 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-40495-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40495-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6665C2828FF for ; Fri, 26 Jan 2024 18:33:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A06F210F0; Fri, 26 Jan 2024 18:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="utuHxNlP" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 E6F3B1DFF9 for ; Fri, 26 Jan 2024 18:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706294025; cv=none; b=d8NhbcBK3L3nj0x487INWYo0sivONRQ11B+0445zbDgZKzMHyP6GEH/T9Gka4MCeFoW2V343bvR/DnaWSCh+ynXLW6Gdkz2LRoP7ra+X1mmWt3xh4NmZQc5VYGbt2WLQ+i3gA0CKQjzeso3qBItHHATdZAuujWX4cCHvWJeRZp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706294025; c=relaxed/simple; bh=lQzonua4L7LeuBe7wO8Mc6DzTpXm+HWTrEtwIwlJ7TA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hEH8dANXQerTAB9gXvmkxWPRpQmVTJhQ6sz7TN6kSfRI/O8jOmH6hiNqe91Suf7qu0MLsr36mJEdAJfQo+uwbcfoFZDjAmEgLU0sFl71SUFlCQ3U+c6PCBl/RaDerxkInvh1/UTj21aB60qzIgiEf5Gz37BXA8/J0sUSnb45aq8= 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=utuHxNlP; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64f63d768so1025180276.2 for ; Fri, 26 Jan 2024 10:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706294023; x=1706898823; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6Dcc9LRXvpntKzSYVjpRtgdZNNstahDCXgoyjCxDxqY=; b=utuHxNlPmFVAA8LFUEBKQ3+hSCqPfaLcBYYkznaR13an82F8BU0OlnqY//MFOGorky fj1RQtmo/63wYPFHrLGUmBntqysTKd8iNxW4SlReSYp01vWj1s+ED33/0b4C67tAoPGC O8abyLHS3YQkK4P9BtVREHGEhmvOaK3lvw8yV1i64PhFSiXIeLcEyoWJMxWlr55DvhMU eCtoHSOP8stzIHKOytHUczZ+sgEB8GuIUa94QdWRPN8cE6v24Lu7MdTpXp4lrpL8dprC KMWMerZq6sGMzAW+HeTmk2nDit47EO53mmvQCh/vkmMRXj0uhuwxWCHKTxgppyICmEnr LyRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706294023; x=1706898823; h=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=6Dcc9LRXvpntKzSYVjpRtgdZNNstahDCXgoyjCxDxqY=; b=wFQdLGDTtHkiKsZyca+I87wSGTi3qqWIxSBSD76FHX4Wl6/cRiSFJ+l7SBGNkCGRPz zEBtNMZClzPHGVl2x7nIvRcOHlHy8o7EmqhF9utbh5u8gUr1NKTFIPFGmEbdHLR+CtPx 8xOTS9qTWv9VTptkKkJTzxEKoDWtzNJUYJoDYToEExjPJ0LVU4+bh6WfMNfluKLG4REl teCwWX1bdHp+7DyW8/7ziWzf4xfxprBCfeQNi97XPl8CNkzVHjjdZyBORkWZ2yoTRj+e aAhBXBhmy19Z3bWvzNuGeL2Y4CYiYQhPd6CODeiTCOb99qiNFJX4pCx5xFgTGYKF9P3Y QtNQ== X-Gm-Message-State: AOJu0YyOM9TxtLe6F8O0IFPSuaayiCoWMcO3E3sEvAe71weYviN80qQh 8Sn3PlhGbHHgefwLV5Hnfq33CAGSCLQzIhaj0H1ITxj+PQzrwRYDmsTfAHjfVTBmuyyU5dSAO97 tEQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2481:b0:dc2:1cd6:346e with SMTP id ds1-20020a056902248100b00dc21cd6346emr139746ybb.8.1706294022986; Fri, 26 Jan 2024 10:33:42 -0800 (PST) Date: Fri, 26 Jan 2024 10:33:41 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240124003858.3954822-1-mizhang@google.com> <20240124003858.3954822-2-mizhang@google.com> Message-ID: Subject: Re: [PATCH 1/2] KVM: x86/pmu: Reset perf_capabilities in vcpu to 0 if PDCM is disabled From: Sean Christopherson To: Mingwei Zhang Cc: Aaron Lewis , Paolo Bonzini , "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Jan 25, 2024, Mingwei Zhang wrote: > On Wed, Jan 24, 2024, Sean Christopherson wrote: > > On Wed, Jan 24, 2024, Mingwei Zhang wrote: > > > I think this makes a lot of confusions on migration where VMM on the source > > > believes that a non-zero value from KVM_GET_MSRS is valid and the VMM on the > > > target will find it not true. > > > > Yes, but seeing a non-zero value is a KVM bug that should be fixed. > > > How about adding an entry in vmx_get_msr() for > MSR_IA32_PERF_CAPABILITIES and check pmu_version? This basically pairs > with the implementation in vmx_set_msr() for MSR_IA32_PERF_CAPABILITIES. > Doing so allows KVM_GET_MSRS return 0 for the MSR instead of returning > the initial permitted value. Hrm, I don't hate it as a stopgap. But if we are the only people that are affected, because again I'm pretty sure QEMU is fine, I would rather we just fix things in our VMM and/or internal kernel. Long term, I want some form of fix for the initialization code, even if that means adding a quirk to let userspace opt out of KVM setting default values for platform MSRs. Side topic, vmx_set_msr() should check X86_FEATURE_PDCM, not just the PMU version. > The benefit is that it is not enforcing the VMM to explicitly set the > value. In fact, there are several platform MSRs which has initial value > that VMM may rely on instead of explicitly setting. > MSR_IA32_PERF_CAPABILITIES is only one of them. Yeah, and all of those are broken. AFAICT, the bad behavior got introduced for MSR_PLATFORM_INFO, and then people kept copy+pasting that broken pattern :-(