Received: by 10.213.65.68 with SMTP id h4csp147583imn; Thu, 15 Mar 2018 12:18:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELu7uP1addvmYaH402n0cB62evwCT7nrATXwDDsJEMPnlOELdPn66VmmBJWCcFr0KGhsV/DP X-Received: by 2002:a17:902:a516:: with SMTP id s22-v6mr6862756plq.191.1521141498306; Thu, 15 Mar 2018 12:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521141498; cv=none; d=google.com; s=arc-20160816; b=cFOpDSDvI+B7KA5oGZ030bZwZ/iTsVwAyK9yPK30TjjlgaTzY090ovBhTWofT7qFTW SRyA7RvZ8cd+PE2XFquPT+m5N8W7ubxNGeVx35stfu2DEJcL5gImPC7FqHp+GboLKjGI l+4lHKYun7sK73W2O6pklAqeSoAwMLPyhHtDNoEtGf91r+NRHhEwvP7tLsevoV/NSsxk wuT7aqEdIlxFGcT5OzCL/jugveFSToz9SDbqXFzNyYmIHcE771Bt8XzlS0iuBuXRGaEp lhwTPubVYJ7KZGqqJbm1EqxIRbYyC9qwxeSBZblk7pA8AKTTfL+uz0cpTvPleozHZsXS CCvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gEOKyIe1U9YBfXe66t+RgpZxY6v2Q9Kuc9lgV7yWwOA=; b=rANaXBZJc9YksWmamHEGWcPuunkykSZ3ZErhtuTdk65mj2AKPyjsl96Tr1dlC5LARq P8iQiuoyl6lO5mBxHqXhu6d85iSKW1aiR2W4H8XOmqPL+OxXnhJX1Q4NrJKrfsHV2Eh3 bNJkaYeSsoxzm0ntp/B8OsYldF7T2OzoN/eV+dfLAYab7hCmRJh2a7jFTfMkS+EBXqbW X4MYAHPZmtIrApvFSmt9cJ8W1Wn3M39CZDHzCqDaXwFbArqh53d7hzUAFbkuX8i+QJLx LIFvG25cEm+Jj4jdIoOrQnUOMMfRSCduXhKdhWWV+UBEXm2PTqA7lw5FyA3zpi+F9Uu0 7ogA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h191si1971386pgc.716.2018.03.15.12.18.03; Thu, 15 Mar 2018 12:18:18 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932588AbeCOTRE (ORCPT + 99 others); Thu, 15 Mar 2018 15:17:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:45271 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753054AbeCOTQ1 (ORCPT ); Thu, 15 Mar 2018 15:16:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 447B7AFC4; Thu, 15 Mar 2018 19:16:25 +0000 (UTC) From: Michal Suchanek To: linuxppc-dev@lists.ozlabs.org Cc: Kate Stewart , Madhavan Srinivasan , Paul Mackerras , Michael Neuling , "Bryant G. Ly" , Mahesh Salgaonkar , "Naveen N. Rao" , Daniel Axtens , Nicholas Piggin , Al Viro , David Gibson , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Sergey Senozhatsky , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Masami Hiramatsu , Andrew Donnellan , Philippe Ombredanne , Joe Perches , Oliver O'Halloran , Andrew Morton , "Tobin C. Harding" , Michal Suchanek Subject: [PATCH RFC rebase 8/9] powerpc/64s: barrier_nospec: Add hcall triggerr Date: Thu, 15 Mar 2018 20:15:57 +0100 Message-Id: <54913b22e2f3647c670b6fb3e1fecce34729b736.1521141122.git.msuchanek@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: <20180313200108.GA4082@hirez.programming.kicks-ass.net> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adapted from the RFI implementation Signed-off-by: Michal Suchanek --- arch/powerpc/platforms/pseries/mobility.c | 2 +- arch/powerpc/platforms/pseries/pseries.h | 2 +- arch/powerpc/platforms/pseries/setup.c | 37 ++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 8a8033a249c7..9d506be1580e 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -349,7 +349,7 @@ void post_mobility_fixup(void) "failed: %d\n", rc); /* Possibly switch to a new RFI flush type */ - pseries_setup_rfi_flush(); + pseries_setup_rfi_nospec(); return; } diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h index 27cdcb69fd18..d49670c67686 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h @@ -100,6 +100,6 @@ static inline unsigned long cmo_get_page_size(void) int dlpar_workqueue_init(void); -void pseries_setup_rfi_flush(void); +void pseries_setup_rfi_nospec(void); #endif /* _PSERIES_PSERIES_H */ diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 9877c3dfcdc8..4b899a4db6dd 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -459,30 +459,47 @@ static void __init find_and_init_phbs(void) of_pci_check_probe_only(); } -void pseries_setup_rfi_flush(void) +void pseries_setup_rfi_nospec(void) { struct h_cpu_char_result result; - enum l1d_flush_type types; - bool enable; + enum l1d_flush_type flush_types; + enum spec_barrier_type barrier_type; + bool flush_enable; + bool barrier_enable; long rc; /* Enable by default */ - enable = true; - types = L1D_FLUSH_FALLBACK; + flush_enable = true; + flush_types = L1D_FLUSH_FALLBACK; + barrier_enable = true; + /* no fallback available if the firmware does not tell us */ + barrier_type = SPEC_BARRIER_NONE; rc = plpar_get_cpu_characteristics(&result); if (rc == H_SUCCESS) { if (result.character & H_CPU_CHAR_L1D_FLUSH_TRIG2) - types |= L1D_FLUSH_MTTRIG; + flush_types |= L1D_FLUSH_MTTRIG; if (result.character & H_CPU_CHAR_L1D_FLUSH_ORI30) - types |= L1D_FLUSH_ORI; + flush_types |= L1D_FLUSH_ORI; + if (result.character & H_CPU_CHAR_SPEC_BAR_ORI31) + barrier_type |= SPEC_BARRIER_ORI; if ((!(result.behaviour & H_CPU_BEHAV_L1D_FLUSH_PR)) || (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))) - enable = false; + flush_enable = false; + /* + * Do not check H_CPU_BEHAV_BNDS_CHK_SPEC_BAR - the ORI does + * nothing anyway when not supported. + */ + if ((!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))) + barrier_enable = false; + } else { + /* Default to fallback if case hcall is not available */ + flush_types = L1D_FLUSH_FALLBACK; } - setup_rfi_flush(types, enable); + setup_barrier_nospec(barrier_type, barrier_enable); + setup_rfi_flush(flush_types, flush_enable); } #ifdef CONFIG_PCI_IOV @@ -658,7 +675,7 @@ static void __init pSeries_setup_arch(void) fwnmi_init(); - pseries_setup_rfi_flush(); + pseries_setup_rfi_nospec(); /* By default, only probe PCI (can be overridden by rtas_pci) */ pci_add_flags(PCI_PROBE_ONLY); -- 2.13.6