Received: by 10.223.176.5 with SMTP id f5csp4152181wra; Tue, 30 Jan 2018 02:59:28 -0800 (PST) X-Google-Smtp-Source: AH8x227EGNjwgPJATkufwX4BUeANitbEmPLN+aeMIhyMKUdIfRSQGhKNgRiLaM65W8o8cZKglzXi X-Received: by 2002:a17:902:1682:: with SMTP id h2-v6mr24366785plh.116.1517309968219; Tue, 30 Jan 2018 02:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517309968; cv=none; d=google.com; s=arc-20160816; b=WAx9Mlfsv4u+6U/4OIVCBx4+oodv0i+j4ypzzyKeTTeOtZhIrX3NPt239eMT/iv4/Z LBn1GvJNGMQVAAR91xQ42XPlcYuv+yxu0BzG0wlWfhmqZ1h5tWR4QeZw6LVSsPoIGhCK 1I8QWv7mU/ac/7V3DGOcGPHo2hiR0baBmZRmguRF5mpxz/W7+756zKgCYVutJyAfNxfR mm1jwyopcULCtpTehIkvlF9PraMuIcJcQhUBcqlOpfJIBb2igJPyZwHpWCLvu2Bzx+Sw pR4LkHWztVv5BzcmaenE70TPEyq9DUvGhURntakxPUuJ9itpUMUTCfl8Una1xXo+S/CF Rvfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=WWyArB4C0eXZnmwBtUlSfLq3038dHgKe9ulyu2r8kQg=; b=vrD/vSr/UoipIY7b7PTcgRHmWMgnJoKvCOJ1uncAw6hjGoTkABof/mgy/2DW0KeKug dzmKQ4dRV3gOVsPaaJDQoPNEzeL55rfdeqb0PbxJiW5Pe/RozaDKwsyghl3xRUf9OeFC Nt0baJ6wiuawuZY3VwghKxLrxTURPkVs2UIboZ7wjY7pf9jAYZSGt6Hh32yM0nu0jfiR JHoH4oP9W2+Iug1RqwL7TqRDW5H0QKTyY8tO9l9+JSB+5uvMZfp2H/P39fPIS9zXcyIl DUIF/0AyU9y03qrYUDR2H6LntQx/2lC4BsMye8yqM7ntXXeWvSBS1a+X+w5xA+slYdwf rnkw== 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 f7si14226086pfh.215.2018.01.30.02.59.14; Tue, 30 Jan 2018 02:59:28 -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 S1751804AbeA3K6Y (ORCPT + 99 others); Tue, 30 Jan 2018 05:58:24 -0500 Received: from mail.skyhub.de ([5.9.137.197]:49548 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbeA3K6W (ORCPT ); Tue, 30 Jan 2018 05:58:22 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id viuUtcqlgSAG; Tue, 30 Jan 2018 11:58:20 +0100 (CET) Received: from pd.tnic (p200300EC2BCF0F005D4DFBFD0E3B986B.dip0.t-ipconnect.de [IPv6:2003:ec:2bcf:f00:5d4d:fbfd:e3b:986b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 5BFFF1EC03B9; Tue, 30 Jan 2018 11:58:20 +0100 (CET) Date: Tue, 30 Jan 2018 11:58:14 +0100 From: Borislav Petkov To: David Woodhouse Cc: arjan@linux.intel.com, tglx@linutronix.de, karahmed@amazon.de, x86@kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, peterz@infradead.org, pbonzini@redhat.com, ak@linux.intel.com, torvalds@linux-foundation.org, gregkh@linux-foundation.org Subject: Re: [PATCH] x86/cpuid: Fix up "virtual" IBRS/IBPB/STIBP feature bits on Intel Message-ID: <20180130105814.m5zd43dyx2o2ius2@pd.tnic> References: <1517269773-16750-1-git-send-email-dwmw@amazon.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1517269773-16750-1-git-send-email-dwmw@amazon.co.uk> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 29, 2018 at 11:49:33PM +0000, David Woodhouse wrote: > Despite the fact that all the other code there seems to be doing it, > just using set_cpu_cap() in early_intel_init() doesn't actually work. > > When the CPU is queried again in identify_boot_cpu(), it all gets > overwritten again. Do it in init_scattered_cpuid_features() instead. > > Turning the bits off for bad microcode can use setup_clear_cpu_cap() > to force them off for all CPUs; I was less keen on forcing the feature > bits *on* that way. > > Signed-off-by: David Woodhouse > Fixes: 2961298e ("x86/cpufeatures: Clean up Spectre v2 related CPUID flags") > --- > I feel I must be missing something. Is the rest of early_init_intel() broken too? Does that help? diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 6936d14d4c77..1dd596d0a6c4 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -182,21 +182,21 @@ static void early_init_intel(struct cpuinfo_x86 *c) * Intel CPUs, for finer-grained selection of what's available. */ if (cpu_has(c, X86_FEATURE_SPEC_CTRL)) { - set_cpu_cap(c, X86_FEATURE_IBRS); - set_cpu_cap(c, X86_FEATURE_IBPB); + setup_force_cpu_cap(X86_FEATURE_IBRS); + setup_force_cpu_cap(X86_FEATURE_IBPB); } if (cpu_has(c, X86_FEATURE_INTEL_STIBP)) - set_cpu_cap(c, X86_FEATURE_STIBP); + setup_force_cpu_cap(X86_FEATURE_STIBP); /* Now if any of them are set, check the blacklist and clear the lot */ if ((cpu_has(c, X86_FEATURE_IBRS) || cpu_has(c, X86_FEATURE_IBPB) || cpu_has(c, X86_FEATURE_STIBP)) && bad_spectre_microcode(c)) { pr_warn("Intel Spectre v2 broken microcode detected; disabling Speculation Control\n"); - clear_cpu_cap(c, X86_FEATURE_IBRS); - clear_cpu_cap(c, X86_FEATURE_IBPB); - clear_cpu_cap(c, X86_FEATURE_STIBP); - clear_cpu_cap(c, X86_FEATURE_SPEC_CTRL); - clear_cpu_cap(c, X86_FEATURE_INTEL_STIBP); + setup_clear_cpu_cap(X86_FEATURE_IBRS); + setup_clear_cpu_cap(X86_FEATURE_IBPB); + setup_clear_cpu_cap(X86_FEATURE_STIBP); + setup_clear_cpu_cap(X86_FEATURE_SPEC_CTRL); + setup_clear_cpu_cap(X86_FEATURE_INTEL_STIBP); } /* -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.