From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965461AbeAMBxh (ORCPT + 1 other); Fri, 12 Jan 2018 20:53:37 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:36688 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965376AbeAMBxf (ORCPT ); Fri, 12 Jan 2018 20:53:35 -0500 X-Google-Smtp-Source: ACJfBouCOyhgm5eA32UYobkHflVS4oc1WFUp83FGNo3IPSxdL+4WJhvnQdmFvzHU1HTV8PtwleJ+aGoRH5TlezjpSfY= MIME-Version: 1.0 In-Reply-To: <20180113010728.27928.8537.stgit@tlendack-t1.amdoffice.net> References: <20180113010728.27928.8537.stgit@tlendack-t1.amdoffice.net> From: Dan Williams Date: Fri, 12 Jan 2018 17:53:34 -0800 Message-ID: Subject: Re: [PATCH v1] x86/retpoline: Use lfence in the retpoline/RSB filling RSB macros To: Tom Lendacky Cc: X86 ML , Linux Kernel Mailing List , Rik van Riel , Andi Kleen , Josh Poimboeuf , Peter Zijlstra , Linus Torvalds , Jiri Kosina , Dave Hansen , Borislav Petkov , Andy Lutomirski , Kees Cook , Thomas Gleixner , Tim Chen , Greg Kroah-Hartman , David Woodhouse , Paul Turner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Fri, Jan 12, 2018 at 5:07 PM, Tom Lendacky wrote: > The pause instruction is currently used in the retpoline and RSB filling > macros as a speculation trap. The use of pause was originally suggested > because it showed a very, very small difference in the amount of > cycles/time used to execute the retpoline as compared to lfence. On AMD, > the pause instruction is not a serializing instruction, so the pause/jmp > loop will use excess power as it is speculated over waiting for return > to mispredict to the correct target. > > The RSB filling macro is applicable to AMD, and, if software is unable to > verify that lfence is serializing on AMD (possible when running under a > hypervisor), the generic retpoline support will be used and, so, is also > applicable to AMD. Change the use of pause to lfence. Should we use ASM_IFENCE for this?