From patchwork Thu Dec 8 19:38:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13068812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9ED4C4332F for ; Thu, 8 Dec 2022 19:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4I1glXFlPGHh6JDgu/aJGN1upp147ADowmC80lNfViQ=; b=EoaOJ7+0n12f9w1KN0VK313aTT agunHpNUE3mC7CJuWC1M7U4SKPuExEn8IoqQM/G6j6yyurAIanJDBp6Yudl6aDygJ44gbbu7QlKMD LvybiEyFn2TbBKGboIEHvLCfU9uuUZLvnUL8LKkxQkF5s9zJbI6527q56p8mE3ZNj0CPh8KhnkKYH ctxbQaD4BkgWH0j7UAOLDJ/k8xm1TOAA6/UrU2ASTyOc7mshPxeNWizkQYYKVPPpLUdeVhKt8xVI/ Mi1VgFTH2K7snyQMdYWU6qDKJMS45ylUsB8gWodRtX385vhJqkgAFAV80fvLZlStVPB1PrnGyp+mH QSxoQyAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3Mzm-00A8BB-AT; Thu, 08 Dec 2022 19:55:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3Myx-00A7bR-QM for linux-arm-kernel@bombadil.infradead.org; Thu, 08 Dec 2022 19:54:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZDFxAZ/PI9aKYqwedjkDPDUn0PCD9WUxHYy13eGAWTI=; b=nJXuDimDoUSDTbMPHke94FTpPw TJhlYb1aSs7rk3ol/HFYAwl9b1gGetd4g8BZx+q/ezYCyb6cY3l7KTGGDtNRoqkhzNyqMrvyYRbbk juqa8UIWW3BZqKRv84x9OTv4HQt9D+/7Nf0+jl2jwI2p5aVFBiqL1lX0sb9ypRFWQfE9qDUavU274 3IZM3mvaH7LDGQYEZrxb8J3VrV894TZp29+60Kay7MswdM4O6SMGF/ucOqxrP31sTYb3UVv42g/sg HlevdOEAD6Gzq87cHSDXE4Gs9/kgZzmXOMv30mjc1YxCkWufLEikuuQvmSPVqrKKGI429jj3IRqcj 3dqWKkDA==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3Mki-007G8D-82 for linux-arm-kernel@lists.infradead.org; Thu, 08 Dec 2022 19:40:18 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id b17-20020a25b851000000b006e32b877068so2546824ybm.16 for ; Thu, 08 Dec 2022 11:40:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZDFxAZ/PI9aKYqwedjkDPDUn0PCD9WUxHYy13eGAWTI=; b=UW5TQakihQ1Rj8oX0fHh6ol3yHICPRAUjId2fBE9HBOx4Z4cfwRHCzOFro0DVog5Py z1d9aYSN4fRQh+yVjk9c6erIMnvGY+3XCA5eND2mJd3lmcs6ZMcic9/HWoIHmoYD+B1m XjqLDiAn+QBJHnf0vzOfnGkxZlkIa53ilOScS8egg7kyZLK+h2NKejyWCaVjbbt+sR5R IhfagMv7s1KO30A1KDYGC5ziILrcoD8HH6N1IH5+EVj3HMWjpbtHUPdv5fpd7dQKJ+67 MzWuFb+b2SqNDBq56KYHPAYiPt7QBIFy/9sPV8aGa7CXG5RzY4NELQedDkJBW9qr9WbA evPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZDFxAZ/PI9aKYqwedjkDPDUn0PCD9WUxHYy13eGAWTI=; b=58VUUE+60fq06+SkmStkRAjK9DFf/IBs/rkQ0MNecZbdP7EVQntAVtkbzifYitAIpp i6kd/IFQ6gYYvpnU3+g9W6oswEJfVk6308btNd9rmaSBsS1SVf18QfxcdU9KOwiwQEuT YWA82EhrrRPEXE9rnEy5ZOSmpsUlJz8+UbACdJeOfl/Xoue59JEdilyy8wZGEFBZOygZ d8VXXM2314m8HWNrLn0turol1YKHAMqSOXvJKcA+90lxXatdQvp+glK8v5cJEva/jarv GDaS904nKjD5Ma7VdPC6Wb2JqH6n++p/UupoTC1sIQ5nr3oqQTcAkbtXO1jAD2gHcnnq /5mw== X-Gm-Message-State: ANoB5pm0oEd9Qe6F/tcVI7003v9uO0L3dTqt0LtAsOvnCbCbu+YXBTUC IET2kqiNpkkbwLdaHt3nRMYHUxjNuYQOPQ== X-Google-Smtp-Source: AA0mqf4h5P1c4eLdLR7BQ8qrkqY9isQdWdfvRcIECxB1d810mucDHdG6W99tV9EeqSL89xl1lTy+w8pwh40XXQ== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a25:6a89:0:b0:6dd:989f:2af4 with SMTP id f131-20020a256a89000000b006dd989f2af4mr92028743ybc.38.1670528406445; Thu, 08 Dec 2022 11:40:06 -0800 (PST) Date: Thu, 8 Dec 2022 11:38:55 -0800 In-Reply-To: <20221208193857.4090582-1-dmatlack@google.com> Mime-Version: 1.0 References: <20221208193857.4090582-1-dmatlack@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221208193857.4090582-36-dmatlack@google.com> Subject: [RFC PATCH 35/37] KVM: x86/mmu: Move tdp_mmu_max_gfn_exclusive() to tdp_pgtable.c From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Sean Christopherson , Andrew Morton , David Matlack , Anshuman Khandual , Nadav Amit , "Matthew Wilcox (Oracle)" , Vlastimil Babka , "Liam R. Howlett" , Suren Baghdasaryan , Peter Xu , xu xin , Arnd Bergmann , Yu Zhao , Colin Cross , Hugh Dickins , Ben Gardon , Mingwei Zhang , Krish Sadhukhan , Ricardo Koller , Jing Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221208_194016_307500_742A412E X-CRM114-Status: GOOD ( 12.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move tdp_mmu_max_gfn_exclusive() to tdp_pgtable.c since it currently relies on the x86-specific kvm_mmu_max_gfn() function. This can be improved in the future by implementing a common API for calculating the max GFN. No functional change intended. Signed-off-by: David Matlack --- arch/x86/include/asm/kvm/tdp_pgtable.h | 3 +++ arch/x86/kvm/mmu/tdp_mmu.c | 11 ----------- arch/x86/kvm/mmu/tdp_pgtable.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/kvm/tdp_pgtable.h b/arch/x86/include/asm/kvm/tdp_pgtable.h index ff2691ced38b..c1047fcf1a91 100644 --- a/arch/x86/include/asm/kvm/tdp_pgtable.h +++ b/arch/x86/include/asm/kvm/tdp_pgtable.h @@ -67,4 +67,7 @@ u64 tdp_mmu_make_changed_pte_notifier_pte(struct tdp_iter *iter, struct kvm_gfn_range *range); u64 tdp_mmu_make_huge_page_split_pte(struct kvm *kvm, u64 huge_spte, struct kvm_mmu_page *sp, int index); + +gfn_t tdp_mmu_max_gfn_exclusive(void); + #endif /* !__ASM_KVM_TDP_PGTABLE_H */ diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index c035c051161c..c950d688afea 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -828,17 +828,6 @@ static inline bool __must_check tdp_mmu_iter_cond_resched(struct kvm *kvm, return iter->yielded; } -static inline gfn_t tdp_mmu_max_gfn_exclusive(void) -{ - /* - * Bound TDP MMU walks at host.MAXPHYADDR. KVM disallows memslots with - * a gpa range that would exceed the max gfn, and KVM does not create - * MMIO SPTEs for "impossible" gfns, instead sending such accesses down - * the slow emulation path every time. - */ - return kvm_mmu_max_gfn() + 1; -} - static void __tdp_mmu_zap_root(struct kvm *kvm, struct kvm_mmu_page *root, bool shared, int zap_level) { diff --git a/arch/x86/kvm/mmu/tdp_pgtable.c b/arch/x86/kvm/mmu/tdp_pgtable.c index fb40abdb9234..4e747956d6ee 100644 --- a/arch/x86/kvm/mmu/tdp_pgtable.c +++ b/arch/x86/kvm/mmu/tdp_pgtable.c @@ -170,3 +170,14 @@ int tdp_mmu_max_mapping_level(struct kvm *kvm, { return kvm_mmu_max_mapping_level(kvm, slot, iter->gfn, PG_LEVEL_NUM); } + +gfn_t tdp_mmu_max_gfn_exclusive(void) +{ + /* + * Bound TDP MMU walks at host.MAXPHYADDR. KVM disallows memslots with + * a gpa range that would exceed the max gfn, and KVM does not create + * MMIO SPTEs for "impossible" gfns, instead sending such accesses down + * the slow emulation path every time. + */ + return kvm_mmu_max_gfn() + 1; +}