Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp148892rwe; Tue, 30 Aug 2022 23:33:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR731/yko86gOBlK7X9JGSGIbhiT9UnvY3WOSWAxveGMf/yCP4X+cqyOdczlwj/6BcwltISx X-Received: by 2002:a17:903:24c:b0:172:7090:64a4 with SMTP id j12-20020a170903024c00b00172709064a4mr24522089plh.124.1661927612631; Tue, 30 Aug 2022 23:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661927612; cv=none; d=google.com; s=arc-20160816; b=UFtDbn3fESL6eAzGTjvo3FxQKFRQKPoyyAyfGwUdfl8v2Mhw9yrD7mg9ptRjgcgtcw GuYmMmQDoogNHNuOzyKSlsOYTbGrmXRn2tcXqeHU1iOUlsV55K/oox3boGf2vbQDI6Ds ZDeZtFXPzpQifziPXkY2ztFDpVqQdNz8Ke4fXmL19whRXXw4FE/iq4FjJeG7ckCxaxg/ yRcstk8Cx7qVEbPl85WWidVq4wQOBT3bHZ3WKolKhaKaDu3FTMfFHAYEZPUJQ9JX1QeT T/67Fsr/HiXDTJ905psQbQvZxNx6ZQBgY4/6Yn7f7tCrj5ya6y+TzEZEvg/RMTEIJDV+ JaLA== 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=q0RL9hcvSBeKbl7mI4q8jnXwWqDmenfiCErqBoOJUqQ=; b=DRIWqXcOsPR0xdRBOBpSz7vIwrDFBEf2Zw78eXsZZVsoJ2f7xjKxg/d6Xr0Sqofakw SBzbuMMqvaqP2GYaCxKKsJy9eHdOtT1EJTY448yXzm4z7juJRn0FG1xRKaTgvdxKpy9c A6woYW3SLNylfWmmg/25lD8ixmMy/ruFXspAvN1NpW25xXj8F5EX0KsdckSvDtc8igKG F4VS2IdBm2DRm/hrypcVTUDvFXhOi9kh0BL9+qq3LxPLpyanRRWAEv2b5YsNTEzYY3VP i2M3f5aT9vtLs/GtJjiQMNRqoqg3YCKxihU5sX3QFf6XOfnNjR/oiXDC0gwxstyRPPJ3 ANlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eFUUocwd; 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 x9-20020a17090a970900b001fdcb564d73si962447pjo.79.2022.08.30.23.33.21; Tue, 30 Aug 2022 23:33:32 -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=eFUUocwd; 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 S230111AbiHaGT4 (ORCPT + 99 others); Wed, 31 Aug 2022 02:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbiHaGTy (ORCPT ); Wed, 31 Aug 2022 02:19:54 -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 ESMTPS id 57294B4B8 for ; Tue, 30 Aug 2022 23:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661926792; 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=q0RL9hcvSBeKbl7mI4q8jnXwWqDmenfiCErqBoOJUqQ=; b=eFUUocwdXByvBz8dcu4So0O7zXVRvh2+tkhXirO88WoQPV4zPqVK692Dr4lnDOYIjg5Q1+ LwCndrZJlsWY5mYD8W/PZt8KTSyJFz8HpZMCETPOAfTkAUqsQwZZOyE8rkh61dqGG8Gfsn MdDK4MSC/W3sEtU6/c3L80waeduyGBk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-G3Vfp39vNKOo56wOZsSujQ-1; Wed, 31 Aug 2022 02:19:49 -0400 X-MC-Unique: G3Vfp39vNKOo56wOZsSujQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3E153C0E20E; Wed, 31 Aug 2022 06:19:48 +0000 (UTC) Received: from starship (unknown [10.40.194.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 203662166B26; Wed, 31 Aug 2022 06:19:46 +0000 (UTC) Message-ID: Subject: Re: [PATCH 07/19] KVM: SVM: Drop buggy and redundant AVIC "single logical dest" check From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Suravee Suthikulpanit , Li RongQing Date: Wed, 31 Aug 2022 09:19:45 +0300 In-Reply-To: <20220831003506.4117148-8-seanjc@google.com> References: <20220831003506.4117148-1-seanjc@google.com> <20220831003506.4117148-8-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.78 on 10.11.54.6 X-Spam-Status: No, score=-2.1 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=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, 2022-08-31 at 00:34 +0000, Sean Christopherson wrote: > Use the already-calculated-and-sanity-checked destination bitmap when > processing a fast AVIC kick in logical mode, and drop the logical path's > flawed logic. The intent of the check is to ensure the bitmap is a power > of two, whereas "icrh != (1 << avic)" effectively checks that the bitmap > is a power of two _and_ the target cluster is '0'. > > Note, the flawed check isn't a functional issue, it simply means that KVM > will go down the slow path if the target cluster is non-zero. > > Fixes: 8c9e639da435 ("KVM: SVM: Use target APIC ID to complete x2AVIC IRQs when possible") > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/svm/avic.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c > index 3c333cd2e752..14f567550a1e 100644 > --- a/arch/x86/kvm/svm/avic.c > +++ b/arch/x86/kvm/svm/avic.c > @@ -411,15 +411,7 @@ static int avic_kick_target_vcpus_fast(struct kvm *kvm, struct kvm_lapic *source > * Instead, calculate physical ID from logical ID in ICRH. > */ > int cluster = (icrh & 0xffff0000) >> 16; > - int apic = ffs(icrh & 0xffff) - 1; > - > - /* > - * If the x2APIC logical ID sub-field (i.e. icrh[15:0]) > - * contains anything but a single bit, we cannot use the > - * fast path, because it is limited to a single vCPU. > - */ > - if (apic < 0 || icrh != (1 << apic)) > - return -EINVAL; > + int apic = ffs(bitmap) - 1; > > l1_physical_id = (cluster << 4) + apic; > } Oh, I didn't notice this bug. However isn't removing the check is wrong as well? What if we do have multiple bits set in the bitmap? After you remove this code, we will set IPI only to APIC which matches the 1st bit, no? (The fast code only sends IPI to one vCPU) Best regards, Maxim Levitsky