Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4634512pxu; Tue, 13 Oct 2020 03:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDToaOdmljme4Dm4R/hBSZQlXPDhtMm5iL4NYbe9Xtqm2T7kqJ7Z4sumRR2jR++uWMAiCz X-Received: by 2002:a17:906:1b01:: with SMTP id o1mr33917172ejg.539.1602584968280; Tue, 13 Oct 2020 03:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602584968; cv=none; d=google.com; s=arc-20160816; b=A575rwyyoKfI/SXxXFaqtYO/5ori5lskqH5owxXyA8/sNVh7RosYndWW9DRnbFS3/K 0o4OPhWTulbW6u9SHKrHomcI1z5vWDXgMu6jy/C3+iwGC4Xjzg56ERt+KR7JrtQf01US 64mOMAHpF1XL6ys9dyYe7iB+YgudU3k25sOE3DqPe/4q04ct7l5PtGc4XLTCEilMc1eV p0ZjO8yGFw4OSpML3TUGaPHsnmLbZWiZJg5WBJmKjmECwbLzQG2/JjEDro2S+C+as2Hx 9vOp/DtouBLFraQ5+C7xUSgUzQM3afOsz2f3xO6bZwuHHzVyYhwaTSzS9nMFY3+VTq0C 20vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=tJGFCgNc33rWNuDFOxVNPDjzdCjTI+8/78jp+wEpPVk=; b=dyFqxwXFOD8P1Nr0JlrcxC9UsFmwM7bHy1Ar2S2RImV0oF2gapi51B10JKTnqZf456 bX8xyma8lGtS1fkKg0YgVioV809PrcsZfyhIVhMDmTdhZLRyWCwsdWPSCQsQ5gMG40wG aPIelQxwY1lpjGKleccRAUrEiMpoT4yTHVlbo8tnMMFyv6a+obP8WFEiEEJfY81r5dcl 9yMvfNSEbIq9v6uZnnHG2iayGLJ2cxZnjYFhCdBVV42jfAl1keHJyIp4CmnL0tUYdEzb AfRlp0P23I9DMU/H0oR1NQeG7NuAbOHF0VghPldRSZGno90L69E9DBWaUb/TgdwE93y8 bbaQ== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si14039860eds.162.2020.10.13.03.29.05; Tue, 13 Oct 2020 03:29:28 -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; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730847AbgJLUsq (ORCPT + 99 others); Mon, 12 Oct 2020 16:48:46 -0400 Received: from mga18.intel.com ([134.134.136.126]:32797 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgJLUsp (ORCPT ); Mon, 12 Oct 2020 16:48:45 -0400 IronPort-SDR: Ga9jL4XqRZoF/1D1vPbHZsHj3CpAhD1MgNQqMX+Mylk6bSQjbiKpXtgx504ddlcc0SLEVcLG2d aHJWxQBJQKZQ== X-IronPort-AV: E=McAfee;i="6000,8403,9772"; a="153633359" X-IronPort-AV: E=Sophos;i="5.77,367,1596524400"; d="scan'208";a="153633359" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2020 13:48:44 -0700 IronPort-SDR: H1g1CQHMtcwO1nWWiBZcdHpuTzPfruHJRRdh25uJeXaBoAYCtJIBhg3KVBUEXVaTG53rphSmVx fgUHljXAvRCA== X-IronPort-AV: E=Sophos;i="5.77,367,1596524400"; d="scan'208";a="356745959" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.167.7]) ([10.209.167.7]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2020 13:48:43 -0700 Subject: Re: [PATCH v14 03/26] x86/fpu/xstate: Introduce CET MSR XSAVES supervisor states To: Cyrill Gorcunov Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu References: <20201012153850.26996-1-yu-cheng.yu@intel.com> <20201012153850.26996-4-yu-cheng.yu@intel.com> <20201012195808.GD14048@grain> From: "Yu, Yu-cheng" Message-ID: Date: Mon, 12 Oct 2020 13:48:42 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201012195808.GD14048@grain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/12/2020 12:58 PM, Cyrill Gorcunov wrote: > On Mon, Oct 12, 2020 at 08:38:27AM -0700, Yu-cheng Yu wrote: > ... >> /* >> * x86-64 Task Priority Register, CR8 >> diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c >> index 038e19c0019e..705fd9b94e31 100644 >> --- a/arch/x86/kernel/fpu/xstate.c >> +++ b/arch/x86/kernel/fpu/xstate.c >> @@ -38,6 +38,9 @@ static const char *xfeature_names[] = >> "Processor Trace (unused)" , >> "Protection Keys User registers", >> "unknown xstate feature" , >> + "Control-flow User registers" , >> + "Control-flow Kernel registers" , >> + "unknown xstate feature" , >> }; >> >> static short xsave_cpuid_features[] __initdata = { >> @@ -51,6 +54,9 @@ static short xsave_cpuid_features[] __initdata = { >> X86_FEATURE_AVX512F, >> X86_FEATURE_INTEL_PT, >> X86_FEATURE_PKU, >> + -1, /* Unused */ >> + X86_FEATURE_SHSTK, /* XFEATURE_CET_USER */ >> + X86_FEATURE_SHSTK, /* XFEATURE_CET_KERNEL */ >> }; > > Why do you need "-1" here in the array? The only 1:1 mapping is between > the names itselves and values, not indices of arrays so i don't understand > why we need this unused value. Sorry if it is a dumb questions and > been discussed already. > The indices are used indirectly in fpu__init_system_xstate() to set bits in xfeatures_mask_all, i.e. xfeatures_mask_all &= ~BIT_ULL(i). So they need to match the xstate feature bits. Yu-cheng