Received: by 10.213.65.68 with SMTP id h4csp518312imn; Tue, 13 Mar 2018 11:35:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELvuwqbb/qeoSJb9gtKKbx7RJt/uZ94KbG825OfnS+Oqg5cfF9lzGm+5E+Lxf2DJv1QHuSzC X-Received: by 10.98.217.76 with SMTP id s73mr1497217pfg.209.1520966116590; Tue, 13 Mar 2018 11:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520966116; cv=none; d=google.com; s=arc-20160816; b=mOwtYKEb4P1+cgC1HcVLzwWT3QGO903lGEiFVVLoVlRAreffQzdkh+/iS2PTZfHWTc NdnYSNqXCFWuWe5OCllp98M8Nk80egpNSCR/fO2zq7GJ/QZ/JApO9yq0wWh0xMQStmW6 jWJLagh9Q4+EByAPTMhNBvWLIHqcebeNpyOqi9VefxY2TxYMrWr5CP3kLAZ7g6DVXLw6 zaLm5rtVy44QKJvh4fnJIyUOuqQ+O9zkQmxB5i7ZEU39nPXHN9rpMSxyWASVOO3naEgs HWHqWFmbwLXdvz3OBn7u5MOKM5G9lV34C9qZwPr/aC/fS1E0TJvR11imzD3BAZcMxuDz DN0g== 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=5MbJoKo+c1+tYVpuHyQ2aYrQ4Y0B9cuaEC+XCSoTvXs=; b=cTlV5hvKBjhclsd6OClV38ndTMIQmR2nA3DK6R+/kO7m+kiecgYLYjgCKfpXPbrsMX s1y5s9OXXSICDpDQZgTmg2FGs3FVEwm8px95/h9xozRsuKOyXugMMpUd4yTOGmWk9M9V 9AROcLR0GYvIG7GLBDIp/MrhuA5x8dPZvV8664S+0vQ6mXSK3NZA19rkSs5K8vv+WKjj kSeKYauzYtt1m2v5Su/CzszNQkZtH6Q8LRZ5BXJsXkmPSsGQg8W2wboKofn+rtRAZL1d egpG8JEV/Nw+KuyemNB66FOSEqx43FTuGVuF2aBpnSpMz2a+ZjARUrm4DSYELEPOJB9F JM4Q== 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 v6-v6si525143plg.618.2018.03.13.11.35.02; Tue, 13 Mar 2018 11:35:16 -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 S1752636AbeCMSd7 (ORCPT + 99 others); Tue, 13 Mar 2018 14:33:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:53540 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752558AbeCMSdz (ORCPT ); Tue, 13 Mar 2018 14:33:55 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7BE64AF59; Tue, 13 Mar 2018 18:33:54 +0000 (UTC) From: Michal Suchanek To: linuxppc-dev@lists.ozlabs.org Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Peter Zijlstra , Michal Suchanek , Kate Stewart , Greg Kroah-Hartman , Philippe Ombredanne , Nicholas Piggin , "Tobin C. Harding" , Mahesh Salgaonkar , David Gibson , Al Viro , Michael Neuling , "Oliver O'Halloran" , "Naveen N. Rao" , Madhavan Srinivasan , Masami Hiramatsu , Andrew Morton , Balbir Singh , Sergey Senozhatsky , Christophe Leroy , Andrew Donnellan , Daniel Axtens , Russell Currey , Joe Perches , "Bryant G. Ly" , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , linux-kernel@vger.kernel.org Subject: [PATCH RFC 7/8] powerpc/64s: barrier_nospec: Add hcall triggerr Date: Tue, 13 Mar 2018 19:33:05 +0100 Message-Id: <1c687d0e029de81ae27465dd4c32036e956f4970.1520965380.git.msuchanek@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Copypasta from rfi implementation Signed-off-by: Michal Suchanek --- arch/powerpc/platforms/pseries/setup.c | 38 ++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 1a527625acf7..b779ddb8e250 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -459,38 +459,50 @@ static void __init find_and_init_phbs(void) of_pci_check_probe_only(); } -static void pseries_setup_rfi_flush(void) +static 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; + flush_enable = true; + barrier_enable = true; + /* no fallback if the firmware does not tell us */ + barrier_type = SPEC_BARRIER_NONE; rc = plpar_get_cpu_characteristics(&result); if (rc == H_SUCCESS) { - types = L1D_FLUSH_NONE; + flush_types = L1D_FLUSH_NONE; 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; /* Use fallback if nothing set in hcall */ - if (types == L1D_FLUSH_NONE) - types = L1D_FLUSH_FALLBACK; + if (flush_types == L1D_FLUSH_NONE) + flush_types = L1D_FLUSH_FALLBACK; if ((!(result.behaviour & H_CPU_BEHAV_L1D_FLUSH_PR)) || (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))) - enable = false; + flush_enable = false; + + if ((!(result.behaviour & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR)) || + (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))) + barrier_enable = false; } else { /* Default to fallback if case hcall is not available */ - types = L1D_FLUSH_FALLBACK; + 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 @@ -666,7 +678,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