From nobody Mon Feb 9 06:25:41 2026 Received: from mail-vs1-f73.google.com (mail-vs1-f73.google.com [209.85.217.73]) (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 532EB215F42 for ; Thu, 29 Jan 2026 23:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769729845; cv=none; b=Gn4TgAdshOGBddZ0pPO7SmFRm0RWdAJfLEWZ5cmoVN3xwaZPqoX3oZaXOHrvTCkb1+6EnoCQ+GGGehAY679D2DORGPho/1vnC4VJLzfJX7V+qyyGvpepJtVciPsdWK9nEEjUHV/8lmFDwERrZFzOc+wZRw78Qx7ovcfEHVAvS3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769729845; c=relaxed/simple; bh=P2gomgDRGmJ4vLTkCMnRaUel1qN8UOZyfcbTRRVQbSk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bikQR+eyeulJw8yCiPpcsGC+TwUbhvu2c5D2YEmSgyC50Ri5k2prbf4fRTUr00rPDNdR/OKUCbO8pBqMcfHuwVdk3DEdxSnkobBATzVYVczanUzGlttkie7cDwGaPsQFDrzibpyy9yt+h+SuTF+27gWip6YO3zv6vASccBbJ3Z8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jmattson.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2mNDwfOP; arc=none smtp.client-ip=209.85.217.73 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--jmattson.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2mNDwfOP" Received: by mail-vs1-f73.google.com with SMTP id ada2fe7eead31-5f167c4ab16so3805236137.3 for ; Thu, 29 Jan 2026 15:37:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769729843; x=1770334643; 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=9edmz9F0+Ueeg69+oBnQppllXkvN4AaYJE9iZBV8Nzc=; b=2mNDwfOPaAgah4OToKOGowOWupJsvoUznZC/Qh8AchYNZ1Fa1WfVMi90l2Tbbma/zN Z0aAeX+zTiD5Dk/R08Oul7MydbFjG59isw63no8vGI7V3ZdBFn5oHn5xLOvpLGxObDFj VqGUr+wuJOV/rOV7LZIIMoGEWBNmp4gpalBqkaDm2bY16yC8b8THCYn6ZVqw/ouqZbqU JXVlJKx4tmjgw/LkAXGYiTbjRCC1abLBNgR6z95JgYKyKY5NzBY1vb75t+wrP/FkLLBm Vvq4Zbemp+NmRjf7qKEjEm6c2GtzP617G3eJaB0/PZ90/dznEU3ZkaOl8wWopXu0sBGd EV0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769729843; x=1770334643; 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=9edmz9F0+Ueeg69+oBnQppllXkvN4AaYJE9iZBV8Nzc=; b=JszqbAlLv2I+X9B3GPt3BbIR21Mcud1JzXu238Tg9+brWUk7bZ2pYKMeUZb7B+XFv7 TTvFkkdaQggpz93YS1XHHMoHfPqq3FYxpeIfSROVT6GGCaSTuwWA1txIJMVmMaKJQcAg HrOR0dUY0HMSCz6wpmDhpglhzbJlcSLmshUVy4g2lGRKyqyohlf3JbFlnBHiwd2I+qhB QMmAgMK32D3XYifMfhclubFRo3ftf4HT/AxjEqqTfhFyDcfmHWieMku2BDO4W6bdNAne b6gmY4jL74G8z8MU2KIHWgkHFsGvG4ARnDGPYspayFVzHF+6ioR7q0cwcu5L9dCUm3bh digA== X-Forwarded-Encrypted: i=1; AJvYcCXuHWmB0zDrYNBzKyxy5fVKQd+uO9u02/F25VzdJCcQxvcnH16XJNKON5Pvm8PwzTAztGxndTxxkIcPoKk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0LrmEudRfcoCx8p+AhsEvXq5jN5n+/mjH+TGYx/lbjabHmO8C 8njdIMxZbu7KK8/pA96QUFdKAQMhSg2/WPQYfGFsIKeEcBNKNuWh+z/zM7IMpmeg5mrqYSRH05F 5eq2HAbJDyeoUNQ== X-Received: from plbll8.prod.google.com ([2002:a17:903:908:b0:2a8:759b:173d]) (user=jmattson job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d485:b0:2a0:9eed:5182 with SMTP id d9443c01a7336-2a8d96a6b54mr8177095ad.20.1769729346081; Thu, 29 Jan 2026 15:29:06 -0800 (PST) Date: Thu, 29 Jan 2026 15:28:09 -0800 In-Reply-To: <20260129232835.3710773-1-jmattson@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260129232835.3710773-1-jmattson@google.com> X-Mailer: git-send-email 2.53.0.rc1.225.gd81095ad13-goog Message-ID: <20260129232835.3710773-5-jmattson@google.com> Subject: [PATCH v2 4/5] KVM: x86/pmu: Allow Host-Only/Guest-Only bits with nSVM and mediated PMU From: Jim Mattson To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: mizhang@google.com, yosryahmed@google.com, sandipan.das@amd.com, Jim Mattson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the vCPU advertises SVM and uses the mediated PMU, allow the guest to set the Host-Only and Guest-Only bits in the event selector MSRs. Signed-off-by: Jim Mattson --- arch/x86/kvm/svm/pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c index e2a849fc7daa..7de7d8d00427 100644 --- a/arch/x86/kvm/svm/pmu.c +++ b/arch/x86/kvm/svm/pmu.c @@ -243,6 +243,9 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu) =20 pmu->counter_bitmask[KVM_PMC_GP] =3D BIT_ULL(48) - 1; pmu->reserved_bits =3D 0xfffffff000280000ull; + if (guest_cpu_cap_has(vcpu, X86_FEATURE_SVM) && + kvm_vcpu_has_mediated_pmu(vcpu)) + pmu->reserved_bits &=3D ~AMD64_EVENTSEL_HOST_GUEST_MASK; pmu->raw_event_mask =3D AMD64_RAW_EVENT_MASK; /* not applicable to AMD; but clean them to prevent any fall out */ pmu->counter_bitmask[KVM_PMC_FIXED] =3D 0; --=20 2.53.0.rc1.225.gd81095ad13-goog