Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp988831imm; Tue, 15 May 2018 12:06:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosZuRzsDSPCYGtxz+7JL5MIU8TZujL3ivblQKt6KBSOATV377RWhE49409Lla7TSKCng1H X-Received: by 2002:a62:ea1a:: with SMTP id t26-v6mr16504433pfh.117.1526411197646; Tue, 15 May 2018 12:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526411197; cv=none; d=google.com; s=arc-20160816; b=PFgutwgLG4XQ/dGuEsFwBX3/JpbzG0tL0TD8sSwELipkP/EnacVYkntiPg2aEdBSx8 gwmSS6KmFoWiFTtu0Jw0G8WZPFMM+mOCwMDx8wmilWqzywLSB1h7CutS1IL9ppSDRXib v5BLfRd7/1TvCKJVEZgHmF8wmMqC+moxDiSTiUXJ96HgPRFxHbz7VM421NAOF2oHcUYo QajrCecgbrO6JYejQdj1LLiifmV+iFY383Z8bqY/hwXtkT1qIEk8DHTO1yhZ6GJc6MJf Iz19srXPdsJvPZFSGQPRB0C3zpImko8RdxVGMdDP7nlkaUEQyRcENWah7aNB+Yy5s7Zr XMvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=tehtG7hs1hqZa/4BLnpA4DIWxMwWJbeeud3oG3YAHGw=; b=fEm103fMhSMJ+oaIbeSnvxnxySJ+G6UyDfh0tAQtZEQWmnvnRBoBwk9gjlVhPiBflT 1Yiw5u3rTgEfBBZ853VLo83WNpa6vQHVz1lZPuSYUad5c91g1zXNrdTGjP1EWin1sWPw EllTY/WCX/gs3B9qedCkKhAVxxeivDzRkNsbMpFaxNgtdvEsX5qp8402yKjmJwYZYqeD /6Ru6uasq4wynRfixTAtjl23KqmJQAGDeUVNWQP0M/UPPjOLr1Eam5euH2twHGJdlAAn yxRG4y2dZnodrd/pw/ZU8qX73+tQbQvueUSacK0yt+3bsJ015RVk4M4WqUvPlma6T1IP 5dTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Gh8Idxgz; 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 h12-v6si677174plt.494.2018.05.15.12.06.17; Tue, 15 May 2018 12:06:37 -0700 (PDT) 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=@ziepe.ca header.s=google header.b=Gh8Idxgz; 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 S1752433AbeEOTEc (ORCPT + 99 others); Tue, 15 May 2018 15:04:32 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39076 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751886AbeEOTEa (ORCPT ); Tue, 15 May 2018 15:04:30 -0400 Received: by mail-wm0-f65.google.com with SMTP id f8-v6so3076303wmc.4 for ; Tue, 15 May 2018 12:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=tehtG7hs1hqZa/4BLnpA4DIWxMwWJbeeud3oG3YAHGw=; b=Gh8IdxgzHH4GMXIv+uQARaYoeAp9pFs3NfHWE1X8JVHqYqJLlrCtjgDN6pDOCrXusH kC5GAXwDI/yVrk+VxyBXERMZS8DdUDgTwTWD/wOVcTVThV+KYCZSChhbm6bTQBnGU2yj EbER9r8DwhLw5W6QVDbDcf7IYvBtofYwNxL/eY4eC9QUcmz3TM0SpTBMCehHRnamMFko knwbRTmTC6prlHzY4kEG4uLQxW7nrqQB0gcToRBh6iVs/f62taUAhB8rxyeTPLIcqUSO AXqQeb9Pq2IMhKCZC6EFnD7PymlSu3l1DMfq9PTGE0Dz7PE5w/Fxr56mmptUVvJIRJdm aa7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=tehtG7hs1hqZa/4BLnpA4DIWxMwWJbeeud3oG3YAHGw=; b=ubKh2yugu+V5FBm2RpMHLTkih5IvNCsUSeTjNBitDkAHiOGWvyn2kg8D5wC5UDNVbR XZ+WEk1BlUteEqyqS8Ekfb00ETt14PKFtjBbnC8xYUuCrwRVqC5uE62QM7bAjrGkVZhd Gpn0zqL2urBDUIQsLimgW9tPElW4AXLJgmzJNolOyQujWwKC5VgsqK2Ly1e/gZturkKe UdJbvM9Bz013rjl4bTO2xtVYL8LB84hVKeWSdOeS9u1tEJeNuxBqSuLcmngXfn5GoxMl KEotRAquBF4zBi7qiyErwFL9gzB+2KARIn5e+5NCgm2iEFmADsdwnocahdOTdNg1dqwa 4uVQ== X-Gm-Message-State: ALKqPwc/Tcp/SWuSvpzs6VgCBpkQKZMZlX1Y4mMe9nmqmH/AHHp6V8I8 RLlYlglvc7e7wx4yowzoVzMMXA== X-Received: by 2002:a1c:7e8d:: with SMTP id z135-v6mr8537397wmc.6.1526411069276; Tue, 15 May 2018 12:04:29 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id t189-v6sm1253365wmf.22.2018.05.15.12.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 12:04:28 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1fIfFI-0000Qq-3P; Tue, 15 May 2018 13:04:24 -0600 Date: Tue, 15 May 2018 13:04:24 -0600 From: Jason Gunthorpe To: =?utf-8?B?SMOla29u?= Bugge Cc: Hal Rosenstock , Doug Ledford , Don Hiatt , Ira Weiny , Sean Hefty , OFED mailing list , linux-kernel@vger.kernel.org Subject: Re: [PATCH IB/core 2/2] IB/cm: Send authentic pkey in REQ msg and check eligibility of the pkeys Message-ID: <20180515190424.GL5615@ziepe.ca> References: <20180509093020.24503-1-Haakon.Bugge@oracle.com> <20180509093020.24503-3-Haakon.Bugge@oracle.com> <3bee76df-49a6-cf3c-6df4-749a6309358e@dev.mellanox.co.il> <20180514210200.GN21531@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 08:11:09PM +0200, Håkon Bugge wrote: > > On 15 May 2018, at 02:38, Hal Rosenstock wrote: > > > > On 5/14/2018 5:02 PM, Jason Gunthorpe wrote: > >> On Thu, May 10, 2018 at 05:16:28PM +0200, Håkon Bugge wrote: > >> > >>> We are talking about two things here. The PKey in the BTH and the > >>> PKey in the CM REQ payload. They differ. > >>> > >>> I am out of office, but if my memory serves me correct, the PKey in > >>> the BTH in the MAD packet will be the default PKey. Further, we have > >>> per IBTA: > >> > >> This sounds like a Linux bug. > >> > >> Linux does not do a PR to get a reversible path dedicated to the GMP> so it always uses the data flow path, thus the GMP path paramenters > >> and those in the REQ should always exactly match. > >> > >> Where is Linux setting the BTH.PKey and how did it choose to use the > >> default pkey? Lets fix that at least for sure. > > Linux isn’t. The BTH.PKey is inserted by the HCA (hw or fw) coming from the P_Key table (10.9.2 in IBTA), selected by a pkey_index associated with the QP. > > As per C10-133: Packets sent from the Send Queue of a GSI QP shall > attach a P_Key associated with that QP, just as a P_Key is > associated with nonmanagement QPs That language doesn't mean the PKey is forced to the default, it says the pkey is programmable. Linux implemented programmable PKeys for the GSI by using the work request, so it deviates from what the spec imagined (which was probably one GSI QP per PKey). See ib_create_send_mad for instance: mad_send_wr->send_wr.wr.wr_cqe = &mad_send_wr->mad_list.cqe; mad_send_wr->send_wr.wr.sg_list = mad_send_wr->sg_list; mad_send_wr->send_wr.wr.num_sge = 2; mad_send_wr->send_wr.wr.opcode = IB_WR_SEND; mad_send_wr->send_wr.wr.send_flags = IB_SEND_SIGNALED; mad_send_wr->send_wr.remote_qpn = remote_qpn; mad_send_wr->send_wr.remote_qkey = IB_QP_SET_QKEY; mad_send_wr->send_wr.pkey_index = pkey_index; The pkey_index associated with the QP1 is ignored: /* * PKey index for QP1 is irrelevant but * one is needed for the Reset to Init transition */ attr->qp_state = IB_QPS_INIT; attr->pkey_index = pkey_index; attr->qkey = (qp->qp_num == 0) ? 0 : IB_QP1_QKEY; ret = ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_QKEY); Since is is present in every WR. > >> Basically this means that any pkey in the REQ could randomly be the > >> full or limited value, and that in-of-itself has not bearing on the > >> connection. > >> > >> So it is quite wrong to insist that the pkey be limited or full when > >> processing the REQ. The end port is expected to match against the > >> local table. > > > > Note that there is thorny issue with shared (physical) port > > virtualization. In shared port virtualization, the VF pkey assignment is > > a local matter. Only thing SM knows is the physical port pkeys where > > both full and limited membership of same partition is possible. It is > > conceivable that CM REQ contains limited partition key between 2 limited > > VFs and for that a new REJ reason code appears to be needed. > > +1 This is not a difficult issue. If the GMP is properly tagged with the right PKey then it will never be delivered to the VM if the VM does not have the PKey in the table. It is up to the hypervisor to block GMPs that have Pkeys not in the virtual PKey table of the VF. The only time you could need a new REJ code is if the GMP is using a PKey different from the REQ - which is a pretty goofy thing to do considering this VM case. Remember the SM doesn't know what Pkeys are in the VM, so it is basically impossible for the REQ side to reliably select two different pkeys and know that they will bothmake it to the VM. One pkey could be done reliably if it matched ipoib, for instance, but two really cannot in the general case. So again - the bug here is that the GMP is being sent with the wrong pkey. Fix that, then see what is left to fix.. If I recall there were bugs here in mlx drivers, where the driver sent with the wrong Pkey. I think this has actually been fixed now, so please check the upstream kernel to be sure the Pkey is not what it is supposed to be. Jason