Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp39008pxh; Thu, 7 Apr 2022 13:17:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylevTHwDUBoiN5my1r3CKeSjN1E8bcQ4Pv6JuLvrIFzsR0CJKSMln5czRO0pYdVjSfy4as X-Received: by 2002:a65:5247:0:b0:382:9715:44fe with SMTP id q7-20020a655247000000b00382971544femr12624778pgp.577.1649362642131; Thu, 07 Apr 2022 13:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649362642; cv=none; d=google.com; s=arc-20160816; b=lshy8YgeDZEAovxqznfAMvrpIua+veMoBCLBLGxwlcnm5LrKdtT+ZvnFp69LNI7QW2 KLkiO5+X7HsDyaOfqqHZ3jGpx68NjHykH3cuNUpT2VgfGsSxcLBG6XO/4wVpsfxzWSdD bkM1b0hUI34zvgEnDzgIHEq6oDtOGmru9MKGPTFMS5EQ59UYK13W9wDBnrIdE0nPHR8+ 8Vvub2KKImUpB6MoZwoZcR3n38Br2qMRTgzEtoHHlj0Ttg8BVs01PX0hkXxWOtcGOnUK Xq+ZJh/V0jZTKsSHuJxEVcjEgT0AjetsHwWwe7CoHlqWGB0lragUh0yOFTLmP5DUBmnZ r/cA== 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=hZYvN1HtpiMWFnNuQjMBXb03gZgQM/PZsPG90Kr0xZ4=; b=aARnYPQ8ORrE7i+MCHGZBQjFJY1OalaCrn73kBYiIcYjq7SojGYlHy8p4GPfrmc6r/ hHPMxRl+qv2f9dDabznRVWuGnlXclNWsxv8dxKsdrzjZ4u+I29yxxYUqszrJ/61UHvAZ Qj6NoZWwhrAfbDNSGcYDZ4ednwCXahpOuNGwz0AMs1iUa36jarlZKUnxuILlQKOFlzgF Mgpld8bejWNRHBQh9S1ugKlEnvCHeTKsDqW0Yf+S7ccK6Yq1vt54hnuZfp5VCC/Sh7xK qRzDDZ5Ej6LeoIhw64bGnCEyxA173qK1Wzql6DsBC9FNRAe3zRngOSmoG0WloenynF++ eEjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=G5m5k4vQ; 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 x189-20020a6363c6000000b003995a4ce0b9si9052305pgb.498.2022.04.07.13.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:17:22 -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=G5m5k4vQ; 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 1C57E30505A; Thu, 7 Apr 2022 12:37:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbiDGQKi (ORCPT + 99 others); Thu, 7 Apr 2022 12:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345797AbiDGQKf (ORCPT ); Thu, 7 Apr 2022 12:10:35 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C710A56F6 for ; Thu, 7 Apr 2022 09:08:30 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id z16so5869888pfh.3 for ; Thu, 07 Apr 2022 09:08:30 -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=hZYvN1HtpiMWFnNuQjMBXb03gZgQM/PZsPG90Kr0xZ4=; b=G5m5k4vQXUwL1k+L0eJSqU5MDgQfzgDVie8hMWVBvOwKPK0MPeq3Uw7smawUjYYmXZ C5VyAER0920ta43X8fpVnjeRGq5sHWMfWXgZrtQJKGED38+6CAnXw8jBo/5p2G/76qoO GD7j1kN3/HbBq9/VBZufLoXfI7gHFNN0iGxQeSERHEtWYsmiWdQOQfqrx79jV3ByWVId 58glwc+Myxl4sngQ6KXGcu9rMDrS3QDFmeK+zT3/xZakxZvFc0RT8prt99hyN0nCp5LT FJjYJ9uFnCbHmlOkhbIGkbXmLl6pAKGxpCV2+L6ECJ8cx/v9i2iWZR+XMworgwKI9dCG r7XQ== 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=hZYvN1HtpiMWFnNuQjMBXb03gZgQM/PZsPG90Kr0xZ4=; b=xI/F5Vo8LqsS/QB+8cp+nFeLsRVrU7c3B751qxV0wKpQEt9qhZCPj9uw9YtIHoaFK4 OiDpeDVEIm1ug4GZsMS5PXMhuyDyHQvhL3lYsrOlPxvDHOowB5R0pWSFRHc1wt5pSnZI HEyWpL8dA6QhCCKEfzg+F8u9kMhAYd7+oG5gVzAcNo6U7Y8lqfAqr0GNVthHptL209vx qwKm93nbcPif3VB2DpmBqhONjkraUyJ7MX+NaHTQZhERY7KpcfWziPIF7TvgFM9TdEev JqAF62+YLxMLksti+7LiTanAYzFM/pUKoHp3mhgBtnQTAn2QeiY0hjJKYRCkDJ+VmMyi 3MEQ== X-Gm-Message-State: AOAM532L1YzR9BY3hdTG7pRTh8z7zUeOGJUj6xncaad9E/EwR+AbGoIH PUQM8kcnxRAlBAFnSn4Qs87tRw== X-Received: by 2002:a05:6a00:2d0:b0:4f4:1f34:e39d with SMTP id b16-20020a056a0002d000b004f41f34e39dmr14947659pft.14.1649347709341; Thu, 07 Apr 2022 09:08:29 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id 83-20020a621556000000b004fe5d8c5cf3sm5054446pfv.156.2022.04.07.09.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 09:08:28 -0700 (PDT) Date: Thu, 7 Apr 2022 16:08:25 +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> <8e0280ab-c7aa-5d01-a36f-93d0d0d79e25@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8e0280ab-c7aa-5d01-a36f-93d0d0d79e25@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 4/7/22 17:02, Sean Christopherson wrote: > > 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. > > So the TDX module sets RVI while in an STI interrupt shadow. So far so > good. Then: > > - it receives the HLT TDCALL from the guest. The interrupt shadow at this > point is gone. > > - it knows that there is an interrupt that can be delivered (RVI > PPR && > EFLAGS.IF=1, the other conditions of 29.2.2 don't matter) > > - it forwards the HLT TDCALL nevertheless, to a clueless hypervisor that has > no way to glean either RVI or PPR? > > It's absurd that this be treated as anything but a bug. That's what I said! :-)