Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3793150pxu; Mon, 30 Nov 2020 10:20:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoOxI9KZhRxIzo74K3M+kkpDG1sxZeqGa1NYWXnDW5bxVeFVc5Vd2/yIbkMBE4PnrK9TU+ X-Received: by 2002:a17:906:5002:: with SMTP id s2mr4205859ejj.16.1606760404813; Mon, 30 Nov 2020 10:20:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606760404; cv=none; d=google.com; s=arc-20160816; b=Ns/qN5IJM6pdIhtBmWdYzRXGNsSmp/ocf5MNvvfv7iy43Cz0wSEI0FK9nb1G9GQ3cJ atXrr/nDCgCBXcZFXZ7CpmrtmOJcz/1ywoBntweW+RDsWfMzfkeZfpcgJe1TjYkdy5mv h4H3LOv88JZVUd7hvLQucyDI7UZI3N2JvWk/enQR/078i/uJXCvw0LB0owMbBBFdy1Qe rmTwl1DhZKgPzqTLiz8xL1SikjBncoSz6m7OFMM7uTl+gy9Zku9XBXKvqc7AZF1N01X9 6RsS6r+wQMhJygqV14GOoleMdHG9PMHhX/qi/occc64+FEjYVVzrrXKc67HeySv3WJVU Rs2Q== 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=Qxg9fj+0XCIGonLy291dTMO3lLUWRmtT3yL5N2eRulk=; b=sTUTo4v2XHm7rpYfOcTgi1RUchGk9eeYla3BeAQ5iEkkRFfdPF3rg7vhtSDCWqpuUO tp8fEqbUSw0dKIlGgM7SYW/Jvv3IgMeIr1vCNSlIeEnRZC+3d1EP2wnQU9gvjqV3o3Pa FkbcID1+6wXSqbOZ1NyDLITfa1eZcqq6ZjRJUL1kaYUCkyOa5W0GY37NRKPzNpNflvqC 5PiCs57wjAYmRVSnClPfBdK+5zTmVeSdvk2mC8K7rpArwdmdlvGCWmoLSSeBB3Hih8Nc 8KurkZfVXdHqYHjYpWX1rh82gbrF/2NQAdmg0tj6iyV2hBh6Tcx3CztLML5KAgRkwzZj O5NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pxwOMjeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si10055357ejh.425.2020.11.30.10.19.37; Mon, 30 Nov 2020 10:20:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pxwOMjeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388017AbgK3SPS (ORCPT + 99 others); Mon, 30 Nov 2020 13:15:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388014AbgK3SPS (ORCPT ); Mon, 30 Nov 2020 13:15:18 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281A4C0613D2 for ; Mon, 30 Nov 2020 10:14:32 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id e5so81878pjt.0 for ; Mon, 30 Nov 2020 10:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Qxg9fj+0XCIGonLy291dTMO3lLUWRmtT3yL5N2eRulk=; b=pxwOMjeOK6XW/T0vsBXN9b4un8VB0QjBPH+3KbpEs7wEDpetbEvfGEBtN+T8eTjB78 jABD75yAkF33MXZVRACJUvelYVjEbwB5rHV4+ik0GMOlFGO1Yn/Dn1cNoprvwrUjnlKD RQ35XzWl96elMe70F0KpoZ4PweCTg9UNfI8Wixfuc7dQvMaikI5qXCE1uLFIomcaUrQ2 r5lhPZdLjJ8g38g2ScLXWr5KHEpk4ub8yAGlWQ+h7g6X7TNxC3kzsub602ei+2ejxpSA OSF3hvLFxE1au2XKip/+jWaiUQeHsRs/FwEkDgp2sVOFXGSoZT1HbcwyX7lUhS9BenYk UD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Qxg9fj+0XCIGonLy291dTMO3lLUWRmtT3yL5N2eRulk=; b=fsuxyk72MJFuKLdbLAlzGdAOayCM6lrtuin3M5cHMB+kXI2NDeT0TiBjCrIxrsAwV3 fIxuOFESiIeHGbGf5sMu2EWsLEEPQckkfvtnAt+l9/HVTGBqeOCUQnxzxz7kCsWJVAZs ztYuYNpBErAbUFmuUfnGKYzJZx5P/T6t3rEx8tqbuMDoUvO2k5O1f31sg0HhEiWhQUX6 HhGE20VFcYOPRxj6t808sYDYUCQQDMWxM0rYgCRLNBXnvLY7ffBCKt5B8VgNLj7X7WyT 7vPbQP+H5g7i0H8rrDpeQsOOPL9FwDQ3AyXDLVxO4iIkbxi0mYNWu2gVPdiM3z1H001L 63fQ== X-Gm-Message-State: AOAM531waXx6kECKmMh5ZdA3LGxI1Dv2DeEb0oaeAnsNJk9DdR+xotT+ ouBIr9zKwnuJCl3lR5puQmBMxA== X-Received: by 2002:a17:90b:19cf:: with SMTP id nm15mr35878pjb.63.1606760071602; Mon, 30 Nov 2020 10:14:31 -0800 (PST) Received: from google.com (242.67.247.35.bc.googleusercontent.com. [35.247.67.242]) by smtp.gmail.com with ESMTPSA id e1sm17255827pfi.158.2020.11.30.10.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 10:14:30 -0800 (PST) Date: Mon, 30 Nov 2020 18:14:27 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: Tom Lendacky , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Jim Mattson , Joerg Roedel , Vitaly Kuznetsov , Wanpeng Li , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Brijesh Singh Subject: Re: [RFC PATCH 00/35] SEV-ES hypervisor support Message-ID: References: <20200914225951.GM7192@sjchrist-ice> <20200916001925.GL8420@sjchrist-ice> <60cbddaf-50f3-72ca-f673-ff0b421db3ad@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60cbddaf-50f3-72ca-f673-ff0b421db3ad@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 30, 2020, Paolo Bonzini wrote: > On 16/09/20 02:19, Sean Christopherson wrote: > > > > TDX also selectively blocks/skips portions of other ioctl()s so that the > > TDX code itself can yell loudly if e.g. .get_cpl() is invoked. The event > > injection restrictions are due to direct injection not being allowed (except > > for NMIs); all IRQs have to be routed through APICv (posted interrupts) and > > exception injection is completely disallowed. > > > > kvm_vcpu_ioctl_x86_get_vcpu_events: > > if (!vcpu->kvm->arch.guest_state_protected) > > events->interrupt.shadow = kvm_x86_ops.get_interrupt_shadow(vcpu); > > Perhaps an alternative implementation can enter the vCPU with immediate exit > until no events are pending, and then return all zeroes? This can't work. If the guest has STI blocking, e.g. it did STI->TDVMCALL with a valid vIRQ in GUEST_RVI, then events->interrupt.shadow should technically be non-zero to reflect the STI blocking. But, the immediate exit (a hardware IRQ for TDX guests) will cause VM-Exit before the guest can execute any instructions and thus the guest will never clear STI blocking and never consume the pending event. Or there could be a valid vIRQ, but GUEST_RFLAGS.IF=0, in which case KVM would need to run the guest for an indeterminate amount of time to wait for the vIRQ to be consumed. Tangentially related, I haven't looked through the official external TDX docs, but I suspect that vmcs.GUEST_RVI is listed as inaccessible for production TDs. This will be changed as the VMM needs access to GUEST_RVI to handle STI->TDVMCALL(HLT), otherwise the VMM may incorrectly put the vCPU into a blocked (not runnable) state even though it has a pending wake event.