Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp191368rdb; Thu, 16 Nov 2023 16:23:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhno1nbvHG71J0TpLPMsmAhDaa+MpWRRTxzUOVk+pjhOsMv7HX0GyQ4qFmuuyzsZmVcWz6 X-Received: by 2002:a05:6870:2009:b0:1c8:39a6:779e with SMTP id o9-20020a056870200900b001c839a6779emr20923808oab.19.1700180631063; Thu, 16 Nov 2023 16:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700180631; cv=none; d=google.com; s=arc-20160816; b=u1Dvra+1/EWoKk9SgC9odvz3KLLGtP3URXWI9KlI7R6kR4HjAy025qbUERNX+G4g92 yXEsaFnrTebPrnvZEFF00kfT2ST3XXt+1aOghktsiCVLfEvBVt3Cd5xQrUMno3kHscQ+ o442+D5XcdhmRplSNRH8O+hO3geC+/osnaFWgFqPDD5PkYUMoBm7JEfV2J0rAg1+vdHt 57s0TtinzJqMRVmTKFvey8W0TtXCRiafr7vlBUBGlVfMdJS5y4lQWsAJSjMGoY1h6IXm +JkUP+Xt0nAVhm7nzmOm72dHtVkL1JdfCpsSpKkSbWe7yXC/PV/SRrZVOc+kxXf4sD9G DMvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Kn4tEnVMXTpbIoFuxjYdoE+/dqSjZUJrU+Av7yTtPU0=; fh=1Be8UynfIG+Duu9kbImSJDV1BXKOznS5Lf0DQgUMWfI=; b=aKK8xGZMQMnLCSSfO/UR6CM3uy9lI+zQBcvGFt/EPhKadcTYdcbfXq5dQWkjV46UMv zwxQZHMa+w6TJPoOkfV/jQCcYFnZL/uH6xzrnwnHoEDBzKwvZ0eP64uoLgni1w1goYWJ tgQnj1owVmNyoMxZzSz5TDZSuB/rmNRsjVFftUdPGgFnZMLX+ybisLNVWTFeRFGydcJK GyAh00UQn+bebvwzFn67HZi9YHUOtb8wqGgHdJDAHVJHKLz+fAztd3sqztfuBMiBfUDd uni0M7RQ4Sq3t7hHSig+vEVZdmsT+/kCTQjMob19q34pAvpAx69EzOFOTr//it9ICSsG 53Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="B//PXgQG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z12-20020a63e10c000000b005be00724141si576740pgh.533.2023.11.16.16.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 16:23:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="B//PXgQG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0609781F3306; Thu, 16 Nov 2023 16:23:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345553AbjKQAXj (ORCPT + 99 others); Thu, 16 Nov 2023 19:23:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbjKQAXi (ORCPT ); Thu, 16 Nov 2023 19:23:38 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 474CC11D; Thu, 16 Nov 2023 16:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700180615; x=1731716615; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=UrE/vjJRMr1sQ4SBUTBqQB3FZS2smt9NfEySrUQQePk=; b=B//PXgQGV7CG3oVXXgFfC6o8Zml992iVyTHX13zgtXRE5Kl6ZOW4zbFq MEZ7hs+oeQTqncpBja7qT22FUX9RyUEozcU5Pnuw8XIVrCpQTAXNqOYm/ UobUwHayr5wBXOm7makh48fFmVwkiPXFE4txwUPL989N3ecUzTlub1C5K 830Xsm/5zFq8cMlBb7hTA6ZWpGXdsgToJs7ADk3T7JMk0guKJIg6pqSs2 aofoETAk9HMlNV6WQ+pCgrRURA+vjVxFB5OKo3pESlgJYkmTSQ8QClSRk qqFyKPpbDj7HZwYtbiCPtyzSvDWunfqW0zw/ebgZ1j02lj+TPARkrX5eJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="376258166" X-IronPort-AV: E=Sophos;i="6.04,205,1695711600"; d="scan'208";a="376258166" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 16:23:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="1096944836" X-IronPort-AV: E=Sophos;i="6.04,205,1695711600"; d="scan'208";a="1096944836" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 16:23:34 -0800 Date: Thu, 16 Nov 2023 16:23:34 -0800 From: Isaku Yamahata To: Binbin Wu Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v6 03/16] KVM: TDX: Pass KVM page level to tdh_mem_page_add() and tdh_mem_page_aug() Message-ID: <20231117002334.GC1277973@ls.amr.corp.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 16:23:48 -0800 (PST) On Thu, Nov 16, 2023 at 04:18:28PM +0800, Binbin Wu wrote: > > diff --git a/arch/x86/kvm/vmx/tdx_ops.h b/arch/x86/kvm/vmx/tdx_ops.h > > index e726102d3523..0f2df7198bde 100644 > > --- a/arch/x86/kvm/vmx/tdx_ops.h > > +++ b/arch/x86/kvm/vmx/tdx_ops.h > > @@ -63,6 +63,11 @@ static inline u64 tdx_seamcall(u64 op, u64 rcx, u64 rdx, u64 r8, u64 r9, > > void pr_tdx_error(u64 op, u64 error_code, const struct tdx_module_args *out); > > #endif > > +static inline enum pg_level tdx_sept_level_to_pg_level(int tdx_level) > > +{ > > + return tdx_level + 1; > > +} > > + > > static inline void tdx_clflush_page(hpa_t addr, enum pg_level level) > > { > > clflush_cache_range(__va(addr), KVM_HPAGE_SIZE(level)); > > @@ -104,11 +109,11 @@ static inline u64 tdh_mng_addcx(hpa_t tdr, hpa_t addr) > > return tdx_seamcall(TDH_MNG_ADDCX, addr, tdr, 0, 0, NULL); > > } > > -static inline u64 tdh_mem_page_add(hpa_t tdr, gpa_t gpa, hpa_t hpa, hpa_t source, > > - struct tdx_module_args *out) > > +static inline u64 tdh_mem_page_add(hpa_t tdr, gpa_t gpa, int level, hpa_t hpa, > > + hpa_t source, struct tdx_module_args *out) > > { > > - tdx_clflush_page(hpa, PG_LEVEL_4K); > > - return tdx_seamcall_sept(TDH_MEM_PAGE_ADD, gpa, tdr, hpa, source, out); > > + tdx_clflush_page(hpa, tdx_sept_level_to_pg_level(level)); > > + return tdx_seamcall_sept(TDH_MEM_PAGE_ADD, gpa | level, tdr, hpa, source, out); > > } > > For TDH_MEM_PAGE_ADD, only 4K page is supported, is this change necessary? > Or maybe huge page can be supported by TDH_MEM_PAGE_ADD in the future? No and no. Will drop the argument. Nice catch. -- Isaku Yamahata