Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5635759pxb; Mon, 28 Mar 2022 15:17:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwymKhG8gglXwWC7VkQfwYbyKd0BJoVBktfTQOgJKGI3G+fOgqjG6dWihCTPe+mY2WTIkhT X-Received: by 2002:a05:6808:1914:b0:2da:6aad:d999 with SMTP id bf20-20020a056808191400b002da6aadd999mr714017oib.245.1648505844533; Mon, 28 Mar 2022 15:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648505844; cv=none; d=google.com; s=arc-20160816; b=CyL4syJhjb+6C7f4jQrYHHjyCp6aPJozVsTKQU6OVep6r3aqsehXvyhikfoJbC7Jj5 nQ7MyzCPnp/k7tfrcuIN2XlD/fQg19n0kwOT0Z0qMOONXa01HhJfKjC2WkpF6/3TdW8I fY4TviuR6zptajj/SMu8CQp/VgXLdNjFsys2vlWwwU2lQxzliva+l/QAo2C8TVPAwgLf VZ91Z7H3Nv9A71JckgxdZ/NQ1G/fpPDzmFs7tYecVH2mHC5F1o8SBnBrMFFWm+wS9fiM sF/WRG/R850l+w1Pft1u2gK3N8Qg6s1eaR9l3BnItWN8njpRawpRoXw1D0BJel+PVuQ/ MH0Q== 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=k9swn3UFVhgUXTfUhyp3q19zbpP+fWfmwmrzd9mdhuI=; b=WucGirHe7cFZbmVLulHR0SdNOQen4AIJ4ZKyK6HQWlK9VxVtAIU50wdbgs4ZTbmKm4 MYhzMFpE4Oz+QkVoUzpuIVwmUCfDuEenNJ4rO0iANrSZA25PF4S5+kDcE4RhAmD+/1aA +u2olVtiSQgZt2Ja/BfNCl1DoYf/S5DdBNznLk1TkN/pLaGS1RW1FLPEAVBVbr+q69Gg /7d3njOZiclkkOKgo7ne5wQ0sU7tFxKCABGL3qU1V2xnykD4W5O2kb1wFH2DO8p2XwAP kidxD3YJblj7k/7Yql06RLaOxgW7eCN0NHFbqeu5aNTcslpHTu1IKdZnWeh3N/W/PiUB ch5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=H+qH3IZy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p22-20020a056870831600b000de12c0b3f8si10901598oae.194.2022.03.28.15.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:17:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=H+qH3IZy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E27B181B32; Mon, 28 Mar 2022 14:35:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244726AbiC1Rwj (ORCPT + 99 others); Mon, 28 Mar 2022 13:52:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244644AbiC1Rwh (ORCPT ); Mon, 28 Mar 2022 13:52:37 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3D93C735 for ; Mon, 28 Mar 2022 10:50:56 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id l4-20020a17090a49c400b001c6840df4a3so82924pjm.0 for ; Mon, 28 Mar 2022 10:50:56 -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=k9swn3UFVhgUXTfUhyp3q19zbpP+fWfmwmrzd9mdhuI=; b=H+qH3IZyJmG67UHSvVV7IVVXEF0PU0oygFqGrp1ftXvA0kbdX9isRmj4lQghH+0oVx M23tHe9cunGKcFjBk/S4/8xYZ5SZ6YwJawFegP8XU8ismQ8CEj7yYyBllhQeb58vnPS8 QPZVd2kyVjHkP/Hw1BOfjEUGqPJsMJaVjj3ck3aZtDKniYz7BK6cM+WltubF/h852fzl R+frgR5k+wo4AOEZqBzvg0zNfdJicrQV1XGWNEY4otWyoD1MgbcdOlxN0/T41uZLhDlq HesGN+EFX8DRdAJDCkqFf2bw2P+XYpLpuc46eypq6pfAV/U7b+5TrRogLk89w4ZstQEq xB+w== 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=k9swn3UFVhgUXTfUhyp3q19zbpP+fWfmwmrzd9mdhuI=; b=qUQkGG2u73/wtb1r/xAm+iik6Gprrld4MKQXPCC83fOvm8Q9HaCs/KtQpZ0TJnR5QB 7A5He6fOyG1ap9p3XQ7gt4G0ZTWgYbHtDoBsEPMADy9e6X1zVWTPfUHL4Ym1pug1S2HQ 2FMZNAJ+ZjZD0BrG45o5HMnbTPmtagiQm8a84vlAaJ/kEm7qepKHgGOksOGfSkjVxcGT 9LpGrhfyxC53rVzDFW/UXLkUtebjAr2YENchKeI3SFFfyfNA2zejAtSPu2HkF5jncx9j 36PxDbrSgMQtS7xGOWGt95RocuXfWXukxnDhUTMGpzH8zQ9kOunC527k0xXN2sjRA6uY rmHg== X-Gm-Message-State: AOAM533WdEU2mbt22B9Uc13V6tfSJwx1bSFc8njk/o+3levrcHIlmtKN sM7265HSd5wER7UBvicKoeXRtA== X-Received: by 2002:a17:903:11c7:b0:151:7290:ccc with SMTP id q7-20020a17090311c700b0015172900cccmr27401517plh.95.1648489856246; Mon, 28 Mar 2022 10:50:56 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id z6-20020a056a00240600b004e17ab23340sm17616971pfh.177.2022.03.28.10.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 10:50:55 -0700 (PDT) Date: Mon, 28 Mar 2022 17:50:51 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Upton , Peter Shier Subject: Re: [PATCH 00/21] KVM: x86: Event/exception fixes and cleanups Message-ID: References: <20220311032801.3467418-1-seanjc@google.com> <08548cb00c4b20426e5ee9ae2432744d6fa44fe8.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Sun, Mar 27, 2022, Maxim Levitsky wrote: > Other than that I am actually very happy that you posted this patch series, > as this gives more chance that this long standing issue will be fixed, > and if your patches are better/simpler/less invasive to KVM and still address the issue, > I fully support using them instead of mine. I highly doubt they're simpler or less invasive, but I do hope that the approach wil be easier to maintain. > Totally agree with you about your thoughts about splitting pending/injected exception, > I also can't say I liked my approach that much, for the same reasons you mentioned. > > It is also the main reason I put the whole thing on the backlog lately, > because I was feeling that I am changing too much of the KVM, > for a relatively theoretical issue. > > > I will review your patches, compare them to mine, and check if you or I missed something. > > PS: > > Back then, I also did an extensive review on few cases when qemu injects exceptions itself, > which it does thankfully rarely. There are several (theoretical) issues there. > I don't remember those details, I need to refresh my memory. > > AFAIK, qemu injects #MC sometimes when it gets it from the kernel in form of a signal, > if I recall this correctly, and it also reflects back #DB, when guest debug was enabled > (and that is the reason for some work I did in this area, like the KVM_GUESTDBG_BLOCKIRQ thing) > > Qemu does this without considering nested and/or pending exception/etc. > It just kind of abuses the KVM_SET_VCPU_EVENTS for that. I wouldn't call that abuse, the ioctl() isn't just for migration. Not checking for a pending exception is firmly a userspace bug and not something KVM should try to fix. For #DB, I suspect it's a non-issue. The exit is synchronous, so unless userspace is deferring the reflection, which would be architecturally wrong in and of itself, there can never be another pending exception. For #MC, I think the correct behavior would be to defer the synthesized #MC if there's a pending exception and resume the guest until the exception is injected. E.g. if a different task encounters the real #MC, the synthesized #MC will be fully asynchronous and may be coincident with a pending exception that is unrelated to the #MC. That would require to userspace to enable KVM_CAP_EXCEPTION_PAYLOAD, otherwise userspace won't be able to differentiate between a pending and injected exception, e.g. if the #MC occurs during exception vectoring, userspace should override the injected exception and synthesize #MC, otherwise it would likely soft hang the guest.