Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp767487pxa; Wed, 5 Aug 2020 12:15:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygq+MxhO4psGKUkLs9i6xQ+PQVq55K1KfHZRlw1IKp2JBgIDiIYdT+IkLrmS0oGyKZES6/ X-Received: by 2002:a17:906:fcb3:: with SMTP id qw19mr769283ejb.271.1596654930599; Wed, 05 Aug 2020 12:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596654930; cv=none; d=google.com; s=arc-20160816; b=Z3v1kpVxzPSQSvYQH3VRB79K2LPi+iZ4sAoNqjsZTpNm42rKsLR8dzOht0sZMUTFEH 2to8/Mcb+nvvKmjHUjc0pdwzC8MzwyTqOgBJhZvFYY2qqjyp0kVkw2YDDhKWLljUAEll ywvwk/zHO/cYqhbPlIa/oSpVscBkxoBHc7UbVLbUV/daDBvVy8/sg/TM2lr6WhH6vdA4 CEGvsUo1EQaEkB/xLfepFIROLzz16BKX+xlhR1iPBhUg5QJ41aIEWuMkgEdrUsvdyk4a XMlUg99ru+N43eiKohKpzyidbyGioaxpL1fng3qE8RbzBh4jVR58wgJ9L9zwUWL9XjaE Hpfw== 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:ironport-sdr:ironport-sdr; bh=Ahd52Y1i0Rj3wYN5EbpOB7JY2fe4UYoNlz/5GAbXCQk=; b=fkWUecHvxSBIqUfRMFrowo/oQ4/UCbm9Yq7faO+lqy5y0NJQ41xrBVNSNqugIUHNoq yXhIiczll7pT18QFUe1+CJfiD8WLE0VL3/4HIogKH14xAAAYK5NcoscM2KXTHt0nRIHN N5/BlLoWbAppGa/Qyo+qQHmsUbIIsYuIKl0d5ZhAtPiPcksCPEz0fA4IBkIWg2rpHQTi ZaTAXBWFfJgPK3QoCW6Z2TSJOOjYxIEaKFk6tX+dlAlykQkqxQzhf7BYpT9/ZZLeKSXl 5XbRZ9EQwIyqi9URZ4qflRyJFvlX2TJ4ISzZiP3NEMQXY7xXy1QTniVtn6G6L4s16DZL IPqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id dc15si1871086ejb.374.2020.08.05.12.15.07; Wed, 05 Aug 2020 12:15:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728724AbgHETNw (ORCPT + 99 others); Wed, 5 Aug 2020 15:13:52 -0400 Received: from mga17.intel.com ([192.55.52.151]:40671 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbgHETLq (ORCPT ); Wed, 5 Aug 2020 15:11:46 -0400 IronPort-SDR: qKX/ElW97fakr3JPsGtRORLgay4GLsxsHmianTeKpbmcvse2HSjsa2LrUTsaFSiJQq52pY06wl BHzHcCNgLGvA== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="132713644" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="132713644" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 12:11:45 -0700 IronPort-SDR: gMtDv2wkDCrBFAxkgWEqDl3k5FFjBnx432Tkp7OHaGlY0qBEc7kSWXLpFuba6aQYFJUUSHKTnj sNu4wS1fmExQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="289026130" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga003.jf.intel.com with ESMTP; 05 Aug 2020 12:11:44 -0700 Date: Wed, 5 Aug 2020 12:11:26 -0700 From: Ricardo Neri To: Andy Lutomirski Cc: Borislav Petkov , "H. Peter Anvin" , Borislav Petkov , Thomas Gleixner , Ingo Molnar , X86 ML , "Peter Zijlstra (Intel)" , Dave Hansen , Tony Luck , Cathy Zhang , Fenghua Yu , Kyung Min Park , "Ravi V. Shankar" , Sean Christopherson , LKML , Ricardo Neri , Dave Hansen , linux-edac Subject: Re: [PATCH v2] x86/cpu: Use SERIALIZE in sync_core() when available Message-ID: <20200805191126.GA27509@ranerica-svr.sc.intel.com> References: <20200805021059.1331-1-ricardo.neri-calderon@linux.intel.com> <20200805044840.GA9127@nazgul.tnic> <47A60E6A-0742-45FB-B707-175E87C58184@zytor.com> <20200805050808.GC9127@nazgul.tnic> <20200805170717.GB26661@ranerica-svr.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 05, 2020 at 11:28:31AM -0700, Andy Lutomirski wrote: > On Wed, Aug 5, 2020 at 10:07 AM Ricardo Neri > wrote: > > > > On Wed, Aug 05, 2020 at 07:08:08AM +0200, Borislav Petkov wrote: > > > On Tue, Aug 04, 2020 at 09:58:25PM -0700, hpa@zytor.com wrote: > > > > Because why use an alternative to jump over one instruction? > > > > > > > > I personally would prefer to have the IRET put out of line > > > > > > Can't yet - SERIALIZE CPUs are a minority at the moment. > > > > > > > and have the call/jmp replaced by SERIALIZE inline. > > > > > > Well, we could do: > > > > > > alternative_io("... IRET bunch", __ASM_SERIALIZE, X86_FEATURE_SERIALIZE, ...); > > > > > > and avoid all kinds of jumping. Alternatives get padded so there > > > would be a couple of NOPs following when SERIALIZE gets patched in > > > but it shouldn't be a problem. I guess one needs to look at what gcc > > > generates... > > > > But the IRET-TO-SELF code has instruction which modify the stack. This > > would violate stack invariance in alternatives as enforced in commit > > 7117f16bf460 ("objtool: Fix ORC vs alternatives"). As a result, objtool > > gives warnings as follows: > > > > arch/x86/kernel/alternative.o: warning: objtool: do_sync_core()+0xe: > > alternative modifies stack > > > > Perhaps in this specific case it does not matter as the changes in the > > stack will be undone by IRET. However, using alternative_io would require > > adding the macro STACK_FRAME_NON_STANDARD to functions using sync_core(). > > IMHO, it wouldn't look good. > > > > So maybe the best approach is to implement as you suggested using > > static_cpu_has()? > > I agree. Let's keep it simple. > > Honestly, I think the right solution is to have iret_to_self() in > actual asm and invoke it from C as needed. Do you mean anything different from what we have already [1]? If I understand your comment correctly, we have exactly that: an iret_to_self() asm implementation invoked from C. Thanks and BR, Ricardo [1]. https://lore.kernel.org/lkml/20200727043132.15082-4-ricardo.neri-calderon@linux.intel.com/ Thanks and BR, Ricardo