Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp420570lqg; Thu, 11 Apr 2024 07:05:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaRv7Zr9TybNiiQlWMCSO/RaL6pJkJnAaJF1c2XYfCpWL7eD97YrAJhaaqHMuFh5RKlp9RMry+QsiQdxCtuVrlfNCDYXTmUQ0+ajp1Bg== X-Google-Smtp-Source: AGHT+IFGK8CGW1hGLWXytdmyzWbyS4Hg7Y8uv09R6rucF/WKu1zGzQMn1mBc4IUzPKlG3y28Mr7o X-Received: by 2002:a17:906:f188:b0:a51:c169:afbf with SMTP id gs8-20020a170906f18800b00a51c169afbfmr3966621ejb.65.1712844353000; Thu, 11 Apr 2024 07:05:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712844352; cv=pass; d=google.com; s=arc-20160816; b=uW5qYu88DlsXnrQkG9rBHt0uRbbNwOR8vjSIO4wzwjeGghP/04ihLGk0UqK81YB/sI L6NWc9Qfkr0NsgzKC4hywxrN1jCyCHdJApX5B4uoTaySPRrROgIVpB9+QpduqyQ2rpZT /0lnSL06Hvd2fGauAqpPk8KLvNXVzWoq72dQ+Rq7lyoYF80RFwUxlattfLeqwPs+BpEH ZOHMn/EXgDaDvMTGxLnUCv38ZrW/y5iD4HGU/piq1kDGm4X+TCvGb4gZ//AZo5N0LGNP fGcHNr/gVT357RggCSA2MAHsDM6Id9/5Rvix5DF0qlZYHHajL24/95QsezGYFQoksZqk rhHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=gv0uEmfxcV0o1KTjrBW7d5VYbmIjgWwr011CMxJ3/SQ=; fh=8HC6qeECW5oKsmBrUqSLRWe+eTu1s7wnKX4Q2v53raU=; b=ldC104GDNGW/Gic1cXmUOwmacpBVamqPLAfViKqMxXqbPGaJ95jD1iaWtRUNmxZIsX CB/+tytylBe3Wh6i5RNfotH6NzeIWrTwApI+UBQb65fsfg5qh3SAPXHyQlzU3c3KO4UW V/CTBkbjjBK4lNlUdLMnB3AiEpzISW1IH8VaO34nWni8ewZg6c1AbeqCXxbpDc+wdEoH nUPnCnrQIGYGrqB8PW9igoD8uSNvmA6M9ShryWO39t5pfmd4uODZQ4f3/vEArHwuu6gb obgrd4x2+1pBkMKMWuRW037Nlg3/SoACON0Y3AhNIkjUFkhHlldCLDsHAuGQgWcG18yc eZrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rNdUaFYV; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-140593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id js13-20020a17090797cd00b00a51af7d4654si824891ejc.205.2024.04.11.07.05.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rNdUaFYV; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-140593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8B60B1F21123 for ; Thu, 11 Apr 2024 14:05:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B41E0150984; Thu, 11 Apr 2024 14:03:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rNdUaFYV" Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 932D514F9E7 for ; Thu, 11 Apr 2024 14:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844231; cv=none; b=tZD01q1tUjzmG9ojT9hdehvPt4sA3CHz6blDSTIeS5TOrfXSOYgG97hygmt8a9pJQcwwlZRKLY/RMM2hEia/U+6qtFMTwWdUMe6xf5NybjgUiM9X9NL8DSP3QSrDJqcX8Mjr7w8CycBlQBkKZic2OpfVAq69jamPuGjKvqhdi/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844231; c=relaxed/simple; bh=0xnaIVIg2McZSemKKHSu5d2zpo1EqA8Xpzut4W7GquE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=O+7N4TYMr1Fgh7WtMqsT2PVOtZK38bDTFZ7xy1Lk9OwxeCVHJucseMwY+RCAJkxEWUbZ9H7dwjnEoL0WYtYxe8ht+0NXYBThbInxviKvoJe0o2OqLYfcaqpeif8/9VyUFGfx/lYPHS0qIshlT9RwzYwD0LTv1sr+zODk09JlUWU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rNdUaFYV; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-1e36b79fedfso58151635ad.1 for ; Thu, 11 Apr 2024 07:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712844230; x=1713449030; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=gv0uEmfxcV0o1KTjrBW7d5VYbmIjgWwr011CMxJ3/SQ=; b=rNdUaFYVLCCqMjPRUfK0aOjB7fvQV58qgYK2GDle8opaogiiJVfdZ3b6c/2bpi10R+ H290r4rrTSEbhzrbOUur5qWUhsyWauhgreSBGGwz5rGdt+a9emKE759hsMDuUqlmyJHK My/h2JdqtNXDGcCLLFKOuZvtQiWUoGHDDcdO8rKVkW1jXNMPMvEAogcbT3ZcSdBvazj2 ORzyLBurIfXH+MSEroVfMHJFykHF8X0Fmxf3ay9p+mYTnRBl+y2mYpeN/mnmAzjD6ThC SfKmNH2df0M7iVvNrLwqR4sgioVYxilt0Sg9gh626GXKmMOQk4TWGRwR963Biac/amWA WrCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844230; x=1713449030; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gv0uEmfxcV0o1KTjrBW7d5VYbmIjgWwr011CMxJ3/SQ=; b=IZ9lrGG1Gqh1/21fw7WnaqM7bm3jxXErhkHIzlbkS/UJJmXGAeyBCjRkAogVCkPtik 3NzbBna+OuxhBUzGW7i4NsEHST5LN8+h+Ftr9e7w9a3YQsM/ds6ACy6M5Z2COBKSPe8O HgVfUtdBUsbjToVI7mYwZuaQSy6DaRlTefoB3vhFDifymJAWauKKCY+UoQNugTDvcMPy pTLRKb8XEwZjb8qGTiPFHkeidv1/e247b2/m3QYOmPBk7T79nWMgTKDQNwizLvJ509lQ pXZwUFqBzLYW4VXc1UvNL/+xvSjvwPD866W3cfAietu+MI8TDtMPkegCvWv8rdRzvdqL WObw== X-Forwarded-Encrypted: i=1; AJvYcCVkv9JV6WqcVsuHM0UnxLp92/6ySRy3N+gq+2OFxBMGDR4U8lQ4+9hzG2xklNM9rkLBsuO/Cgw7CXL39rBkyJmdtS5wdIHGk1TY0b6p X-Gm-Message-State: AOJu0Yyv8UXU3M95dK0I8sr4f00wZcScHnuVuPeeXLqxvvGY7ILk+VdT I4JxdrgP333DtY/HNgzmyi2iloj2rJ0B4CjcAL/rcsTyBi7v6EwFQBbnp2EHFpdLWX9vb/6Tb1c b9w== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2290:b0:1e5:57ac:a7aa with SMTP id b16-20020a170903229000b001e557aca7aamr138693plh.10.1712844229893; Thu, 11 Apr 2024 07:03:49 -0700 (PDT) Date: Thu, 11 Apr 2024 07:03:48 -0700 In-Reply-To: <8afbb648-b105-4e04-bf90-0572f589f58c@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240322212321.GA1994522@ls.amr.corp.intel.com> <461b78c38ffb3e59229caa806b6ed22e2c847b77.camel@intel.com> <8afbb648-b105-4e04-bf90-0572f589f58c@intel.com> Message-ID: Subject: Re: [PATCH v19 023/130] KVM: TDX: Initialize the TDX module when loading the KVM intel kernel module From: Sean Christopherson To: Kai Huang Cc: Isaku Yamahata , Tina Zhang , Hang Yuan , Bo Chen , "sagis@google.com" , "isaku.yamahata@gmail.com" , "linux-kernel@vger.kernel.org" , Erdem Aktas , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "isaku.yamahata@linux.intel.com" Content-Type: text/plain; charset="us-ascii" On Thu, Apr 11, 2024, Kai Huang wrote: > On 11/04/2024 3:29 am, Sean Christopherson wrote: > > On Wed, Apr 10, 2024, Kai Huang wrote: > > > > > What happens if any CPU goes online *BETWEEN* tdx_hardware_setup() and > > > > > kvm_init()? > > > > > > > > > > Looks we have two options: > > > > > > > > > > 1) move registering CPU hotplug callback before tdx_hardware_setup(), or > > > > > 2) we need to disable CPU hotplug until callbacks have been registered. > > > > This is all so dumb (not TDX, the current state of KVM). All of the hardware > > enabling crud is pointless complex inherited from misguided, decade old paranoia > > that led to the decision to enable VMX if and only if VMs are running. Enabling > > VMX doesn't make the system less secure, and the insane dances we are doing to > > do VMXON on-demand makes everything *more* fragile. > > > > And all of this complexity really was driven by VMX, enabling virtualization for > > every other vendor, including AMD/SVM, is completely uninteresting. Forcing other > > architectures/vendors to take on yet more complexity doesn't make any sense. > > Ah, I actually preferred this solution, but I was trying to follow your > suggestion here: > > https://lore.kernel.org/lkml/ZW6FRBnOwYV-UCkY@google.com/ > > form which I interpreted you didn't like always having VMX enabled when KVM > is present. :-) I had a feeling I said something along those lines in the past. > > Barely tested, and other architectures would need to be converted, but I don't > > see any obvious reasons why we can't simply enable virtualization when the module > > is loaded. > > > > The diffstat pretty much says it all. > > Thanks a lot for the code! > > I can certainly follow up with this and generate a reviewable patchset if I > can confirm with you that this is what you want? Yes, I think it's the right direction. I still have minor concerns about VMX being enabled while kvm.ko is loaded, which means that VMXON will _always_ be enabled if KVM is built-in. But after seeing the complexity that is needed to safely initialize TDX, and after seeing just how much complexity KVM already has because it enables VMX on-demand (I hadn't actually tried removing that code before), I think the cost of that complexity far outweighs the risk of "always" being post-VMXON. Within reason, I recommend getting feedback from others before you spend _too_ much time on this. It's entirely possible I'm missing/forgetting some other angle.