Message ID | 20230216154115.710033-1-jiangshanlai@gmail.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp370292wrn; Thu, 16 Feb 2023 07:41:34 -0800 (PST) X-Google-Smtp-Source: AK7set8liWJp/Qq9dsAax+9TAF6l3QzAfKLC4op0luQoA18E9fdEYeZg2oYzHg8YRtNueaBDZw1/ X-Received: by 2002:a17:906:8596:b0:870:58ae:842e with SMTP id v22-20020a170906859600b0087058ae842emr6730319ejx.24.1676562094554; Thu, 16 Feb 2023 07:41:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676562094; cv=none; d=google.com; s=arc-20160816; b=hCEdNZb8+FZxX+qvWlRVasGV2PQLoL+HJcQtrV4fO10Ci4GqBSJu+beiZeYOgNaepY /EawR2lecWqkJkWATrwBbiB6cyhGNqUMDhWIMWK6W/Nx+2yVlbc9whTreho2fsTAeavW PFwogyNkOYp+0R/SgOvoMqO2gx0L2pWHBjRwP8o42cjFxTb8AY4m2VSSjXLzbMXWtaAi UeniyxE21uW+UHsYQesGC/pcv0KOIC4CIRsSxy5ZW2u6wxa7nF+R+n/nr7guRhONONLl 7gtrUNVIe/E4VkG1wrFnM/1OVOG8mhyZp1BwkHGN+1esLCiJF85yMfeEA+oMI9SfBWsh VzAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dckOt9ZcX3PBA7dkA4NwToXQbFSTM3HdmIxpC2CHEx4=; b=rC4u+Tded/AMhOF7D8RSgvhRUqiSIldjrPt9zyuHdjcQri7irFrAh9+6Svri83pBXu ra39E3PHVtPGABykYxXVCSY2qLbipWH9C9eSqPwW+n5QPgvIxwJOsf4tUlVNGTqVEz0i sIJkXn69rOuYdKMzqHGjTMzzSkwU3ROcMLEYusBgN1zZKzFSEKl2d73VylybLsep2cqe 6IOW1Z4RjthvKj/oHdA1IUoAlv+g5kSpzkE397voEIcImIwS/8fn1jncBvJxXBfvLvSC 3AfBb4kWtrdOky6tMVI1gptbeoVGVRpBaFKAHN5Be0VgrJa6T8qRg2VZfSYstLUyIxhF Ku4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SUuT3baK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vw22-20020a170907059600b0088b8749e9ebsi2100806ejb.417.2023.02.16.07.41.11; Thu, 16 Feb 2023 07:41:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SUuT3baK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229687AbjBPPkO (ORCPT <rfc822;aimixsaka@gmail.com> + 99 others); Thu, 16 Feb 2023 10:40:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjBPPkN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Feb 2023 10:40:13 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC38252A2 for <linux-kernel@vger.kernel.org>; Thu, 16 Feb 2023 07:40:12 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id jk14so2403436plb.8 for <linux-kernel@vger.kernel.org>; Thu, 16 Feb 2023 07:40:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dckOt9ZcX3PBA7dkA4NwToXQbFSTM3HdmIxpC2CHEx4=; b=SUuT3baKGqj/B16sQzWVhF0tjHQKfms9VZGD+WjuO36OsuaSh7+WjyDOo+bAWJzfrJ uZ3//iMlKj9mB6z4VYu8pW7ClECgdkx1roDBTvkjmsN/3/cIV1OMt1kOgkPVtkUfJE3N RASXvWPlRvWntkgi5HO0Ye1XoedAjkY3JBO4eHkmcvuXMbtyuZPjCNNdFSzWXRDzF5q0 b66EbxOKorT9apZ7d2jlViVQklpGd+GfANyvuNHhnhghbY7SaRzfDiy8IR6BF/WroZI2 8SZ7EghKlHHrMVn7SXjiclXB+m3LUmQhAjoLwSK2uJwQoKukbBGcVu0k//FMi/JYzDyQ HHTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dckOt9ZcX3PBA7dkA4NwToXQbFSTM3HdmIxpC2CHEx4=; b=vHbP80IAJG4lIRA0nGMCLzHzZ/gXhIMdjUGuK/NS+4tDHBiAH5hfVd1hPipcb+n7Vn kIjN6BC5daoBV3SD/39LTf6uc3HR6lhTrwNDQTro9YyVvDCYO+ka+NnIn8IoaHyL/C7f kT/9cNPz7j9RUX0I7KYkHfxDBWIA59OGg6kD+xB4PYjMm6Kb6MgLSuRHBvkaYm6kGoSR Kp8/dDO5rLFLGyXriV6ifQCKrdqXkzMi+4x8JTj3EIuqhw7ooC2f/Lv0KBkFLJSgKSdY KoE5Zsvht6S8C7adf67V2dHwxVossTMBXBHKzdyQTQVEsHVETYcfSbms870YlwVXT2Jh 5DyQ== X-Gm-Message-State: AO0yUKXmjZ2oXnUQUWeh2Xa9swnYox2nal6lTLxdR7kZaExjzWRJ05Xv spBmH6wpZXEP6/rzAIOReFFB28BaFW8= X-Received: by 2002:a17:902:e5c3:b0:19a:a80e:a6d5 with SMTP id u3-20020a170902e5c300b0019aa80ea6d5mr7406336plf.23.1676562011281; Thu, 16 Feb 2023 07:40:11 -0800 (PST) Received: from localhost ([198.11.176.14]) by smtp.gmail.com with ESMTPSA id bi12-20020a170902bf0c00b00194c1281ca9sm1468078plb.166.2023.02.16.07.40.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2023 07:40:10 -0800 (PST) From: Lai Jiangshan <jiangshanlai@gmail.com> To: linux-kernel@vger.kernel.org Cc: Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com>, Lai Jiangshan <jiangshan.ljs@antgroup.com> Subject: [PATCH V3 00/14] kvm: x86/mmu: Share the same code to invalidate each vTLB entry Date: Thu, 16 Feb 2023 23:41:06 +0800 Message-Id: <20230216154115.710033-1-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758002774423167719?= X-GMAIL-MSGID: =?utf-8?q?1758002774423167719?= |
Series |
kvm: x86/mmu: Share the same code to invalidate each vTLB entry
|
|
Message
Lai Jiangshan
Feb. 16, 2023, 3:41 p.m. UTC
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
FNAME(invlpg) and FNAME(sync_page) invalidate vTLB entries but in
slightly different methods.
Make them use the same method and share the same code.
Patch 1: Address a subtle bug reported by Sean Christopherson.
Patch 2-6: Add FNAME(sync_page)
Patch 7-14: Refactor code which uses FNAME(invlpg) and finally use FNAME(sync_page).
Changed from V2:
Convert the address type and fix subtle bug
Check mmu->sync_page pointer before calling it
Fix the defination of KVM_MMU_ROOT_XXX
[V2]: https://lore.kernel.org/lkml/20230207155735.2845-1-jiangshanlai@gmail.com/
[V1]: https://lore.kernel.org/lkml/20230105095848.6061-1-jiangshanlai@gmail.com/
Lai Jiangshan (13):
KVM: x86/mmu: Use 64-bit address to invalidate to fix a subtle bug
kvm: x86/mmu: Move the check in FNAME(sync_page) as
kvm_sync_page_check()
kvm: x86/mmu: Check mmu->sync_page pointer in kvm_sync_page_check()
kvm: x86/mmu: Set mmu->sync_page as NULL for direct paging
kvm: x86/mmu: Move the code out of FNAME(sync_page)'s loop body into
mmu.c
kvm: x86/mmu: Reduce the update to the spte in FNAME(sync_spte)
kvm: x86/mmu: Use KVM_MMU_ROOT_XXX for kvm_mmu_invalidate_addr()
kvm: x86/mmu: Use kvm_mmu_invalidate_addr() in kvm_mmu_invpcid_gva()
kvm: x86/mmu: Use kvm_mmu_invalidate_addr() in
nested_ept_invalidate_addr()
kvm: x86/mmu: Allow the roots to be invalid in FNAME(invlpg)
kvm: x86/mmu: Remove FNAME(invlpg) and use FNAME(sync_spte) to update
vTLB instead.
kvm: x86/mmu: Remove @no_dirty_log from FNAME(prefetch_gpte)
kvm: x86/mmu: Skip calling mmu->sync_spte() when the spte is 0
Sean Christopherson (1):
KVM: x86/mmu: Sanity check input to kvm_mmu_free_roots()
arch/x86/include/asm/kvm_host.h | 17 ++-
arch/x86/kvm/mmu/mmu.c | 201 ++++++++++++++++++++----------
arch/x86/kvm/mmu/paging_tmpl.h | 209 +++++++++-----------------------
arch/x86/kvm/vmx/nested.c | 5 +-
arch/x86/kvm/x86.c | 4 +-
5 files changed, 205 insertions(+), 231 deletions(-)
Comments
On Thu, 16 Feb 2023 23:41:06 +0800, Lai Jiangshan wrote: > From: Lai Jiangshan <jiangshan.ljs@antgroup.com> > > FNAME(invlpg) and FNAME(sync_page) invalidate vTLB entries but in > slightly different methods. > > Make them use the same method and share the same code. > > [...] Applied to kvm-x86 mmu, thanks! Made a few tweaks, I'll respond to invididual patches (if I haven't already; and if I forget, I apologize in advance). [01/14] KVM: x86/mmu: Use 64-bit address to invalidate to fix a subtle bug https://github.com/kvm-x86/linux/commit/753b43c9d1b7 [02/14] kvm: x86/mmu: Move the check in FNAME(sync_page) as kvm_sync_page_check() https://github.com/kvm-x86/linux/commit/90e444702a7c [03/14] kvm: x86/mmu: Check mmu->sync_page pointer in kvm_sync_page_check() https://github.com/kvm-x86/linux/commit/51dddf6c49b9 [04/14] kvm: x86/mmu: Set mmu->sync_page as NULL for direct paging https://github.com/kvm-x86/linux/commit/8ef228c20cae [05/14] kvm: x86/mmu: Move the code out of FNAME(sync_page)'s loop body into mmu.c https://github.com/kvm-x86/linux/commit/c3c6c9fc5d24 [06/14] kvm: x86/mmu: Reduce the update to the spte in FNAME(sync_spte) https://github.com/kvm-x86/linux/commit/e6722d9211b2 [07/14] KVM: x86/mmu: Sanity check input to kvm_mmu_free_roots() https://github.com/kvm-x86/linux/commit/f94db0c8b9fa [08/14] kvm: x86/mmu: Use KVM_MMU_ROOT_XXX for kvm_mmu_invalidate_addr() https://github.com/kvm-x86/linux/commit/cd42853e9530 [09/14] kvm: x86/mmu: Use kvm_mmu_invalidate_addr() in kvm_mmu_invpcid_gva() https://github.com/kvm-x86/linux/commit/9ebc3f51da6f [10/14] kvm: x86/mmu: Use kvm_mmu_invalidate_addr() in nested_ept_invalidate_addr() https://github.com/kvm-x86/linux/commit/2c86c444e275 [11/14] kvm: x86/mmu: Allow the roots to be invalid in FNAME(invlpg) https://github.com/kvm-x86/linux/commit/ed335278bd12 [12/14] kvm: x86/mmu: Remove FNAME(invlpg) and use FNAME(sync_spte) to update vTLB instead. https://github.com/kvm-x86/linux/commit/9fd4a4e3a3d9 [13/14] kvm: x86/mmu: Remove @no_dirty_log from FNAME(prefetch_gpte) https://github.com/kvm-x86/linux/commit/91ca7672dc73 [14/14] kvm: x86/mmu: Skip calling mmu->sync_spte() when the spte is 0 https://github.com/kvm-x86/linux/commit/19ace7d6ca15 -- https://github.com/kvm-x86/linux/tree/next https://github.com/kvm-x86/linux/tree/fixes