From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> To: Michael Ellerman <mpe@ellerman.id.au> Cc: Shuah Khan <shuah@kernel.org>, cascardo@canonical.com, linuxppc-dev@lists.ozlabs.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests/powerpc: return skip code for spectre_v2 Date: Tue, 28 Jul 2020 12:50:39 -0300 [thread overview] Message-ID: <20200728155039.401445-1-cascardo@canonical.com> (raw) When running under older versions of qemu of under newer versions with old machine types, some security features will not be reported to the guest. This will lead the guest OS to consider itself Vulnerable to spectre_v2. So, spectre_v2 test fails in such cases when the host is mitigated and miss predictions cannot be detected as expected by the test. Make it return the skip code instead, for this particular case. We don't want to miss the case when the test fails and the system reports as mitigated or not affected. But it is not a problem to miss failures when the system reports as Vulnerable. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> --- tools/testing/selftests/powerpc/security/spectre_v2.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/powerpc/security/spectre_v2.c b/tools/testing/selftests/powerpc/security/spectre_v2.c index 8c6b982af2a8..d5445bfd63ed 100644 --- a/tools/testing/selftests/powerpc/security/spectre_v2.c +++ b/tools/testing/selftests/powerpc/security/spectre_v2.c @@ -183,6 +183,14 @@ int spectre_v2_test(void) if (miss_percent > 15) { printf("Branch misses > 15%% unexpected in this configuration!\n"); printf("Possible mis-match between reported & actual mitigation\n"); + /* Such a mismatch may be caused by a guest system + * reporting as vulnerable when the host is mitigated. + * Return skip code to avoid detecting this as an + * error. We are not vulnerable and reporting otherwise, + * so missing such a mismatch is safe. + */ + if (state == VULNERABLE) + return 4; return 1; } break; -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> To: Michael Ellerman <mpe@ellerman.id.au> Cc: cascardo@canonical.com, Shuah Khan <shuah@kernel.org>, linuxppc-dev@lists.ozlabs.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests/powerpc: return skip code for spectre_v2 Date: Tue, 28 Jul 2020 12:50:39 -0300 [thread overview] Message-ID: <20200728155039.401445-1-cascardo@canonical.com> (raw) When running under older versions of qemu of under newer versions with old machine types, some security features will not be reported to the guest. This will lead the guest OS to consider itself Vulnerable to spectre_v2. So, spectre_v2 test fails in such cases when the host is mitigated and miss predictions cannot be detected as expected by the test. Make it return the skip code instead, for this particular case. We don't want to miss the case when the test fails and the system reports as mitigated or not affected. But it is not a problem to miss failures when the system reports as Vulnerable. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> --- tools/testing/selftests/powerpc/security/spectre_v2.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/powerpc/security/spectre_v2.c b/tools/testing/selftests/powerpc/security/spectre_v2.c index 8c6b982af2a8..d5445bfd63ed 100644 --- a/tools/testing/selftests/powerpc/security/spectre_v2.c +++ b/tools/testing/selftests/powerpc/security/spectre_v2.c @@ -183,6 +183,14 @@ int spectre_v2_test(void) if (miss_percent > 15) { printf("Branch misses > 15%% unexpected in this configuration!\n"); printf("Possible mis-match between reported & actual mitigation\n"); + /* Such a mismatch may be caused by a guest system + * reporting as vulnerable when the host is mitigated. + * Return skip code to avoid detecting this as an + * error. We are not vulnerable and reporting otherwise, + * so missing such a mismatch is safe. + */ + if (state == VULNERABLE) + return 4; return 1; } break; -- 2.25.1
next reply other threads:[~2020-07-28 15:51 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-28 15:50 Thadeu Lima de Souza Cascardo [this message] 2020-07-28 15:50 ` [PATCH] selftests/powerpc: return skip code for spectre_v2 Thadeu Lima de Souza Cascardo 2020-08-02 13:34 ` Michael Ellerman 2020-08-02 13:34 ` Michael Ellerman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200728155039.401445-1-cascardo@canonical.com \ --to=cascardo@canonical.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=shuah@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.