Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp907603rwi; Thu, 27 Oct 2022 08:52:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PzMeUxdLd/kxgIbB9vTgaLZie59WKIRv+nq81s41wga9NVImS1iw7iMHs5Ujw0Ko+gqjr X-Received: by 2002:a17:906:9c84:b0:7ad:90d9:a6cf with SMTP id fj4-20020a1709069c8400b007ad90d9a6cfmr2857063ejc.595.1666885968853; Thu, 27 Oct 2022 08:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666885968; cv=none; d=google.com; s=arc-20160816; b=0qgCGu3iHZm84LVtS4ckvPNtQQG4oe1zpbqSfEOcrGqy0R3nKqnoC0MLVqtKyu9wUI whDil9nN4KaJJBPXycwSrbsAcG4lEHkjtxKBxHzODXdMY1giSwlInqNJiMfzvh9MieAc 49KtbJ7fiGryfzcVAcbyCy+Ni6MiPuWvi72XURKE3ITzhBCIA7UT8mCJGBSweqRtr3T+ prhkU/v5RcfdPNaKIWpwltZI1IFqwpBNxTal/laJdEw8ov7Zj4weTmbkkcAVwxyx3hjL RuXKdcjP5m1B9hVy41aPVFODwzMI06dJ0aTwdAaeMhkyqhBebiZJkNJGWWoiSaqIUQhT DJiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CG8yKmCdGH0EgXIBdXzRi8YlQ5k1G5IlWAKBnZ0hkQc=; b=h7JgOBpBTELKTjy09YyE7J0KHKdDA4DUSM1h7ITdGBEy9JLFG9GCpL5O2hTxRQbaBw +NCmy4F2USRCztuHVCM9CiX0uCDAbj28jw54URsGyJ0grPw0W57QzkD/tmmG9wnAZyMM BCpDm4mLLKAEoP0gvok+WZ9PkEK+xmKQLp3ho5bYzRltM6hJCbEdeS+S1x5iYDalfBtb MKXzwHLcoFAM5jpv00k6DQT+keSzy7lFwn+TFyOFAAIFHbnnjZpQa98pN6+gQR79o9Yx zQpbCRShuGWLLgEtKousW/D1DpSyDmRLUwBBJsq/EvlJ+ASgtRGzNDnoCfseeTPJKwHP FSFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cXx7AKZQ; 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 dt11-20020a170907728b00b0078d8f2658e3si1980923ejc.833.2022.10.27.08.52.21; Thu, 27 Oct 2022 08:52:48 -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=cXx7AKZQ; 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 S235166AbiJ0P1M (ORCPT + 99 others); Thu, 27 Oct 2022 11:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235642AbiJ0P1J (ORCPT ); Thu, 27 Oct 2022 11:27:09 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B20817537B; Thu, 27 Oct 2022 08:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666884429; x=1698420429; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=g6NyrQKF9LXeHoOqXcvYnumDkoDsCA06btGLwWECbcQ=; b=cXx7AKZQxM6xMz9OYsAQ5QbCE8KHpy8BgZr6u0uDwZC3iTQpG35YnRpU YZ4MPncpFMyVWnuHh7F+xp/0Pf4dZODiJ788CLyI0Nh8KBVRiNfwcxOGa gCfP16DVTj8hOAPfPG9ccI3k4NosAifVCocsvXRhu9+rdLOf2MrDWaIbK bz/gDnPvJeE2kX2nhVk2GwJmIV7RuAlpY11rDIF9U6eEVQ9DMrc++VAPk hCohVOTMDAy4Giwm1KpjU5ig1iTPx2BYwsrzw11UbWrN3wZSKItf7THTb 9agaLMdW/AAyD8/HHE75a0r11WABFuPuB9EA+bNOBDDFjE/FD30ExJS5k Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="291556175" X-IronPort-AV: E=Sophos;i="5.95,218,1661842800"; d="scan'208";a="291556175" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2022 08:27:08 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="663657349" X-IronPort-AV: E=Sophos;i="5.95,218,1661842800"; d="scan'208";a="663657349" Received: from vstelter-mobl.amr.corp.intel.com (HELO [10.212.214.108]) ([10.212.214.108]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2022 08:27:07 -0700 Message-ID: <03677288-2e96-a66e-fb1a-331e3b0d112f@intel.com> Date: Thu, 27 Oct 2022 08:27:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v6 01/21] x86/tdx: Use enum to define page level of TDX supported page sizes Content-Language: en-US To: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, seanjc@google.com, pbonzini@redhat.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, kirill.shutemov@linux.intel.com, reinette.chatre@intel.com, len.brown@intel.com, tony.luck@intel.com, peterz@infradead.org, ak@linux.intel.com, isaku.yamahata@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com References: <8a5b40d43f8b993a48b99d6647b16a82b433627c.1666824663.git.kai.huang@intel.com> From: Dave Hansen In-Reply-To: <8a5b40d43f8b993a48b99d6647b16a82b433627c.1666824663.git.kai.huang@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, SPF_HELO_NONE,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 On 10/26/22 16:16, Kai Huang wrote: > +/* > + * Get the TDX page level based on the kernel page level. The caller > + * to make sure only pass 4K/2M/1G kernel page level. > + */ > +static inline enum tdx_pg_level to_tdx_pg_level(enum pg_level pglvl) > +{ > + switch (pglvl) { > + case PG_LEVEL_4K: > + return TDX_PG_LEVEL_4K; > + case PG_LEVEL_2M: > + return TDX_PG_LEVEL_2M; > + case PG_LEVEL_1G: > + return TDX_PG_LEVEL_1G; > + default: > + WARN_ON_ONCE(1); > + } > + return TDX_PG_LEVEL_NUM; > +} Is TDX_PG_LEVEL_NUM part of the ABI? Or, is this going to accidentally pass a whacky value to the SEAM module? This needs something like this at the call-site: page_size = to_tdx_pg_level(pg_level); if (page_size >= TDX_PG_LEVEL_NUM) return false;