Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2779274lqo; Mon, 20 May 2024 17:21:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXhkXWK3Nmi86aG507/TYJWJbkwUhTNLj2gTHDpuGV+6GLaDMOZ14L31MS88JPgT/muOC51mR4gR4aJWIcIFNc8qmHeHuuW+Kk9tXo0Q== X-Google-Smtp-Source: AGHT+IHAwNdJlUOhiZ9LShW4VCi4VHm/ZGc8HYNIa+ydd7TiWZ1A3FKHjwKCWHxjYYRWelTxIFps X-Received: by 2002:a05:6122:1693:b0:4d4:3ec6:421e with SMTP id 71dfb90a1353d-4df882a870fmr28129912e0c.4.1716250909213; Mon, 20 May 2024 17:21:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716250909; cv=pass; d=google.com; s=arc-20160816; b=gjKoBHnkHjS+m0DQJR/kPk8+fvNwcqoTqjmidhMaZzX4zlSrDWGWiC/LUmGEdMxmuQ C59SPOpJoGppx0G37Z4YHUa+ePAHbhOAHAw+kXJ64Wq074iLvXwkmVZApbiKLY1UtYpf vOQdhCA2Su3JK5oD0Yg2nNBEfTuMN2k604JnIvt6HjFTrNabLvSjArIcw6kbMGfPPvQX jo7GGhTLZwPVHElqX9xigde7cZFtRPMu4PMTwQ/vmCpH20LnHSMUOD5nJDiIcIV7JUEF LsnRaLgg2PNulPyjW1lsD2Pd+7D6p0E2PVCYemdgariwij4vsKO4kjRDsZfGpWCxJD5Z CBbg== 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=vCsUNW09v7zKL9dHQIPxnsYeWbnXda/uqjR3962X8Sw=; fh=//Ni7n/3m3P+WRMlqKDKV9MPlz/uo1RDH1FRSgNp9Sg=; b=Szj9I7eK8uJLoPgJumPi+5PydZl/MvatVrMLuGNR+mHJmnuIxfLyH5I/ggs76knOZC lzLQ/Z6puXOR5GWOxmg4i6E35yKO040X4CJe0XpH1XMWjw/ST52Or8LAR8oHavNrUHCo r7TpptjH44war0IMippddTVBzJ1xKFQkWr3l01d/l1HD4LBYi7aPVD0/7j53bG5dOYmg MitOAh48MLXcQxpNQKmlTIvqP4QU/LVpSKMhCiC/TTSfBck3UcXVeaNpoVw3TN3hOQpK EVl9FIhAwjlBBOQL/1DenvZMzASkKjb4qcrhqDtoQ5eBFh7NdGyKtegzMuR3lINvKcZ4 V2fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NYhTmonl; 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-184319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e02b17b56si15890831cf.426.2024.05.20.17.21.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 17:21:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NYhTmonl; 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-184319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184319-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CC39B1C21078 for ; Tue, 21 May 2024 00:21:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEAB0BE4D; Tue, 21 May 2024 00:21:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NYhTmonl" Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 9A1018BF8 for ; Tue, 21 May 2024 00:21:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716250897; cv=none; b=Gi5bM+AfoPL5O+AXSoQeAJ1J/iBSE7cp1RFeTj7ZAV4HGlzOsV9ZfIcenOuaBeQrqAgb6QeJOtPRvLhmzGzwisFBQ/Th2PiZRF+FaQg61TrI2aKqaq8GbUKO66OeFpuJI4ijVw0Phm5udvdL8aFiOZfEyuBsYTtA73TNQkrD5JI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716250897; c=relaxed/simple; bh=7FgnFOkdDgFgsLvHLPfWZW/CX/nmh1MR9HxCA63N6To=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fi//usXKvPGsQuk1GJSSSRDNsxlB7QRiE1qd4YHd9gImfrxRpMSTFsafuTvb9CMWfTFuPxBRu3+0AGP4g0jJl3Ab7FOGEkwO+AnTD6/QiGYE+cS6auK7n6reB1tcYuI46yJMH8744hg1uGwhe7rKCoiGc1aynxfiz+qizhlNnhQ= 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=NYhTmonl; arc=none smtp.client-ip=209.85.214.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-pl1-f201.google.com with SMTP id d9443c01a7336-1ed3b77d45aso140267495ad.0 for ; Mon, 20 May 2024 17:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716250896; x=1716855696; 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=vCsUNW09v7zKL9dHQIPxnsYeWbnXda/uqjR3962X8Sw=; b=NYhTmonlgKmICgZSj7JdhyP6TbV1kx3IyOJpx+S9FjCKlM9PXgHNmB8KWyGQMDQnZO 1HJiVYrIdDQh/WYBrreOYqQ+jPveDskSLRZnBcLUQFRXKUu9Ylaq/OEVMnIMZ3enHYCz lV3HPRkxFU/8LTj6OoZcPJzcpMzLXjEx2WXXm8cMfFsKpCM8Z8Y3774m8dbUXbuiPI8D y2u1JpK/T4BhN/HW5n/Vy/cMFspWnZthr4SvBPgp5uaHlBqS9vE/ud9sA3GZRAm21QLn gKLcwOUtHFs6n6WpJiW7OVtCTznGbDViOte9kZ44HPAnRos7BC3W8EwmLSPq2wCyD4sw XVIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716250896; x=1716855696; 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=vCsUNW09v7zKL9dHQIPxnsYeWbnXda/uqjR3962X8Sw=; b=iHprSuqGNUl8BIAqZOXlfOSZhG7qcyuieOHvFSMJUIhP1eMSrntA5MlxWRMH9avEax uAy35Tvl4IWjH4Z9dmRBMk9zXq0F3dBc8utGviuNz7dIg97jkjWsdqJMVwuUp882N/vv aEbKBhJzJAk/X3ZCKdJjKmb9HkzCJPwTE3U9iWOkdcGuXCgXtJDk7iXjBylZ/zwU4ty7 zvfazuSdf9bHeqXuCU0QU3mGbtAlo+bk/1hHDbJwZJ13qe+B/QKbkcHEL7HqkhA0ma77 I4in/aA+W3QVkCT35EOAI8Dx9y2JZEEp/UGMwg6tnlT0tlXBD7v5rAxrBswx04sOFQw9 3L8Q== X-Forwarded-Encrypted: i=1; AJvYcCVE/ZZHfl655sKJxsr5ywfiOujUyBYmF/fY5e1LEwxo9Fm7oD9p/F61yjhORs95EjLXJKxWHxSqrXE8NJ8+CNuTN5R4L2cwB9InagE3 X-Gm-Message-State: AOJu0Yw0D9TSPq1OliRLODnDF7oYl0oVFDrupig7VkS+2tcFWZmTcpm4 hEDkKabvPliRs8u7gFAZqudsy4LN9g4NjZEz8eM+cnc81Hu4TrFfGGuGxVPmVTBBHvaZV8IA8I/ tdQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:c40d:b0:1eb:4c47:3457 with SMTP id d9443c01a7336-1ef43c0ffeemr27830225ad.1.1716250895850; Mon, 20 May 2024 17:21:35 -0700 (PDT) Date: Mon, 20 May 2024 17:21:34 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240518000430.1118488-1-seanjc@google.com> <20240518000430.1118488-3-seanjc@google.com> <78b3a0ef-54dc-4f49-863e-fe8288a980a7@intel.com> Message-ID: Subject: Re: [PATCH 2/9] KVM: nVMX: Initialize #VE info page for vmcs02 when proving #VE support From: Sean Christopherson To: Kai Huang Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Tue, May 21, 2024, Kai Huang wrote: > On 21/05/2024 11:22 am, Sean Christopherson wrote: > > On Tue, May 21, 2024, Kai Huang wrote: > > > On 18/05/2024 12:04 pm, Sean Christopherson wrote: > > > > Point vmcs02.VE_INFORMATION_ADDRESS at the vCPU's #VE info page when > > > > initializing vmcs02, otherwise KVM will run L2 with EPT Violation #VE > > > > enabled and a VE info address pointing at pfn 0. > > > > > > How about we just clear EPT_VIOLATION_VE bit in 2nd_exec_control > > > unconditionally for vmcs02? > > > > Because then KVM wouldn't get any EPT Violation #VE coverage for L2, and as > > evidence by the KVM-Unit-Test failure, running L2 with EPT Violation #VEs enabled > > provides unique coverage. Doing so definitely provides coverage beyond what is > > strictly needed for TDX, but it's just as easy to set the VE info page in vmcs02 > > as it is so clear EPT_VIOLATION_VE, so why not. > > > > > Your next patch says: > > > > > > " > > > Always handle #VEs, e.g. due to prove EPT Violation #VE failures, in L0, > > > as KVM does not expose any #VE capabilities to L1, i.e. any and all #VEs > > > are KVM's responsibility. > > > " > > > > I don't see how that's relevant to whether or not KVM enables EPT Violation #VEs > > while L2 is running. That patch simply routes all #VEs to L0, it doesn't affect > > whether or not it's safe to enable EPT Violation #VEs for L2. > > My logic is, if #VE exit cannot possibly happen for L2, then we don't need > to deal whether to route #VE exits to L1. :-) > > Well, actually I think conceptually, it kinda makes sense to route #VE exits > to L1: > > L1 should never enable #VE related bits so L1 is certainly not expecting to Not "should never", "can never". If L1 attempts to enable EPT_VIOLATION_VE, then VM-Enter will VM-Fail. > see #VE from L2. But how to act should be depending on L1's logic? E.g., it > can choose to ignore, or just kill the L2 etc? No. Architecturally, from L1's perspective, a #VE VM-Exit _cannot_ occur in L2. L1 can inject a #VE into L2, but a #VE cannot be generated by the CPU and thus cannot cause a VM-Exit. > Unconditionally disable #VE in vmcs02 can avoid such issue because it's just > not possible for L2 to have the #VE exit. Sure, but by that argument we could just avoid all nested VMX issues by never enabling anything for L2. If there's an argument to be made for disabling EPT_VIOLATION_VE in vmcs02, it's that the potential maintenance cost of keeping nEPT, nVMX, and the shadow MMU healthy outweighs the benefits. I.e. we don't have a use case for enabling EPT_VIOLATION_VE while L2 is running, so why validate it? If whatever bug the KUT EPT found ends up being a KVM bug that specifically only affects nVMX, then it'd be worth revisiting whether or not it's worth enabling EPT_VIOLATION_VE in vmcs02. But that's a rather big "if" at this point.