Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp98792lqb; Tue, 16 Apr 2024 09:47:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUGkXVGxtfgxg16aIJfbI3v3hVQpICEWsndpVTp/uxPGrANMLbAJMdh4eRpc4azFBcgwevclzA/3Eje2xS3mIkHmlLeOZVkI5HkQ5C5A== X-Google-Smtp-Source: AGHT+IFa4PiMk+s/neqgvppLujV786v1Nh4YER0vslVqW/b90izFoh8Cx+mPK3O+IId9DpgU/qe6 X-Received: by 2002:a17:903:2c7:b0:1e3:e295:3f47 with SMTP id s7-20020a17090302c700b001e3e2953f47mr14429140plk.69.1713286023828; Tue, 16 Apr 2024 09:47:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713286023; cv=pass; d=google.com; s=arc-20160816; b=L6aUikFUwS0wiGvlJCIQfKrNbNkBc+bFYWGm7P/Y7M3AotLmXx8aQ/UNzhdnLysMH8 F9rsONVwhkrhOInf+dVb+vvp9w8pduZqd6ENXS6LCpk25bRJPaLTzkLK/XdRjkVYzfad MMjdMZW6ebVLjHzYVDRO1vLWXxHHlCfkfulPgcPFpIlplqg807faFalKIPzZqzZoDjCi NEoHMceBZuL+QilURCaz7x2dZuWeI5/8jBQoe1uKK4EOh92cHJ0MIywZ6bdQbV03pE0a 6StgKvC2YsqeUitaUCUwuJSPdmGRZf7N123srftLpzfxhuVnGgB2SvLoi378/FrHhVNZ ACaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NrNXKkZoCToSfgx+Z6eE8LudANVkc6a74WVaqgZzjrI=; fh=mnt0rZv5wuHPaERSOzeiRH5QAy6/mYUQszctjgvxWPo=; b=UXHLVV7bHjJX6S1P4KMe8fbKvpWlg7sTfhqMLs4b2DZdRaYjhJDoazdWh5lNBpnsbF HYJtBiiceVBqrOOrb/IaAD9uPUcOCAikgEfmo9zpvi/cmYNSJO3gn9NLeKBXMDtYyB6o RbgTWnYljs/1pEYiDUDXatHJ1vlozSN+fow4Fa0TdFOCMc4IAzzxJOJ47DrO9mve89rH 8cuexvMCnUXUtUKPvh0DBiOoPy2tJ9mE1p6fEWQCVu5DuGgJ+xyLi+2BV2W7t2yAhKI1 RNt5EfuWnYXuPxmfoSHEYtHIg9r7Q82f9Wnnz9oy+seEmWnZR03gUC2eLzUQFou5/0xb AUNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YxGhi2SS; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-147253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ma8-20020a170903094800b001e6401bc084si4723669plb.568.2024.04.16.09.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 09:47:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YxGhi2SS; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-147253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E66E8286C48 for ; Tue, 16 Apr 2024 16:40:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7B0F84E11; Tue, 16 Apr 2024 16:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YxGhi2SS" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0114310A22; Tue, 16 Apr 2024 16:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713285644; cv=none; b=eeH/xr7rJkY0zhCGGbuGIPoYWbhC/pNOOTDLXqzhFfVNEJxQISjsy1TCfqmiOwiwORLsuOrIufgC7eWC9uceIzPBlaKELds69XP4gawIa58UmrFrJAHY7tRzRt3rsP7U33CmEdzN0Ri9MmE+LQjgBZHNL5t6F5zH3O63EsJX0uw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713285644; c=relaxed/simple; bh=c9rv2ENZUtW89CuH5U8B/1vQYk4rvmSwwB56Zf73aj0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QVYh8icJwtxDvfDZ1/B6LLHm5rg7CML4uH2WP1sRDvzjC9r+eYL3UTv98oWU/SW8Dva8+WHmMxeCeTGdngp6oO9AVbxTKNfaNyAQMwNt9r6AElcsoME23XuxfeFR2LIFjqgKEwrDWupW0XMF5Dfn1zpPMyGKaB1sJQeTTM2ZWn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YxGhi2SS; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713285643; x=1744821643; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=c9rv2ENZUtW89CuH5U8B/1vQYk4rvmSwwB56Zf73aj0=; b=YxGhi2SSRj8Tt4Q+I5ydNmpLNV51AWKHDX1hcvvR5yDXYe5yqzpR7z+4 DnJx0zkMIZXqn0S/YC9gkwQAwXu5sX28ku3gKEgyf/lOLB2XKukW37+sk EhGFjzZ8+BjfJJz9g0o66NM7ZABAVPmwvUGrL5UkXRgnmzxGHRTYSI6GM ghtPALwQsdGPGcwxCR7oh+SLPTLCKAt8uEyDZ3w7nykoPzt6I+hm7MIcb qUVGwpXYk2qBNI4KyxJ3+mLTM3W6TKM11Qt24L4FEOHFFTYTMroBD1H+5 dYpjhvJBe2qYeccWqtAyMKCd/7n/gT5NpYEmZNNZsDTLkrgRZBPpPO8C3 w==; X-CSE-ConnectionGUID: RIuodRcSRUuVh0Vo1RHK3Q== X-CSE-MsgGUID: JWeJHHA8QeiHeMrOxwEsIA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="9289188" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="9289188" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 09:40:42 -0700 X-CSE-ConnectionGUID: /u9bDAVcSWqs0tXiTvD9MQ== X-CSE-MsgGUID: IrKk4m3VQW+WflQgAuFKEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22371840" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 09:40:42 -0700 Date: Tue, 16 Apr 2024 09:40:41 -0700 From: Isaku Yamahata To: Xiaoyao Li 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 038/130] KVM: TDX: create/destroy VM structure Message-ID: <20240416164041.GY3039520@ls.amr.corp.intel.com> References: <7a508f88e8c8b5199da85b7a9959882ddf390796.1708933498.git.isaku.yamahata@intel.com> <8aad3a39-dc7a-471e-a5f0-b3b1d5a51a00@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8aad3a39-dc7a-471e-a5f0-b3b1d5a51a00@intel.com> On Mon, Apr 15, 2024 at 04:17:35PM +0800, Xiaoyao Li wrote: > On 2/26/2024 4:25 PM, isaku.yamahata@intel.com wrote: > > ... > > > + > > + kvm_tdx->tdcs_pa = tdcs_pa; > > + for (i = 0; i < tdx_info->nr_tdcs_pages; i++) { > > + err = tdh_mng_addcx(kvm_tdx->tdr_pa, tdcs_pa[i]); > > + if (err == TDX_RND_NO_ENTROPY) { > > + /* Here it's hard to allow userspace to retry. */ > > + ret = -EBUSY; > > So userspace is expected to stop creating TD and quit on this? > > If so, it exposes an DOS attack surface that malicious users in another can > drain the entropy with busy-loop on RDSEED. > > Can you clarify why it's hard to allow userspace to retry? To me, it's OK to > retry that "teardown" cleans everything up, and userspace and issue the > KVM_TDX_INIT_VM again. The current patch has complicated error recovery path. After simplifying the code, it would be possible to return -EAGAIN in this patch. For the retry case, we need to avoid TDH.MNG.CREATE() and TDH.MNG.KEY.CONFIG(). -- Isaku Yamahata