From patchwork Fri Oct 27 20:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 159155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp875480vqb; Fri, 27 Oct 2023 13:50:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhpTwWmeFMwG0DNzLf9aKFKim0cliH8qTYvWui1XClpKumgfvSERED6lGkJ1wNIuVv4u2V X-Received: by 2002:a05:6a21:3e02:b0:17d:53aa:d54d with SMTP id bk2-20020a056a213e0200b0017d53aad54dmr3790010pzc.37.1698439806882; Fri, 27 Oct 2023 13:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698439806; cv=none; d=google.com; s=arc-20160816; b=rIWES8Kcw0aJOnoTkDgL76UexzMhG6weiE3n6XxCGgcxUuIx1OS3OQ/ocHAVtr1dCs enEcUuPk6/xvTQKHz1MPPaDE7/mpnzs4nMT/ztnFem4cwjdirPQ4LN5/BN9QehJGvlj5 vK3YVdKBqUa8YxSejeZ2YRY3DCk6XpPZPJtdigMwIcOayR6uQF3I7zJBvLB29JfWXaym rpUP1Nf2XOPD7JRRRwYXsiTY16Z8ozsGjobYJofGXbqXL/Ms5qjOIVVdAfiga+0iQ226 M3fZTXQSliJYiVM+qiZdWB/0GvJi7reI6EhfbXU5y3ttrWMfvI5Bmeu324PJEjq4UkHW AjBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:reply-to :dkim-signature; bh=o0CV1M/k92Q3xvDsogLi4g0xsgOAA/CC5ii4d683MKg=; fh=dogxdQWc7Q2U5Ekp9F18wEHwMgE3kRwQ/60KgTj3654=; b=I3qbVMSARh0HmYyT4rgyU7mOpD1e6zZ7IS7xs3d02WsJZZ7WKixMP68vYr9G+py3TE xzuSFSf+38STl5/7fpIsRaU12BV9z7shmTdifOwFdaw4lL7OB0kHh5zle4dNbLWFLF+0 Jh9pSOF9ky+max/8W41OxgBDbYFHwS+KwmqArG1pxO8oKwz0ZQIfG2IUt1OqdvUTr/ES lGT7/X0Rni2SV76xlcr1F88WMjtnKuZFlj8zHfOGTxX1LUijY5agV6wL46hmwx/7Ue4D otqfd/XNZIfTcjIHy+GU2hqlTvFYVf6nQyVLfUh6eTGQ4zxOPQlPYbsQAPkggs0WTlaS Qzkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CtvkMEik; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g27-20020a63375b000000b005b884c4db36si1549662pgn.494.2023.10.27.13.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 13:50:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CtvkMEik; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AF0C080AB1E3; Fri, 27 Oct 2023 13:50:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346496AbjJ0Utz (ORCPT + 27 others); Fri, 27 Oct 2023 16:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346543AbjJ0Uts (ORCPT ); Fri, 27 Oct 2023 16:49:48 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E67D55 for ; Fri, 27 Oct 2023 13:49:45 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5ae5b12227fso22076817b3.0 for ; Fri, 27 Oct 2023 13:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698439784; x=1699044584; darn=vger.kernel.org; h=content-transfer-encoding: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=o0CV1M/k92Q3xvDsogLi4g0xsgOAA/CC5ii4d683MKg=; b=CtvkMEikP2CIqXDhyruQ08qAT0RVSGGx25ICdO8QSDKBv2JOk+PKxIbL1FTVI/8gdo 9dZUehrz3Ary66ADg2Ex4PRIYexOybRjAepWK3l2gAB094BOUvqQ1Ot3HQEkKz8SylbF 3dmFmTevGZmk/j9k93r/A3atGjTY/81nWnYhLlUHuymiqcQ2yBe16SJBK97nuqhQFNfP JDwe+TW3xmHs+3c2hIBZoLP0oFr49561MErFATbCQdSherQ6zKDrwcuBq1PckJspJVDA sJ/xcF1IXv9NbADE5OUZG1LY/L+Umn3gS2tB3Zon+C1yFMeJ8eSNBIzgOjRRAL0wlhtZ bdVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698439784; x=1699044584; h=content-transfer-encoding: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=o0CV1M/k92Q3xvDsogLi4g0xsgOAA/CC5ii4d683MKg=; b=X385voY3O0xNZyGG7vWANO+fJQ2gp1Pzb10W2h31IvzZ6d/8zeY5HSfiPBev07OaFe ILP2TdRfDIiwMACXF9Ich5WfrWi78Y/pTgcjR4bACP4WdlUbO36Wwa2cXFEOwLyZw5N9 xyqoizp6Ogrdpd5BOJhpYIYk6kx3WM0SBEIN0rWp3nzEhbDrkuIlvnizhBD43NUh9cm9 L5kAMDUptDeNNBOzLAioqAKYBs4DE1OGqzNlOSZ1yaKaUbCiqKv8vdLg1MPmbdPiy9D7 NlOVFVX5HOWrMeiEJgzBNBkSLE0cjxWRafxsGF54USd6yRJK23/qo4Yv5a5rwNCSgDe3 q/uA== X-Gm-Message-State: AOJu0YzBmAUWPwRR0sIoVavGyBjskQE4CBlXyl1hMYtyg0OdJhpdZ8x6 lMqHd8V2AUhHy8iAc+N0GyzTL2Swl2I= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:add5:0:b0:d9a:4f4c:961b with SMTP id d21-20020a25add5000000b00d9a4f4c961bmr70045ybe.1.1698439784672; Fri, 27 Oct 2023 13:49:44 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 27 Oct 2023 13:49:28 -0700 In-Reply-To: <20231027204933.3651381-1-seanjc@google.com> Mime-Version: 1.0 References: <20231027204933.3651381-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231027204933.3651381-5-seanjc@google.com> Subject: [GIT PULL] KVM: x86: MMU changes for 6.7 From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 13:50:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780943218813859551 X-GMAIL-MSGID: 1780943218813859551 This is mostly the first half of a series by Yan to optimize KVM's handling of guest MTRR changes for VMs with non-coherent DMA. Yan had to put more complex changes that actually realize the optimizations on hold, but the patches here are all nice cleanups on their own. The following changes since commit 5804c19b80bf625c6a9925317f845e497434d6d3: Merge tag 'kvm-riscv-fixes-6.6-1' of https://github.com/kvm-riscv/linux into HEAD (2023-09-23 05:35:55 -0400) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-mmu-6.7 for you to fetch changes up to 1de9992f9de0a92b6e11133aba0e2be833c11084: KVM: x86/mmu: Remove unnecessary ‘NULL’ values from sptep (2023-10-18 14:34:28 -0700) ---------------------------------------------------------------- KVM x86 MMU changes for 6.7: - Clean up code that deals with honoring guest MTRRs when the VM has non-coherent DMA and host MTRRs are ignored, i.e. EPT is enabled. - Zap EPT entries when non-coherent DMA assignment stops/start to prevent using stale entries with the wrong memtype. - Don't ignore guest PAT for CR0.CD=1 && KVM_X86_QUIRK_CD_NW_CLEARED=y, as there's zero reason to ignore guest PAT if the effective MTRR memtype is WB. This will also allow for future optimizations of handling guest MTRR updates for VMs with non-coherent DMA and the quirk enabled. - Harden the fast page fault path to guard against encountering an invalid root when walking SPTEs. ---------------------------------------------------------------- Li zeming (1): KVM: x86/mmu: Remove unnecessary ‘NULL’ values from sptep Yan Zhao (5): KVM: x86/mmu: Add helpers to return if KVM honors guest MTRRs KVM: x86/mmu: Zap SPTEs when CR0.CD is toggled iff guest MTRRs are honored KVM: x86/mmu: Zap SPTEs on MTRR update iff guest MTRRs are honored KVM: x86/mmu: Zap KVM TDP when noncoherent DMA assignment starts/stops KVM: VMX: drop IPAT in memtype when CD=1 for KVM_X86_QUIRK_CD_NW_CLEARED arch/x86/kvm/mmu.h | 7 +++++++ arch/x86/kvm/mmu/mmu.c | 37 ++++++++++++++++++++++++++----------- arch/x86/kvm/mtrr.c | 2 +- arch/x86/kvm/vmx/vmx.c | 9 +++------ arch/x86/kvm/x86.c | 21 ++++++++++++++++++--- 5 files changed, 55 insertions(+), 21 deletions(-)