From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 7BCA8A0526;
	Wed,  8 Jul 2020 23:49:04 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id C30BE1E534;
	Wed,  8 Jul 2020 23:49:03 +0200 (CEST)
Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com
 [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 909531E4EE
 for <dev@dpdk.org>; Wed,  8 Jul 2020 23:49:02 +0200 (CEST)
Received: by mail-lj1-f193.google.com with SMTP id h19so56000689ljg.13
 for <dev@dpdk.org>; Wed, 08 Jul 2020 14:49:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=IuHGwqkiYYLN5EW1JBKcPuwEK1JR7nTMvB9gA6BUOLo=;
 b=im+7MylA3flro3FID7FdfmochYSq13tOW88d0VeWOW4GBpo6crbDda6wn+EF75gdQA
 FpdTlXvSUraJN6WV9cdHaetDT8DADuqKyVVgewM4tgHC1ZKok+qrOCDSVDIaBNH8720V
 uXN/9hBhEBbaN7uKetqJK9eWa34ltvtJ6MmsRdcrIee2TZv7wgE6lrkqeproW7Krj5A/
 85s4JoB62vOygEjfRty12hNxDT/hMzCA+FHTBVvB8y8CxPoolvjmb648wkui9kykuWKF
 yp3QtvgmBBeHNVuTCEKIvBEfUdKU03eZ0fS0TYy4jsKcvlqU0kFxQhgp9iLC90l9mGLs
 +StQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=IuHGwqkiYYLN5EW1JBKcPuwEK1JR7nTMvB9gA6BUOLo=;
 b=JGQksL4x37XjPGa8nwaYS3m8IfaBWL49yjyA/+XCtcSq8lXzL4pSYSMgEjDgbqJocY
 o0a+QlCCnLlivhD27BiWe5MHWidFpNhlBiVPVO4+3faKtooR3c+rk7th6/lpzw+W4oir
 tDjiP0Za2qelphw/DxPzlTpfA34DbTJeML5Bv/i1Fr3RjLC2f6sMLHPVOho8lpFWoX/t
 SsI3gBJ5dMuj/0qiayZ7IIIfCFCZ2hNyb+hY1F3F/ZRRQZR7FIG3pF/Zhj4ccxKz0QbW
 1ldlxkOx4EF12k//+u2HblYCOzUgYTHox+tF60h65YzvrXHqqOoZfYlTWNDejRXFfRRc
 OuSA==
X-Gm-Message-State: AOAM532OohWGUbPKd/LJjhCVCy+GregSzMZMWogp/1lXWu0S7NBgB7AY
 MKOBcfl6p/nB4qNNSr/3VnIYSJystD6FJw==
X-Google-Smtp-Source: ABdhPJw5nJP04GUwKwQUphJceaOYCu6ZpjOXsb3ssXYNzfRfOZ9rR9tE33Rd78U7jlEiR0JeG666vA==
X-Received: by 2002:a2e:8807:: with SMTP id x7mr21164023ljh.21.1594244941675; 
 Wed, 08 Jul 2020 14:49:01 -0700 (PDT)
Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru.
 [37.110.65.23])
 by smtp.gmail.com with ESMTPSA id x16sm300032lfc.76.2020.07.08.14.49.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 08 Jul 2020 14:49:00 -0700 (PDT)
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
 Ranjit Menon <ranjit.menon@intel.com>,
 Pallavi Kadam <pallavi.kadam@intel.com>,
 Tal Shnaiderman <talshn@mellanox.com>,
 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Date: Thu,  9 Jul 2020 00:48:43 +0300
Message-Id: <20200708214843.3080-1-dmitry.kozliuk@gmail.com>
X-Mailer: git-send-email 2.25.4
In-Reply-To: <20200707202203.8780-1-dmitry.kozliuk@gmail.com>
References: <20200707202203.8780-1-dmitry.kozliuk@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v2] eal/windows: detect insufficient privileges
	for hugepages
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

AdjustTokenPrivileges() succeeds even if no requested privileges have
been granted; this behavior is documented. Check last error code in
addition to return value to detect such case.

Make error messages more specific and add troubleshooting hint.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---

v2:
    Improve error reporting (Tal Shnaiderman).

 lib/librte_eal/windows/eal_hugepages.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/windows/eal_hugepages.c b/lib/librte_eal/windows/eal_hugepages.c
index 5779cd325..7f8a7dfca 100644
--- a/lib/librte_eal/windows/eal_hugepages.c
+++ b/lib/librte_eal/windows/eal_hugepages.c
@@ -41,6 +41,10 @@ hugepage_claim_privilege(void)
 		goto exit;
 	}
 
+	/* AdjustTokenPrivileges() may succeed with ERROR_NOT_ALL_ASSIGNED. */
+	if (GetLastError() != ERROR_SUCCESS)
+		goto exit;
+
 	ret = 0;
 
 exit:
@@ -98,12 +102,14 @@ int
 eal_hugepage_info_init(void)
 {
 	if (hugepage_claim_privilege() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot claim hugepage privilege\n");
+		RTE_LOG(ERR, EAL, "Cannot claim hugepage privilege\n"
+			"Verify that large-page support privilege "
+			"is assigned to the current user\n");
 		return -1;
 	}
 
 	if (hugepage_info_init() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot get hugepage information\n");
+		RTE_LOG(ERR, EAL, "Cannot discover available hugepages\n");
 		return -1;
 	}
 
-- 
2.25.4