From patchwork Mon Apr 1 23:29:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13613091 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89334CD1292 for ; Mon, 1 Apr 2024 23:30:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 573D06B0093; Mon, 1 Apr 2024 19:30:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54B8A6B0095; Mon, 1 Apr 2024 19:30:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C4596B0098; Mon, 1 Apr 2024 19:30:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 21ECD6B0093 for ; Mon, 1 Apr 2024 19:30:01 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D264F1206E3 for ; Mon, 1 Apr 2024 23:30:00 +0000 (UTC) X-FDA: 81962558160.15.3FA6B21 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf23.hostedemail.com (Postfix) with ESMTP id 0CD0E14001A for ; Mon, 1 Apr 2024 23:29:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ZkqoVvtj; spf=pass (imf23.hostedemail.com: domain of 3dkMLZgoKCGEISGNTFGSNMFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3dkMLZgoKCGEISGNTFGSNMFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712014199; a=rsa-sha256; cv=none; b=lDtiimyQme94wZoY+BpD7+mA7rdM/v3sgQETteTBUf9B6j5+rPxfQ+T0qTvggHIUYT6NPU Px0LhRx4I3moAP+fGsvONI8Hj2WJJsFp9PvYWfW3pRSE3AFZaQz1ql/2ga2gJy0oMuHjv9 QDMjQ/+famlIePHMDolAViqMeTCS400= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ZkqoVvtj; spf=pass (imf23.hostedemail.com: domain of 3dkMLZgoKCGEISGNTFGSNMFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3dkMLZgoKCGEISGNTFGSNMFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712014199; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lJfaFUFI3gJojofhvI2fMvWTfkDCiiHnhDdEzunFXno=; b=VzBipoXzwC2u4B5WQMuCQGcZ8JiTmnMq4ts3wmdARx7+6BkffFCmKKixVrigjgJib8mcxf yBK3z9gMx++T3oRdct0A1O8ezuoe7WaDmyrd3oAQZkPlBHqnJnEQ17xoKwqr0oQMY+lTlv Md6AngHmu3syznIR94QVOBy9QJZH50o= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-614bc5c53a1so27295307b3.1 for ; Mon, 01 Apr 2024 16:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712014198; x=1712618998; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lJfaFUFI3gJojofhvI2fMvWTfkDCiiHnhDdEzunFXno=; b=ZkqoVvtj+XhZUkSO4Ezd0KNXtuwZQ5uC/Oy/bc/0M7XT/H2k9o59JWlfb2y48fFgC+ 04vscDBixNWZbfP+0vxP2h/p48r13NZhwTKVeyha6vcFLaXymYMzorScyeHzSssfU24U WBmr9HJVkVTYGdjE1da1bfpJwuZgpxUUUYRKMfmfUrOaewwtlV/6X+HYKiXChKQyUexP 6WYQzdhyd0pj0ReIH8FE8mIUvBeXSDdzJW9xSwQT2qCnkI3CcxfX32csTtWmJrtyilLo pLUYWol9L1is9xCqi2XoqjpE/8HJ+I9Vyd7Tn+wnFYD5lzlBzMm/CwSYQ/KQ8BJSgB40 r4Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712014198; x=1712618998; 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=lJfaFUFI3gJojofhvI2fMvWTfkDCiiHnhDdEzunFXno=; b=XfnjYlO7u1kMd2wZhgyBstUJFD28U2ry9qtjZtnnOsnQeukRb8e/S3NsiKyWtqhVUH mnowoZbHJW86xHUNig5dEXp12hQVcCYsdDAFoQmp9jZlK++WoOECAseMRT13KTorjI/t kLrBGri9zU/3xUmp04YHDLNPvj6Jn1pLk7sJyk0poTQsolvdeZ06KFKymZZbHDjB/m2p P/MV6uCyDticpkDlJ4QKJjsMQyqSR0W2/Zj04uOMO/xj5S9P2kny/iQDrPtJEPTJpW0w PwS3P9aJd/RZqVUkLgvIMExcfPlIZ3U6WmNp2Vua2NOGc+75RUqTlPxegRFeskh1d+cJ pd0w== X-Forwarded-Encrypted: i=1; AJvYcCWWAlTyFkFt64Y42x0QNSjI6evy2cSKN0E1VSyZxB5QfgQJhxYfCz0ggpD92tFHcMG27JHfCM2VPqgODjLZheI/TVI= X-Gm-Message-State: AOJu0Yx0pGhCHNBx5pwhQV2enyWJMk4d5lWONZLNU5gjqo0SpdNAoCBF 8DAQLN7mdVwSZ/Pxt2NPb1Ff9XqJfYUMbfJ5SF1YOO/Mg07OX2i3xWt2ioloJOJONeqmuhNwMYk RFS2rE011bfmnHzoYYQ== X-Google-Smtp-Source: AGHT+IEzS+9pOebrRYAPHZcYp9+yLQ7vZUDEjcM1NuDRlvVAs7z0PGB+6rnD36HZsSFqff67vdpG7JIIt1VZPePZ X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6902:1006:b0:dcc:94b7:a7a3 with SMTP id w6-20020a056902100600b00dcc94b7a7a3mr767796ybt.12.1712014198123; Mon, 01 Apr 2024 16:29:58 -0700 (PDT) Date: Mon, 1 Apr 2024 23:29:41 +0000 In-Reply-To: <20240401232946.1837665-1-jthoughton@google.com> Mime-Version: 1.0 References: <20240401232946.1837665-1-jthoughton@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240401232946.1837665-3-jthoughton@google.com> Subject: [PATCH v3 2/7] KVM: Move MMU notifier function declarations From: James Houghton To: Andrew Morton , Paolo Bonzini Cc: Yu Zhao , David Matlack , Marc Zyngier , Oliver Upton , Sean Christopherson , Jonathan Corbet , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Shaoqin Huang , Gavin Shan , Ricardo Koller , Raghavendra Rao Ananta , Ryan Roberts , David Rientjes , Axel Rasmussen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, James Houghton X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0CD0E14001A X-Stat-Signature: 5nonjbautpq5joegjzc6gnxy11n16o3e X-Rspam-User: X-HE-Tag: 1712014198-348167 X-HE-Meta: U2FsdGVkX18v/RY3NTUW971brUiFf7SUz63olyF/i3PbJ7kwYFhNpxoj6QaiOzXRHllF5WJWVYEzACUAatsU6J1TBTFmONUP3PmJsBjNF6590xgB6ShgDu/1pFiuv1gIsbzhLPVoeQEvyFoO4hbXIYaTiY4aZd8faMHjIa2RySEXwulQ7A8hyHFYveULnQMgjFBPnnJkgV4uYL5Tp8kJaJ718nx0pKQUFs3TaHl1Ss9Z8LFR7Z5iE3zA/aztApy8UPLRBkDBpihaBnxbYyF5N9J31fBhbq+GlqZDBjowPl+17MnpCUByI1kdN+mLESYfYRaLFF1J+6/WM1rJFqO3jrBNCdYSDlJgZDuVv0pB+Jrdy45JY/OYVDziUxMYK4zjt878j6gikZOh5aSUvkXmhbOnwZ8rwW57/ZX8EAI3JAKrv2uon9RAxZ1ctiWnd1ldtffjMJv8NuHHGDjJY7lxVCt0JH1hpMaAizMnAXdzq2BWUE+yeDUFz29Nmu7Y82B3QB/8d9J8pW54ludYFUr/Mit3Zwmm8+hMGTASNRuW2aeGg4W+a8qQjJmlK9WAIqvsNtQbxNrhZSFfCzYlPmCuPjld8eYy9LKd9DKe11PSu50XRmH0oEdTbSFXHFTgUK/7ZZNVfsv3+18QE5e24y8G9pXLraol5alF/kKVqqu1lJzthqfZ7XnrW3GsDRusYwyibQv1N51VXtwcvKH62rtmPFhl1hywPyT3qO28zQ74KS98pPDlHzNWntaCBUpgSeqMPWhcA2q28bCFm9bF/n8o5UEBdMEXJ2I0rbvnNv+Z3apKKmr48T0seTIjAgA0RUTbtIlnBEJIGCDgHv+ai7Gcpfmnt2DnagV3E5p98+6/bG9d3Ddx7ZbHvf5tXjo9yJRJNQnZSQLoTiMu38JmGNzrLcnhCXxGcqeC6tAaFf1WMORTdY/g3UE1VyI2JlDmqLpg1IxJP8h3zWjhnqkKtJN QsBHpL5C NI2QcloFIGEh2Ho1tdoAeAB3VQlO4esjRQzSlFpYz0oJE1ezMBgjnNA+8GUAcgEXOPtjjOl/RJ4fCecsTPc8dwOfrBqmMd98htwPWw9ZXF56z4ZuSi3m7N4j83jqdOZ//xXN+EqqkDGMTxlfbRyPbxIDEaayI1kqxux8OsFkGNlY0teumY2VmshXqfBeuZITAo7FhqjvaEF/2Bndz872pDRjej47h/U+5l0Zr347GBHrT/aNxywLGZ9Re0i7xW4STNGcaW49Dm4ILetHgDGd8x9yf7gmEhVugZnIat87x6f6wkbB6fLCxRDK+cer3CXfldcKGxkeYAu3o7ryJnGCzEvNLRpZmG958YOuhEy0E6om25ib/6Ddjg9UCsSND6kLeyFVj30WPVz4/J1k/b5eZ/QTQVnkP9H0kqE1G+RagV0RIsNbm5rMYmW4LUQV8Mq2V0fgP3w0sJ3XQtp/aXIFe7pSSDoSgdfX4fF8YqFhUM4azOjyOeZ/zUSxkzHMBX/KOWKciA//n0JJqs0PVRXz7Glktt61G07h+EOYjSM3GKx6EmGbzuss9QZhXSiN8Vd5w36MQXeo4nVg0uvWczKPiMqgieb6FxTBIev2b7nWt7M9gX5yOnyKBaoFdLZt+3JMAs3TAbxMvfSWMBDA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To allow new MMU-notifier-related functions to use gfn_to_hva_memslot(), move some declarations around. Also move mmu_notifier_to_kvm() for wider use later. Signed-off-by: James Houghton --- include/linux/kvm_host.h | 41 +++++++++++++++++++++------------------- virt/kvm/kvm_main.c | 5 ----- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 48f31dcd318a..1800d03a06a9 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -257,25 +257,6 @@ bool kvm_setup_async_pf(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu); #endif -#ifdef CONFIG_KVM_GENERIC_MMU_NOTIFIER -union kvm_mmu_notifier_arg { - pte_t pte; - unsigned long attributes; -}; - -struct kvm_gfn_range { - struct kvm_memory_slot *slot; - gfn_t start; - gfn_t end; - union kvm_mmu_notifier_arg arg; - bool may_block; -}; -bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range); -bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range); -bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range); -bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range); -#endif - enum { OUTSIDE_GUEST_MODE, IN_GUEST_MODE, @@ -2012,6 +1993,11 @@ extern const struct kvm_stats_header kvm_vcpu_stats_header; extern const struct _kvm_stats_desc kvm_vcpu_stats_desc[]; #ifdef CONFIG_KVM_GENERIC_MMU_NOTIFIER +static inline struct kvm *mmu_notifier_to_kvm(struct mmu_notifier *mn) +{ + return container_of(mn, struct kvm, mmu_notifier); +} + static inline int mmu_invalidate_retry(struct kvm *kvm, unsigned long mmu_seq) { if (unlikely(kvm->mmu_invalidate_in_progress)) @@ -2089,6 +2075,23 @@ static inline bool mmu_invalidate_retry_gfn_unsafe(struct kvm *kvm, return READ_ONCE(kvm->mmu_invalidate_seq) != mmu_seq; } + +union kvm_mmu_notifier_arg { + pte_t pte; + unsigned long attributes; +}; + +struct kvm_gfn_range { + struct kvm_memory_slot *slot; + gfn_t start; + gfn_t end; + union kvm_mmu_notifier_arg arg; + bool may_block; +}; +bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range); +bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range); +bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range); +bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range); #endif #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ca4b1ef9dfc2..d0545d88c802 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -534,11 +534,6 @@ void kvm_destroy_vcpus(struct kvm *kvm) EXPORT_SYMBOL_GPL(kvm_destroy_vcpus); #ifdef CONFIG_KVM_GENERIC_MMU_NOTIFIER -static inline struct kvm *mmu_notifier_to_kvm(struct mmu_notifier *mn) -{ - return container_of(mn, struct kvm, mmu_notifier); -} - typedef bool (*gfn_handler_t)(struct kvm *kvm, struct kvm_gfn_range *range); typedef void (*on_lock_fn_t)(struct kvm *kvm);