Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3854300pxu; Mon, 30 Nov 2020 11:38:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+Bzqt2MSgFkRwv5q2IDG7lLxkB3JpDtmpbCAquwQwg3UgfD1APfOHkwVV2Ua/k2kTtw/x X-Received: by 2002:a50:8f64:: with SMTP id 91mr23660105edy.310.1606765099345; Mon, 30 Nov 2020 11:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606765099; cv=none; d=google.com; s=arc-20160816; b=iLVPcQchFPAQmxMm/8fl9Xigcp5K3lLcM60XnZOHk+BDeCO9aFW2kURa2rcL6sbuII f0LQOXSFA0r+McrwAEpan4CCf6HAMQpLks/Z4f6y721gu9RRQw/bQ8b5bGThQHyBNqdz reRSAMEk5mPDykzAwQtSgZiRnD/pC5Vf8RsVK27hrPlgofWb1ZggvSB7e8GMgrZGhXgY hSlp2Bo9ZIyhbp6fRMVfdj2YEATrPjYd452SuvpoD+cRctq1ymmoa3uixTAgmPMUZmBW jdlHwneSlZOajFncNll2Z1FXJ6LV8hZ0uzjcfhInA7i74cMelMkesePXmKwdNsev9XAQ zNZA== 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=P2JAtkf1gp7Yf1H5qMpHVhFTHg5rB+CUXS9hxTq7SNI=; b=eHG/K4lz9K/UCaCuqeb6RIePuBcbV1xFMX9J5YSly49BwGhNkvil3061K2xnaknLbv qJsSRTKsj+4kxIztMZRc0dM2H8BLImWHeIS1zGUNQ45PkqJC8tOiU+V2GUjJPH0ZausO uDDW7dHY8oly+/YlMGjkCv3Nn7fj5QGnZ2USlRnM2OWOJTqQHUKLX6opyFN8uY6+AI3S 3O78H+p09ykembYqqEGV7q7Tj6MdMPX1P1tUii14ABw1uf+4oPGhL5jot6V+QGY8gT4V nil8oBan4wWYWktb3EurXf4MV58Ll1poGkijV+4/4EfAv7PpSlYi4Y9k7QB3VXiAaTv4 GMCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NxXmrbpD; 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 a24si12179270edn.327.2020.11.30.11.37.55; Mon, 30 Nov 2020 11:38:19 -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=NxXmrbpD; 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 S1729858AbgK3Tfk (ORCPT + 99 others); Mon, 30 Nov 2020 14:35:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbgK3Tfk (ORCPT ); Mon, 30 Nov 2020 14:35:40 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5CE2C061A4A for ; Mon, 30 Nov 2020 11:35:24 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id bj5so7058928plb.4 for ; Mon, 30 Nov 2020 11:35:24 -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=P2JAtkf1gp7Yf1H5qMpHVhFTHg5rB+CUXS9hxTq7SNI=; b=NxXmrbpDRHsldZTSsy0qE8vgOBTXLxOjMsnknxQQmDK3ngRn9DeklqrZntmKGe336V PYcy6x37/WGVPR99++qUet3IX2DSV8yQ86gipBOngnu8ogVhs/PZvb1tzSl1JLMcmOJy n9kvgQA9gderMszFPhEFdt2zyJfwiWDeQKqKdqhsj/QSn6lEN7lZ0v/WsMizgrFAO7L1 TYV+W7i+T+NkctnB/0dahbFAciISfVT99LNI/DJ+/cfVPJ5jDKhDSNljWuY92DEkSo5Z j6bE8j0zHFoVIQPX5U+UjzNuozZGfsAO5PK5BN/If6+oLq2Vb8sUQ1jDl+HpxbgczSqp JvKw== 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=P2JAtkf1gp7Yf1H5qMpHVhFTHg5rB+CUXS9hxTq7SNI=; b=EiJv+1PF1mEncudvmfuIIrZEz4UcMTKg3RbbUpEIiKFYqU2tXVUdetaIMuVvKiaXTP 0VE88GdPQzb1I4zIlEb86VdBIZZy3afEpMLX0p/dvk+xTpP1xBTrN9hChspZ/QvJ6ygr vq1HefyNddXSRD9pvkV28Zv4J5yKDVKGCt3l0DO99KthEdJaGlS11X4TQlPFUdBO5TRx d/TnkKaUtgL7Ua0tIaDulp+5Zi9/BDTJ5eF2YvcmEqhZEza0ol3h+biJdided3BBVG/u P2wcav6YltI1WxFdbLuGbeJ6/CWCzuYyrLrM8coFskX+A1c6+0A2M0FYrZxd2I4PiEZm wymA== X-Gm-Message-State: AOAM530qVheQmE9Mb5Fe6+Jkb9VzCHlXFqoERHhdMDiNuWgEHVxL5oqO XRo7NPtclrsP22TxLUTpxjZBgkURToDQJg== X-Received: by 2002:a17:902:8b89:b029:d6:df6e:54df with SMTP id ay9-20020a1709028b89b02900d6df6e54dfmr20239687plb.0.1606764924152; Mon, 30 Nov 2020 11:35:24 -0800 (PST) Received: from google.com (242.67.247.35.bc.googleusercontent.com. [35.247.67.242]) by smtp.gmail.com with ESMTPSA id q19sm17552238pff.101.2020.11.30.11.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 11:35:23 -0800 (PST) Date: Mon, 30 Nov 2020 19:35:19 +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 , Xiaoyao Li , Isaku Yamahata 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> <8759948d-aa0b-3929-bda6-488b6788489a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8759948d-aa0b-3929-bda6-488b6788489a@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Isaku and Xiaoyao On Mon, Nov 30, 2020, Paolo Bonzini wrote: > On 30/11/20 19:14, 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. > > Delayed interrupts are fine, since they are injected according to RVI and > the posted interrupt descriptor. I'm thinking more of events (exceptions > and interrupts) that caused an EPT violation exit and were recorded in the > IDT-vectored info field. Ah. As is, I don't believe KVM has access to this information. TDX-Module handles the actual EPT violation, as well as event reinjection. The EPT violation reported by SEAMRET is synthesized, and IIRC the IDT-vectoring field is not readable. Regardless, is there an actual a problem with having a "pending" exception that isn't reported to userspace? Obviously the info needs to be migrated, but that will be taken care of by virtue of migrating the VMCS.