From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF440EB64DD for ; Mon, 3 Jul 2023 15:03:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C3C328000B; Mon, 3 Jul 2023 11:03:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2739D280001; Mon, 3 Jul 2023 11:03:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13B0528000B; Mon, 3 Jul 2023 11:03:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 049B7280001 for ; Mon, 3 Jul 2023 11:03:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C14E71406E7 for ; Mon, 3 Jul 2023 15:03:55 +0000 (UTC) X-FDA: 80970620430.20.EDBC345 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf04.hostedemail.com (Postfix) with ESMTP id A330A40198 for ; Mon, 3 Jul 2023 15:03:46 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=O6AB5gQl; spf=none (imf04.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688396626; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lqm8TMHAWxnUZDzATcGlvFdy39sG8ALavmX6CjixFQY=; b=SJqXsER0CvMf5tqxaniFKjoOYodXCAI9gWVDZod22qEunIyOxuOB/oPfE/TAsT68EsXAVo eMbmbXsQEl2pGKMv23E5Q9ob+akq+FN1dEzvqNTYAHVUvCp+tnGbdsmEzMJhupm1kQPVkD Dq1xkFO3u2GCxTqDCW3RRCPze61Xdck= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688396626; a=rsa-sha256; cv=none; b=7JCi/yNkVqLJ0/3zoGjPbqBcu4X2fOyFZS2Ij7pbnWQXSk3oXXX1kirkEprZsbXWr3+gKw SZNL99TKjO6yqRqVZmaAMTY9NgVNcJKc/AcVJ5n32Etqf3wTtfJ82DVotvn84PlvrcqUk1 0+u4jGoML0efYDlBORmI+P+KeXwOQvo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=O6AB5gQl; spf=none (imf04.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=lqm8TMHAWxnUZDzATcGlvFdy39sG8ALavmX6CjixFQY=; b=O6AB5gQlNheuz9I5RbADZ+PUPJ ATvZw+X674CVJh9wuJPOYigu7eaM8Z083C4NEiKq1Si5rnvRlevUcbPxP0jcx8JZcSe1t4p6+DvMO WP11P0qeKkF6uNZKtoSNgnSvQfE66aXLVi91zjVih0lPLxuhl91jUUkbAiE2gxaiwX1JFUDXzVYZF wquoHmeV34TDMueUkhk2tqBMdnszXSsJLoH+CICY/Cy3xgP1XMWNOhj1I6vQYH28aJjo2Y9uVhUYl TkX7Xor/1XGCOJbhgsh1hykay1S5tOdWtpzIQ0G5qIewfazGh5bzHRwSmHP1YSA+pwfVLgsEKonIo OFyknsQQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qGL5Q-00A6hA-0p; Mon, 03 Jul 2023 15:03:33 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8433E300095; Mon, 3 Jul 2023 17:03:30 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6A2732029B0A3; Mon, 3 Jul 2023 17:03:30 +0200 (CEST) Date: Mon, 3 Jul 2023 17:03:30 +0200 From: Peter Zijlstra To: Dave Hansen Cc: Sean Christopherson , Isaku Yamahata , Kai Huang , "kvm@vger.kernel.org" , Ashok Raj , Tony Luck , "david@redhat.com" , "bagasdotme@gmail.com" , "ak@linux.intel.com" , Rafael J Wysocki , "kirill.shutemov@linux.intel.com" , Reinette Chatre , "pbonzini@redhat.com" , "mingo@redhat.com" , "tglx@linutronix.de" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Isaku Yamahata , "nik.borisov@suse.com" , "hpa@zytor.com" , Sagi Shahar , "imammedo@redhat.com" , "bp@alien8.de" , Chao Gao , Len Brown , "sathyanarayanan.kuppuswamy@linux.intel.com" , Ying Huang , Dan J Williams , "x86@kernel.org" Subject: Re: [PATCH v12 07/22] x86/virt/tdx: Add skeleton to enable TDX on demand Message-ID: <20230703150330.GA83892@hirez.programming.kicks-ass.net> References: <104d324cd68b12e14722ee5d85a660cccccd8892.1687784645.git.kai.huang@intel.com> <20230628131717.GE2438817@hirez.programming.kicks-ass.net> <0c9639db604a0670eeae5343d456e43d06b35d39.camel@intel.com> <20230630092615.GD2533791@hirez.programming.kicks-ass.net> <2659d6eef84f008635ba300f4712501ac88cef2c.camel@intel.com> <20230630183020.GA4253@hirez.programming.kicks-ass.net> <20230630190514.GH3436214@ls.amr.corp.intel.com> <20230703104942.GG4253@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: 9utoe8wb3gmkm9typ3sym9gjosdjh8wn X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A330A40198 X-Rspam-User: X-HE-Tag: 1688396626-42123 X-HE-Meta: U2FsdGVkX1/5L+MJ2ExY1asAW0SbNDQian7fQZri8TqEwkVtEBLR/unGmIpfmRg4SoUTsu1tRXfET9nqouIdlKpElRx3900KpGvHchi4cREmHS5rd/zon0tKPyjsjzXhqltXW4Ip2UpdbIuoPVHDf83M+ZZ+HjeOxxCT/3PvgvuBUCnfOwWwnQ1cyc+fjUsNcmS7rnmODoRV0uDfdamBwphmZ6tZb+L3BZJw32Fye4WA2oYOjafnVHJgBStWR1uyGR7HsIAGq8bghC7hJgoJ6/X+biV+vOHPXGTiMxtaqdhcmLVG2fJ5UhPrSHcfUFRlwduGyTP9skSdraPxlI4NTSvti7SFDUiCoIteN0y8hFG+DwTGoJfeyjENnXEl2Ruvbc1I8CpBRdA1x58xqGPw2aKJ2GWtBXefqRi2H4G5cTpHQOnH8uo+gUqiuEkVjM16FLW9tWtMqjWyi57v3EZPAAe2nthc6WBzHlBz9BlEAACrQzBXGwbox8vmaPKvxpDaPkfCdOLN7hQzVB1AHfLhFkVhbHDQydXx7oWPFmcWgOgIrTToa59bazrvyFWtjC0ueQUlsApoZkQOYFrQb3Qs9nTZB5vNiNKU8DVCAHoh58KQgDFO41H3RRMxjRP5XzyusXfZRkUb73QY1/smkBtK3T+LuaFPA96TQEGACB1uR5siOKCC5P+TzvsNsHap9FSc5eMbl0CC06rHhj2qILPnzuXy+K8XriZQnKICcQKTRSSZRGO027zecjGa4s6oo2M8AzLYSoHNplGihA/FFBQh9BOrljKu5R9BX68DrstJAAaUwKELcEFxEcxYPyYbTAyszFobOWoMY8eGAL1a/MLFMeFnJ7Kmh4pGkBKIYf/BYmKj16SrKpsYBjmgKqxAqguRBFox6+MK3u+BA3Dyt6mVTh6jnQtudVuQyLTHEk9uMIVFOwbvgQLtRAE+OHfNMSBnI/e+C5pweMcPyWN+AKB KHzJTAe4 vCSIaPTCsLAJ9bs67REzAiirOYvXd1lhYUpWSpbeuPY6GnHYawOvFr+zFnztRWDc1lowB+lv8pygZneNDmLC1FI/AbIWSVFSjgDUHd4GKHs9zfApIxvz46GPpvBCIBoLfaXag8J+vy97hihTcfeiVkwCoG0Jx/5eSvLilbzhDjnTkpnLBTAeq/T0V/v1e0B80EJvCtFAvEuXUY7wVKsU5gCmzcKWRFe8cnF5G70stSeqdbA39zC14j6FZ4LTosINdqwoP X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jul 03, 2023 at 07:40:55AM -0700, Dave Hansen wrote: > On 7/3/23 03:49, Peter Zijlstra wrote: > >> There are also latency and noisy neighbor concerns, e.g. we *really* don't want > >> to end up in a situation where creating a TDX guest for a customer can observe > >> arbitrary latency *and* potentially be disruptive to VMs already running on the > >> host. > > Well, that's a quality of implementation issue with the whole TDX > > crapola. Sounds like we want to impose latency constraints on the > > various TDX calls. Allowing it to consume arbitrary amounts of CPU time > > is unacceptable in any case. > > For what it's worth, everybody knew that calling into the TDX module was > going to be a black hole and that consuming large amounts of CPU at > random times would drive people bat guano crazy. > > The TDX Module ABI spec does have "Leaf Function Latency" warnings for > some of the module calls. But, it's basically a binary thing. A call > is either normal or "longer than most". > > The majority of the "longer than most" cases are for initialization. > The _most_ obscene runtime ones are chunked up and can return partial > progress to limit latency spikes. But I don't think folks tried as hard > on the initialization calls since they're only called once which > actually seems pretty reasonable to me. > > Maybe we need three classes of "Leaf Function Latency": > 1. Sane > 2. "Longer than most" > 3. Better turn the NMI watchdog off before calling this. :) > > Would that help? I'm thikning we want something along the lines of the Xen preemptible hypercalls, except less crazy. Where the caller does: for (;;) { ret = tdcall(fn, args); if (ret == -EAGAIN) { cond_resched(); continue; } break; } And then the TDX black box provides a guarantee that any one tdcall (or seamcall or whatever) never takes more than X ns (possibly even configurable) and we get to raise a bug report if we can prove it actually takes longer. Handing the CPU off to random code for random period of time is just not a good idea, ever.