Received: by 10.223.185.116 with SMTP id b49csp77019wrg; Thu, 8 Mar 2018 13:10:11 -0800 (PST) X-Google-Smtp-Source: AG47ELu5dHqw18/XhwXEgjwEbPHwo4rPla7Oj1H3w/hgfOL6wYIUZALyvUVlWQJdqdZd1pRptGr1 X-Received: by 10.98.28.202 with SMTP id c193mr1940272pfc.109.1520543411860; Thu, 08 Mar 2018 13:10:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520543411; cv=none; d=google.com; s=arc-20160816; b=lK0TVAdSYjSb7NKFjr9GTbBs2paVGT3Kz3L7b/F2ZVJQi5UFhqXCodbBMWWebFgyDs tVKF7GJbka6/H/LAzlb2DPum9mkvLBdM4PBdssEQha/++/iyMrxSRIHnscWIPZPsJtFt Lp/NlAQKiqsGWmG22UZNUTtTVenVY+NolPE6645Fa1TL7KJBpLvCPlJhkfjpUfyMMCzA irXu3lpIqwm+0fFWeOgdfPOvny9JavibRB5n5wtYzd/KCtOivBt17fi1WkRSGGMi1UcE pm7uqm6i/MDvTlvwcNaF5z1PTjJnrvUXhbuU7qtG+bU7kBtRF4qO5vXXnfEV36HaaQdq +e2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=a7b7ztYgxtvFgvLm9EtozxZ6HpbLHT+S0ErEit+qWMk=; b=qwZubHtpTN9AaEjI52raLXGjGbaLL3GDcZxN+zcUbBUKBrg2/A26FMmhRE2GL1Mq3x m4W+xlJ3hQmzp5XlU6glKrST+XFWQUROPBkzPjkNkAJCr2iVDzmx6VOcM+nGyyVoPG7L p75pfFcB0eq8tetenXCevPeB5DMHOZPPNMBTskl8ajbo/oG0lP4gj28kgE6p0yjjhfUS tknUcdyu2sCPV129yiH6a2P+NCeqXWxcAJ/gR+owdFLkg6GZdzJI037Rk9j3QJ2zWu3g Ci9i5fpJtfC+9qCvyEcmelJ0ALcLsm4WhAnY5902KIi3mU/rzdWColrYU94o9hX4Golx I9Rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16-v6si15045109plp.87.2018.03.08.13.09.57; Thu, 08 Mar 2018 13:10:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751554AbeCHVIs (ORCPT + 99 others); Thu, 8 Mar 2018 16:08:48 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34846 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751248AbeCHVIr (ORCPT ); Thu, 8 Mar 2018 16:08:47 -0500 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 mx1.redhat.com (Postfix) with ESMTPS id 58DB54015A42; Thu, 8 Mar 2018 21:08:46 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 7C54A215CDA7; Thu, 8 Mar 2018 21:08:43 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 08 Mar 2018 22:08:04 +0100 Date: Thu, 8 Mar 2018 22:08:04 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , "K. Y. Srinivasan" , "Michael Kelley (EOSG)" , Roman Kagan , "Denis V . Lunev" Subject: Re: [PATCH v2 2/3] x86/kvm/hyper-v: remove stale entries from vec_bitmap/auto_eoi_bitmap on vector change Message-ID: <20180308210804.GN12290@flask> References: <20180301141514.3482-1-vkuznets@redhat.com> <20180301141514.3482-3-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180301141514.3482-3-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 08 Mar 2018 21:08:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 08 Mar 2018 21:08:46 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-01 15:15+0100, Vitaly Kuznetsov: > When a new vector is written to SINx we update vec_bitmap/auto_eoi_bitmap > but we forget to remove old vector from these masks (in case it is not > present in some other SINTx). > > Signed-off-by: Vitaly Kuznetsov > Reviewed-by: Roman Kagan > --- > arch/x86/include/uapi/asm/hyperv.h | 2 ++ > arch/x86/kvm/hyperv.c | 32 ++++++++++++++++++++++---------- > 2 files changed, 24 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h > index 197c2e6c7376..62c778a303a1 100644 > --- a/arch/x86/include/uapi/asm/hyperv.h > +++ b/arch/x86/include/uapi/asm/hyperv.h > @@ -318,6 +318,8 @@ typedef struct _HV_REFERENCE_TSC_PAGE { > #define HV_SYNIC_SINT_COUNT (16) > /* Define the expected SynIC version. */ > #define HV_SYNIC_VERSION_1 (0x1) > +/* Valid SynIC vectors are 16-255. */ > +#define HV_SYNIC_FIRST_VALID_VECTOR (16) > > #define HV_SYNIC_CONTROL_ENABLE (1ULL << 0) > #define HV_SYNIC_SIMP_ENABLE (1ULL << 0) > diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c > index 05f414525538..6d14f808145d 100644 > --- a/arch/x86/kvm/hyperv.c > +++ b/arch/x86/kvm/hyperv.c > @@ -74,13 +74,30 @@ static bool synic_has_vector_auto_eoi(struct kvm_vcpu_hv_synic *synic, > return false; > } > > +static void synic_update_vector(struct kvm_vcpu_hv_synic *synic, > + int vector) > +{ > + if (vector < HV_SYNIC_FIRST_VALID_VECTOR) > + return; > + > + if (synic_has_vector_connected(synic, vector)) > + __set_bit(vector, synic->vec_bitmap); > + else > + __clear_bit(vector, synic->vec_bitmap); > + > + if (synic_has_vector_auto_eoi(synic, vector)) > + __set_bit(vector, synic->auto_eoi_bitmap); > + else > + __clear_bit(vector, synic->auto_eoi_bitmap); > +} > + > static int synic_set_sint(struct kvm_vcpu_hv_synic *synic, int sint, > u64 data, bool host) > { > - int vector; > + int vector, old_vector; > > vector = data & HV_SYNIC_SINT_VECTOR_MASK; > - if (vector < 16 && !host) > + if (vector < HV_SYNIC_FIRST_VALID_VECTOR && !host) > return 1; > /* > * Guest may configure multiple SINTs to use the same vector, so > @@ -88,18 +105,13 @@ static int synic_set_sint(struct kvm_vcpu_hv_synic *synic, int sint, > * bitmap of vectors with auto-eoi behavior. The bitmaps are > * updated here, and atomically queried on fast paths. > */ > + old_vector = synic_read_sint(synic, sint) & HV_SYNIC_SINT_VECTOR_MASK; > > atomic64_set(&synic->sint[sint], data); > > - if (synic_has_vector_connected(synic, vector)) > - __set_bit(vector, synic->vec_bitmap); > - else > - __clear_bit(vector, synic->vec_bitmap); > + synic_update_vector(synic, old_vector); > > - if (synic_has_vector_auto_eoi(synic, vector)) > - __set_bit(vector, synic->auto_eoi_bitmap); > - else > - __clear_bit(vector, synic->auto_eoi_bitmap); > + synic_update_vector(synic, vector); This looks like it solves the problem when we get two SINTs with the same vector back-to-back , but shouldn't these bits really be cleared on EOI (either auto or manual)? Thanks.