From patchwork Fri May 26 23:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 13257445 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 49E86C83005 for ; Fri, 26 May 2023 23:44:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2E5F280006; Fri, 26 May 2023 19:44:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB3CA280001; Fri, 26 May 2023 19:44:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D547F280006; Fri, 26 May 2023 19:44:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C4E29280001 for ; Fri, 26 May 2023 19:44:55 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8A44012030A for ; Fri, 26 May 2023 23:44:55 +0000 (UTC) X-FDA: 80834038950.27.5226FB2 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf22.hostedemail.com (Postfix) with ESMTP id C8EB9C0006 for ; Fri, 26 May 2023 23:44:53 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="Ne/YRQ/s"; spf=pass (imf22.hostedemail.com: domain of 3dERxZAYKCOslhmUNbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yuzhao.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3dERxZAYKCOslhmUNbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yuzhao.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=1685144693; 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=7JLLUnbPXAaoH9i/N14KC8FRF4yfK0mZvbZkcTBOq5Y=; b=oHv4RBY9+cz67bWDu3JLTE6mPB2ZW6V4vudB2QxHP8n+IgsL3Osaut6bypsdwZqqvrq3rj PzDIxVUZMGFIMzKK2aXACQA1fBvZE641gsdts194B8dEjGzaqFdEssmQNNjOJs/me78oXc wGhiAuahxSEEEDeoUtyC9t1/WTACsTk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="Ne/YRQ/s"; spf=pass (imf22.hostedemail.com: domain of 3dERxZAYKCOslhmUNbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yuzhao.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3dERxZAYKCOslhmUNbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685144693; a=rsa-sha256; cv=none; b=1YYlVPQQAZfSKM60lTEDGP0j47v/YIF9vx/JdSuJTxbcmtgWAUnJ8Kw0hbWOEVfAUTbCGO UogATFSEfn1HArBoYEVU+dxwtdsKVNQNFgD6eeWf8aGy9k7diRG8s/2gYRDtErnACmbPS1 yl+Jut87GbiElgfVNJX37ZzekpB01eo= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-ba8cf175f5bso5006623276.0 for ; Fri, 26 May 2023 16:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685144693; x=1687736693; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7JLLUnbPXAaoH9i/N14KC8FRF4yfK0mZvbZkcTBOq5Y=; b=Ne/YRQ/svpJFGXhXpgHmwxc0D9cLMxIoz8hghy2YEExILLlaUzGTTLTu8b32WLIGJt Pl2W5ENMW5Sa2Kwrgh0yVLYa4j/IXKl/wxvEFqusCYfl9i2LCglCwg4qFOwnu/SiZlAZ epK5zgrczZWcQF0/2oLgZ8laj6CsPXbNpnBrvrF3XhoGhjELY5RWTIQgLbNJgOlO3uxt 4d+XiEr2KggZNk0D2a/3M0F1IRHplA5m+1NXrAN0tP918Y2nokL0n9zRLbfOWAMyaJ2Q beEb9W4X5NKj/DpGHg7ZQVC9QnQZ7wDRATscsNx8htwusD9k+VmLxpoV1j1SSPGezxSx 58Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685144693; x=1687736693; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7JLLUnbPXAaoH9i/N14KC8FRF4yfK0mZvbZkcTBOq5Y=; b=W0TUccfdljpkuke+jUh2tr2yXMSbj6AScokeH2cax7sK+J+edjJSSvScJ2+cr/awWA GAti20dIaK6+FhyKPbmUaSIn1Z1gvb+hCIAIMe9+hKSDCyPw+/ki3KfV3Iovy6QdzQV6 47cAlDaKwsyMJgaIEtpee6EzdHIa7g95RghHLnrnMnxnAyA/t7s/sC6twYWRGjmahINm 4j+IozW119Ky0jUUW85JL1BVmEFzwiHVvU20/g7jrsZAwOH3nfopGYopXJ5rL/VNIBZ7 y60maNTrCItJCuT92R5+nYykbnaj0Q9C/l7JE0aoMlWEAd0r4M8KmrWDO0oiBoni2Rzd s9Tg== X-Gm-Message-State: AC+VfDx/YTH2pWuvI+SghHcLI3l3AmeIjqmFzx5krgxwrNNR7Kz1iMb/ bZHDCWvPIJcLk2Wpp5nB8c/QerYGzSI= X-Google-Smtp-Source: ACHHUZ5CZlpEmT2VkUcPhwDn9jTP7EScM/+97DNWp/Z/n1uD6F2Bv8HNZfloYPpxuZT6MB0BvBWbDvtVv+8= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:910f:8a15:592b:2087]) (user=yuzhao job=sendgmr) by 2002:a5b:9c6:0:b0:ba8:381b:f764 with SMTP id y6-20020a5b09c6000000b00ba8381bf764mr354063ybq.3.1685144692904; Fri, 26 May 2023 16:44:52 -0700 (PDT) Date: Fri, 26 May 2023 17:44:33 -0600 In-Reply-To: <20230526234435.662652-1-yuzhao@google.com> Message-Id: <20230526234435.662652-9-yuzhao@google.com> Mime-Version: 1.0 References: <20230526234435.662652-1-yuzhao@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH mm-unstable v2 08/10] kvm/x86: move tdp_mmu_enabled and shadow_accessed_mask From: Yu Zhao To: Andrew Morton , Paolo Bonzini Cc: Alistair Popple , Anup Patel , Ben Gardon , Borislav Petkov , Catalin Marinas , Chao Peng , Christophe Leroy , Dave Hansen , Fabiano Rosas , Gaosheng Cui , Gavin Shan , "H. Peter Anvin" , Ingo Molnar , James Morse , "Jason A. Donenfeld" , Jason Gunthorpe , Jonathan Corbet , Marc Zyngier , Masami Hiramatsu , Michael Ellerman , Michael Larabel , Mike Rapoport , Nicholas Piggin , Oliver Upton , Paul Mackerras , Peter Xu , Sean Christopherson , Steven Rostedt , Suzuki K Poulose , Thomas Gleixner , Thomas Huth , Will Deacon , 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, linuxppc-dev@lists.ozlabs.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, linux-mm@google.com, Yu Zhao X-Rspamd-Queue-Id: C8EB9C0006 X-Rspam-User: X-Stat-Signature: e643kxugz45kpec8z7un5hzsf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Xs4Y7votMovOnf5PfPMVpHFl6jpm6JqQtH6b2wRo/eaTtjy4YbPJAWgEwVYzffnPcDIZ5+/36WoUmrmkAUlGODdRpeKaGWIiXc1ixehNtdftLGTIBPFY/aQCMf/PLXm9+T4H641I+4808wNw3CIxPkF2Q5OqAeGzRQJLwsY1YjdFkzslX75E++AFauwTm5PxkRxxRhvgJ7lFgsn2EQVlmYV6MZ/N+tS14j2h8KbMVHpcLANiDGT1lLWvPHhJrbsPuYGXXzHOWTE7zsq7r+aOTSQiY5zLEMX5OKAYS7GPqyxDmopeTOdPPN9853JrrE2ZphrLmUdQZ4n6v+N2aOAs73t0+NKUeyVcHyjYtVv8hFPpuYb07wYWlecVgs2ueZM0Z/XOqnQW1BdlVHKWaMvzJERdiisGuOY/Dnqpo61/pM8ksqVxRX/nIZSbOd9vk24oHHfiZQc6sWzI5JiFNrCFIL0Jubqk20bkGR+47BuZyBr/FIqrIS8ngDj4UL8DceXCWcFkaPsbXZ/sEYzEM15AtkNo2MjIzVgr2pUNsYUv26kxXxocFhKNxo/h3pDC/ECqZL/PKX7CgB/ekt3cW/uZ+pf2Z65AWYKwnq/BoA== 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: tdp_mmu_enabled and shadow_accessed_mask are needed to implement kvm_arch_has_test_clear_young(). Signed-off-by: Yu Zhao --- 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 fb9d1f2d6136..753c67072c47 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1772,6 +1772,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; @@ -1855,6 +1856,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 92d5a1924fc1..84aedb2671ef 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -253,12 +253,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 1279db2eab44..a82c4fa1c47b 100644 --- a/arch/x86/kvm/mmu/spte.h +++ b/arch/x86/kvm/mmu/spte.h @@ -153,7 +153,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;