Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp594063imb; Fri, 1 Mar 2019 08:43:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwMFiI8nTOSIbMzOS0K1HtNrgpWwFMJjvHDkiqMBSMlg1t/+28tybCyI4liKKM5gGk8UXZS X-Received: by 2002:a63:6e88:: with SMTP id j130mr5629181pgc.67.1551458607057; Fri, 01 Mar 2019 08:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551458607; cv=none; d=google.com; s=arc-20160816; b=gDrksFAmpD3A0bZRBCYi0b6D+3FRGpK9A7Er/7bZO4sK9C66F/FqNuh8wPrPI/Y794 E6d+6yRC0+ftFUAqeBp+LnfhLQTzQ+MMPsewT6GMu1gyWpq8MVpKe07de5w4220dO3tv IOB2rHBRtnxQbhsaLsWEqvNUA2IuhFvH1ADK7EUW35TBH9bmk3DqCZ+EYhKTwMpF7DJs Xd2QR4lzP+44t1AQUPepWKHX6VYIPlw0tMg+hqxaTHW3XB38fCZWQm7rR5EicJrI3OqQ VfBn8nIcoXEkS5BG9nw8+vAwxc7fTBrWtU2l3taIWlkCVmz6vvga06yIiTwziKUaHXW+ s5bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=JUsgvf3MV+RSr1rZbxgyDXMXjB6MPH4qMPs6U7eC3tQ=; b=PgEp7ayPkNQNdeE6aEms6j112skeOPrhuMAm4FQyyewaYnIwRRmWjpyS+fEhzCp5Ku b6j18tR2f4qahhl+A4umWBvJXmM6I277q+jjP4xb+y+O8RW8rAc+GbD/3RCt7LNnbVwb MJluS2hFHN922Icg7FZovEZPmVtElJS6XjrRS3e2rDniZBcPbs487vi/D/BcLxZNOYIg Rr8lDB55K79DV4bN9OvSbCariVhzi0u+4Cs4IM3owtXEmA91I0XCU8CuoE4zVldD0j/d FidktUUdYrbjjYQ2eOE+//QF+Adpcjovn1ywCkr6X73PY0nAJHLBE7MKS7Jtv8kzuuDg ksoQ== 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 z67si16879108pfb.278.2019.03.01.08.43.11; Fri, 01 Mar 2019 08:43:27 -0800 (PST) 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 S2389023AbfCAQlY (ORCPT + 99 others); Fri, 1 Mar 2019 11:41:24 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38676 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728449AbfCAQlY (ORCPT ); Fri, 1 Mar 2019 11:41:24 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AFC7080D; Fri, 1 Mar 2019 08:41:23 -0800 (PST) Received: from [192.168.100.242] (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 047CB3F575; Fri, 1 Mar 2019 08:41:22 -0800 (PST) Subject: Re: [PATCH v5 09/10] arm64: add sysfs vulnerability show for speculative store bypass To: Andre Przywara , linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, Dave.Martin@arm.com, shankerd@codeaurora.org, julien.thierry@arm.com, mlangsdo@redhat.com, stefan.wahren@i2e.com, linux-kernel@vger.kernel.org References: <20190227010544.597579-1-jeremy.linton@arm.com> <20190227010544.597579-10-jeremy.linton@arm.com> <04eb2b5d-3754-0e39-3c6e-54b45741da83@foss.arm.com> From: Jeremy Linton Message-ID: Date: Fri, 1 Mar 2019 10:41:22 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <04eb2b5d-3754-0e39-3c6e-54b45741da83@foss.arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 3/1/19 1:02 AM, Andre Przywara wrote: > Hi, > > On 2/26/19 7:05 PM, Jeremy Linton wrote: >> Return status based on ssbd_state and the arm64 SSBS feature. If >> the mitigation is disabled, or the firmware isn't responding then >> return the expected machine state based on a new blacklist of known >> vulnerable cores. >> >> Signed-off-by: Jeremy Linton >> --- >>   arch/arm64/kernel/cpu_errata.c | 43 ++++++++++++++++++++++++++++++++++ >>   1 file changed, 43 insertions(+) >> >> diff --git a/arch/arm64/kernel/cpu_errata.c >> b/arch/arm64/kernel/cpu_errata.c >> index 5f5611d17dc1..e1b03f643799 100644 >> --- a/arch/arm64/kernel/cpu_errata.c >> +++ b/arch/arm64/kernel/cpu_errata.c >> @@ -279,6 +279,7 @@ static int detect_harden_bp_fw(void) >>   DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); >>   int ssbd_state __read_mostly = ARM64_SSBD_KERNEL; >> +static bool __ssb_safe = true; >>   static const struct ssbd_options { >>       const char    *str; >> @@ -387,6 +388,9 @@ static bool has_ssbd_mitigation(const struct >> arm64_cpu_capabilities *entry, >>       WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); >> +    if (is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list)) >> +        __ssb_safe = false; > > Is that the only place where we set it to false? > What about if firmware reports that (at least one core) is vulnerable? Maybe.. Normally if the firmware is functional enough to report the core state, then I would expect the kernel mitigation to be enabled. But your right, if the mitigation is disabled then it might be possible for us to miss the blacklist and report the machine safe even if the firmware reports it vulnerable. The core problem though is really that the blacklist isn't complete, because we also report an incorrect state if the firmware fails to respond. Although that said, there are still some other interesting paths here which might fall into the "unknown" case if you get creative enough (ex: think force disabling a SSBS mitigated machine). Anyway, its probably worth flagging the machine vulnerable if we get SMCC_RET_SUCCESS to avoid cases which miss the blacklist. > >> + >>       if (this_cpu_has_cap(ARM64_SSBS)) { >>           required = false; >>           goto out_printmsg; >> @@ -420,6 +424,7 @@ static bool has_ssbd_mitigation(const struct >> arm64_cpu_capabilities *entry, >>           ssbd_state = ARM64_SSBD_UNKNOWN; >>           return false; >> +    /* machines with mixed mitigation requirements must not return >> this */ >>       case SMCCC_RET_NOT_REQUIRED: >>           pr_info_once("%s mitigation not required\n", entry->desc); >>           ssbd_state = ARM64_SSBD_MITIGATED; >> @@ -475,6 +480,16 @@ static bool has_ssbd_mitigation(const struct >> arm64_cpu_capabilities *entry, >>       return required; >>   } >> +/* known vulnerable cores */ >> +static const struct midr_range arm64_ssb_cpus[] = { >> +    MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), >> +    MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), >> +    MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), >> +    MIDR_ALL_VERSIONS(MIDR_CORTEX_A75), >> +    MIDR_ALL_VERSIONS(MIDR_CORTEX_A76), >> +    {}, >> +}; >> + >>   static void __maybe_unused >>   cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities >> *__unused) >>   { >> @@ -770,6 +785,7 @@ const struct arm64_cpu_capabilities arm64_errata[] >> = { >>           .capability = ARM64_SSBD, >>           .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, >>           .matches = has_ssbd_mitigation, >> +        .midr_range_list = arm64_ssb_cpus, >>       }, >>   #ifdef CONFIG_ARM64_ERRATUM_1188873 >>       { >> @@ -808,3 +824,30 @@ ssize_t cpu_show_spectre_v2(struct device *dev, >> struct device_attribute *attr, >>       return sprintf(buf, "Vulnerable\n"); >>   } >> + >> +ssize_t cpu_show_spec_store_bypass(struct device *dev, >> +        struct device_attribute *attr, char *buf) >> +{ >> +    /* >> +     *  Two assumptions: First, ssbd_state reflects the worse case >> +     *  for hetrogenous machines, and that if SSBS is supported its > >                 heterogeneous > > Cheers, > Andre. > >> +     *  supported by all cores. >> +     */ >> +    switch (ssbd_state) { >> +    case ARM64_SSBD_MITIGATED: >> +        return sprintf(buf, "Not affected\n"); >> + >> +    case ARM64_SSBD_KERNEL: >> +    case ARM64_SSBD_FORCE_ENABLE: >> +        if (cpus_have_cap(ARM64_SSBS)) >> +            return sprintf(buf, "Not affected\n"); >> +        if (IS_ENABLED(CONFIG_ARM64_SSBD)) >> +            return sprintf(buf, >> +                "Mitigation: Speculative Store Bypass disabled\n"); >> +    } >> + >> +    if (__ssb_safe) >> +        return sprintf(buf, "Not affected\n"); >> + >> +    return sprintf(buf, "Vulnerable\n"); >> +} >>