Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2702147imw; Wed, 6 Jul 2022 10:15:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyUJYrxAbVVAHooTD7lbVFf49nwYer7SxXet1xJ7KOT4tUJB0CpU+1BQK41Mcyb4F3fkzU X-Received: by 2002:a17:907:da7:b0:726:9c0b:708b with SMTP id go39-20020a1709070da700b007269c0b708bmr41154226ejc.595.1657127759365; Wed, 06 Jul 2022 10:15:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657127759; cv=none; d=google.com; s=arc-20160816; b=DLQHndzpfB3WMe/Kno37v0zwbIw36CYpfm08c8CMKuLRsA2ZiTeqQ3fs6Z6hwH3eXy +b66dgMWYJRLwLekLbiNsadHx6OzoEvx2upcuwbm1bNh3K5crQTte+Qeoeaqzb77VxaX RJpbtMFXAuOgcjZsSKDnnNdKY7FeohhtnSr6WH5klZlipJJW+0dxgqA5wS+tb81+tGC2 dAwHmms1h3Ic7B6BSa1wSghMN8BTfed0N4Cmg8hSP7bronbWl8vbciBE5Kt3v9MaGQqi X2dFfSIoEmo8MZNc3LIHnN1VQPkiqMUMLSiPz2z05hxQXHgSR8g5MS2V+W2Y4VC16CQf FvkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=mxdgugHFm61QnWsTGvwXhJEDhQIxbzyKJe6gVnyZ9vs=; b=aryi1UymdpqljwZxN/NaP2oSOcoumaTt8Crt7l53EzBCerKR3/r9fpf47QrsPeWze8 OaqjiB5VHJYDC94fk3PQmMBf8D5V3pd4pD56nhVawy+3Cj65z7bD+ZXCR27hPNbG3ITM TXbFhl008mbWUyXacJslDY+AnkDVmMm8U+bWQwjD6CRQ4L3ZPEiWH6Ys7aL2BZIh7BHG CDdjiPH0SRz2IZnJmb8E1Ma18Q0+oiRPh3CFM24falFYEMgOrcNW/BsrGXWeoVo+3zns JNOEDDFp1JEP5yGrgBFCYzAad7/J6l7NhM5e8eHgrHp2dKRBy9bdyqJF1I7tSihrvFRH IqEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=d0myfOqH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fk8-20020a056402398800b0043591428d2bsi153737edb.421.2022.07.06.10.15.29; Wed, 06 Jul 2022 10:15:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=d0myfOqH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232578AbiGFRN4 (ORCPT + 99 others); Wed, 6 Jul 2022 13:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233210AbiGFRNy (ORCPT ); Wed, 6 Jul 2022 13:13:54 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D8121928B for ; Wed, 6 Jul 2022 10:13:53 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-10c0d96953fso8596647fac.0 for ; Wed, 06 Jul 2022 10:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=mxdgugHFm61QnWsTGvwXhJEDhQIxbzyKJe6gVnyZ9vs=; b=d0myfOqHKv7z4m9YAIJf5wvcr7uG8MYKd3NTDLI12QlwayakyRAxJl1j+8cMZ0sZ56 201DIPhgtHGPMFW6Zii31tyyvcKDfufKxkB96/wFI9PgUInulMaV5u8y90T3MiVSbtc3 q6YBu8YTzozuF3c4jq96gI53G0w8Ztr+ln43h4YOki/8ZW/vMOz6M8l3kIzFF4LEGAHC FaIfrP36jEjkuNiy6bc0PLqPvhSHqINcnNx5LcmNdEfOsM9MPvyvnHnS15/UPLxdz5/v WLEGdgwfJLpypek5LUOCo+KA+/uJD6tgVM4WNG1zrolkVzIMcMWSRSvk6SCBGjSlBc6q h1ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=mxdgugHFm61QnWsTGvwXhJEDhQIxbzyKJe6gVnyZ9vs=; b=7ePnWS2xKnhkGvsUBqeXLrhGWms85HFJFRIvq6XhRrgdONYCoL2a8Hhbo6cw+itGkO x6DYiuI0j3jRNzBx23L0RE2y2cMWvxV3CiEGYc8ROqDrwwtcNYr2mkcQs/ufiXLxZqSi 3Gi+UgAApV1dBRJauwwGvA8URIqI+IIWggjtbsH3n/7RrIr7KqyRFyd75rbwowOA0+aZ 8WiUbcgfMicXE4xxQKBlhD5cUykneD8AphGtaoP7eQRNWlMCgpP0by1Pg2kEjLAxGrX6 EeRdA83UoEemkwmSxz4of+WUSNIYY3Af0h/Xsu19ClZANsB5MK+w4kuXJwYvC045kvNg DNIA== X-Gm-Message-State: AJIora956Lw0XtZgeNZt1dCnQ8D4Q92GqiGjddIN54rrr1JSE6qOyX4D 5nnHmyJ5LxL0/0CPkKvIHgUg0aygLtlDlQ/g+5IVJQ== X-Received: by 2002:a05:6870:c596:b0:101:6409:ae62 with SMTP id ba22-20020a056870c59600b001016409ae62mr26484802oab.112.1657127632275; Wed, 06 Jul 2022 10:13:52 -0700 (PDT) MIME-Version: 1.0 References: <20220614204730.3359543-1-seanjc@google.com> <7e05e0befa13af05f1e5f0fd8658bc4e7bdf764f.camel@redhat.com> In-Reply-To: From: Jim Mattson Date: Wed, 6 Jul 2022 10:13:41 -0700 Message-ID: Subject: Re: [PATCH v2 00/21] KVM: x86: Event/exception fixes and cleanups To: Maxim Levitsky Cc: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Upton , Peter Shier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Wed, Jul 6, 2022 at 4:55 AM Maxim Levitsky wrote: > 1. Since #SMI is higher priority than the #MTF, that means that unless du= al monitor treatment is used, > and the dual monitor handler figures out that #MTF was pending and re-= injects it when it > VMRESUME's the 'host', the MTF gets lost, and there is no way for a no= rmal hypervisor to > do anything about it. > > Or maybe pending MTF is saved to SMRAM somewhere. > > In case you will say that I am inventing this again, I am saying now t= hat the above is > just a guess. This is covered in the SDM, volume 3, section 31.14.1: "Default Treatment of SMI Delivery:" The pseudocode above makes reference to the saving of VMX-critical state. This state consists of the following: (1) SS.DPL (the current privilege level); (2) RFLAGS.VM2; (3) the state of blocking by STI and by MOV SS (see Table 24-3 in Section 24.4.2); (4) the state of virtual-NMI blocking (only if the processor is in VMX non-root oper- ation and the =E2=80=9Cvirtual NMIs=E2=80=9D VM-execution control is 1); an= d (5) an indication of whether an MTF VM exit is pending (see Section 25.5.2). These data may be saved internal to the processor or in the VMCS region of the current VMCS. Processors that do not support SMI recognition while there is blocking by STI or by MOV SS need not save the state of such blocking. Saving VMX-critical state to SMRAM is not documented as an option. > 2. For case 7, what about General Detect? Since to raise it, the CPU need= s to decode the instruction > Its more natural to have it belong to case 9. I think it actually belongs in case 10. The Intel table says, "Fault-class Debug Exceptions (#DB due to instruction breakpoint)," and I probably just blindly added "General Detect," because it is a fault-class debug exception. You're right; the CPU has to decode the instruction before it can deliver a #DB for general detect.