Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5092650ybl; Tue, 14 Jan 2020 03:24:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzLhLD9wkkNABmQYt/aTK2Usd2lF6cca2WkpwlD5tBrvT4/OtYsIRnaaEeEe4+qqNkz9E4a X-Received: by 2002:a9d:6a5a:: with SMTP id h26mr17177033otn.103.1579001061943; Tue, 14 Jan 2020 03:24:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579001061; cv=none; d=google.com; s=arc-20160816; b=Yq98uDARmZRhwU3u+lFulS9A2O3M0+umlt6Zoqb5kVes9wHpbh25PNnjdEH3V5afZc yBhiLgpkhb3TrET1l5Rt1HMQwUd2oPk33KUisTew3t2kF7LSSXbmUjlH6iDSuJnYdExw qqIPybuzColTPXPgA+OXoAG5+MtrP3c5RNy7vN9jQ8uyqTe5UBFzNXXSZc/4ql3aJcXk d0uXTVvnWGZQCQlRqRaWBUaoRkLnB+2IL/XH9zRfBg8lmsRDRsfe7O/i5i1WIy/MuxuX fL0hEsCNu4gxvEWocC+SH9tw/FimiK66oSCs5v9BKlWLYZ8dmi+/deFi4beKsf2jbQvT 1WlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wD1u8gWe0LjUGikJnDQZGDgjKuto6jCVUIUEFNDuQbk=; b=c/lLe1g3YGcgsU+4CygmJY+ov/CpqYPH5hFskn7Ih9TI+WnhB+AV/dYYVLDcRE77jX TURhixt4WujTnI8NAyo7UoOj1GXzk2TLiset+YiMkuUxC5Oo5qQ9njTqM+/fXY29IiEv OmuMkuX3NR013wqTiXALt24uTgivtvONEZ+e+fy7EYvdyvjUrMMuvJQ0CLKVSiEIaGMG WhNx3uU+Ay6gm9vu8IhWrnnuqdv4QQB+MDbOb6TeFWcZIYklD5zUYyjI5FBYTaAdQKIR yZsGeDarH1z2/KeT72S60PXmQDtGnusuh1iHMIIh1TkJYs1c8OZJegS7rTeo9V3GioYo f0bw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c19si8943160otp.3.2020.01.14.03.24.09; Tue, 14 Jan 2020 03:24:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729420AbgANLWm (ORCPT + 99 others); Tue, 14 Jan 2020 06:22:42 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:58754 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725820AbgANLWm (ORCPT ); Tue, 14 Jan 2020 06:22:42 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DE3A7121F63BD1BB6E66; Tue, 14 Jan 2020 19:22:39 +0800 (CST) Received: from DESKTOP-8RFUVS3.china.huawei.com (10.173.222.27) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Tue, 14 Jan 2020 19:22:32 +0800 From: Zenghui Yu To: CC: , , , , , , Zenghui Yu Subject: [PATCH v2] KVM: arm/arm64: vgic-its: Properly check the unmapped coll in DISCARD handler Date: Tue, 14 Jan 2020 19:22:12 +0800 Message-ID: <20200114112212.1411-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.173.222.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Discard is supposed to fail if the collection is not mapped to any target redistributor. We currently check if the collection is mapped by "ite->collection" but this is incomplete (e.g., mapping a LPI to an unmapped collection also results in a non NULL ite->collection). What actually needs to be checked is its_is_collection_mapped(), let's turn to it. Also take this chance to remove an extra blank line. Reviewed-by: Eric Auger Signed-off-by: Zenghui Yu --- v1->v2: - Rewrite the commit message with Eric's suggestion, the original one is not so good... - Add Eric's R-b virt/kvm/arm/vgic/vgic-its.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 17920d1b350a..d53d34a33e35 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -839,9 +839,8 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its, u32 event_id = its_cmd_get_id(its_cmd); struct its_ite *ite; - ite = find_ite(its, device_id, event_id); - if (ite && ite->collection) { + if (ite && its_is_collection_mapped(ite->collection)) { /* * Though the spec talks about removing the pending state, we * don't bother here since we clear the ITTE anyway and the -- 2.19.1