Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp358578lqp; Thu, 4 Apr 2024 15:57:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUl/AjwNgIVx+QKHYnQXS4mI8YI10bkOpCmYDn1q6T6bcV+mt0Xt9tVecbUjSuhKEVcZ5cUQ3wGJymSVhW0obWOGqK7UkVQiIEvWk3GcA== X-Google-Smtp-Source: AGHT+IEuSJED6fcIaceSElS7akFFlXEMbs+n3YynZqAm7WKoSa+pqRA+G24upLV406kGIZDH8a+3 X-Received: by 2002:a17:902:d506:b0:1e0:cdbf:24c2 with SMTP id b6-20020a170902d50600b001e0cdbf24c2mr4739581plg.29.1712271473904; Thu, 04 Apr 2024 15:57:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712271473; cv=pass; d=google.com; s=arc-20160816; b=IpMYgUcYnZ3r43J6iom0mLWvILpqRCYSzaPFz6eWdxu4E7pPPj8NRWvkKIXY50hmPb cEz8dr0ZcCxRnpWroD+CS3M2ZL4V5PuBIXvh8lnftQEWpZUtW1iN6Ot8LqGcUq1/wPRY WbVRAWUFvkcyrKiDHNhUeG1ZsiLYgXJTeIq6L8GlWBFbsfs5rQMNdqK9QQ796G1lAMg/ ZQUmlPn5/bOw1/AQ6PeOLO4l04xBrGaVZw7jdHr3uBtw2IfOFU34VkPvk9VYFOLLRcxA Vb4UavJFGd4XQ9TRSL6IgcbPUA8ZCwKDl5Yvgeuqkt3fCuZX+yhLIxx1N27jhzeov3t9 p5Ug== 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=lsOQoN7hxmCV0LDs2mMcH4xPxMzlScVQ7Q1vgpJyJKk=; fh=XIL7v27eUao8LpD5Dmv0wihkIRPkj57G4XLUbgmv9To=; b=uQER50uGTsS7IIEVK4457pJfxKj+2hcXXJtzP/dx9WgVgTdCS0wsFZ+K2ZNwH4U83I 6oPndDRL622TaP0ZPpq08wNELWqflpEsh+NQlt/mO99BJ3M8IFhVzDFlCN91Abq3boVa +/QG7/r1/rR9Ct6OM6qoDLBjV51eCR95AeRJVpocN3p39FLteW77gtvxmG0X0qn2Z35c B+/tBSHVSzYVbu4pLXQoLUtAwxBfJptz1VXOc+s8LOuAFqGN1al4B7iD9900igOpB3L8 HJHVGBjU7oIPtQZbenjAxAUK9dTz9pDggQT/+kNuARb18LLAgIFiOj+BH7xADa1XVBqW XKQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rlZVHMZ5; 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-132218-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h7-20020a170902680700b001e0f36613c4si229982plk.498.2024.04.04.15.57.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 15:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132218-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rlZVHMZ5; 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-132218-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132218-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 56CC1B224D4 for ; Thu, 4 Apr 2024 22:45:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81B7971723; Thu, 4 Apr 2024 22:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rlZVHMZ5" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.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 4A83E6FE04 for ; Thu, 4 Apr 2024 22:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712270739; cv=none; b=r/IRsKdwyq1M0SHvTKS5xtFANNh9KUYxUATPnF0EXVhhuZnP/iwLGTY3ZubgeLOhK+henQqZbMBcFCCB5rOp4f1ciOB8OYMcKtdmqRE0ZD6iuPcs6DcHE6TRsOCUvxs5kLQA4dh+YQcEZPaCTSiFXhNR/g1kVI7o5QiwaSjrroE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712270739; c=relaxed/simple; bh=MUx2dwxzhoYs9ch7Wt+3vyW6IzeDkamXK5A2n7Xd0fQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hFLW+8Cs33bPy7KTt53Lf5hMrGCTXaO6DBwOLAy0pfh0EyyrnW0l+nY6btowW0inZaJ5oY/E4Y2VVFh+DUoiAM8Jj6R5qX6nO2zvCVu7UWOPYFo/Pt6uEHOyqnlr/VZPK4NSfkPdoMUEShP+yLaoWjnGlGeOI6KbUZZIjA2cBkY= 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=rlZVHMZ5; arc=none smtp.client-ip=209.85.215.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-pg1-f201.google.com with SMTP id 41be03b00d2f7-5dcab65d604so1264628a12.3 for ; Thu, 04 Apr 2024 15:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712270737; x=1712875537; 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=lsOQoN7hxmCV0LDs2mMcH4xPxMzlScVQ7Q1vgpJyJKk=; b=rlZVHMZ5nkCmofPXmmi5kTjbSpLrvOq/byimfIOESIbpsiotgBaEyJ0KkSol1Q4Yxl TXCtLx2omC+oJSC8zjG6u2g2XRqcOOkZNO/lupWYIiUnTnEdro5ShxZoupBwG5OyGP58 2Sx8wSvr8QKAivlYwg1iQBmKCzTRzh5GPyhk3o92tZb1diLRU3a9PeFylHfWmDztp/Sd DkraUMslxAm7dWcF6ctGelMOB4lwE2kaKJA2+9poXjid/4i5q9F6A8hvkMbwrjch1Oks jNrmyxyN5upAODQj5Y45G1YPiJpmp8k3qiB5fPdNKZpJlBuIWxdZoMr61AOVDf1h471O 72HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712270737; x=1712875537; 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=lsOQoN7hxmCV0LDs2mMcH4xPxMzlScVQ7Q1vgpJyJKk=; b=OUDAE3ylo872VKcCVWcuXgv+ezqvaayk5EX6kQ54W4rXOyF5aa+kutMT3L/jFsMc33 HaVHQuR607LFJwU2/pEKgW8qaUvH15y7VRMh7dTYOjhP9VgvpaMf7CP9GH3kgd0s3323 4Olvo4b1Ap0cEePOLqFMvRbD0zM9RcuOHo/KHQFKsbzx5TnNyVFUxSY88cqRLbNZbNmV +0Cpc1hJ7ZQy8LMHv7VrPJHlt4nTurIwwgn0v3vIgR39hKqVDCVvTqaUKoWB7BjwxsTn nECsW2n8I2QWyDGgX0SNahlmgIUwTL6VvST+aRbkm5x8IbRDoJZs3fE7hhEr9x4bKV+d 2smw== X-Forwarded-Encrypted: i=1; AJvYcCXR5wXx6WlDpnHdvFQl/bTfmQ2iWIQ46L2gdEChq8NW5DMWF0K9H3xe+ggO2zfloL8wkwMJXKZFCLecip4NAofCLP8eTP5vDZe++1h6 X-Gm-Message-State: AOJu0YwK5uBXMcjjQCfwvMXJHEhSgP3ODDGREwNVkIwUh2RG95uHI9D/ 5/orZzcpdD9eqetFhEjRHFQbv0ONCSwDnzwGOMUXiRSHukjwZ7KBWXJoZ8mTpgLJxPIZs0JzFQs ycw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2282:b0:1e2:b75e:37b5 with SMTP id b2-20020a170903228200b001e2b75e37b5mr2512plh.2.1712270737181; Thu, 04 Apr 2024 15:45:37 -0700 (PDT) Date: Thu, 4 Apr 2024 15:45:35 -0700 In-Reply-To: <1f30ab0f7a4dc09e65613f6dc1642fb821c64037.camel@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <1f30ab0f7a4dc09e65613f6dc1642fb821c64037.camel@intel.com> Message-ID: Subject: Re: [PATCH v19 078/130] KVM: TDX: Implement TDX vcpu enter/exit path From: Sean Christopherson To: Kai Huang Cc: "kirill.shutemov@linux.intel.com" , Isaku Yamahata , Tina Zhang , Hang Yuan , Bo Chen , "sagis@google.com" , "isaku.yamahata@gmail.com" , Erdem Aktas , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" On Thu, Apr 04, 2024, Kai Huang wrote: > On Thu, 2024-04-04 at 16:22 +0300, Kirill A. Shutemov wrote: > > On Mon, Feb 26, 2024 at 12:26:20AM -0800, isaku.yamahata@intel.com wrote: > > > @@ -491,6 +494,87 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) > > > */ > > > } > > > > > > +static noinstr void tdx_vcpu_enter_exit(struct vcpu_tdx *tdx) > > > +{ > > > > ... > > > > > + tdx->exit_reason.full = __seamcall_saved_ret(TDH_VP_ENTER, &args); > > > > Call to __seamcall_saved_ret() leaves noinstr section. > > > > __seamcall_saved_ret() has to be moved: > > > > diff --git a/arch/x86/virt/vmx/tdx/seamcall.S b/arch/x86/virt/vmx/tdx/seamcall.S > > index e32cf82ed47e..6b434ab12db6 100644 > > --- a/arch/x86/virt/vmx/tdx/seamcall.S > > +++ b/arch/x86/virt/vmx/tdx/seamcall.S > > @@ -44,6 +44,8 @@ SYM_FUNC_START(__seamcall_ret) > > SYM_FUNC_END(__seamcall_ret) > > EXPORT_SYMBOL_GPL(__seamcall_ret); > > > > +.section .noinstr.text, "ax" > > + > > /* > > * __seamcall_saved_ret() - Host-side interface functions to SEAM software > > * (the P-SEAMLDR or the TDX module), with saving output registers to the > > Alternatively, I think we can explicitly use instrumentation_begin()/end() > around __seamcall_saved_ret() here. No, that will just paper over the complaint. Dang it, I was going to say that I called out earlier that tdx_vcpu_enter_exit() doesn't need to be noinstr, but it looks like my brain and fingers didn't connect. So I'll say it now :-) I don't think tdx_vcpu_enter_exit() needs to be noinstr, because the SEAMCALL is functionally a VM-Exit, and so all host state is saved/restored "atomically" across the SEAMCALL (some by hardware, some by software (TDX-module)). The reason the VM-Enter flows for VMX and SVM need to be noinstr is they do things like load the guest's CR2, and handle NMI VM-Exits with NMIs blocks. None of that applies to TDX. Either that, or there are some massive bugs lurking due to missing code.