From patchwork Tue Jun 11 00:21:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13692690 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 183A1C27C55 for ; Tue, 11 Jun 2024 00:22:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DC086B0095; Mon, 10 Jun 2024 20:22:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 589BC6B0096; Mon, 10 Jun 2024 20:22:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DD6A6B0098; Mon, 10 Jun 2024 20:22:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1C5BE6B0095 for ; Mon, 10 Jun 2024 20:22:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CE3FF410A8 for ; Tue, 11 Jun 2024 00:22:06 +0000 (UTC) X-FDA: 82216705452.18.1D39C03 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf06.hostedemail.com (Postfix) with ESMTP id 16CFA180004 for ; Tue, 11 Jun 2024 00:22:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=YCtaeILG; spf=pass (imf06.hostedemail.com: domain of 3rJhnZgoKCLUeocjpbcojibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3rJhnZgoKCLUeocjpbcojibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718065325; a=rsa-sha256; cv=none; b=MHZCjXWixNlYk3sZeo6Z35kiju2GKsWC961SatdJqx4FWsCc8Vpk1NYgpfQPCkBvOM4oTM QE4pvoSmZ2+Rk/FIeXMALHcjZAk+ZFD0DTxFg9bUCgkeKTvhl+c7OnL2g+WTirAuFCjoR8 JS51DQYa48ju6eSChGjHP7pPYj4VU24= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=YCtaeILG; spf=pass (imf06.hostedemail.com: domain of 3rJhnZgoKCLUeocjpbcojibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3rJhnZgoKCLUeocjpbcojibjjbgZ.Xjhgdips-hhfqVXf.jmb@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=1718065325; 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=HV93t1qtvLY2HqXeqD4WwNLQ267HOmhqjDYyVDwgnFc=; b=bsWyZbmSNkBZj6DxGdz8kNxIPPxaP1evM2CWyD7icib2WFVhjC35MWCNuiyX4ZHVtgjY/g OY5qFa9P22a/Q8IG3PdKbo0//iiHpeuCThR/KHBE3Idwf2kYgb0CE9lRZIag7zmT8PXJ93 ZCTNPNxku5EGrXb3UWdDufqeJq4koy4= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62777fe7b86so81372357b3.1 for ; Mon, 10 Jun 2024 17:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718065324; x=1718670124; 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=HV93t1qtvLY2HqXeqD4WwNLQ267HOmhqjDYyVDwgnFc=; b=YCtaeILGOsLQzok148iUFAblxXyy6NbHdgJ6tO0SeO/Od6a9fOa7wM0IcXL6zn9ivF QwyVHCuih196hi1cfrdfaqLAEEUuVV8+jnPsObnPTPt8w5KSgLWpM2kVI0y9M577qPsX +zHc6NvDemShO0ie8aQKZbRSTETXrzcI7hiiSiZCWG0RjLji+Bkk9V3I3LIw2m8/lFWp 7cdSUVE7rdRbaNlhIaw9a3cx8Gk+ny8J+bo5glnyAiAVQUGJYhb8Flx0b6EzBX76SD+2 KLNU8C5LNrIU7kZnikxHwpVDjTjZb6w3tiWy0YTc2GczU1B/oyVK8mX5HbcC44rVWwup Sz1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718065324; x=1718670124; 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=HV93t1qtvLY2HqXeqD4WwNLQ267HOmhqjDYyVDwgnFc=; b=CsFmw00hPlY9hM3LYYT7SrHtnN0GKo8F6MYU7pMu43RKAedcSMPIkx6YNbh8SJ8fmJ jpAk/nPwe07uLo56eXdKvVOkex+XgaYr8bBhUuB5Tsh2ZlZNJ+lxDmFe7uU5tZMIPoM8 RAS3ZNpEzsSpwq9YTvP8cuIaVATtKfr0iRrh1ONryRmk3K4WOmGS+6LhZD2ysron90/M ETYBUz9Ez1pCEJwNBUzHGjnQZkHFki0a2Lmr0PLGAweECwu7Q1O0VoRc2LUPZhEXawLk chJdCFugNkRtPpAMnI+iMlr44eFE3+GeZwDIgbwxnCeHTzqGX7cvjvw5NDi9drlCkfBo DG7Q== X-Forwarded-Encrypted: i=1; AJvYcCVHYqDm0d5w6seMZ5XGVjVcaHCGezshbTfyYGB4sFW/YS8D7ViYr2Bzfr6G5JvqJ6bS2ggdq3lrHqp9JgLHe29kQmc= X-Gm-Message-State: AOJu0YwgiCjMIEkHG783rr8VplUDMspqqNaTaZAsHG0XhPAk0ej92Fvo GWFMxmvytXOzSP6FCRzH4GbztNV7ndcmx6k5wQ02HH1fQsUOcQO2LTgku4S2hmuXB2A/CTU0yjG f84NiO/8kcLOfWnBlTw== X-Google-Smtp-Source: AGHT+IGdrDSzxMWV88JW0LA6UnAEJXd+QZJzNBe66poa1GZZ236cqaZmaxZKOwtkV9plz4I87xyLdQPCAlnoV8zg X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:690c:38b:b0:627:7563:95b1 with SMTP id 00721157ae682-62cd5652459mr33516247b3.5.1718065324168; Mon, 10 Jun 2024 17:22:04 -0700 (PDT) Date: Tue, 11 Jun 2024 00:21:42 +0000 In-Reply-To: <20240611002145.2078921-1-jthoughton@google.com> Mime-Version: 1.0 References: <20240611002145.2078921-1-jthoughton@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240611002145.2078921-7-jthoughton@google.com> Subject: [PATCH v5 6/9] KVM: x86: Move tdp_mmu_enabled and shadow_accessed_mask From: James Houghton To: Andrew Morton , Paolo Bonzini Cc: Ankit Agrawal , Axel Rasmussen , Catalin Marinas , David Matlack , David Rientjes , James Houghton , James Morse , Jonathan Corbet , Marc Zyngier , Oliver Upton , Raghavendra Rao Ananta , Ryan Roberts , Sean Christopherson , Shaoqin Huang , Suzuki K Poulose , Wei Xu , Will Deacon , Yu Zhao , Zenghui Yu , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Stat-Signature: 9c5711z86r1mq7b6uxopso7hk5igpcdn X-Rspamd-Queue-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S2sMfc7AOSfnFBnyg93Fa+bzF42PgvGS3JYDLnMgTjIvpWbTBkh0BRfQ/Bdlh8sNDQAZ4To7tFnNkrgaFflcIuxCm05BdcAl7Yf2NhmlrszXx2LhdXQ+51EIy9WeQrM37LjZ3E9ZJL4IUmIzYtQHVryKLuoGfKgnLVIkSPF5uYaT91SbJOmq7YRyqgu9Y8VpP+vSqgnvciCAIstD7Vnss9Rc2n8OtDtD9yejQYtHHNSns3jihBrV07Janb0lgsDfH/cE31CuA/4XHozm5fCkOwLj0+dt7a3hpw+axw/dblF69NzNOCS/Xh2OnXF8w2dkhMfNt282QF2DRFMe7k25KnPDWE5iPCmnIGYo8jl/6lIc+I76Ip5qelx57bZrvgrJGnIiOB+YG/bps9EQn0E1o+5aez5WKGUAXBX/NACG7m4rFzUiAcBHVYzm73EzAU/abfs/ktD41+Mp/5V7K9+bWwZ7BOLJ7F2cfGDYIgXVKYjTbZPtlqSWz1WabSUeCpJTv0O/r3ZX+mdc8dUM3aAlVAoiPdy/xS3eIQAZP0eOJFeEYjTXp/A4rMho4JAfFcKvYnX4ftc 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: From: Yu Zhao tdp_mmu_enabled and shadow_accessed_mask are needed to implement kvm_arch_young_notifier_likely_fast(). Signed-off-by: Yu Zhao Signed-off-by: James Houghton --- arch/x86/include/asm/kvm_host.h | 6 ++++++ arch/x86/kvm/mmu.h | 6 ------ arch/x86/kvm/mmu/spte.h | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 011c8eb7c8d3..0dc1fa99cdbb 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1855,6 +1855,7 @@ struct kvm_arch_async_pf { extern u32 __read_mostly kvm_nr_uret_msrs; extern u64 __read_mostly host_efer; +extern u64 __read_mostly shadow_accessed_mask; extern bool __read_mostly allow_smaller_maxphyaddr; extern bool __read_mostly enable_apicv; extern struct kvm_x86_ops kvm_x86_ops; @@ -1960,6 +1961,11 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, bool mask); extern bool tdp_enabled; +#ifdef CONFIG_X86_64 +extern bool tdp_mmu_enabled; +#else +#define tdp_mmu_enabled false +#endif u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index 2e454316f2a2..267f72b065f5 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -271,12 +271,6 @@ static inline bool kvm_shadow_root_allocated(struct kvm *kvm) return smp_load_acquire(&kvm->arch.shadow_root_allocated); } -#ifdef CONFIG_X86_64 -extern bool tdp_mmu_enabled; -#else -#define tdp_mmu_enabled false -#endif - static inline bool kvm_memslots_have_rmaps(struct kvm *kvm) { return !tdp_mmu_enabled || kvm_shadow_root_allocated(kvm); diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h index 52fa004a1fbc..9ca6d80fb86c 100644 --- a/arch/x86/kvm/mmu/spte.h +++ b/arch/x86/kvm/mmu/spte.h @@ -172,7 +172,6 @@ extern u64 __read_mostly shadow_mmu_writable_mask; extern u64 __read_mostly shadow_nx_mask; extern u64 __read_mostly shadow_x_mask; /* mutual exclusive with nx_mask */ extern u64 __read_mostly shadow_user_mask; -extern u64 __read_mostly shadow_accessed_mask; extern u64 __read_mostly shadow_dirty_mask; extern u64 __read_mostly shadow_mmio_value; extern u64 __read_mostly shadow_mmio_mask;