Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1904720pxb; Sat, 7 Nov 2020 02:48:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz+h87wGtyaG3ykfyuhUJmS+mjCWmV2fbi4rtMHtimFFjng5QPtU3UUmEwGlo6Q0W0At5N X-Received: by 2002:a17:906:491a:: with SMTP id b26mr6224562ejq.385.1604746101212; Sat, 07 Nov 2020 02:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604746101; cv=none; d=google.com; s=arc-20160816; b=rrgJ+hhz82s6xsI4E/cNd8qIp3LlyJDYHqLnTygHLJg+3csBT4X5T7x7cck+4J1Nuh WM/sg2WYaIeRth4El+gtaIboUpQxk43ds8KPGGMi4255WZgtZ5YbmByIPac0loIlofpi JcS71syObVAFfsI7xs0JpeB0pD/IjSQUpC/XiBM/N0G0eVqkLuGh0TvQbjSDB/lYWiDZ Sp7qfQESqi2d/F/MnhHehCEUgP/D+PO7XXsK0MnVCG1pdd5BDRZNCVWtD1bwj6cO2/KF VNT8ZrifyiEqxf48dILrbWYetFROiiHh7lN8AUPfwr5DR7IidkZ+9V1K7506KnWPiFDn Eovg== 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 :message-id:date:subject:cc:to:from; bh=tz8l/A7xrew+lDRZl2d47XzsPjUFEdcybj4uEuBnpKM=; b=hRsuSwFxyrVKudJAc0fpL5/a3b1s0r56bzzij8pV6GECLeRo0pYqNZw86IIsuHJaKY B47SGcEc8eg2QloALHLQ4N3vkyjEw6H9bpoxiwy0MdyPqnXLYIQ8kgt6V58jwB4UCF5/ 1iTihLF/G5e6efZibjTA1tqd0dYqn5rcwG4Yju9/cwF/uwmobbmZO154wUdTfWNnmfEz 8SPkEpEVgEOzV56sNtgosK5n2LMwPS2Uasc59E0N38hx1GJq9KxLRZSuDG5+KqNcsmrn rRh0VE9e5GryQfCveHqkmkvjUm5GzcrB0kLLYIX1czkox16jNQZMNt8EKkaTmLtA+n/i 67fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si3120043edj.302.2020.11.07.02.47.57; Sat, 07 Nov 2020 02:48:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727730AbgKGKm4 (ORCPT + 99 others); Sat, 7 Nov 2020 05:42:56 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7154 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbgKGKm4 (ORCPT ); Sat, 7 Nov 2020 05:42:56 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CSv3V3ZGsz15SKt; Sat, 7 Nov 2020 18:42:46 +0800 (CST) Received: from huawei.com (10.175.112.208) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Sat, 7 Nov 2020 18:42:42 +0800 From: Xu Qiang To: , , , CC: Subject: [PATCH -next] irq-chip/gic-v3-its: Fixed an issue where the ITS executes the residual commands in the queue again when the ITS wakes up from sleep mode. Date: Sat, 7 Nov 2020 10:42:26 +0000 Message-ID: <20201107104226.14282-1-xuqiang36@huawei.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.208] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On my platform, ITS_FLAGS_SAVE_SUSPEND_STATE is not set,thus do nothing in its suspend and resuse function.On the other hand,firmware stores GITS_CTRL,GITS_CBASER,GITS_CWRITER and GITS_BASER in the suspend, and restores these registers in the resume. As a result, the ITS executes the residual commands in the queue. Memory corruption may occur in the following scenarios: The kernel sends three commands in the following sequence: 1.mapd(deviceA, ITT_addr1, valid:1) 2.mapti(deviceA):ITS write ITT_addr1 memory; 3.mapd(deviceA, ITT_addr1, valid:0) and kfree(ITT_addr1); 4.mapd(deviceA, ITT_addr2, valid:1); 5.mapti(deviceA):ITS write ITT_addr2 memory; To solve this problem,dropping the checks for ITS_FLAGS_SAVE_SUSPEND_STATE. Signed-off-by: Xu Qiang --- drivers/irqchip/irq-gic-v3-its.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 0fec31931e11..06f2c1c252b9 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -42,7 +42,6 @@ #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING (1ULL << 0) #define ITS_FLAGS_WORKAROUND_CAVIUM_22375 (1ULL << 1) #define ITS_FLAGS_WORKAROUND_CAVIUM_23144 (1ULL << 2) -#define ITS_FLAGS_SAVE_SUSPEND_STATE (1ULL << 3) #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0) #define RDIST_FLAGS_RD_TABLES_PREALLOCATED (1 << 1) @@ -4741,9 +4740,6 @@ static int its_save_disable(void) list_for_each_entry(its, &its_nodes, entry) { void __iomem *base; - if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) - continue; - base = its->base; its->ctlr_save = readl_relaxed(base + GITS_CTLR); err = its_force_quiescent(base); @@ -4762,9 +4758,6 @@ static int its_save_disable(void) list_for_each_entry_continue_reverse(its, &its_nodes, entry) { void __iomem *base; - if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) - continue; - base = its->base; writel_relaxed(its->ctlr_save, base + GITS_CTLR); } @@ -4784,9 +4777,6 @@ static void its_restore_enable(void) void __iomem *base; int i; - if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) - continue; - base = its->base; /* @@ -5074,9 +5064,6 @@ static int __init its_probe_one(struct resource *res, ctlr |= GITS_CTLR_ImDe; writel_relaxed(ctlr, its->base + GITS_CTLR); - if (GITS_TYPER_HCC(typer)) - its->flags |= ITS_FLAGS_SAVE_SUSPEND_STATE; - err = its_init_domain(handle, its); if (err) goto out_free_tables; -- 2.25.0