Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3538856ybt; Tue, 30 Jun 2020 05:32:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw15eK64xYFOXpeXMsYoM4d9fj23FG0Kef+6Ok92mRQiG59BKEdDnUYX/h/Ynluzl9eSgyS X-Received: by 2002:a17:907:2058:: with SMTP id pg24mr19069819ejb.79.1593520353123; Tue, 30 Jun 2020 05:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593520353; cv=none; d=google.com; s=arc-20160816; b=AfNIvGuwIWHNRq1TUWf7DNXkYUu2lespoRXqkz2uUysIrdWmlNGe4Q/0dQZ35PeSq9 K0Ks44Aanh2T+wNIeh0u2NMhqVN5mFZ3Z+ikUZCeDN04wHaTwpqTZ+Rts/TuTSu/RYHo FBgJiZArfXaT+wMzC9R+ALGshmsASBEq5tSVHAIO5eCFZtLk1Qv/ER0zkK43/rV8bgL5 ydKN2lxGEzcLYAblYyEAOQylvVy2fK/ABLnkTtDaz76ff6e5sViruyZdmrbDV1TUgsIB 3VVRgbzifhsjWuxKJlaVi57rSUhCIFzP8bxRnAEdkgltGHd1F8qKdeGPEuyAJ9CIHCCA /3zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:message-id:date:subject :cc:from:ironport-sdr:dkim-signature; bh=1SYBHjTB+q5E+ZB8QENYuEXlQudyQrqQO5pO6Am+EEU=; b=cFR2VKrWVc54njeR9RIuSQgPrYl7W3Ym5zIxFDPGSd8uCQc4ouMp8k7UvfHKBy0/H1 2DvmLhhGx6S8Tqr3Im7nTGT00nWvo0XjrDIUABukADboAmjhyTr481JSGxWEFQ+NJLqM Mxb6jvGa4U1aXMhThnBOvoZGO7+Zd0xJwJVSJkhBStmNnHc1B4hGA8Iy/PshYituhb/0 OQVLNqtqnxHI0pQaGDYEEVd+T4JK48WMUQMl4ERHlfa/ApEX4VNalaUT7DnKIOjgM0Km bWJciQaLYH+0yicd+ZvIIqBBNVBp6JFUkQZ4+Qz4c9J8EpPoFZZTXj5MDfDmNp1lHUeF /E/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@amazon.de header.s=amazon201209 header.b=H2gEzFv0; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si1622757eja.474.2020.06.30.05.32.09; Tue, 30 Jun 2020 05:32:33 -0700 (PDT) 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; dkim=fail header.i=@amazon.de header.s=amazon201209 header.b=H2gEzFv0; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387426AbgF3M3m (ORCPT + 99 others); Tue, 30 Jun 2020 08:29:42 -0400 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:3750 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730095AbgF3M3m (ORCPT ); Tue, 30 Jun 2020 08:29:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1593520181; x=1625056181; h=from:to:cc:subject:date:message-id:mime-version; bh=1SYBHjTB+q5E+ZB8QENYuEXlQudyQrqQO5pO6Am+EEU=; b=H2gEzFv0kVTs7zN9dem+WBaSAh/9oFVo0mO+eDE3d7n+zPvwGeS0grV/ zBUFkFHBSXAaaWrYTinmEcyIxPM8Jeit5zAww9HJFp1USU8yiwc7JToPV FTwQbL3GyalSH86SK/gHo9rQIVZVxZBSD7dS7F57vlb4EjtoOmqPAOOmp 8=; IronPort-SDR: 24GE8aKjT5T9+JGempUpxCY0xCGWdMUQzMqL9jkMNbtduu4ZyyCdQF6qGsE8klTAMuwe714Jgk xvtVzeu8wrVQ== X-IronPort-AV: E=Sophos;i="5.75,297,1589241600"; d="scan'208";a="39354207" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-69849ee2.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Jun 2020 12:29:39 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-69849ee2.us-west-2.amazon.com (Postfix) with ESMTPS id DD6ADA23B6; Tue, 30 Jun 2020 12:29:38 +0000 (UTC) Received: from EX13D18EUC001.ant.amazon.com (10.43.164.108) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 30 Jun 2020 12:29:38 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D18EUC001.ant.amazon.com (10.43.164.108) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 30 Jun 2020 12:29:37 +0000 Received: from dev-dsk-mheyne-60001.pdx1.corp.amazon.com (10.184.85.242) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 30 Jun 2020 12:29:36 +0000 Received: by dev-dsk-mheyne-60001.pdx1.corp.amazon.com (Postfix, from userid 5466572) id 92633222EA; Tue, 30 Jun 2020 12:29:35 +0000 (UTC) From: Maximilian Heyne CC: Amit Shah , Maximilian Heyne , , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , , Subject: [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0 Date: Tue, 30 Jun 2020 12:29:23 +0000 Message-ID: <20200630122923.70282-1-mheyne@amazon.de> X-Mailer: git-send-email 2.16.6 MIME-Version: 1.0 Content-Type: text/plain To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Controller ID's (cntlid) for NVMe devices were introduced in version 1.1.0 of the specification. Controllers that follow the older 1.0.0 spec don't set this field so it doesn't make sense to validate it. On the contrary, when using SR-IOV this check breaks VFs as they are all part of the same NVMe subsystem. Signed-off-by: Maximilian Heyne Cc: # 5.4+ --- drivers/nvme/host/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 28f4388c1337..c4a991acc949 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2773,7 +2773,8 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) put_device(&subsys->dev); subsys = found; - if (!nvme_validate_cntlid(subsys, ctrl, id)) { + if (ctrl->vs >= NVME_VS(1, 1, 0) && + !nvme_validate_cntlid(subsys, ctrl, id)) { ret = -EINVAL; goto out_put_subsystem; } @@ -2883,7 +2884,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) goto out_free; } - if (!(ctrl->ops->flags & NVME_F_FABRICS)) + if (!(ctrl->ops->flags & NVME_F_FABRICS) && ctrl->vs >= NVME_VS(1, 1, 0)) ctrl->cntlid = le16_to_cpu(id->cntlid); if (!ctrl->identified) { -- 2.16.6 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879