Received: by 10.223.176.46 with SMTP id f43csp2048963wra; Sun, 21 Jan 2018 10:02:34 -0800 (PST) X-Google-Smtp-Source: AH8x225V1lpEaQ3726wQBDRJ+7bNQ2Fb0HcNlGBfMcYEFbKG2xIMC+4ueqD15k2CXHXWc2pMrH5r X-Received: by 2002:a17:902:7614:: with SMTP id k20-v6mr2237781pll.343.1516557754734; Sun, 21 Jan 2018 10:02:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516557754; cv=none; d=google.com; s=arc-20160816; b=vZJRT8C8XXObM0qRzsg3U/a2URiplbgMQ1nu5A4GAErHqg+vtnekVtuj9Torhh7+wZ CQ97vjQjCn9n71myMlg8W09pIP795FcvGwPmfX5pftGqBYVMpJZF7QKIKwagvbuNz50B AKJ07XUkwN7to3r5/V2jCTY1KYySkerYPnP5Fdnxmeax4EwqIxe+V+SctSjHPAfvdewr 7MrwycLs90Jz1jgJw2wd3YhuyNEau7ai7tGaihPCDEy9wYhFBwAzlRLzoSfwQyMIxNk2 z8GdeztH+pOmia3AXuvHtCD6EfhMWtwcqyu++RUPppIWQ0M4D3Vs4j/5bEfEbk/M842w TeBw== 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=UP08mMz/zf/3W/55YuQuX0Db2d693U7eTVg2Jg5E0AY=; b=pBWTcObu0s9v+ZeTFzSkO+Be7edMC4vpQ040QcKdk5aJLInSAQb37mr41FSIC+eMqL K4eKZCYod8D+ZWilyYuGWFuUlXv6UIgcWu2RBfPBUiPnid/5J/MHJHfNApEzLjOjRo84 uj6QWjaKuogmblQzQpIiLguX74JkVEeywQEieJyu1f/tV/jADqec2knvep2S41myGFYA KsAzUYt+gqOJGpOptStqd38g3DlB8VA+UehZgpVpQjdv+vUatYEK0sM6yEt8B2b28X6K 8uSyiBQO2gOHiwHe0MQ9IOyn1VsgdIM31l7Qe3HxlrhauSrzkJFmittmJkVdI9A9GvFg EKIw== 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 h1-v6si2684170pls.571.2018.01.21.10.02.19; Sun, 21 Jan 2018 10:02:34 -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 S1751282AbeAUSB4 (ORCPT + 99 others); Sun, 21 Jan 2018 13:01:56 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:35077 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbeAUSBy (ORCPT ); Sun, 21 Jan 2018 13:01:54 -0500 X-IronPort-AV: E=Sophos;i="5.46,392,1511827200"; d="scan'208";a="66414892" 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> From: Andrew Cooper Message-ID: Date: Sun, 21 Jan 2018 18:01:36 +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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) 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 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. Thanks, ~Andrew