Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp23668pxh; Thu, 7 Apr 2022 12:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0jYSLAIpWYjA7ATibfbT8PVm5Fciw9XTRcv4I26qeyPVypr7eBIfOaWuJNQSZHIwA8blo X-Received: by 2002:a17:902:8490:b0:156:7eb1:33c7 with SMTP id c16-20020a170902849000b001567eb133c7mr15556725plo.39.1649361010096; Thu, 07 Apr 2022 12:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649361010; cv=none; d=google.com; s=arc-20160816; b=dk5TfEEsMwbBC7hRk+BSph4FTKaQ18OxuDaK/nI9LN0GidtdMN5/bQRbqTJpb6HlpY VAWSdQZOu4D9mH1VhSwAzUH/UTaJxJpz+U6xMP5X1K6oio+4SNWNEysQXsznxDPdq5HD gqEuW1vr1JN3CoA37NFTT9AR311R/zxcmnbPE1USeZkjn6EOcDhJVak5s62KfNYfBNgA Go6hLqyBzj9Zk934KsMmNLrZVGNDJpiFSP6otWkLQ3Uq3V8Kv1RamIZwLuYopnHoZOAP GmNSkvGYNUVcjB4N21iRtpBqRGF6jCoECj0cVpo7m3bVhze5dwX7fKFzlZ2aTCZ0fIAy OLQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xEawbGCu7y1vIILENYYhWZ3wFJRgV8eFUGqPfSyynR8=; b=k0ohBMR8XHLRGhles9F81SkuyZ7aEvhBXa7koJqlBsklqlKy+tT9z9dv9+UP0v+F+7 NxWoqvvbYPB9uQKG0hTgfMcIOBc1i9mL2iOeCwc7gfu+99QgpYk+7KHNHg0NIdd0ISc3 1KjnBnSCD/UGfl5xEgGaXsEth7I1K4YY9GQhJrV6Te68oy0Af22yro59eRnWH6EGuvG5 UJSSDJFrpgTKLET7yEY8IZZP4lpJz1NUvGYcXB3RqOJrPdWXFCkuHBh3hRJxAgN6e12v i7BkLe7Hf7v3E0q/o+czGNSnHx0n5H2vNGtaguHcrWzSdfM2q9MNk5hoOYaKaqKJEYWA 1JVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kT7UcNQE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id lp10-20020a17090b4a8a00b001caa595ba18si2976939pjb.118.2022.04.07.12.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 12:50:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kT7UcNQE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 041A02675A9; Thu, 7 Apr 2022 12:21:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344391AbiDGPEg (ORCPT + 99 others); Thu, 7 Apr 2022 11:04:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344385AbiDGPEc (ORCPT ); Thu, 7 Apr 2022 11:04:32 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13BEB07 for ; Thu, 7 Apr 2022 08:02:31 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id g15-20020a17090adb0f00b001caa9a230c7so9098695pjv.5 for ; Thu, 07 Apr 2022 08:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=xEawbGCu7y1vIILENYYhWZ3wFJRgV8eFUGqPfSyynR8=; b=kT7UcNQE86YbVV1ncLaMb3kTbBan1KlOCH/D3jXUD7/D0gtfwONcVekSrOn56tAvwY NzoNtHDIcwJnSaSR8hcCkG5et9Ikuwekgq65+M8l4hNJMUFb2v3lQn8N9GvVvg3GOnXO EqBKpyWvDn10RTyGuD5hl/4pmjBSIq3jsij3qiing91l9We7zb4r+3ig2ekGsiU9yee9 A80NB+vH+JkfN4VObloBwtVrPR47ap2pWplyKBdaDrs8r9vmjqXjJtNc7hco+YBo7X4H oKFqFqF7WudSWyFQr/7gIFKufOD6vG479hHGkt1RsKpm18fQQ24ahiQ3t36iSf9Kh4VR itiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xEawbGCu7y1vIILENYYhWZ3wFJRgV8eFUGqPfSyynR8=; b=jOiYpIOKC8gfu1FQLN9ODBZwqK5z31YNc1VOnxygsr2zUMcBTZlXBJjAL1VVnhzyss 4Pr/TZdz5MvdK7xU7pmokF0xOnUxuLMAgtsCE+zLlEOx93evNcG0sz7v1ICJCiQ+5fnn n85w7GRYsJ7993qtt9BsRl58K06PlMhnFMvzc8ZAGESDleyLplaKxi7RIFMfMyoNtL+y 1eTEUThCfBdI8Zbm64tMcTIQqpsiegblb4oxgJduJH23k8+zhi0UKd/S9UATCXnGeZjO FkfJX3TH5XUH/5rhbUiTkYUvQ9Vii6UbR7FcKIZ4S8jFocUdHkoQaKopl9MXHhc9BPXd A39w== X-Gm-Message-State: AOAM533aGQ/RTn1I0ownaCUBUkNqGGnoQZlJk/ssCR1y4BFCKal0dDKJ q2Y/3I28NFlqFVFUv+BSOKlOovJwYOHOuA== X-Received: by 2002:a17:90b:250f:b0:1ca:b9fa:efcd with SMTP id ns15-20020a17090b250f00b001cab9faefcdmr16486299pjb.123.1649343750979; Thu, 07 Apr 2022 08:02:30 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id y16-20020a17090a6c9000b001c993d935e7sm9487387pjj.56.2022.04.07.08.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 08:02:30 -0700 (PDT) Date: Thu, 7 Apr 2022 15:02:27 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl Subject: Re: [RFC PATCH v5 092/104] KVM: TDX: Handle TDX PV HLT hypercall Message-ID: References: <6da55adb2ddb6f287ebd46aad02cfaaac2088415.1646422845.git.isaku.yamahata@intel.com> <282d4cd1-d1f7-663c-a965-af587f77ee5a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <282d4cd1-d1f7-663c-a965-af587f77ee5a@redhat.com> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 07, 2022, Paolo Bonzini wrote: > On 3/4/22 20:49, isaku.yamahata@intel.com wrote: > > + bool interrupt_disabled = tdvmcall_p1_read(vcpu); > > Where is R12 documented for TDG.VP.VMCALL? > > > + * Virtual interrupt can arrive after TDG.VM.VMCALL during > > + * the TDX module executing. On the other hand, KVM doesn't > > + * know if vcpu was executing in the guest TD or the TDX module. > > I don't understand this; why isn't it enough to check PI.ON or something > like that as part of HLT emulation? Ooh, I think I remember what this is. This is for the case where the virtual interrupt is recognized, i.e. set in vmcs.RVI, between the STI and "HLT". KVM doesn't have access to RVI and the interrupt is no longer in the PID (because it was "recognized". It doesn't get delivered in the guest because the TDCALL completes before interrupts are enabled. I lobbied to get this fixed in the TDX module by immediately resuming the guest in this case, but obviously that was unsuccessful. > > + details.full = td_state_non_arch_read64( > > + to_tdx(vcpu), TD_VCPU_STATE_DETAILS_NON_ARCH); > > TDX documentation says "the meaning of the field may change with Intel TDX > module version", where is this field documented? I cannot find any "other > guest state" fields in the TDX documentation. IMO we should put a stake in the ground and refuse to accept code that consumes "non-architectural" state. It's all software, having non-architectural APIs is completely ridiculous.