Received: by 10.223.176.46 with SMTP id f43csp2977403wra; Mon, 22 Jan 2018 06:34:45 -0800 (PST) X-Google-Smtp-Source: AH8x225lWD17gS4SdT92A02zXFTIClkLP3TJFL4RGz/ezvBVvrzsNQcyfYM/EjVtaVZXqjma1pnI X-Received: by 10.99.102.1 with SMTP id a1mr7350809pgc.452.1516631685727; Mon, 22 Jan 2018 06:34:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516631685; cv=none; d=google.com; s=arc-20160816; b=Ul1VI75v1U4lSfIJXRzmLX3UinOEf7MrDakC60LcjYNKuVKQyA2wWjDBgnOjgLNl+6 iYPFOGNGutUTnL918hD7ffBMRYoR8MLcxDKfIPw2ePqTQ8JzwhZeYLL/XVWG9IAlx9h8 aJJMStHKSIakRjkeRnkLscDXraKV36HoR1aDy5DbebrM/2X5CNwlzXaz0Kz0Suntvqm6 EbpLMrz7T7p5sjTbJMm/BFugBobHj+IhKKdeO/cImmjaknX+H63+DkfLf1BK3tF0xJMu JX/0wwmoLcJ2h5Fa6002ANSmiqG/4Tcd47M+T2RZOsK6VeuLhHY3V0B/0q7cswGgrK3Q zE+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=hrQQrhp2rsHsIKWmrgbvPqmrvHsi1H8dwEPb7c7Wwhk=; b=Ni7WSmXCkkPv4C2wFi9zpJtJGLvsfDw6xlE570EeAYmOAJPmgPSiIftVkc2ZLowXXh i4BkVTVshNparfOmM3w0Q68s6e2bV7vG6+p6AhG6hxj0FuiNyAmh6OuTXO8JzrISzbGa 8xjbJW0od0AHJ8A9nx0kw1j+OMUB6d+4FgiueLbsHSkk2Z17ytSb1np/JQW6yOQOjZaU RfrPEBUDkCRawD/UP136QlMzM7hu7oBCZBKtmsr0ZEqvAVirp4KvuLNHVCieED53UH77 BAB+3+v0fdqOshO0+1jZZU/KKWlO4f5f0M2gSvhr9lXYnSCIlXrhuZ7cGgxQ+NSpDwpg MjSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay8-v6si3567518plb.198.2018.01.22.06.34.31; Mon, 22 Jan 2018 06:34:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751299AbeAVOdZ (ORCPT + 99 others); Mon, 22 Jan 2018 09:33:25 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:7747 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbeAVOdX (ORCPT ); Mon, 22 Jan 2018 09:33:23 -0500 X-IronPort-AV: E=Sophos;i="5.46,396,1511827200"; d="scan'208";a="66451288" Subject: Re: [PATCH v2 2/8] x86/cpufeatures: Add AMD feature bits for Prediction Command To: Tom Lendacky , David Woodhouse , , , , , , , , , , , , References: <1516528149-9370-1-git-send-email-dwmw@amazon.co.uk> <1516528149-9370-3-git-send-email-dwmw@amazon.co.uk> <568a0210-43a1-5580-c0f4-d6d8cc5e982a@amd.com> From: Andrew Cooper Message-ID: <046d1752-bf19-d80e-a7ce-cdf521bacf8c@citrix.com> Date: Mon, 22 Jan 2018 14:33:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <568a0210-43a1-5580-c0f4-d6d8cc5e982a@amd.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/01/18 14:31, Tom Lendacky wrote: > On 1/21/2018 12:01 PM, Andrew Cooper wrote: >> On 21/01/18 17:50, Tom Lendacky wrote: >>> On 1/21/2018 3:49 AM, David Woodhouse wrote: >>>> AMD doesn't implement the Speculation Control MSR that Intel does, but >>>> the Prediction Control MSR does exist and is advertised by a separate >>>> CPUID bit. Add support for that. >>>> >>>> Signed-off-by: David Woodhouse >>>> --- >>>> arch/x86/include/asm/cpufeatures.h | 1 + >>>> arch/x86/kernel/cpu/scattered.c | 1 + >>>> 2 files changed, 2 insertions(+) >>>> >>>> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h >>>> index 2efb8d4..8c9e5c0 100644 >>>> --- a/arch/x86/include/asm/cpufeatures.h >>>> +++ b/arch/x86/include/asm/cpufeatures.h >>>> @@ -207,6 +207,7 @@ >>>> #define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* AMD Retpoline mitigation for Spectre variant 2 */ >>>> #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */ >>>> >>>> +#define X86_FEATURE_AMD_PRED_CMD ( 7*32+17) /* Prediction Command MSR (AMD) */ >>>> #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */ >>>> #define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* Fill RSB on context switches */ >>>> >>>> diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c >>>> index df11f5d..4eb90b2 100644 >>>> --- a/arch/x86/kernel/cpu/scattered.c >>>> +++ b/arch/x86/kernel/cpu/scattered.c >>>> @@ -28,6 +28,7 @@ static const struct cpuid_bit cpuid_bits[] = { >>>> { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 }, >>>> { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, >>>> { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, >>>> + { X86_FEATURE_AMD_PRED_CMD, CPUID_EBX, 12, 0x80000008, 0 }, >>> I replied to the previous version, but I'll add it here, too. >>> >>> This should be moved to the existing 0x80000008/EBX entry rather than have >>> it in scattered. >>> >>> Also, there will be a total of three bits: >>> IBPB: 0x80000008 EBX[12] >>> IBRS: 0x80000008 EBX[14] >>> STIBP: 0x80000008 EBX[15] >>> >>> Since IBRS and STIBP share the same MSR, if a processor only supports >>> STIBP (MSR bit 1), for ease of software implementation the processor >>> does not GP fault attempts to write bit 0. In a similar manner, if a >>> processor only suppors IBRS (MSR bit 0), the processor does not GP >>> fault attempts to write bit 1. >> Are you able to comment on the read behaviour after a write which is >> ignored? >> >> If the behaviour is "read as written" then virt cases are fine.  If the >> "ignore" causes a zero to be read back, then we're still going to need >> to intercept and emulate all VM accesses. > The behavior is "read as written", so the bit will be updated even though > the support for the bit is not present. Fantastic!  Thanks for confirming. ~Andrew