From patchwork Thu Feb 22 19:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 205006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp155953dyb; Thu, 22 Feb 2024 11:16:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVPTZQPvdJ6EM7OgRNEo1MoqXmXayMd4V4qzH4MvR81wo3RevFMMUfX/BkdNeEhh1X8N5QEmh8fIoigGDI1jMf9tqetHQ== X-Google-Smtp-Source: AGHT+IHKDaPhUnIcl/L90dkvvXc8jYF9mYvzOMA330AhbrDwbAk96r44XGKxjKLC+5qP5M/11ARc X-Received: by 2002:aa7:8a06:0:b0:6e4:59d0:febe with SMTP id m6-20020aa78a06000000b006e459d0febemr13509201pfa.7.1708629390994; Thu, 22 Feb 2024 11:16:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708629390; cv=pass; d=google.com; s=arc-20160816; b=jHQBGqOwbgEI8nI7zU8dWiRZBrCTelu1r97mK1MUGalBeX/dxc0ByMlysJzd9BjJzB MwNsnC9D5PfY5Z+61Cvqf3zuFqnXn8hwj5e9FbSPcPnRN8RogDGBTw00lG3wRLMa+67p sPf4FbOuajco68MdT2DX7T6iAIX/S54h+GyUcRsZPS98lUQ2MoG/M/tQG5DCav+XJ6LD CYMM3eoNq+Aa3auDwzh49mVObLMP0PdrPNoEThpWfr5CN/Cl0evJTKgNI8vqIDkA5bh8 02YVMUaf2Vlmfy2w5pNzasIaNlUk3HuHhOCuZ6/E+77sh4KlZdEWn6FUwb8gbmZl6Trh i2kQ== 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 :reply-to:dkim-signature; bh=TYSivnN6sKEY4CZofc9WbYnjIg5hjEEjj41nwAaSQHo=; fh=6z20+Ty6JFzrxks7FibXZeq78dGYseODPIift93+rLI=; b=mjhPqEVX+Smk3oXFZ07e6A4/Bk0ZVaXuwOJSPsWa/yPW7k82PRQ/Yh4SvTOj6GYV24 ycQ/LdzVXd78s12n97rhdjvgFuqo1odMjDUjXQjT8LqlFGUpaM6uRE7VRZo6hWrC5iIW /Urzf0UgCH+8W1okqTOGETXmG1UlPwfkMnkBa9RIvn3WnGPPw1mtKYfARb8F7Kzj7Rmy VfOVHQHBMPiyxMnWnKeZyQVS9WmxkC7yozVkEcLoiM/+3LQ/twzIyFx0uWvxTGVlPlZe f6yWEocb40+wrzppVXetBR+Zc9TcpSL42V+hKBAf40GczaR/RGBnwnMF+CPizM24VOez CNBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=XSBf7+zj; 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-77215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77215-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v18-20020aa78512000000b006e13ce606c6si10469278pfn.110.2024.02.22.11.16.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 11:16:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=XSBf7+zj; 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-77215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77215-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AB6192845FE for ; Thu, 22 Feb 2024 19:08:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 576C16E5E4; Thu, 22 Feb 2024 19:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XSBf7+zj" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 55F5D14B836 for ; Thu, 22 Feb 2024 19:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708628794; cv=none; b=LSTDC1y1l9c3aILccoZVPjzkIofHN5WV8LjtPIqMVEj/sAPKkPPB4sWUeUFx8afdJpNwhy7ybd5436L3U0DuNaUzvJRXyry+4R7pex1QVhWZuGpkdwvQUNAY+i9zrvVHyO5nzNk5cmI/PVlBAPXHhFWGcDwaIfA9dMBrhBSj808= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708628794; c=relaxed/simple; bh=Lpr6OXMdJrHRiK6NwVBpGyZp/lhKwMDMfWMCx4WLc3E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bebgajRtq6IX+Xm7VtQXrDZaMPsaPxsFVAJ8++PFw0iJDKF+gjM6IPlzSOK1QnHiPDZ9Rfkxa98U6GI4j9+RXaSaEYWIxPGnDwy2/KwCjEPdWGJFyADOUHeJZUp0liEcXRfyt8YYUeNfzE6J+ShkvmFcsOJGwY4DbMSXgezFJMM= 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=XSBf7+zj; arc=none smtp.client-ip=209.85.219.201 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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b267bf11so15829276.2 for ; Thu, 22 Feb 2024 11:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708628780; x=1709233580; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=TYSivnN6sKEY4CZofc9WbYnjIg5hjEEjj41nwAaSQHo=; b=XSBf7+zjqQSIdpqoyLdYZLXRBC8iVe9qqogTHUaBn57Ovayhzn94jJFmygn3Zcr4Ac V81jFQbw9uesISW4op0RXFqQ5VdLV/HFSoQMgT2F9cyXbcgC41UpHUEuMTsrIOESuQ8y tXXqOls0CCgznvtf0okfVtRp4miaFDLaNVNepblvY6Scs59lYYEy29yNVrwJF5fxGDpy wU+9Wev99fJvjYZ1taG7kkLvXLU9vnb7mGQyFIJ/qr3VUX+KCGweZjS/Wz1vrtiYi95r v0A5hzhGtLDUgKFWTwP6/5NKLqZrhp4TMNIpGvo+nihezpIBbEPgpDCLO+OELV9SDIlb qPqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708628780; x=1709233580; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TYSivnN6sKEY4CZofc9WbYnjIg5hjEEjj41nwAaSQHo=; b=MofZg7Kj2DugWVZZCHN362zZfsD7WDdB75EJKvvR/TfMv5TsazdGjJrI6ibCuSW/Zk Ncy33HM84xL116eeeG0ZAI5jIk8wM5CYBgAgX5vwkkcBgQuhQcOGN30GiBTeYzrpg3P8 NlZBB/jQSGsey1bsA9Sw+01gbRPdganBoVc4En9pnqKKVXhJMUj7Z1YD6648zTTS3l/H VOhauR7+BigH6wmK47ycPSsXxP6+s8wI6t8qQaxO8SIseKkgGJd1XhDPiGONTnD6RJZQ pl4mMYbBpvdEMM5SO2xy2/1TKscwHAWFbgu4SP8qjTRo9VWuEbwd1c2XaS3xWCmgdlO+ q19w== X-Forwarded-Encrypted: i=1; AJvYcCW7TzNVRPx8BT6ZoR8v+unbwMkc6i/eyH7MEO2qq7GlwVspycfg00PmpCsjtF7V4a+ut1pzSW1gFXZiDN4jlyfIzUK5794JYtPvDoir X-Gm-Message-State: AOJu0YyOw7UJjVn9S2eY3a24DOQ1uacHxiZBtkd5+/qoiNDgG4fop94y ihlSPoLeL+vB4IV1iFatP1IYATqZHm9LxI3YY+Qgiohw2nY1Yjco43hvJ2lC9hp5NM0R7IVLo/K NWw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:18cc:b0:dc7:6f13:61d9 with SMTP id ck12-20020a05690218cc00b00dc76f1361d9mr1123ybb.4.1708628780537; Thu, 22 Feb 2024 11:06:20 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 22 Feb 2024 11:06:10 -0800 In-Reply-To: <20240222190612.2942589-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240222190612.2942589-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240222190612.2942589-4-seanjc@google.com> Subject: [PATCH 3/5] KVM: x86/mmu: Restrict KVM_SW_PROTECTED_VM to the TDP MMU From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Fuad Tabba , Michael Roth , Isaku Yamahata , Yu Zhang , Chao Peng X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791627772323847458 X-GMAIL-MSGID: 1791627772323847458 Advertise and support software-protected VMs if and only if the TDP MMU is enabled, i.e. disallow KVM_SW_PROTECTED_VM if TDP is enabled for KVM's legacy/shadow MMU. TDP support for the shadow MMU is maintenance-only, e.g. support for TDX and SNP will also be restricted to the TDP MMU. Fixes: 89ea60c2c7b5 ("KVM: x86: Add support for "protected VMs" that can utilize private memory") Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 86d88bc7a6d0..1e0cc1906232 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4580,7 +4580,7 @@ static bool kvm_is_vm_type_supported(unsigned long type) { return type == KVM_X86_DEFAULT_VM || (type == KVM_X86_SW_PROTECTED_VM && - IS_ENABLED(CONFIG_KVM_SW_PROTECTED_VM) && tdp_enabled); + IS_ENABLED(CONFIG_KVM_SW_PROTECTED_VM) && tdp_mmu_enabled); } int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)