Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp502223lqi; Thu, 7 Mar 2024 03:52:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXE9i9Gno0TzOgpWhWeJTA3XCIwD3XdLg8wI3qhKK97YcCYgVvnNmKpGHJnu3hp8ezhOVgc9EC5mypaAbtCWIqCzp9JudXi2sJp1ZoOLQ== X-Google-Smtp-Source: AGHT+IFsc3sD1Bbs/KCJRcbKnKYxnXJtCZV5uS+Qz8TTNQG4baAGLCWPFdfYcjoDWVNjUGluxfux X-Received: by 2002:a05:620a:580d:b0:788:24b4:49fa with SMTP id wm13-20020a05620a580d00b0078824b449famr8901058qkn.48.1709812347543; Thu, 07 Mar 2024 03:52:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709812347; cv=pass; d=google.com; s=arc-20160816; b=wbhvrseHXswK3bLcEZP4Iy7JYKxSGkXvrT8gTPg8eBtlD/QqtpKI+MaOiN+GCrCu6D kiO5XAYD4f/6/K6PYsTwHnqJWxRM+ozc4YiHPHzk9pY+yreJioKX48mwR7Cfw/1+FAPM VkTjRMBLqwXTjebANALoun+FBhDj99ZUWsZXjT2Z4YjTM3BuA3djlQ8BaNum7xCe0YzV 15pLiRMqq0CfpmbQyrPvsx3WLehyWz6U0ZuJVm7WTUfERNo+OmOF6IQ5A+LVdmziPERF PBKXTjLad9T8FIM+O6bmhjGkCxZzHVtuIcFrPPLylSUcDJdaAgOArPLo7E0/+J9sV/4a +6Yw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1Tq4PX5OVD/1UTnQNhTdu/i2sdk567MAMJr4rNiSaJg=; fh=o7TpnEpK+WRjkIPhiR1Zv3+RQz5Sc127KA2F6USkSvo=; b=z8RzSqGRKSrNgD6M3ioIg1bxnm5cblZSg9ax5VHtlhwErcHuJ7lqXnN/6Atd6THOh6 FsxIVGge9QbjT/SJ44gs1zT3jjM/CIYA0mU3NTP2hINtuYli3dplFV1/nrGdj774Xi0T ulYZpyLac2odhUhXSCs70eZMYXcQx3zYBqpAxJk9PuxvbSO/731QpPM+9oksExe5RHVQ Mbqbhk4yHtBqyAC6BIb3ALXq4XlmDG5jgTBYpyVrsrii51X1V6ekOYVe+UXBwYvHzetJ ycOfFFxw9jZf4X3qIKgK+gGmY1GluudVqFplYhbUJ922CA9PPB9fb7S+RnX1GVb7DNJg VTJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6Yp9Wsa; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-95486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h12-20020a05620a21cc00b007881dbc7521si11240308qka.726.2024.03.07.03.52.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 03:52:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6Yp9Wsa; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-95486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4B9DA1C2355F for ; Thu, 7 Mar 2024 11:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E874F12BE97; Thu, 7 Mar 2024 11:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="W6Yp9Wsa" Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 769C212838A for ; Thu, 7 Mar 2024 11:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709812053; cv=none; b=Uvyq8XaAgiiLzdgFWyb5z55U12eWSmu3tlgMDC+gg0nTpwi3hsEb6yihWibmWiQGPiv1FP8e3wmFLKN3v+YIPv0aB5gHQ0X3WLYFCNbx98vNXlm2FHjKFf6vXRlvaYzxRU0U62dn8lj8jYjXvvPWNpT0Nc7bw/6PhJHJIM9e5V0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709812053; c=relaxed/simple; bh=YvjRBsx4NNUuFJLAuYRgRN71netU30jNtmha+Q+ZmKI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z5ZEfUl9ifKFtucv2mae2G9PegOtiHPLwIEKKnaYl2tCXTS4t6bZmNISJjeeQee5xchYVazWV+QMq90PuqiYmIqaStrpfnon1orAbIv6sF875jnN96xeeVVdG/wBWomi0XN2+Fcdf8cExocSWQkJIrlCDzxzVlGvtThSldoXecE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=W6Yp9Wsa; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-42f111283a6so3658841cf.3 for ; Thu, 07 Mar 2024 03:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709812049; x=1710416849; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=1Tq4PX5OVD/1UTnQNhTdu/i2sdk567MAMJr4rNiSaJg=; b=W6Yp9WsamSkUsISNl92eb1eOWkXtPvXUZo9yEozFl7d73o5IUkH/YVDNOw+28OauF3 ta25mngvQ4SaP4En+7PsxowY4wGPpEpY2jYD/0fpUezRCG5Wef/5CIsN3tNjQoTVJext 3Kjg/mUhpQl05EyFVhmz7uk+3vhr+hDbITi4S7CU/rFpSaJLNuahc+oadTF4VY7qCVL5 IPpyvAHgY4XbX/tSsw7gtN+66BufnVboJn4zixvoT8ISAZyTnXq4KGqFDunrdXLZ95pb 55P+QsrKmCQuw47G/g5baweubhPiYgjflT/pjgdvFqQW2/X//2Xm57XlI+z6uW/2ptTR Wdaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709812049; x=1710416849; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1Tq4PX5OVD/1UTnQNhTdu/i2sdk567MAMJr4rNiSaJg=; b=b1XavSB73/sIBeKGOK32d/8rYi/gcYmIHbtQqTvDCH9x8xR4rK9/k1nfrE9YPj14HI UbPCbIJElcz5aoWBZcqkPqFcX12kbwjUPPDxzRaF7wbfSxRb8g4gvo5g3lPsDsgJUFA+ agMB81ODF0JT0Lhx/I2A2rlrnNdOsz9C29AD43/eMU/QYJIZ83TKRLfZWzbANAEanrp2 XUAv5LmYX5Gb6QFmsSGKeyzIoMRgHyBqYNLfmOSwK90x1EbWPZ5EjPpG1ZNuW9/ZzAwS tm1hwEzJsuy9AqT5wdh+rx8LslCgW34ghO0vDXE6oCd51bwbbVilq7F5p5C8ZiZ7PMz5 29cA== X-Forwarded-Encrypted: i=1; AJvYcCUN9l6+4SWqsQOY6d2l5AFFK4CqYjniujYhz8Lpmwq26m+xmBtk/z0l8IdDuHcWk+U3q2VCT9SRN4dEu5ShyyIfvHD2yqU3K1eugB90 X-Gm-Message-State: AOJu0YxRtqfFDrSqaG6eTinAHByTLO33eS6MfjnRAR8/kqh8oWkW19kS hI11VGMd+LYN7lXQoNFZv2ujhctaDOY6MbwmydFjvpaQVIjuWTABKozGR58T0Q== X-Received: by 2002:a05:622a:1a09:b0:42e:b163:ecf1 with SMTP id f9-20020a05622a1a0900b0042eb163ecf1mr9091826qtb.2.1709812047717; Thu, 07 Mar 2024 03:47:27 -0800 (PST) Received: from thinkpad ([117.217.178.39]) by smtp.gmail.com with ESMTPSA id k6-20020ac80746000000b0042ee243ca95sm4943818qth.50.2024.03.07.03.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 03:47:27 -0800 (PST) Date: Thu, 7 Mar 2024 17:17:19 +0530 From: Manivannan Sadhasivam To: Konrad Dybcio Cc: Bjorn Andersson , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] PCI: qcom: Enable BDF to SID translation properly Message-ID: <20240307114719.GA13049@thinkpad> References: <20240307-pci-bdf-sid-fix-v1-1-9423a7e2d63c@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Mar 07, 2024 at 12:19:56PM +0100, Konrad Dybcio wrote: > > > On 3/7/24 12:05, Manivannan Sadhasivam wrote: > > Qcom SoCs making use of ARM SMMU require BDF to SID translation table in > > the driver to properly map the SID for the PCIe devices based on their BDF > > identifier. This is currently achieved with the help of > > qcom_pcie_config_sid_1_9_0() function for SoCs supporting the 1_9_0 config. > > > > But With newer Qcom SoCs starting from SM8450, BDF to SID translation is > > set to bypass mode by default in hardware. Due to this, the translation > > table that is set in the qcom_pcie_config_sid_1_9_0() is essentially > > unused and the default SID is used for all endpoints in SoCs starting from > > SM8450. > > > > This is a security concern and also warrants swapping the DeviceID in DT > > while using the GIC ITS to handle MSIs from endpoints. The swapping is > > currently done like below in DT when using GIC ITS: > > > > /* > > * MSIs for BDF (1:0.0) only works with Device ID 0x5980. > > * Hence, the IDs are swapped. > > */ > > msi-map = <0x0 &gic_its 0x5981 0x1>, > > <0x100 &gic_its 0x5980 0x1>; > > > > Here, swapping of the DeviceIDs ensure that the endpoint with BDF (1:0.0) > > gets the DeviceID 0x5980 which is associated with the default SID as per > > the iommu mapping in DT. So MSIs were delivered with IDs swapped so far. > > But this also means the Root Port (0:0.0) won't receive any MSIs (for PME, > > AER etc...) > > > > So let's fix these issues by clearing the BDF to SID bypass mode for all > > SoCs making use of the 1_9_0 config. This allows the PCIe devices to use > > the correct SID, thus avoiding the DeviceID swapping hack in DT and also > > achieving the isolation between devices. > > > > Cc: # 5.11 > > Fixes: 4c9398822106 ("PCI: qcom: Add support for configuring BDF to SID mapping for SM8250") > > Signed-off-by: Manivannan Sadhasivam > > --- > > Looks sensible.. > > Does switching away from bypass show any performance degradation? > Not at all with my throughput test on SM8450 dev board. But there shouldn't be any performance related issue since we are just forcing the hw to use a different SID (correct one) than the default one. - Mani -- மணிவண்ணன் சதாசிவம்