Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp387546rwe; Thu, 1 Sep 2022 00:48:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR5viu87BX/V8b3LK9JYPrcW7X0j+e+/0strsK2w0buIk3seTLwq/Hy6oMRx5Zus1ZDEpNMj X-Received: by 2002:a17:90b:3006:b0:1fd:e61b:8666 with SMTP id hg6-20020a17090b300600b001fde61b8666mr7135105pjb.95.1662018498277; Thu, 01 Sep 2022 00:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662018498; cv=none; d=google.com; s=arc-20160816; b=cBVcm77FgFgtLFyXgpjeG7fpCTT3kWiKWeb0uzO4JsHAEznsJrQ6LpNCwrXeta3QJN ARvilDQu0wDb+C4tzrOpZtJidwDylDeCQEm9cE/iqcvyQP/6QHcAg5dWE6nTSb5aCZt+ Q2/EOUJYMiM8IdpysB/moJOd5TZtiYrIOJN9KpVCliQsDJDWb8VdU34nQyp2LwlCwbnk N01Vqazuu14P9BjtQnUZRud28jc8QOjPZVmSVIbB/QETnhF5HAB3I35bqgabUiHE5Zqa ATXFS74LbpVly0DxOiRppYIFuuGEfK03KDPIdd9y3ZhaIbyslrVvlQm3jG5C/BJUguIj UKOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=rLl2nOIKEFZdniinXSlpfNIhBWFjfFyMCOH3qNHCRBY=; b=dzNiXg9Rf3H/qmjXaLAqQu3Qa99xZDOMq++Vfai48/0H/nB8thsbcxK66dDsvzr7KU HIJ0iJU8LagNnfVJOO7hU3lTPkM81KdFOcl3KRt6rodbm86zGjSI/+khGMOdEeKPRDCx FvXs4XVqc5mU0vbNIxizH78fZnPRXU4HHY3svzv6oEGde64yWDeTNL+1lQXWHOOoEhLF 1mQeCbLnkYFlLyOPyQJuh8QEI2E34obdni0FRO1CcGdkQquGYhIEA+qMBcEaXfYOzEs5 5fBn1zzP2u3DJjapMnokf+9IOnxla2m/ZM3Wj/EadkgrLoeqU3YpPmwW4q+zwGFTZQFi yhJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X+TQ4sSo; 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 s20-20020a17090aad9400b001fb158c56d8si4055542pjq.113.2022.09.01.00.48.07; Thu, 01 Sep 2022 00:48:18 -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=X+TQ4sSo; 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 S233179AbiIAHpo (ORCPT + 99 others); Thu, 1 Sep 2022 03:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233322AbiIAHoP (ORCPT ); Thu, 1 Sep 2022 03:44:15 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A3BD126DC3; Thu, 1 Sep 2022 00:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662018252; x=1693554252; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ejI/izm9+TYQ0O7NVLS4b04vZ6yIXtzj2hWSThsqVrQ=; b=X+TQ4sSoUwqscFzt0ZQGW7bLk9Bv3+W6V87bmxtKEZ6AUT2dFCQsFilO QoC8yIfMGDEPFVKF+YVJw5abGCoyp2ex2sPo7/lffe3rkN+ZNyE1zInP6 3yetuAWW+9YByri742mJk2SOVJuFhztQtOzw5yEddp8NcdHNsnnY45XKO MXWCrK1qTG4BF2YGJfkB2fKj2Aow4t7yey4tu4QIMyyVe6eE4o+sIWAho XiGsaynTPXDuL3gF68n24N2IIoE2p/3/YFjws+EQq8tRNPhMrSCz7ivfi RZN6Jr+DeYo+O9HWf7dHhR65V8hn4e5oAEwfH5v/f2G4aIje6YakCyivn Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="276046328" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="276046328" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 00:44:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="673731452" Received: from yy-desk-7060.sh.intel.com (HELO localhost) ([10.239.159.76]) by fmsmga008.fm.intel.com with ESMTP; 01 Sep 2022 00:44:09 -0700 Date: Thu, 1 Sep 2022 15:44:09 +0800 From: Yuan Yao To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: Re: [PATCH v8 041/103] KVM: x86/mmu: Add a new is_private member for union kvm_mmu_page_role Message-ID: <20220901074408.lnmyrc5fmsd3kqdf@yy-desk-7060> References: <621bbca9e03f1350e393657da3f27f295b57a490.1659854790.git.isaku.yamahata@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <621bbca9e03f1350e393657da3f27f295b57a490.1659854790.git.isaku.yamahata@intel.com> User-Agent: NeoMutt/20171215 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Sun, Aug 07, 2022 at 03:01:26PM -0700, isaku.yamahata@intel.com wrote: > 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 Reviewed-by: Yuan Yao > --- > 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 e07294fc2219..25835b8c4c12 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -334,7 +334,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 > @@ -346,6 +351,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(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 e1b2e84c16b5..c9446e4e16e3 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(!sptep); > + return is_private_sp(sptep_to_sp(sptep)); > +} > + > static inline bool kvm_mmu_page_ad_need_write_protect(struct kvm_mmu_page *sp) > { > /* > -- > 2.25.1 >