Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3470587rwb; Fri, 30 Sep 2022 04:12:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+eIm0Vw01dUqZqXmC+b1cff8OViTPTcaVu8phV3WFBEYPiucQg6ESIiJDlfupuuOytDT+ X-Received: by 2002:a63:6bc4:0:b0:43c:cd29:6120 with SMTP id g187-20020a636bc4000000b0043ccd296120mr7212319pgc.56.1664536339528; Fri, 30 Sep 2022 04:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664536339; cv=none; d=google.com; s=arc-20160816; b=boD7ytUjJjWSNRrXDaPnBl56wycur6rugEcI3OoTC7mETvgPjrDZZT600X7gVAEJtB n4pQ5QISLr+5KGc4JUpsi9vcfhn3/wGdEAOWZnW5fgLTldiiyHJ11lbLpxxcBafB+STG Haan91gFTlQAaMXC9+Q3zIxNhXfGklrUnOB93349MT9b9+vjrN0w1p5hvNRo53KO76O6 /VEimx0WHIl/ZpIXw9zvXbBCW0dHHKjx7NlGTtfMWc/OSKKj0/rLkw5RJrYSy21IWdgp Hsr9Huaf/2bJe0dhqpcm3cqZDe5XyoSyt5JgvEmhva2e2kcmr12WZgivzKPKFh4WrgFm xjYA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SBuhe/XrTIjJd1bsYuE4t4SqBKtCMDjsVoERzJhlDYY=; b=w39L3WYJ6g0u1d6lMbrBBrDzLRZd76dlAVelm35MKsEbJs6tA33VtPRDRJ2Q87O7Ak A4jvyC1oI+6DKFLrwKdtWzp77+RGxGB49acid2ruJbB0dutrpsh+yTTOrjU9SOoyiklb S0FEwIE6rrj+GgbP2t2otSiNkxGL0PQJwB9dKsmFgh7qPP2Fo1zN2I9w5uQOGgqdfFU6 EPXKpW7S3Ts93NgJ3s4E0558YGHkzAcacGoXUwNcG3uC1VT3GcMs3Xz4X91JfTjyQKs/ xXoQVcozxSlk3tG1UnRJJ694FvYSzs0kJ3knsMOpa6YlThHXsPGu/n0/HSaNA4c+S7Y4 x5JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EBxRkM3H; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a63f856000000b0041c033e9f54si2437580pgj.848.2022.09.30.04.12.06; Fri, 30 Sep 2022 04:12:19 -0700 (PDT) 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=@intel.com header.s=Intel header.b=EBxRkM3H; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbiI3KXT (ORCPT + 99 others); Fri, 30 Sep 2022 06:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbiI3KTJ (ORCPT ); Fri, 30 Sep 2022 06:19:09 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9115E166F0C; Fri, 30 Sep 2022 03:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664533146; x=1696069146; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ghoRFIhfKliM5M6jnyrFU37Y6bcUJpDFK4TlqDcCIaw=; b=EBxRkM3H9DwtgqSkM/SEsr7CV687RcfoajPFGqbDWtOGOAL/6LeSK9iS /3goIP8u4B6ntypI+gLY9wYwCU4sh/HskA06xP/4Bdluq3JkAjO5U7xFb hpUg+Wfx63KcBoFcfN6v0dsUvdWMtrh7MN8ZPDvEwrTKVH/76R7J9+sJ7 L0XNb9HpYkSEb5wrcZ3G0s2dGZEZVXiASS1qitKOkda1Gu8LR28YI7ExV o449mnNxoCrNahMDNBGCXUbCX/Ti7RRHXAwnqdp/0QOw+asvTG3woTLyz 1vUUu4yL5izSIGz2yALh/D07cu99sIwpfNoe6y4Ezp7qMeXf+NcLAicqT A==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="281870100" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="281870100" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:18:58 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="726807640" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="726807640" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:18:58 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: [PATCH v9 043/105] KVM: x86/mmu: Add a new is_private member for union kvm_mmu_page_role Date: Fri, 30 Sep 2022 03:17:37 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaku Yamahata Because TDX support introduces private mapping, add a new member in union kvm_mmu_page_role with access functions to check the member. Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 27 +++++++++++++++++++++++++++ arch/x86/kvm/mmu/mmu_internal.h | 11 +++++++++++ 2 files changed, 38 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 122e1baef012..5f18a6c16715 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -336,7 +336,12 @@ union kvm_mmu_page_role { unsigned ad_disabled:1; unsigned guest_mode:1; unsigned passthrough:1; +#ifdef CONFIG_KVM_MMU_PRIVATE + unsigned is_private:1; + unsigned :4; +#else unsigned :5; +#endif /* * This is left at the top of the word so that @@ -348,6 +353,28 @@ union kvm_mmu_page_role { }; }; +#ifdef CONFIG_KVM_MMU_PRIVATE +static inline bool kvm_mmu_page_role_is_private(union kvm_mmu_page_role role) +{ + return !!role.is_private; +} + +static inline void kvm_mmu_page_role_set_private(union kvm_mmu_page_role *role) +{ + role->is_private = 1; +} +#else +static inline bool kvm_mmu_page_role_is_private(union kvm_mmu_page_role role) +{ + return false; +} + +static inline void kvm_mmu_page_role_set_private(union kvm_mmu_page_role *role) +{ + WARN_ON_ONCE(1); +} +#endif + /* * kvm_mmu_extended_role complements kvm_mmu_page_role, tracking properties * relevant to the current MMU configuration. When loading CR0, CR4, or EFER, diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index 486d719ca2e1..222ee61a415a 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -142,6 +142,17 @@ static inline int kvm_mmu_page_as_id(struct kvm_mmu_page *sp) return kvm_mmu_role_as_id(sp->role); } +static inline bool is_private_sp(const struct kvm_mmu_page *sp) +{ + return kvm_mmu_page_role_is_private(sp->role); +} + +static inline bool is_private_sptep(u64 *sptep) +{ + WARN_ON_ONCE(!sptep); + return is_private_sp(sptep_to_sp(sptep)); +} + bool kvm_mem_attr_is_mixed(struct kvm_memory_slot *slot, gfn_t gfn, int level); static inline bool kvm_mmu_page_ad_need_write_protect(struct kvm_mmu_page *sp) -- 2.25.1