Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp987511lqo; Fri, 17 May 2024 07:35:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0h56p17vzHCvEEO0+SmqJxI4mkMZhAHCqXzw7zRQ9fdmbZ/2x5Lxo6rHhLgvml3yXj7u4PcSeoWyBw2nq0WGQ/2lo7ZaK7HL/d9cPGA== X-Google-Smtp-Source: AGHT+IGPkuJoIp00M/WSj+9BzKi4oEq6Fyp9FB63yXdE4K8O6hCka6Q3GXzslnuYojiWQ9k2TpQh X-Received: by 2002:a05:6a00:9290:b0:6f3:e6e0:d9f3 with SMTP id d2e1a72fcca58-6f4e0385654mr23022959b3a.31.1715956499874; Fri, 17 May 2024 07:34:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715956499; cv=pass; d=google.com; s=arc-20160816; b=U8QPLXZ42G7rLKP3RQ6UHEoDSuHGfTEhBb5a9rtjMBekthBgRTt1ezC/qM1M3pCAyx r0H6dGRrcNavPxLz+SrjZ+hnm+iI717DO3lF9dzo5JyIX4cH5d+xPCQ25/aZ3reRh2go PP3vjMm0JfwiQsvfYfd01xlRporKuxbML3DUrLZi0keZ4N4BGQKcNjP+SHb0cnrISoE0 uuNNnc1w4NGMvRswUPVyjCF07QYUKHxs+G+cVQXcXVAyaNhTY9RafuhtgqjpyDOpSnzm FJ8/jVdbROuqgOqN43B9BLDFsUCbfHnqal6e1KLhrtI6Q6/IHrV3lNPAZLCMzZn5z4f1 ObIg== 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=cCwbxCdw0tA0OWIMCvHgG1A0QngcvUL1VDqvLH7GRrk=; fh=DuspAPUHE18muP+SD/KACSMmflL4p2bu6XrPmH8W8aw=; b=ll+RyjmBTD+kDE2aYP//DjUMwq5pnj/A3dd6ZjfbH0T25QlXdo2LHLr+0b7Uli8bwx eLCMihvBsipDU6b67hNOrTKmVVBEaDR9XyRVN8lv3CwXo8pX12mXU0pgpyAZz4eHYrH9 wSzr2oicAUPFQpQn4axK0X5mX41yDy+JqpzBDnsuX51cOK3/pAWeiE/BFjdDwb0jLaoA xeaL0r6Ha3H+up9PPWSatrNc9niaH5QlYencieTg++SDzL5x8h1mAfimQYciffNqSDDH 1P5EEsI3WxT50XuMrkY7Mw2APgBaK0KuQ2yHLreHLBs107EOISGupXVsk9RwNyL8NMpL QxmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VOEjG4cK; 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-182207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182207-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 41be03b00d2f7-63412958d9csi17856519a12.669.2024.05.17.07.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 07:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182207-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=VOEjG4cK; 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-182207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182207-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 1AD132861BB for ; Fri, 17 May 2024 14:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3507F79F6; Fri, 17 May 2024 14:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VOEjG4cK" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 04774384 for ; Fri, 17 May 2024 14:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715956319; cv=none; b=VhMJ7UIWiZU/e2wPlmMvNelTKAO2DyX8ljnT/ihhbLL+m3oNUtNCo+kBP6VY0KsvanyORK/bg7Xh4NFDA7XWXMtX3JGMVebAKQGLcetcISN7NPsIaqB3T2jW1uJexvFHhxHhNmQ1D+GPYuvX6Tk0rllN0PjN3ynEfjqDrI5BbKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715956319; c=relaxed/simple; bh=lPwyFvnA8RFfjSZrTOFb1sNPxW2YnANTbVeCPsbbj5Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NLcup1YvT2mu9qJMYJXw18oK/qoVt0gi21FCrQMZdR2hFoypl+5njN4FjZ6GY2Yst9o90E6+bEsjm7SRb5OaGsIvjh10hqwbrt2NjXMs/mgeom2uJkQ8pefZTBjGPQaXw7kVHlu9Dvazc2l3mfJ+UJH7TuuWAUR0102d6lDHMTE= 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=VOEjG4cK; arc=none smtp.client-ip=209.85.219.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-yb1-f201.google.com with SMTP id 3f1490d57ef6-de615257412so16087879276.0 for ; Fri, 17 May 2024 07:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715956317; x=1716561117; 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=cCwbxCdw0tA0OWIMCvHgG1A0QngcvUL1VDqvLH7GRrk=; b=VOEjG4cKlb0wom//cRurdkUwqhCis7G0cX8JcGSlercKnyXmquTVfiI/iM2UPX9NxV 7IQuyZHNnYnxLoJtpOajnqjrYyCzrCVlh9VCgcpnFIC6gDH+3nRhaLZM5kFlqSSNPloT DrgxiG1LJUgBAfSA6pHIcVIezuW68V1L8fWvbl/TRMNdqdL+wAwSX5hCk0M8aNufut81 MnNmuQvRrZ8Cy1t/47z5a2vS4r9B9Y0OkYjX8QKhb0tLE1opXICy1h0qhR2GXDsJVOSh 0l5bFbVL1c1A2LhxD7ckozH5SFD4Hd8z3syTudwlLoEczQ5nu8mTuBYNpjU0SEqEWEQX aTNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715956317; x=1716561117; 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=cCwbxCdw0tA0OWIMCvHgG1A0QngcvUL1VDqvLH7GRrk=; b=lfnRFe0/65mxsmUdbhluGdDTq96WiJaBOBKYn8SWBw5/OCmbb3saYh/XWws3Wdyyzz HcSf+ovamYLBVzcwzHJb0oLVUZugsz4rGeB8xIx4mso/tlqlcd2sMtgAWNDGzSzPDoKI Ww9+dU0pz/l6sM/x/Tk1XG2h0ITDUXYJ8k1ehKn9oUO5qPDTRESKRlB0EwfS6e+s0yiO 3Q7luZ7dkT+ew4xKBXtpuM/wgbkipGGdA8mG2Vh05faRNJneLKjnjIofbIM2XX0WLCzV IbY0Or4abZdM+LPXPLoECoxqDDJa0fMgPLlh5vP1QsDNi6zC9nWaDydP4LdNxJa0f+cb XWpg== X-Forwarded-Encrypted: i=1; AJvYcCUxyB+6ZCiWvWcLzDI2GxzhbE28T9ka8LJyY/OGs6SrFyNwRVFbAQH0EIGuC5Ufvye03NJuKtpuEOqDWiUNHFjKk4dkJ3K0yhw0GPCi X-Gm-Message-State: AOJu0Yx9jATTyaY1Kpcgu+dLgsXsyYDC6oRX2S1UHN9IYqVBDGAgw9Q7 ln0lu5pN5Ur2YdKlmdS4+66RayrS2Ye+6H6DmUH4KlMjR5PQdQGKeCfRqfOEqnHP8p6dF1rSkbf ALA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2b88:b0:dc6:d233:ffdd with SMTP id 3f1490d57ef6-dee4f0d9077mr5954597276.0.1715956317088; Fri, 17 May 2024 07:31:57 -0700 (PDT) Date: Fri, 17 May 2024 07:31:55 -0700 In-Reply-To: <305b84aa-3897-40f4-873b-dc512a2da61f@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240416050338.517-1-ravi.bangoria@amd.com> <9252b68e-2b6a-6173-2e13-20154903097d@amd.com> <305b84aa-3897-40f4-873b-dc512a2da61f@amd.com> Message-ID: Subject: Re: [PATCH v2] KVM: SEV-ES: Don't intercept MSR_IA32_DEBUGCTLMSR for SEV-ES guests From: Sean Christopherson To: Ravi Bangoria Cc: pbonzini@redhat.com, thomas.lendacky@amd.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, michael.roth@amd.com, nikunj.dadhania@amd.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, santosh.shukla@amd.com Content-Type: text/plain; charset="us-ascii" On Fri, May 17, 2024, Ravi Bangoria wrote: > On 08-May-24 12:37 AM, Sean Christopherson wrote: > > So unless I'm missing something, the only reason to ever disable LBRV would be > > for performance reasons. Indeed the original commits more or less says as much: > > > > commit 24e09cbf480a72f9c952af4ca77b159503dca44b > > Author: Joerg Roedel > > AuthorDate: Wed Feb 13 18:58:47 2008 +0100 > > > > KVM: SVM: enable LBR virtualization > > > > This patch implements the Last Branch Record Virtualization (LBRV) feature of > > the AMD Barcelona and Phenom processors into the kvm-amd module. It will only > > be enabled if the guest enables last branch recording in the DEBUG_CTL MSR. So > > there is no increased world switch overhead when the guest doesn't use these > > MSRs. > > > > but what it _doesn't_ say is what the world switch overhead is when LBRV is > > enabled. If the overhead is small, e.g. 20 cycles?, then I see no reason to > > keep the dynamically toggling. > > > > And if we ditch the dynamic toggling, then this patch is unnecessary to fix the > > LBRV issue. It _is_ necessary to actually let the guest use the LBRs, but that's > > a wildly different changelog and justification. > > The overhead might be less for legacy LBR. But upcoming hw also supports > LBR Stack Virtualization[1]. LBR Stack has total 34 MSRs (two control and > 16*2 stack). Also, Legacy and Stack LBR virtualization both are controlled > through the same VMCB bit. So I think I still need to keep the dynamic > toggling for LBR Stack virtualization. Please get performance number so that we can make an informed decision. I don't want to carry complexity because we _think_ the overhead would be too high.