From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8464C432C8; Tue, 7 Nov 2023 17:19:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F18B402DD; Tue, 7 Nov 2023 17:19:29 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id A5840402A1 for ; Tue, 7 Nov 2023 17:19:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699373967; x=1730909967; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vheeZZLYo+6mmBJUeIcrxnKEWJTabG9FQwS62gLlQVY=; b=fIVWyFnT9sKLvxJvVWeysnddLF9O6GRu35lv56gSTEwOSzJnXrOI9JNn 6yovojqY63eu4sXu37fIWEDE+g3JT/1sSBg/va5ecrpriteSPJR8iB61t iHBXK+p/4s5ySajsf9NUVwoN/U8Fe2JrhEKih4YhlcnFRXQKOdk41HGze q/ozSxFA7tNwLLC5gb9C2KGJMCo7YTPbsY5MIbfLSXfq7aC7RhUSLwQtZ M92n2m9RCCTMqQzNkw8Y+WQ240uAbNYgY//DJ8GAzM6PIw9Uchh5OrB+G 6s5Us6jb/xHD8OucMoZZnslnLMZ4Pj6AlRlYW3wcxiTcR0ChnCspY3I3w A==; X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="389348264" X-IronPort-AV: E=Sophos;i="6.03,284,1694761200"; d="scan'208";a="389348264" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2023 08:19:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,284,1694761200"; d="scan'208";a="10481140" Received: from silpixa00401385.ir.intel.com ([10.237.214.164]) by orviesa001.jf.intel.com with ESMTP; 07 Nov 2023 08:19:25 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: anatoly.burakov@intel.com, David Hunt , Bruce Richardson Subject: [PATCH] eal/x86: fix segfaults in waitpkg power intrinsics Date: Tue, 7 Nov 2023 16:19:01 +0000 Message-Id: <20231107161900.46058-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: David Hunt The code was recently enhanced to allow the use of the waitpkg intrinsics rather than the raw assembly in the rte_power functions. However, the parameters to the intrinsics, while compiling fine, were incorrect, and would segfault when run on the appropriate hardware. This patch fixes the intrinsic parameters. Tested on a system with tpause and umonitor/umwait instructions. Fixes: 60943c04f3bc ("eal/x86: use intrinsics for power management") Signed-off-by: David Hunt Reviewed-by: Bruce Richardson --- lib/eal/x86/rte_power_intrinsics.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c index 483395dcd5..532a2e646b 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -40,12 +40,12 @@ static void intel_umonitor(volatile void *addr) static void intel_umwait(const uint64_t timeout) { +#if defined(RTE_TOOLCHAIN_MSVC) || defined(__WAITPKG__) + _umwait(0, timeout); +#else const uint32_t tsc_l = (uint32_t)timeout; const uint32_t tsc_h = (uint32_t)(timeout >> 32); -#if defined(RTE_TOOLCHAIN_MSVC) || defined(__WAITPKG__) - _umwait(tsc_l, tsc_h); -#else asm volatile(".byte 0xf2, 0x0f, 0xae, 0xf7;" : /* ignore rflags */ : "D"(0), /* enter C0.2 */ @@ -208,17 +208,17 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc, int rte_power_pause(const uint64_t tsc_timestamp) { - const uint32_t tsc_l = (uint32_t)tsc_timestamp; - const uint32_t tsc_h = (uint32_t)(tsc_timestamp >> 32); - /* prevent user from running this instruction if it's not supported */ if (!wait_supported) return -ENOTSUP; /* execute TPAUSE */ #if defined(RTE_TOOLCHAIN_MSVC) || defined(__WAITPKG__) - _tpause(tsc_l, tsc_h); + _tpause(0, tsc_timestamp); #else + const uint32_t tsc_l = (uint32_t)tsc_timestamp; + const uint32_t tsc_h = (uint32_t)(tsc_timestamp >> 32); + asm volatile(".byte 0x66, 0x0f, 0xae, 0xf7;" : /* ignore rflags */ : "D"(0), /* enter C0.2 */ -- 2.39.2