Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp788358pxa; Wed, 5 Aug 2020 12:47:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLmQsPoOV5udUFIJJI7G0egmDfybFvK4HHSC62cBf9t2JY7Svnf64DoxvPssOcpTD2sJcq X-Received: by 2002:a50:a6da:: with SMTP id f26mr924624edc.4.1596656866923; Wed, 05 Aug 2020 12:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596656866; cv=none; d=google.com; s=arc-20160816; b=sAjpa/E3Hfqo+UYTJu0tD/WixoUAC6c/CSxFgkVeX7JUdcNNrLK4ozKeVzTLWXtFxw TpDp9IzhAAYKQLtGX1D5OYSr5NXfHElW/D5I2bJEKA63CWf52Tl8wPvaH7Z4/vZBnR1B CNxYecp5INxcD5JKO17oV78mtVf/dfi+x3mviG9urhMCCCEYxM7JQSpR7AvIwN7vlO6p hFEIfN5pVpGNpDlF6hPLLI0gugwcvVKqnXk55dPo4xOmHG7FQCf1KMD4tTSIx3Jco7H9 xKFbqmTt+uSv7AiH+9GUx7hVQJKlIC7W7gUoTdA0bv91AzxpkXzWuwODuWFXVS+Bw4AY ZOew== 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=YtvA0tmgk9FpcDTkxk/LzlYdPwuTw7K8I2+WDjvwJCo=; b=Xn+C6Fs3JTacqPAV/57pNlTM3EJY6l1p9fnLJ9uXzUNYF2betwZIFcD58wx3/Ak5Re hhjyHr62lpS7+UZ7looRoxiSbeUwaMZi1+jCIgPHtaIzaG95qcWHwRKjIfZImqpRO73f imjAnw+v5BwvwsvaGisKlq89qKOJbeG1e7AOqGg1ktBlMSKDepmJ78OA5w14QycNo2q9 b3LyK0YA9vGbCLoO7ze77Rgj9yKZr5JkMVGGE0Q4+n0jLfwD37V8pQpYzzH630WECGE8 YvvSk+a+0dD8IYPkBi1edET99jLa+NSfMYRpjEkRF45crYYszkmSnVdtw8Nl64r8lWDc ZM8Q== 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 g22si1882738ejd.159.2020.08.05.12.47.24; Wed, 05 Aug 2020 12:47:46 -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 S1728875AbgHETbD (ORCPT + 99 others); Wed, 5 Aug 2020 15:31:03 -0400 Received: from mga04.intel.com ([192.55.52.120]:24715 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728411AbgHERHl (ORCPT ); Wed, 5 Aug 2020 13:07:41 -0400 IronPort-SDR: ftrn1bHXVaUoaYxBD+U0Z9VjorwkCEfZFERK8Cei8Gcv/qjHVs9x7o1YKm5zm27aV20rTtOQY5 7/aBjUbmuKvw== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="150056026" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="150056026" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:07:37 -0700 IronPort-SDR: Rlyu2e2Xng1qZuyU9jpKnOH/LLO1CZOURgcYLNejTmMyJZ0iDuTI/eK/hiWBRfnKYEFrweY2cZ vQvwJeWU15Gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="306768478" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga002.jf.intel.com with ESMTP; 05 Aug 2020 10:07:35 -0700 Date: Wed, 5 Aug 2020 10:07:17 -0700 From: Ricardo Neri To: Borislav Petkov Cc: hpa@zytor.com, Borislav Petkov , Thomas Gleixner , Ingo Molnar , Andy Lutomirski , x86@kernel.org, "Peter Zijlstra (Intel)" , Dave Hansen , Tony Luck , Cathy Zhang , Fenghua Yu , Kyung Min Park , "Ravi V. Shankar" , Sean Christopherson , linux-kernel@vger.kernel.org, Ricardo Neri , Dave Hansen , linux-edac@vger.kernel.org Subject: Re: [PATCH v2] x86/cpu: Use SERIALIZE in sync_core() when available Message-ID: <20200805170717.GB26661@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200805050808.GC9127@nazgul.tnic> 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 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()? Thanks and BR, Ricardo