Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp78624rbb; Fri, 23 Feb 2024 12:22:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVirkqj8Mwm3wtjnMciHIFgv++wpXI4A37KENHjpVHenfoS6MGHAcd5YwfU5BY5zmZh8VJRLWDHcrKHmk5qNHHlC1PFqRahY6p4JsQcjg== X-Google-Smtp-Source: AGHT+IGQx6vDaJvTeSJT+Km6wNUHluojwautYio5UB3ydHBhIEzNdWygDsFou+1vy6GlvJhxAmMr X-Received: by 2002:a05:6a20:6f8e:b0:1a0:c4cf:ea9d with SMTP id gv14-20020a056a206f8e00b001a0c4cfea9dmr1088306pzb.15.1708719762437; Fri, 23 Feb 2024 12:22:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708719762; cv=pass; d=google.com; s=arc-20160816; b=GpfVKJ78qMrFlkf8FzLrw7rCWQfjUMrictUvaUW0TJxwDNfU0qjd3WXIJq8d33aqqF iiHOI01DBdLTR3G5PfwXfD2OYDzWsJRS9jU8ce3OiQpNe1EqGbdKa6kDIx6G71vj6TPa uNlam0z/mT0iVKiRaB3Yyk/lMows+hroSJo6UB1OzQbSo95ac+xf2uKQvwqq3ice6ZW8 LO5xwINgf8KWfrqqGrsCaPCC10I4FKTRCMinLwy4oWwHF94aCJpKE9R1b64oO6uhi45y I4pU3tWidVlH+QkWqT+riKEhbMNlOZlbSZzNPu+AXnWF5L5Jp+n3UUohkQ4zdxep/qun HfFg== 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=SJIQNAlIsKGXsg0lFIYuueKE4jyUGKIK5OKq5RD486Q=; fh=ykUnnx4BgPvNrECOOXUzwP02ZFogvNldpJeDk+ROSoU=; b=ZYCiBK0P0WbZdhyKrrn08A7R5hhUhBkEMdDgJo8y4rD/PEO4VHBYwO3Iym6YYB2f+q sJBHZSeRR2IL2sXZGUrPN0Ya9dP/2EsoO0Tu9z0d/Mo5CNzGhr7uWYQUjuCms23EJA3C Rev5IOyNEcW8IWSKdWoMZVzH1CqnaALOdKc32RZQkfiLWkjaaiebMqgQARW+HZQ7tjQ4 QgQEY3lECHarbZxnJMtRM+ULehI6n1lzMzdlQ7ZIzN/26v2BvWrv1citGutFHt173Y2B 20vDXN6D+nVxRo5lC+76nMjBUteQ9jd56O9rJvhN8dLIDPcgIWCsqKX1g42p8/LGpH+j fbdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HXswtQXg; 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-79094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79094-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w186-20020a6382c3000000b005d760d1af1csi12532140pgd.460.2024.02.23.12.22.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:22:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HXswtQXg; 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-79094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79094-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 1BFD7286CAB for ; Fri, 23 Feb 2024 20:22:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E6451474BD; Fri, 23 Feb 2024 20:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HXswtQXg" 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 2D65C146E9B for ; Fri, 23 Feb 2024 20:21:11 +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=1708719672; cv=none; b=gSt+9OaFhZeJ9xSzdOu4bbEf8sBePWgpM7jw8KlbN1vythBz3RV1DUVi4WCzE7fYezj+Twn4WdbfERg4Co8E36qyp1Gwp+Hh8Y1WEr6p2YLh756UaxTwXZKO4NCQRH7xNiMY5+RRD/K/Ntb3CsGihEbgXpY9Q+JbfK20eb8TWTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708719672; c=relaxed/simple; bh=HGThLVUxXYbVSOOZxCrgBI4/8udXcy4h8pBaZ8gILd4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eZc6UJqws00m8j1YwIcJEPv9pIRHexswxhafRDZ6uWQgRx/jI8WAJJM26AaskF1G0yDfnYZb7dS5Yjh66TC5ckH+72CyCosqGGeeTie/pbs2MtmDwe4Y3BI7jdjCHarCqpZUJUdpFuH9O7lDeqaN52AZ7lUk+xR/RmILI9C87Z8= 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=HXswtQXg; 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-6e41d856114so901790b3a.1 for ; Fri, 23 Feb 2024 12:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708719670; x=1709324470; 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=SJIQNAlIsKGXsg0lFIYuueKE4jyUGKIK5OKq5RD486Q=; b=HXswtQXgBREBdmoKabdRaJen+fLGcnUNFTYOZR0tnm9hpXuuoYpSAZNymOK8xD+le3 jYmcz0L+2WUypcToslY5SxvCEFPysoh21Iggl0rgdd1iS6rAONBBQNNfKRMGPcIjhD6W v55MlgkPuqkZYUbiBdtto5WuB4gOjTd3i4CW2fUv65qZ8huv4XlKiYYjklgLGJDPCr4t bQN7fHpdL4qOgJL40fZxWc56rXnPp58R4DBUfPNBGb4x/epv1uIqeStMICjtB1sJeEGa mujKs29fcmSIgxmfeb8hAUBf8140LMIffBdbI7DC8AJQV8uvEihwb8ozLO3J9QzwIdB/ liiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708719670; x=1709324470; 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=SJIQNAlIsKGXsg0lFIYuueKE4jyUGKIK5OKq5RD486Q=; b=Q4OwBLajm/O7nnpI+5pX9pMIKTBdAJL0vAiKcegdHgB2Z4zEl4pgFiZNIUC0uWGhst 8t506CpSSHuMGfCBNHjYPcHkfRnOVhw6EUuXjG0IkQ+NbiTq4L34YGhss0fLhuqBqXPG eC/g7YgcbZ10/EUGWKUauHu0lFMxuRF7dJcCLKIwp64XwkltKDje3Gzb44PZ2K29BlmL s6Vvhbtan5BlFRvGHNLG/pi6yABeqGBtYRjRaDgryhVQ4HyCERgwPvJcIUX6grhi3Glc sN87zu3LfLLAWKSCOHE1O4XqTtS8q8ohmmCXavLCjPNckUNeLjecNXtU20d2NzjkglCX Y9IA== X-Forwarded-Encrypted: i=1; AJvYcCXRDTBwSXLHLg0DoX2zLwkRrczUhR1XVLwNNrScACg6MgZ/461IurvyVeMT7jHTBSt4Qz02wwyVGaddbbo02IKSqELE9PyXQvEWph86 X-Gm-Message-State: AOJu0Yx/ME3k+bdjVdMF8mVq0NnRgZug9PKB0eStCu7eCcUCznt3Lrif BClt2KbiCtaVNW/FPiG4HRkbrgXJbte/2KDmibiQvYgCi1xLN+Lp3yI5RppJTDlCL/reYLkjhVx Vhg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:3cd1:b0:6e4:8aa4:387b with SMTP id ln17-20020a056a003cd100b006e48aa4387bmr67638pfb.1.1708719670527; Fri, 23 Feb 2024 12:21:10 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:21:03 -0800 In-Reply-To: <20240223202104.3330974-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: <20240223202104.3330974-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223202104.3330974-3-seanjc@google.com> Subject: [PATCH v2 2/3] KVM: VMX: return early if msr_bitmap is not supported From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongli Zhang Content-Type: text/plain; charset="UTF-8" From: Dongli Zhang The vmx_msr_filter_changed() may directly/indirectly calls only vmx_enable_intercept_for_msr() or vmx_disable_intercept_for_msr(). Those two functions may exit immediately if !cpu_has_vmx_msr_bitmap(). vmx_msr_filter_changed() -> vmx_disable_intercept_for_msr() -> pt_update_intercept_for_msr() -> vmx_set_intercept_for_msr() -> vmx_enable_intercept_for_msr() -> vmx_disable_intercept_for_msr() Therefore, we exit early if !cpu_has_vmx_msr_bitmap(). Signed-off-by: Dongli Zhang Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 7470a7fb1014..014cf47dc66b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4127,6 +4127,9 @@ static void vmx_msr_filter_changed(struct kvm_vcpu *vcpu) struct vcpu_vmx *vmx = to_vmx(vcpu); u32 i; + if (!cpu_has_vmx_msr_bitmap()) + return; + /* * Redo intercept permissions for MSRs that KVM is passing through to * the guest. Disabling interception will check the new MSR filter and -- 2.44.0.rc0.258.g7320e95886-goog