Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2386665imw; Wed, 6 Jul 2022 05:12:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vKyE6JeEgs8mxYqn0YoffbJZSH19UDbP99MRk6bbxVUgN22KErZn/d2Kfj5XgBocVDFxKK X-Received: by 2002:a17:906:3087:b0:6f4:2901:608a with SMTP id 7-20020a170906308700b006f42901608amr39604052ejv.646.1657109566716; Wed, 06 Jul 2022 05:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657109566; cv=none; d=google.com; s=arc-20160816; b=bHc+4EhlyLEpRqdcAX/AMgN6XZ38PXbgMQdzyRJ7EdzM5/InE+mTaZkXHM30Pip1H5 Yo6WJNasRbE/0rkfgkNQgflJxqClPpPIvcGr55wv5VfpKwqFwf93Bq0YhZs6vxt7TkP5 gAFtxcSdpt6oyrU4Ku/DSKbcP+wGXb0GnXFbjzRxNKA1d4bKkL8K+1o+4ScoAmGttfS5 eoYf99ZRifD4bvShcgqtD+2VFg83emQ7YKE3S/4nDzbGRJJyMCr/VRL30FRq/Myx7MDs gJfHePUmZ2DSFcvO8pRTlTFd0p/t8HAl0AbNj3Gam9ZPjcPR51eVIxllV3y8UVNbwB2h ZekA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=3n3kg3o2B5nWwM7ZG/qWhzB4HjUo/XQlyxdpJa1Hq3k=; b=EnMpRdz0NjYUXUMxPP+nWBTxLkwdzreljmEUyzOYNFMtM8AMiaiNZDFjX4U2n/96ph U9H7anbRd5Dc5zr10/KDu/TvPy+Q8LM5j3qjB25QnTUIsttpwx96Lenest8ODO4DLnGS 7ciMkw/iFMnPtp5RXO74Stv7acoQIWiV4QWypdSIfxY1XcLykAO9Pg2/1StzQIGsbs5K nEASWhBD1XiKjRE+/YAc1XCnu5WPwpDiLUJCuHmF/vf32LSKMTz12LXL+wZKf8Ffc+UE EunqwLurX7lNnaenNyk2injYAwCrC2xhZ4Z3HNStK/MB8LPDkQ0vg79/jtQvfaa05+jC /4wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CQx+cUIB; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a17090646d500b00722e82edf14si9518807ejs.14.2022.07.06.05.12.21; Wed, 06 Jul 2022 05:12:46 -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=@redhat.com header.s=mimecast20190719 header.b=CQx+cUIB; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232258AbiGFMFC (ORCPT + 99 others); Wed, 6 Jul 2022 08:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbiGFMFB (ORCPT ); Wed, 6 Jul 2022 08:05:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4BB529812 for ; Wed, 6 Jul 2022 05:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657109099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3n3kg3o2B5nWwM7ZG/qWhzB4HjUo/XQlyxdpJa1Hq3k=; b=CQx+cUIBeVY3+ilW+/38F84fRIUmHwN5t4exWcxDImzahcVNS5vgsU+BpPLHxwBax82N6f JT1I0TfGHFI4XulcxGFXrDHv9zDicQSdioOr6bVgoHcweheHa0qzgZsE1ZKoK03OAeBcEk LhyE+y28zsMqb+PUt+rc5RDk/YnBP+k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-160-CbAS9K72MrepWRKCA7RIiA-1; Wed, 06 Jul 2022 08:04:49 -0400 X-MC-Unique: CbAS9K72MrepWRKCA7RIiA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58E66802D1C; Wed, 6 Jul 2022 12:04:49 +0000 (UTC) Received: from starship (unknown [10.40.194.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0855FC04482; Wed, 6 Jul 2022 12:04:46 +0000 (UTC) Message-ID: <5f77a21bd64c2a1f6bc717e823725d62a694ea34.camel@redhat.com> Subject: Re: [PATCH v2 14/21] KVM: x86: Use kvm_queue_exception_e() to queue #DF From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Upton , Peter Shier Date: Wed, 06 Jul 2022 15:04:45 +0300 In-Reply-To: <20220614204730.3359543-15-seanjc@google.com> References: <20220614204730.3359543-1-seanjc@google.com> <20220614204730.3359543-15-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, 2022-06-14 at 20:47 +0000, Sean Christopherson wrote: > Queue #DF by recursing on kvm_multiple_exception() by way of > kvm_queue_exception_e() instead of open coding the behavior. This will > allow KVM to Just Work when a future commit moves exception interception > checks (for L2 => L1) into kvm_multiple_exception(). Typo: You mean Just Work (tm) ;-) > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 511c0c8af80e..e45465075005 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -663,25 +663,22 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu, > } > class1 = exception_class(prev_nr); > class2 = exception_class(nr); > - if ((class1 == EXCPT_CONTRIBUTORY && class2 == EXCPT_CONTRIBUTORY) > - || (class1 == EXCPT_PF && class2 != EXCPT_BENIGN)) { > + if ((class1 == EXCPT_CONTRIBUTORY && class2 == EXCPT_CONTRIBUTORY) || > + (class1 == EXCPT_PF && class2 != EXCPT_BENIGN)) { > /* > - * Generate double fault per SDM Table 5-5. Set > - * exception.pending = true so that the double fault > - * can trigger a nested vmexit. > + * Synthesize #DF. Clear the previously injected or pending > + * exception so as not to incorrectly trigger shutdown. > */ > - vcpu->arch.exception.pending = true; > vcpu->arch.exception.injected = false; > - vcpu->arch.exception.has_error_code = true; > - vcpu->arch.exception.vector = DF_VECTOR; > - vcpu->arch.exception.error_code = 0; > - vcpu->arch.exception.has_payload = false; > - vcpu->arch.exception.payload = 0; > - } else > + vcpu->arch.exception.pending = false; > + > + kvm_queue_exception_e(vcpu, DF_VECTOR, 0); > + } else { > /* replace previous exception with a new one in a hope > that instruction re-execution will regenerate lost > exception */ > goto queue; > + } > } > > void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr) Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky