Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2023924imm; Tue, 10 Jul 2018 11:48:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcocDILZGy68FkRj0WqsiYvgZ+qPSzqNXuX9u/vhCLu1CMc5dB825DY8u2ut/vNCN0k/1rA X-Received: by 2002:a17:902:9693:: with SMTP id n19-v6mr26008818plp.212.1531248519259; Tue, 10 Jul 2018 11:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248519; cv=none; d=google.com; s=arc-20160816; b=0/6TGcugTUvCxjX4yXOsSq0M1Vamnt2cLQTmgKlub5qaS6Q/u2vmCDPVQUgOMMgPOb EpBeay5bUdVFDHMR8Mh4/9rmzyZuOb5qzzEa8Vj+j+yg4AnClevsLqDmiHdfuRdREKQQ kFTJzVEVjkVQ/97hTQC8pN/408o1QSqEGgV70KtqGLle/8/TtBd1ysCw7t2N9OK64SOD PpUbcgdRRoJ5vxAy6ypU+hMfYQgvs9+iMhkyyBk5waWlacTyTe7FbUtrnLCx5A5RN54H hQYFUx+Qco4agCml+qM9I3CuWCbqHxWLVsU3/766W2VvekoVIyDSgYPczXvIa4t/o5os uIRA== 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=OrPdsvwNgc3oxYpVuRGinjk0nUEqoDg7kCfBRpsjUWs=; b=kABpp5+NbeucIrVeXd2POeCQ5Wz5tBwFRcUcLMwFc8PShYhORO6Gw5duhRxcJ/+25Q Udw2MZ1cXE7gSqDtDnA83NJUIqmfPX505vYTemziOIJN5ckzmL6+5P0QDYTO9d1unEio yJSv1zuXcK4oCpjGaDpUyWxmyyVCFFpo+jtVhr/TmL14bWFCw6L/ob0ybXt57/HGlH6o ORpRY9et2amd7y1pktlRQUYmRgnqkI6SUIvJOwFGQq3CpPRerVYZN1T6mkXrw06Ga8Z1 HLGu+Ra3s0aSGQx4c7lBvNlDHvrsl9OBgffnVN6edD9qN6mAyQEiNpnDd0vLMD4D0XaK vTFg== 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 u2-v6si16497872pge.585.2018.07.10.11.48.24; Tue, 10 Jul 2018 11:48:39 -0700 (PDT) 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 S2389036AbeGJSqW (ORCPT + 99 others); Tue, 10 Jul 2018 14:46:22 -0400 Received: from mga02.intel.com ([134.134.136.20]:49770 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732278AbeGJSqV (ORCPT ); Tue, 10 Jul 2018 14:46:21 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 11:46:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,335,1526367600"; d="scan'208";a="73722475" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga002.jf.intel.com with ESMTP; 10 Jul 2018 11:46:04 -0700 Date: Tue, 10 Jul 2018 11:45:07 -0700 From: Fenghua Yu To: Eduardo Habkost Cc: Thomas Gleixner , Dave Hansen , Fenghua Yu , Ingo Molnar , H Peter Anvin , Ashok Raj , Alan Cox , Peter Zijlstra , Rafael Wysocki , Tony Luck , Ravi V Shankar , linux-kernel , x86 , Vedvyas Shanbhogue Subject: Re: [PATCH v2 1/4] x86/split_lock: Enumerate #AC exception for split locked access feature Message-ID: <20180710184506.GA37857@romley-ivt3.sc.intel.com> References: <1530282807-66555-1-git-send-email-fenghua.yu@intel.com> <1530282807-66555-2-git-send-email-fenghua.yu@intel.com> <20180704200742.GD7451@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180704200742.GD7451@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 04, 2018 at 05:07:42PM -0300, Eduardo Habkost wrote: > On Fri, Jun 29, 2018 at 06:23:35PM +0200, Thomas Gleixner wrote: > > On Fri, 29 Jun 2018, Dave Hansen wrote: > > > On 06/29/2018 07:33 AM, Fenghua Yu wrote: > > > > +/* Detect feature of #AC for split lock by probing bit 29 in MSR_TEST_CTL. */ > > > > +void detect_ac_split_lock(void) > > > > +{ > > > > + u64 val, orig_val; > > > > + int ret; > > > > + > > > > + /* Attempt to read the MSR. If the MSR doesn't exist, reading fails. */ > > > > + ret = rdmsrl_safe(MSR_TEST_CTL, &val); > > > > + if (ret) > > > > + return; > > > > > > This is a bit fast and loose with how the feature is detected, which > > > might be OK, but can we call out why we are doing this, please? > > > > > > Is this MSR not really model-specific? Is it OK to go poking at it on > > > all x86 variants? Or, do we at _least_ need a check for Intel cpus in here? > > > > That definitely needs a vendor check. Also the whole code needs to be > > compiled out if CONFIG_INTEL=n. > > > > Aside of that this wants to be enumerated. CPUID or MISC_FEATURES and not > > this guess work detection logic. Why do I have to ask for that for every > > other new feature thingy? > > Yes, please. KVM hosts normally expect guests to not touch MSRs > unless we explicitly tell them the MSR is available (normally > through CPUID). This is important to ensure live migration > between different host kernel versions works reliably. The problem is the hardware design for the feature is complete. The hardware designer cannot change the feature enumeration to CPUID or MISC_FEATURES. In the future, the designer will put future model- specific feature bits in a processor feature MSR and hopefully we will have a nice standard enumeration way for all future model specific features. But split lock is too late (or too early) to be in the feature MSR. Considering the current situation, can we do split lock as following? By default, #AC for split lock is not enabled by kernel. It's disabled by BIOS by default (bit29=0). Kernel doesn't clear bit 29. For IOT/real time users, they know the feature is in the processor and they know the consequence of enabling the feature (e.g. some apps will be killed because of split lock issues). They want to enable #AC for split lock by kernel parameter "split_lock_detect=on". Kernel calls wrmsr_safe(), which can fail on processor not supporting the feature, to enable the feature. There is no enumeration and no flag in /proc/cpuinfo flag for the feature. Is this a right way to go? Please advise. Thanks. -Fenghua