Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1425029lqh; Mon, 6 May 2024 07:25:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKJtEpsPLuJogIJSNjw7dN0UoHKQV2dTYhcKyairyKhftkX2cT5oY2feqcOO74nK1+vofRklDDgY6Ga8yAOt4bAXNdaw+wOOgxt2eSwQ== X-Google-Smtp-Source: AGHT+IHYw2jSSB8fZixlqI0KOotzLACzajcrg0tJxf8dhNVN25jrK+d+v9eN8RioZgiilvft6ceA X-Received: by 2002:a17:907:7f88:b0:a59:c52b:9936 with SMTP id qk8-20020a1709077f8800b00a59c52b9936mr3459370ejc.26.1715005527771; Mon, 06 May 2024 07:25:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715005527; cv=pass; d=google.com; s=arc-20160816; b=kyQgMQXzDADRr/FIfD0MSWiZn0NhFZa6PGs1Daj4CIvcjraJbUh6s033gFIR54pHke pvEhYoZeqsA8t4ExRmxHAWpRTbk51aOnNzmINMUDe7UhsjnameV2brZH2atGsVQ2TddU N4OUe6tFGjJhyH7G/aNZHHvAT488UjU+t7TBa/Dob+Xu5/rrTEsrH//yKK/myNoOpY8w VfFeJ69+sID6iRbd3+5tbF1ct+xdAWQYSOVBAqSLaBfmwrD6vnOUOyBWiDbfr09h2JHw qnHCmlX2ux5ypQUjpGppTXW20wkjz6BOEWJK1CtZ7qSlKhV8YKByQz/MpYZjUSZ3ZPY3 nSIw== 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=0tD0TbCxCaI9AdeqFysPl2S3AZ8t1dkAhioOOzzL9ik=; fh=6Idi0FYUQdBbMoWikUajX+zG4NZW7tzAI+sTWXU/vOM=; b=wUqY+dkfJpU+ZuP6XgIm4k4BwaPF/NeNOqOS69I5skZ6T++sgL3q+Fod7/+cOTB0uo qBfVBub+/+pWy26fqotGlqeORgtkmZAiqM7qjafAIGCk9SeEzSdpjJ2+YgzamDN2UeJr UWmIQwCUMu0m1Q8mfSGzFq2iv35Dyu9LFLoBRJForaj8h2UQcssbzn0PV2lRBQTVGXNQ BQz4qxBRH+m6dGDc8kf1WxyxmmpxL3+OYXB0IUychPRRF1GSyOW6dZnNoOWCBG7t7x3p SdgMlofRvSXGhvkqJYy8uwJC2ixQvFzJHGjIqgfS/XqDAOa3Kaxq5uNrZDFNaHqwq1iH nH8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vrUEveH+; 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-169983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169983-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 t4-20020a17090616c400b00a59a3523c01si3065881ejd.405.2024.05.06.07.25.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 07:25:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169983-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=vrUEveH+; 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-169983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169983-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 57BA21F25D5A for ; Mon, 6 May 2024 14:25:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5708613F426; Mon, 6 May 2024 14:22:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vrUEveH+" 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 096A913E41B for ; Mon, 6 May 2024 14:21:58 +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=1715005320; cv=none; b=DRXQrXClQijP998tGaBdMSxkNT4AvwtuuE+KKgdbZtChWOenIatsOzHC2HlTCESYlR6KDZw1ze7Xz9SDjNlFRebc34IwgUP27u0UtyKy3ZZ7TbXXnQ8+xNENWSjlDnZFoyz0MsX1YOzBN1gEVFaLq1jTj/kXwZrcrwKDjbj0uH0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005320; c=relaxed/simple; bh=5uhwdi1y3SDOCg/HBqp8e6jB1UB0i90gEw/5RzowvJM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nh3V4acwkDKJndSBQcHKYW6PRryKekpPXUdbvubsCyWla1k8NX50FTcArJT53sfzCc7xjAoxZQ4Ic+RVC6qIw8HzzIIVSYH52gTmlPzx0riCZSbO9XvoCHRlCEza9M2A1EmCM7rvX6S1OcL9weXMIb65EgJUM1pryTjI4PG6BXo= 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=vrUEveH+; 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-1edf507b9e4so13723105ad.1 for ; Mon, 06 May 2024 07:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715005318; x=1715610118; 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=0tD0TbCxCaI9AdeqFysPl2S3AZ8t1dkAhioOOzzL9ik=; b=vrUEveH+dbuA5Q5+xTI7Kbda01r6wK1iMzYHtdWsKeoAct0iUw/SK/eA3hRq7Kn9IO TJwADM+ztefEz4DDTIMrTJSrDCwKoj/ANZDB650JhW9cy4K9iOdB+t0/P01aYHzXEvF0 rPYoc8PYHcja1EWrvOPOoRjLdjvmWDqO737nH/7HWQSnYi+5jNkmu+ND4DU7kT3ihioM KFiorzhU8F5QLmJT0HRMAjW6f4VbQJxykV6/AUrlqjfaD7cbUjlar6D9chdVqI8QRvTt pAJIApmlhFJJ2iNUgnfeXyCKk9RW68qF8Hyi7vGrtNwOqu81CrKFP5wIp6sqYL6ZfAF0 9IFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715005318; x=1715610118; 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=0tD0TbCxCaI9AdeqFysPl2S3AZ8t1dkAhioOOzzL9ik=; b=wgBiiNNJS0PPT/lBkObswv+tpaPRopWot/qtAWLKgOdBaowoSE0zup/pSv39MMG5AB L6iXB/VwS2px8Hi9PZzK4z6loRaZQV2gnrjus1Wpu/h+GqDGSlMhqlgGhI6S+2k+AA2P I8XKFLO41+Cjx9V23KAwyyRu2v3NEI53id4zSnGh4dXD/i6YhWH5fQqPkIxgsTTE+WP3 EUPkUe/ZoJf5NckKgfSksSHUe2LZtw/gkQ4v51KpuMSJmGIUC64ubXB6xFtONmVZ9O4q HeoBYz4UytNiOwMAOpRNjV3NLmJBKahaJ0wneZ29Begjzx4Wzpa8f22eviEf/ubJkV1+ o8Pw== X-Forwarded-Encrypted: i=1; AJvYcCXR5D9+i0QUEn0UwveVuYZmCgjsy8glMdYr4cOpfsaApgYqd8nqKwfTSLJwgIgpHqDolMx5N3j9/dvBUtJ0khW9vhtpx8E8FXBAXQxq X-Gm-Message-State: AOJu0Yxye8CYHLCJup6sf/C4qf4lhNw9zJXfiLPWdw6CakQ5I3SGuRk1 ssNxODwBhEfxSvEYYeXQNWuqhY/K2h3R5GtKaD7F2cqJYtm2lda4Wp5MjtpQOe0hcWsGwGf9pAy rkA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2352:b0:1e4:5973:dbdc with SMTP id c18-20020a170903235200b001e45973dbdcmr410280plh.7.1715005318377; Mon, 06 May 2024 07:21:58 -0700 (PDT) Date: Mon, 6 May 2024 07:21:57 -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: <20240403184216.GJ2444378@ls.amr.corp.intel.com> <43cbaf90-7af3-4742-97b7-2ea587b16174@intel.com> <20240501155620.GA13783@ls.amr.corp.intel.com> <399cec29-ddf4-4dd5-a34b-ffec72cbfa26@intel.com> Message-ID: Subject: Re: [PATCH v19 101/130] KVM: TDX: handle ept violation/misconfig exit From: Sean Christopherson To: Chao Gao Cc: Reinette Chatre , Isaku Yamahata , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com Content-Type: text/plain; charset="us-ascii" On Mon, May 06, 2024, Chao Gao wrote: > On Wed, May 01, 2024 at 09:54:07AM -0700, Reinette Chatre wrote: > >diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c > >index 499c6cd9633f..ba81e6f68c97 100644 > >--- a/arch/x86/kvm/vmx/tdx.c > >+++ b/arch/x86/kvm/vmx/tdx.c > >@@ -1305,11 +1305,20 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu) > > } else { > > exit_qual = tdexit_exit_qual(vcpu); > > if (exit_qual & EPT_VIOLATION_ACC_INSTR) { > >+ union tdx_exit_reason exit_reason = to_tdx(vcpu)->exit_reason; > >+ > >+ /* > >+ * Instruction fetch in TD from shared memory > >+ * causes a #PF. > >+ */ > > It is better to hoist this comment above the if-statement. > > /* > * Instruction fetch in TD from shared memory never causes EPT > * violation. Warn if such an EPT violation occurs as the CPU > * probably is buggy. > */ > if (exit_qual & EPT_VIOLATION_ACC_INSTR) { > ... > } > > > but, I am wondering why KVM needs to perform this check. I prefer to drop this > check if KVM doesn't rely on it to handle EPT violation correctly. > > > pr_warn("kvm: TDX instr fetch to shared GPA = 0x%lx @ RIP = 0x%lx\n", > > tdexit_gpa(vcpu), kvm_rip_read(vcpu)); > > how about using vcpu_unimpl()? it is a wrapper for printing such a message. This isn't an "unimplemented" scenario in KVM, this is a "hardware is broken" scenario. Just WARN_ON_ONCE() and move on. Or I suppose since EPT misconfig needs to do something as well: if (KVM_BUG_ON(exit_qual & EPT_VIOLATION_ACC_INSTR, vcpu->kvm)) return -EIO;