From patchwork Wed Nov 29 01:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Lin1" X-Patchwork-Id: 171022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp46903vqn; Tue, 28 Nov 2023 17:23:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxwNAAofYSG9UB/FOTvfsFsMPsn1on2Rk7o00pJKw4uf2vW3gw6D785NEPpEUKsoWIQH9/ X-Received: by 2002:a0c:eb90:0:b0:67a:3840:98eb with SMTP id x16-20020a0ceb90000000b0067a384098ebmr10521667qvo.21.1701221039113; Tue, 28 Nov 2023 17:23:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701221039; cv=pass; d=google.com; s=arc-20160816; b=vHoWwINn4o/Bpvkxi6ljHHf/sHgb+kfNEsQX9V2JJU0QohMDMYkTVZRO6liSUh17qS 1FAGIqQAoLo/B9U5/VtN9LzrobsEWxkRUXQew436VP9r9lQ/xCvzNjfcMJpPYLlPLCe+ JZmF0Y3iYa9lyhuoJTl4LBhYv/t81G5C/f7vFEjskni442Yv0DK117X/UPoW4mIh3nwW TZCBeYHYTS23b6Me+bMj81hLW73yU+bGWriIT2XszmDML4XZghXERggA/Pqy4Coi5m4h dNJs4CYnON1PZFl95VNql3EZZgJu+keUl+DQ9BbM783xjpR211SUq1kj2ICooC9+tgVA 0aiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=zaXV4Ha7PGtYl0lNKaTty0OHlWtgef45lQE88W6rrKI=; fh=M9HM6ASxJ13myMyxe6+D5Y8nbneXlY5qT/Udj6S6pN8=; b=kmu/aBdNQwp29+lQoXSnk0j43RyBEc/hqciNhObcvp7guEcLfsbYhIYLl2vh5Qclpc 2wf1m8+5dOIlZNX3cn4e+aPUUqaTfiggsTbYlALVbsMchZAkPc7v9CCwqr5EVAab/ueh FfiimcQ3mlMI3Nwz6VEzJFE4VrWLxag0R7/wAepmC9V52qv60KNYsPYRE6x9wyMJKiz/ JidNn9CNvU0R/1NDshAMZQBPOOtysjzfVp1rIiX9z4ItOshZOh9Eqp6ZS9/bkNh/+CZn zZqvZjytL5fx1mORKHxgAVSWcziDvVQHUn1leMp3v8LlSKY7C3jbU6CUnBeckzZW75hz 4unQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nj1nBuDu; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r13-20020ad4576d000000b0067a4aa6509csi4830750qvx.561.2023.11.28.17.23.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 17:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nj1nBuDu; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDE0C3858003 for ; Wed, 29 Nov 2023 01:23:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id 009933858D3C for ; Wed, 29 Nov 2023 01:23:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 009933858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 009933858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701221015; cv=none; b=vHpKtbsU6L6hmnyhy5VKjGTjEXgTbCrwtuQqGjkoimSh6Wetyrr3t/iMkNIyDRvkh4T0LmgZk9RIEYdNdvSzmGrHlocAgsp9xpyysdrOYAQnJHWyNp63zYNVzSx/KFGLcEO4RiSJk1f+ynxwmRsOSwmcG8HRME6v3DoJw4pAPCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701221015; c=relaxed/simple; bh=8pG1hIoPNNvTxrjoQ9JlqbckwfumVRRSlQASJoa8u5M=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=uFACiK8WVlmuiJppHB5tvw0SW9+JEeFQEBUc4HuUMv9Gl1d/fY+7v5QuvOXPmD/iP0pp+OU6eDpX1Uxy9ohgDhnxtoXc9RJ0W4mKXNS//2TwXKuIqBnnCpcHcPGLqXdvCquuOGzumFBA6WNETHN0JSrCQuFTAldIG1FCG2P1Z7A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701221014; x=1732757014; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=8pG1hIoPNNvTxrjoQ9JlqbckwfumVRRSlQASJoa8u5M=; b=nj1nBuDulQyAkmKyJSD5Bz3NkyRrNFJIfIjJFZOMmFF17+Rx5d65g4Ah uUo3YI4P0hSOjtmg7PN9aaDdCr9O21lJSLuIHxOczUv3ypFyuzOmX2fVs FcGf8W8FsBzHHZeLAZpPnGWIQS70XOQlSpxbVvkXwQRQJ3htiReRDV1Mk uST0YoiEsrw1xEgMOb858rMSbvdi7sFrrSGsamFCD5JGzaJG1eI3HHOJW WbWp6ePAlycXrDZfI/mnNOllKvnsrGjrLbXWBhH4bJYEoATjgUZQuWFpO huP3nElegRp/VsxqXQPJPMqr8ALU3bEE87DRn64MC2fC9HSZGeHadI4pW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="457405546" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="457405546" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 17:23:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="803117776" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="803117776" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga001.jf.intel.com with ESMTP; 28 Nov 2023 17:23:25 -0800 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id C0742100567D; Wed, 29 Nov 2023 09:23:25 +0800 (CST) From: "Hu, Lin1" To: gcc-patches@gcc.gnu.org Cc: hongtao.liu@intel.com, ubizjak@gmail.com Subject: [PATCH] i386: Fix CPUID of USER_MSR. Date: Wed, 29 Nov 2023 09:21:25 +0800 Message-Id: <20231129012125.458224-1-lin1.hu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783859551994759308 X-GMAIL-MSGID: 1783859551994759308 Hi, all This patch aims to fix the wrong CPUID of USER_MSR, its correct CPUID is (0x7, 0x1).EDX[15], But I set it as (0x7, 0x0).EDX[15]. And the patch modefied testcase for give the user a better example. It has been bootstrapped and regtested on x86-64-pc-linux-gnu, OK for trunk? BR, Lin gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_available_features): Move USER_MSR to the correct location. gcc/testsuite/ChangeLog: * gcc.target/i386/user_msr-1.c: Correct the MSR index for give the user an proper example. --- gcc/common/config/i386/cpuinfo.h | 4 ++-- gcc/testsuite/gcc.target/i386/user_msr-1.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h index f90fb4d56a2..a1eb285daed 100644 --- a/gcc/common/config/i386/cpuinfo.h +++ b/gcc/common/config/i386/cpuinfo.h @@ -861,8 +861,6 @@ get_available_features (struct __processor_model *cpu_model, set_feature (FEATURE_IBT); if (edx & bit_UINTR) set_feature (FEATURE_UINTR); - if (edx & bit_USER_MSR) - set_feature (FEATURE_USER_MSR); if (amx_usable) { if (edx & bit_AMX_TILE) @@ -921,6 +919,8 @@ get_available_features (struct __processor_model *cpu_model, set_feature (FEATURE_PREFETCHI); if (eax & bit_RAOINT) set_feature (FEATURE_RAOINT); + if (edx & bit_USER_MSR) + set_feature (FEATURE_USER_MSR); if (avx_usable) { if (eax & bit_AVXVNNI) diff --git a/gcc/testsuite/gcc.target/i386/user_msr-1.c b/gcc/testsuite/gcc.target/i386/user_msr-1.c index 447852306df..f315016d088 100644 --- a/gcc/testsuite/gcc.target/i386/user_msr-1.c +++ b/gcc/testsuite/gcc.target/i386/user_msr-1.c @@ -1,9 +1,9 @@ /* { dg-do compile { target { ! ia32 } } } */ /* { dg-options "-musermsr -O2" } */ /* { dg-final { scan-assembler-times "urdmsr\[ \\t\]\\%r\[a-z\]x, \\%r\[a-z\]x" 1 } } */ -/* { dg-final { scan-assembler-times "urdmsr\[ \\t\]\\\$121" 1 } } */ +/* { dg-final { scan-assembler-times "urdmsr\[ \\t\]\\\$6912" 1 } } */ /* { dg-final { scan-assembler-times "uwrmsr\[ \\t\]\\%r\[a-z\]x, \\%r\[a-z\]x" 1 } } */ -/* { dg-final { scan-assembler-times "uwrmsr\[ \\t\]\\%r\[a-z\]x, \\\$121" 1 } } */ +/* { dg-final { scan-assembler-times "uwrmsr\[ \\t\]\\%r\[a-z\]x, \\\$6912" 1 } } */ #include @@ -13,8 +13,9 @@ volatile unsigned long long y; void extern user_msr_test (void) { + y = 6913; x = _urdmsr(y); - x = _urdmsr(121); + x = _urdmsr(6912); _uwrmsr(y, x); - _uwrmsr(121, x); + _uwrmsr(6912, x); }