Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2653976imj; Mon, 11 Feb 2019 06:31:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ2i2rME+GKqcrTzpIZE6GiCayxZ4X5YR7fcNa3GIoBYFWnqQGQ7sAbCxrMFuk/1oDeTNuJ X-Received: by 2002:a62:9657:: with SMTP id c84mr37666289pfe.77.1549895504829; Mon, 11 Feb 2019 06:31:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895504; cv=none; d=google.com; s=arc-20160816; b=sendp47l/1GkRF7vxC77UWdmH1iom9GlhKbOyyVD9ACCBe9I5mpf4RNoFv1Ryzjgok DraY+HuDIpcZMnQHAGICD4jHXOOyURJuY8HxN3Z6SeGmqPs1E6yTyIwVYabdArCsO7xD 60udKeZcpjOaYFXUOxhSdHVq8vwi3iEpjOWP9unL+K1CRV7ztpC1xzit0aCNvZrFFRDp hoTkwEQtRuwbrlrgh0g3Hv2vAM9vPm55gA27x9UkxKHUq1AAb3/qFA405eiMtXK1VSh3 wvFj4wf97WgGT6tb+wqpWtDUl2D9F65eGw/OoNmcEfiV6G0QbfvV+JQCIZd91451J4B2 9YNg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2smx59sEVSNTDCc0mcWT3k95/QGGlExahEKEbh/Pau8=; b=bbMXqY/rClITiJZCaqA7yo4HMo9jjcvs9TXT2pXWKN9WWIXkaKp5uCJ7IjnWzfhe5x +PV8znJNHuk8K0IwZdddlhFAsklJkWU8H2yMV3hSgP76RTJS3KRBKso/0nP6n+79+35s HtmjzBNUhwICGt77bCAUsxYUFlECXDEBKjxk/zsVl84kLH5lAGAlkEFdWjQUWCMFw72s AZEA8PCLEkLvNrKZNdD/k02/QFQsSb9IAKDvHOInj/iKrmPSv4KtUnOPZDbDpzpnfuAN Q0zHzPUkQvcbNgKfMi4yHEYaUmtORcFO0xOyX3KImcLfI3OMgCJOYsePPMb7uNw7t934 HGzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xsfePqPs; 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 n7si10146652plk.18.2019.02.11.06.31.28; Mon, 11 Feb 2019 06:31:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xsfePqPs; 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 S1727766AbfBKO3h (ORCPT + 99 others); Mon, 11 Feb 2019 09:29:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:35652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730001AbfBKO3c (ORCPT ); Mon, 11 Feb 2019 09:29:32 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA1BB20675; Mon, 11 Feb 2019 14:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895372; bh=xd5acvtQcvElPKnope4Wr/VzdUtMc+tIoMV+NAEGtR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xsfePqPsi/GA1VNzPcet8RS1snAXxFXHWTp5OcdzLVvucNGEqNolGpdpKs0VASC4Y 5gyIgfR7z/BH/Nv6t1zEEXyYbNHCvxZJ+H7wQEOu5IYcc/7ENA0Eo8csBeuH21PCRl 4LqVnkmVH9eBAoP6OAoUjt6ZhVq0l8m3uxVa6F/8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Zhen Lei , Will Deacon , Sasha Levin Subject: [PATCH 4.20 142/352] iommu/arm-smmu-v3: Avoid memory corruption from Hisilicon MSI payloads Date: Mon, 11 Feb 2019 15:16:09 +0100 Message-Id: <20190211141855.585453813@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 84a9a75774961612d0c7dd34a1777e8f98a65abd ] The GITS_TRANSLATER MMIO doorbell register in the ITS hardware is architected to be 4 bytes in size, yet on hi1620 and earlier, Hisilicon have allocated the adjacent 4 bytes to carry some IMPDEF sideband information which results in an 8-byte MSI payload being delivered when signalling an interrupt: MSIAddr: |----4bytes----|----4bytes----| | MSIData | IMPDEF | This poses no problem for the ITS hardware because the adjacent 4 bytes are reserved in the memory map. However, when delivering MSIs to memory, as we do in the SMMUv3 driver for signalling the completion of a SYNC command, the extended payload will corrupt the 4 bytes adjacent to the "sync_count" member in struct arm_smmu_device. Fortunately, the current layout allocates these bytes to padding, but this is fragile and we should make this explicit. Reviewed-by: Robin Murphy Signed-off-by: Zhen Lei [will: Rewrote commit message and comment] Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/iommu/arm-smmu-v3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 71eda422c926..62ef4afc9ee5 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -576,7 +576,11 @@ struct arm_smmu_device { struct arm_smmu_strtab_cfg strtab_cfg; - u32 sync_count; + /* Hi16xx adds an extra 32 bits of goodness to its MSI payload */ + union { + u32 sync_count; + u64 padding; + }; /* IOMMU core code handle */ struct iommu_device iommu; -- 2.19.1