Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1922677ybl; Sat, 25 Jan 2020 11:57:39 -0800 (PST) X-Google-Smtp-Source: APXvYqy3wT+vRcWME0Y8hfD9eAw20WwysqNHAxPZYFFR5GZC9sAaM7MOlSS7jQzg1OQnpZ11yyx3 X-Received: by 2002:a05:6830:22e2:: with SMTP id t2mr7372980otc.129.1579982258993; Sat, 25 Jan 2020 11:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579982258; cv=none; d=google.com; s=arc-20160816; b=bMU/yaAyLz2fFoDxLnBSS0lR21LFPYzb+aZ7f5NiyPPSCNMpc+XXdgTqjnIxHWEN4z Fyr1/RhezTbXKnXUeeMDE65RVDgfKvnNQteYQR2azGG6ovDCs9HsAnWv3vtaQqSsEIB6 pBVvPTpx3GcTp7s3IgtT+69b6Yi67S/QtG4oaFAJenNcgg/l+qLDTq+3JOs1dhUHkLgk G3IXzkJxMpH8LX1PS48y8Fa/16siHT7o811Lh1yu5x9anIXshg4npm2xAs46EPC/1sfq a+jkWVgkI6q4KVJxwkYHcMW0hvcPvjGvYHGuKGpw0G6XQ2qzU3Uo69veL1xPliAO5fIh 1EDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=JDyndzolpYtgSk8PcS6YELb3KOGeGk9EDk39sDvjfZw=; b=M5dbjEnRYE+jBT1guvWgNb9lkCWkgq9N7AL/SnP8XpqCmSv8vTzMrSht5suJ8Dh1D7 w/SPk+wx3axIiFfLSYodPccfcdTptZELj1ESwXoV6RKrSRwQTRCPad1YBkd4Dlu7flCD +LyX7bZhRxAY1HAayOR3H59NeGWKBPE7tW8xJ/DOFRhjXdSCaq2QhXfeS/F1iMK7mdww ycBqbk8cCI635hlr8gdy/ls9ZzS2z5b2pDoFgVDJhE8Wk7GwB/6Oit+t20mWOWQXo5F2 XXAJ3N305wQOvBCvCQNi/YqWJ4g/v4P+XNDys7mZjOspCwEU1ehrvW1QivYvEfic+M4e tOww== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1506502oif.83.2020.01.25.11.57.27; Sat, 25 Jan 2020 11:57:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729271AbgAYTzT (ORCPT + 99 others); Sat, 25 Jan 2020 14:55:19 -0500 Received: from mga11.intel.com ([192.55.52.93]:34185 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbgAYTzQ (ORCPT ); Sat, 25 Jan 2020 14:55:16 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2020 11:55:15 -0800 X-IronPort-AV: E=Sophos;i="5.70,363,1574150400"; d="scan'208";a="216907851" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.68]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2020 11:55:14 -0800 Date: Sat, 25 Jan 2020 11:55:13 -0800 From: "Luck, Tony" To: Borislav Petkov Cc: Thomas Gleixner , Arvind Sankar , "Christopherson, Sean J" , Peter Zijlstra , Ingo Molnar , "Yu, Fenghua" , Ingo Molnar , H Peter Anvin , "Raj, Ashok" , "Shankar, Ravi V" , linux-kernel , x86 Subject: Re: [PATCH v15] x86/split_lock: Enable split lock detection by kernel Message-ID: <20200125195513.GA15834@agluck-desk2.amr.corp.intel.com> References: <20200122185514.GA16010@agluck-desk2.amr.corp.intel.com> <20200122224245.GA2331824@rani.riverdale.lan> <3908561D78D1C84285E8C5FCA982C28F7F54887A@ORSMSX114.amr.corp.intel.com> <20200123004507.GA2403906@rani.riverdale.lan> <20200123035359.GA23659@agluck-desk2.amr.corp.intel.com> <20200123044514.GA2453000@rani.riverdale.lan> <20200123231652.GA4457@agluck-desk2.amr.corp.intel.com> <87h80kmta4.fsf@nanos.tec.linutronix.de> <20200125024727.GA32483@agluck-desk2.amr.corp.intel.com> <20200125104419.GA16136@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200125104419.GA16136@zn.tnic> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 25, 2020 at 11:44:19AM +0100, Borislav Petkov wrote: Boris, Thanks for the review. All comments accepted and changes made, except as listed below. Also will fix up some other checkpatch fluff. -Tony > > +#define X86_FEATURE_SPLIT_LOCK_DETECT (11*32+ 6) /* #AC for split lock */ > > Do you really want to have "split_lock_detect" in /proc/cpuinfo or > rather somethign shorter? I don't have a good abbreviation. It would become the joint 2nd longest flag name ... top ten lengths look like this on my test machine. So while long, not unprecedented. 18 tsc_deadline_timer 17 split_lock_detect 17 arch_capabilities 16 avx512_vpopcntdq 14 tsc_known_freq 14 invpcid_single 14 hwp_act_window 13 ibrs_enhanced 13 cqm_occup_llc 13 cqm_mbm_total 13 cqm_mbm_local 13 avx512_bitalg 13 3dnowprefetch > > +static inline bool match_option(const char *arg, int arglen, const char *opt) > > +{ > > + int len = strlen(opt); > > + > > + return len == arglen && !strncmp(arg, opt, len); > > +} > > There's the same function in arch/x86/kernel/cpu/bugs.c. Why are you > duplicating it here? > > Yeah, this whole chunk looks like it has been "influenced" by the sec > mitigations in bugs.c :-) Blame PeterZ for that. For now I'd like to add the duplicate inline function and then clean up by putting it into some header file (and maybe hunting down other places where it could be used). > > + /* > > + * If this is anything other than the boot-cpu, you've done > > + * funny things and you get to keep whatever pieces. > > + */ > > + pr_warn("MSR fail -- disabled\n"); > > What's that for? Guests? Also some PeterZ code. As the comment implies we really shouldn't be able to get here. This whole function should only be called on CPU models that support the MSR ... but PeterZ is defending against the situation that sometimes there are special SKUs with the same model number (since we may be here because of an x86_match_cpu() hit, rather than the architectural enumeration check). > > +void switch_to_sld(struct task_struct *prev, struct task_struct *next) > > This will get called on other vendors but let's just assume, for > simplicity's sake, TIF_SLD won't be set there so it is only a couple of > insns on a task switch going to waste. Thomas explained how to fix it so we only call the function if TIF_SLD is set in either the previous or next process (but not both). So the overhead is just extra XOR/AND in the caller. -Tony