Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp92703lqn; Thu, 11 Apr 2024 15:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBUa0lV0iaJjaZUyjnb/OjLbza5WCfT8chjyp3Z5kNtS4zPiV2f4ySETuzbEUOyJvtI80RmIQhZaQ95dGymeYsF/U3Y5KXocDWnA61Xg== X-Google-Smtp-Source: AGHT+IEurzgj4ruxl2y0qYMdGaU8ADA42QYs5kzxocbGtpdriH2CqcFht17oWB5ZDQCnCgcMFE5v X-Received: by 2002:a50:d712:0:b0:56b:9ef8:f630 with SMTP id t18-20020a50d712000000b0056b9ef8f630mr677581edi.2.1712873534275; Thu, 11 Apr 2024 15:12:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712873534; cv=pass; d=google.com; s=arc-20160816; b=gCCQ9gNMVBb3JbuMH9l00OlRPPxbFgDuxHjceG093+1mHrJEqiNSj3yQu8TDeO/fLf RR0BEsjNeasZMQOzheGGB0Qai0E7lIRKqPBWYlGUHIN6TIFFdeebTjrVIUdOCDwHZ3R1 +D7sW5NbqOi45u+6lNMLA/6lPAstXe3tQFU2/0K5siFYSMM8J9APHb8OU6fQeDrMheLB LfYrlsePiG2f1hnI8ZHRUb9/aqwQtOANwwI3RTlCaEY1y4JDlSc8ziSoxn/a/PlIEoKu ImXGtjtSJb/Ikq2w4/MwjCcdnGdoAYYGjw812bCm5r/GL5cyc6iNvnyUyyGL/tTtnGDc NLwg== 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=BbaG91lWLov53dvFGF0ekNiCf4p8bhwzy5hlY8LQwTU=; fh=22g/2RjpfwWn0XjmNJK0kbe7lYK+UyepDw20fDoPK3I=; b=BkMGg+Q1GUEg6L07pUA4/roBp5oeXXiiSt4zQw0z3ifHs7B+Mc+TMlGBbzXbXu4/83 QAjwytTGQUvFEzWCoY/zXq3u7ZU4dYV20oiC04HZRq5siyQSncBvmFD1+17Wq4Y8C64p DCW6mdwh4zelSOCv36RXGqCLy/CV0x09Bi2QftAJOLhyP5j6D/Nk87Fvm294Xdte1lGY rPoRBeSw4XgO8fmLUJjiHrIhZavH15Jf1bTHLlidWeM1B17SimP1DyMQm2LlSo8gnarf /9wVlJhXsuCLljulAQmRTs0ZLA3i98ESfw75Knx9Mv1YbpVAuZFpDXNwruOjYd0stUg+ E8rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zTH9Nrym; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n22-20020a509356000000b0056dfbb2cb24si1053319eda.339.2024.04.11.15.12.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 15:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141665-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=@google.com header.s=20230601 header.b=zTH9Nrym; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141665-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D7D861F23D69 for ; Thu, 11 Apr 2024 22:11:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02AE03E470; Thu, 11 Apr 2024 22:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zTH9Nrym" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 BB3392942D for ; Thu, 11 Apr 2024 22:11:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712873473; cv=none; b=bXcd/t7ZoU1Dqfl7v3V5A46Ho4C6rsWSS8pZBMQnI8FyDDiZhDejdenFeYdKDwV2VtE90Ksofeqfle18SQ/J1uk3+ec7bIHBCy+m8HvIxqkzw7OJOSWefJpqNUZ4gogGwFdc0Pkhogh8ZA5neeF3gkMzDP2fRnjyUhUfyKQOi18= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712873473; c=relaxed/simple; bh=XzMv/PsKvb64ygIMkbPO9rdOLtTv9xpugwFBdSTwbRU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YTq90f02FoQldJpStNW3jKBSQRXVQZItQy0DcDx6O3DOJI/froHWn7+PWc1IgdP42JQrcY6gfrqnBjT3WkqmqfkaZ93fJFiAtJwoZb8+tx/dlOGlJ8IZfYy6wVcKT4yI6KxIEJBdRRdJoLHVaAQ1LXwgpGXoXE9OprWtVH+HEsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zTH9Nrym; arc=none smtp.client-ip=209.85.208.45 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=google.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-56fe56d4d9cso2156a12.1 for ; Thu, 11 Apr 2024 15:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712873470; x=1713478270; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BbaG91lWLov53dvFGF0ekNiCf4p8bhwzy5hlY8LQwTU=; b=zTH9Nrymlnp0x75L1y54QtQhaY8uLPHwiYaAaX4wn7F85Idzirb/LqiSkULv2rJHvZ 7ZO07+YY5FJ3Ol3gl5xDktV794NOvjaLEi3SNoShhS+X4iyh/qeU+G6PUkGxDfBMiY5r eePaw1rcDv/GCQp+o3VtXBBU1pj+xdFF7Dm14ZPU2gGchij801bR7ke0sXP71BcXwCE3 kHTTKfsAeMYrvke55s7cBwwRXC/qeI/YrZ9PHsOjCTzwGngpWI2xIeZaTkdOk3pJLfmI 80UztkQ7MKz30AmAKJqXdicB2e3lMRAQoRvY10+UBG47yP0Tir7YQVZ7mw51cTciMMKb T0ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712873470; x=1713478270; 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=BbaG91lWLov53dvFGF0ekNiCf4p8bhwzy5hlY8LQwTU=; b=G7K6T8ktYD9vZRJ0KK9CbUyzvI9sG0ABHBKv3QfLC2Ksnm9Wo0ddBkJELZXmIpGACk Kv2KKlKEMmLCp3gIOg8ueOCHi1fS8FNCBC0y5Vfczwhc5oivcfBpzlZhY2xSvHPT597W BTopDMK79H/s4wk6LRiQTyvufdyy/r5FXh3gtnfkSj+fx4/C2ErsagHYvEDCwg9uPyeO fSFyyPqI6kY/bKnE9ZG4cCCqbKlWznXvtpXATMSfs2frXLrCVb59IVUNJBpKYy0n0sT5 TDljqJvaPoP0Wux7bEaGbCdVN8eNq+P2DIpgQeHNTyWt/HazhXrXUJqnYOk7w7zTAUjG YVzw== X-Forwarded-Encrypted: i=1; AJvYcCXvoZDAygibxKrKWsxs2juQNCPlIN+c2JjebRSPhFo1qKYyT8va/SpQx7A9yQ0zwA0tx1PcInJbHQna84xGf3cNtPNFSoeIDFMMrwAA X-Gm-Message-State: AOJu0YxAIM6/iNIuCA5OZVbs7kHTJbB6HOUn2Hlv565P257tMCxzKFWM sUeidCGCXzp5F2v+nwlOLUJMwOszTP9xLqW2So3GDWTfCCLuvCp0Y9Ea1hWT7RJEte4VvUUu6r9 tmtXUACKOteHkW88tAdcwsOB86kT6GIdSPp2n X-Received: by 2002:aa7:c554:0:b0:56e:2b00:fcc7 with SMTP id s20-20020aa7c554000000b0056e2b00fcc7mr61633edr.0.1712873469805; Thu, 11 Apr 2024 15:11:09 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> <20240126085444.324918-29-xiong.y.zhang@linux.intel.com> In-Reply-To: From: Jim Mattson Date: Thu, 11 Apr 2024 15:10:54 -0700 Message-ID: Subject: Re: [RFC PATCH 28/41] KVM: x86/pmu: Switch IA32_PERF_GLOBAL_CTRL at VM boundary To: Sean Christopherson Cc: Xiong Zhang , pbonzini@redhat.com, peterz@infradead.org, mizhang@google.com, kan.liang@intel.com, zhenyuw@linux.intel.com, dapeng1.mi@linux.intel.com, kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhiyuan.lv@intel.com, eranian@google.com, irogers@google.com, samantha.alt@intel.com, like.xu.linux@gmail.com, chao.gao@intel.com, Xiong Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 11, 2024 at 2:54=E2=80=AFPM Sean Christopherson wrote: > > On Fri, Jan 26, 2024, Xiong Zhang wrote: > > +static void save_perf_global_ctrl_in_passthrough_pmu(struct vcpu_vmx *= vmx) > > +{ > > + struct kvm_pmu *pmu =3D vcpu_to_pmu(&vmx->vcpu); > > + int i; > > + > > + if (vm_exit_controls_get(vmx) & VM_EXIT_SAVE_IA32_PERF_GLOBAL_CTR= L) { > > + pmu->global_ctrl =3D vmcs_read64(GUEST_IA32_PERF_GLOBAL_C= TRL); > > + } else { > > + i =3D vmx_find_loadstore_msr_slot(&vmx->msr_autostore.gue= st, > > + MSR_CORE_PERF_GLOBAL_CTRL= ); > > + if (i < 0) > > + return; > > + pmu->global_ctrl =3D vmx->msr_autostore.guest.val[i].valu= e; > > As before, NAK to using the MSR load/store lists unless there's a *really= * good > reason I'm missing. The VM-exit control, "save IA32_PERF_GLOBAL_CTL," first appears in Sapphire Rapids. I think that's a compelling reason. > And we should consider adding VCPU_EXREG_GLOBAL_CTRL so that we can defer= the > VMREAD until KVM actually tries to access the guest value.