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 7226FC433FE for ; Tue, 22 Nov 2022 10:31:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 025646B0071; Tue, 22 Nov 2022 05:31:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F18796B0073; Tue, 22 Nov 2022 05:31:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E05FC8E0001; Tue, 22 Nov 2022 05:31:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D30D06B0071 for ; Tue, 22 Nov 2022 05:31:07 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7D3AE41041 for ; Tue, 22 Nov 2022 10:31:07 +0000 (UTC) X-FDA: 80160710574.08.34A7195 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf09.hostedemail.com (Postfix) with ESMTP id 02D76140008 for ; Tue, 22 Nov 2022 10:31:05 +0000 (UTC) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669113063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hyIj3LmVhEYLX36wfujnCfZwEDiB/P1zQlL73AIEtTc=; b=cpDQmqTRoiW4zJJjcEKCD9XuuGn+BRfmpEaX42L8Z0yJQsrtlsRLSMj4W9phuRsIDed2VG 9gFtP8CbKovyrFODpX+j8mfEcVvEg3+ROgz2qWRpqkf6hODFZQnExjbuyetqlfwYvdx+Yz FeQ+wDf3MGhLhA/q34a84itezufzgFDhEzUGYoZQXfYPdhxjpHR1Z2EvjPznhttVolg6H0 +Dxa90UvxxW3hJ/8WZemPpbEuvCN/AZ2Et/UIUqwUgWNYtckfEkQAMEd85iycIUu+Bzffu uLnARxlfknoXvOMXFrtO87NsRC/atGDyq0QFqT8mnKPEDlfqrhAGEQhlBha0AA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669113063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hyIj3LmVhEYLX36wfujnCfZwEDiB/P1zQlL73AIEtTc=; b=v3qfWM+1iFsEhZ6c4Ia+vQVM01NXRwxlYDhbENglPpQJ/FJIqF5Je0Mi/8IJ30DWOcnwy+ dsN+LcrA2cuLuMAg== To: Peter Zijlstra , Kai Huang Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, kirill.shutemov@linux.intel.com, ying.huang@intel.com, reinette.chatre@intel.com, len.brown@intel.com, tony.luck@intel.com, 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 Subject: Re: [PATCH v7 04/20] x86/virt/tdx: Add skeleton to initialize TDX on demand In-Reply-To: References: Date: Tue, 22 Nov 2022 11:31:02 +0100 Message-ID: <87edtvgu1l.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=cpDQmqTR; dkim=pass header.d=linutronix.de header.s=2020e header.b=v3qfWM+1; spf=pass (imf09.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669113066; a=rsa-sha256; cv=none; b=PbsSi9wwZT+JJm54cC4ljNYV4Y8UKkcliJ2LiQycNi8rQOWTuFHA61tjVdJJRxR/0d1LJl qo4f+Dho65eCq90F+hP7TLG9GngdAQyQftENwGaIhz/s9yLV/iqpXctBbBtzH/9swT4bzt gTOWZBxNqOjwoPGo9pdQDye3DNgriWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669113066; 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=hyIj3LmVhEYLX36wfujnCfZwEDiB/P1zQlL73AIEtTc=; b=ddvc+CHXAYlP/2xpM4zmsOziKCZE4ESKeAdZbQpc8ZBJrfaiOWnV7xj7bagS/eRulYqNMw x4cepj7TdQAgPFU0m4T8ZJ6pDrGyi77rZ3y662kfE+LwiV77owNR0hB+LqztHdqqTdm8Ai 0xK9xiReHYEZCE9wN08HDcww5lgj2M4= X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=cpDQmqTR; dkim=pass header.d=linutronix.de header.s=2020e header.b=v3qfWM+1; spf=pass (imf09.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Stat-Signature: ds8emrzxxzus79xs3uofifxnkfq8iexm X-Rspamd-Queue-Id: 02D76140008 X-Rspamd-Server: rspam09 X-HE-Tag: 1669113065-492498 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 Tue, Nov 22 2022 at 10:02, Peter Zijlstra wrote: > On Mon, Nov 21, 2022 at 01:26:26PM +1300, Kai Huang wrote: >> + cpus_read_unlock(); >> + >> + return ret; >> +} > > Uhm.. so if we've offlined all the SMT siblings because of some > speculation fail or other, this TDX thing will fail to initialize? > > Because as I understand it; this TDX initialization happens some random > time after boot, when the first (TDX using) KVM instance gets created, > long after the speculation mitigations are enforced. Correct. Aside of that it's completely unclear from the changelog why TDX needs to run the seamcall on _all_ present CPUs and why it cannot handle CPU being hotplugged later. It's pretty much obvious that a TDX guest can only run on CPUs where the seam module has been initialized, but where does the requirement come from that _ALL_ CPUs must be initialized and _ALL_ CPUs must be able to run TDX guests? I just went and read through the documentation again. "1. After loading the Intel TDX module, the host VMM should call the TDH.SYS.INIT function to globally initialize the module. 2. The host VMM should then call the TDH.SYS.LP.INIT function on each logical processor. TDH.SYS.LP.INIT is intended to initialize the module within the scope of the Logical Processor (LP)." This clearly tells me, that: 1) TDX must be globally initialized (once) 2) TDX must be initialized on each logical processor on which TDX root/non-root operation should be executed But it does not define any requirement for doing this on all logical processors and for preventing physical hotplug (Neither for CPUs nor for memory). Nothing in the TDX specs and docs mentions physical hotplug or a requirement for invoking seamcall on the world. Thanks, tglx