From patchwork Fri Feb 23 20:21:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 20895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp827237dyb; Fri, 23 Feb 2024 12:27:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdnFEctuHDqC+mXfiJLivqCRmikTkMKLt5plyvfIv/0CB0Ys/EnhKbgINj4vaPdynNa6LH+Z9MVajmNhgecAbtAS13Tg== X-Google-Smtp-Source: AGHT+IFjAew1QkGCETqeBuKhQlnvbQO6FOGFG9HiZ8/vLxkhsnaCj7/4CG/C/doJ9vbDsXKpdm7n X-Received: by 2002:a17:902:e74e:b0:1db:e7dc:302f with SMTP id p14-20020a170902e74e00b001dbe7dc302fmr950353plf.17.1708720022346; Fri, 23 Feb 2024 12:27:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708720022; cv=pass; d=google.com; s=arc-20160816; b=f4Uu9/shl4AHOn9TuDPjEvhTj8ZTZOtlzYYtnSogFIoRIXHKLi4kNfRLTvewzqa79n cDGsrM6LSkOTSOcbw1c8Ai4xW+HjvjbWIqHOkK+kVORTXAH9uzg5NW0yRKrJCYhZkG++ RchxGD8iwQBn/Z1woJDUkV1qV+w/+sbUvwXFIQaKPMfvDINdwPTfhxrC83R/+ChjKEnq OBBoIgXnT+1xNGczvxi2f7gFns2rWF7elC5dbq30VKm+7spog62z+upt+yb2V5oVqvVt n0hYcKG6Z44pqM+llchV8tt+/sohz+0nvg/aGImqBfy34si2Y8ydR9//2A9yJ9eJX/OI hgxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=uMOKrbIKnJ6TKtSp5dRNn05/ENEXJGPDCIutix2Nmno=; fh=lyB6k0D/p8hurvnXhRY+dztu+J1mvbh0XspxwyT7GqY=; b=rI7JLceZ4Qh4fzkU8gEqBtLc+lL9T9O1OPXwoBS1er4scbvmULDHuVBgOsN4VKVLbx ODseal2ICxRqKO0rRuJyEbPrZ5IgHDUB2D69FwqdfQxhvGY/+IEkEunIOx8IV3Ne5MCH ptS9BzCxzTOous1876a3U9Zentf0h3hSbAKH7R3lhH3rY9BotSL+ZcQ9N7LXhM8dPrEk GbZHB7AOXM2K3q0kLZDe2Di5PGnCPMbLOZD0VEEjgQpJMuHooEIyhY7iG38Ob+waf9Dk /puEgBd85q1kgvSlNQ89jb8AF4Izhmwa1ZY2agm31SulmpETFuCZAJ2Yx0Z2hEgeveY7 Qphg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=USxebXXe; 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-79092-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e1-20020a17090301c100b001db2ad550d8si12753656plh.134.2024.02.23.12.27.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:27:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79092-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=USxebXXe; 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-79092-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79092-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 13604B26D40 for ; Fri, 23 Feb 2024 20:22:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5DB114939B; Fri, 23 Feb 2024 20:21:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="USxebXXe" Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 3DB23823CD for ; Fri, 23 Feb 2024 20:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708719669; cv=none; b=ncm5GDN9RWQ1el32i6UjoXnHQKfaC4Gh8v8Ede7uMEIzQ6rNgzw6URchycVdRrYkcRLW34WbAGBdm7stp8IZLAdHYPU+UYCt77ViHgidrh/bQ4xl+qg6bZX2eBvbazi1b0rL+VzgzhdhFvbGXt6B0QL9XA7BRn/NH7vgIHgEUwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708719669; c=relaxed/simple; bh=1bmnyFrNrxcCLjE3S/+oXjFKsestIbMgUBvvfSSy+OA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=AHdWh7fZ8lMLXaNgovUjIzM0vTS7vyOZEqEWhmxxm1b4+X/2X2kHTsx1Bhe0Pz1cxLN1qq40hUaHIIMQZi3dp3naaZZ7rJxyh9eSbREiviDk+Egiv0bfce4PZcK1zhX83ASR49ciCcn6YcqVPEaLRMcNWvJmykYCdbAAyIzRqpQ= 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=USxebXXe; arc=none smtp.client-ip=209.85.214.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-pl1-f202.google.com with SMTP id d9443c01a7336-1dc758f4264so4615295ad.3 for ; Fri, 23 Feb 2024 12:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708719666; x=1709324466; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=uMOKrbIKnJ6TKtSp5dRNn05/ENEXJGPDCIutix2Nmno=; b=USxebXXerT99qzSHcujpnpMzyGBUM8k2BxQbJd2jwZFxX+o4lcuxA9mVSpnWg0rJVY Kh7u8oj5ILoFJpTL+XbWBtSsYonNzWRV2qLiZPAQrxgoxLc+fcuunZqiOpzhw8Z8ZNgB 13qvrO1s2o1WFuV+7cobjzrIwSHjv+EUKrS1IpWJZ9D+yGvCfXy86HvnQpWhWEK6xKuE RHftZI8TQWvxYxJkl6ZTPKLwNu0zwEJazYa03xKVda1Vh5vPqgaWzMyWlY7cY3kGrXlf RsywgVZpe4xgc+JgMI0RUMOfGhAD1HMeMK6+gcIqxsnFBLHBx+flFHi7d6ArGxoWxd3h XjNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708719666; x=1709324466; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uMOKrbIKnJ6TKtSp5dRNn05/ENEXJGPDCIutix2Nmno=; b=MqakbZo5vXoUTqLYu+Sq+080PB7WR41EZnO7p8j5V8HvKIcn6ruovc3S8ln62tYW/V 81a4kYX+n2eztUdbDQr820LAWTGjEMDmBNXi394cX30yhILq/XBRJIHSsrfrLGGDCQ/G 3BXrNNw/9Evfz0VRVCddThKJVJQyxBvbcbTO0Dt8/Lc/aU8rqTHW/xN1lJ01FXuyMOtA YORVdUuTxE/Uot6jVH1tsmKrQeBL0Ga+ztDob/GPX872nkp6m6DWXJiE42CU5SiINGy/ swcnIUMrJOuh0iy+TGGYFTKuS8Q1vSP82T2z5jApiJGtnQLi69Z2RFGGRem2DmCSZQcK eI9g== X-Forwarded-Encrypted: i=1; AJvYcCXcG6pD0tUmhvxbJJreKjZAYUsWCM9+EolRPBMl3tdvPzJcqq+zB8f9MaUEthR0efGCNVwrvbSIknzYKPPSMlDMntiqBaAFFSB7IZLS X-Gm-Message-State: AOJu0YwLbCVg1Zzd9dlIUvA0RqQjcsnTC5ss0+fT5cSNzqEaIOHYTMX2 cp6XzbBynjlTGrkJxV7ywU8oPmwys1X5MCYkBnPmszFQoGj90XEgPwC/h4qfu+4qXw3BKG0hqtS 6Ug== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:d50b:b0:1db:cf63:b87b with SMTP id b11-20020a170902d50b00b001dbcf63b87bmr56644plg.7.1708719666432; Fri, 23 Feb 2024 12:21:06 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:21:01 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223202104.3330974-1-seanjc@google.com> Subject: [PATCH v2 0/3] KVM: VMX: MSR intercept/passthrough cleanup and simplification From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongli Zhang X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791722806123158489 X-GMAIL-MSGID: 1791722806123158489 Clean up VMX's MSR passthrough code, in particular the portion that deals with userspace MSR filters (KVM needs to force interception if userspace wants to intercept even if KVM wants to passthrough). As pointed out by Dongli, KVM does a linear walk twice in quick succession, which is wasteful, confuing, and unnecessarily brittle. Same exact idea as Dongli's v1[*], just a different approach to cleaning up the API for dealing with MSR filters. v2: Combine "check and get" into a single API instead of adding an out param. Dongli Zhang (2): KVM: VMX: fix comment to add LBR to passthrough MSRs KVM: VMX: return early if msr_bitmap is not supported Sean Christopherson (1): KVM: VMX: Combine "check" and "get" APIs for passthrough MSR lookups arch/x86/kvm/vmx/vmx.c | 68 ++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 39 deletions(-) base-commit: ec1e3d33557babed2c2c2c7da6e84293c2f56f58