Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp406699ybg; Tue, 28 Jul 2020 08:53:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwi04M/sC37RGmRZVX3l/Vm661Mo7QQgMuwex4hNNnly9MexXn1748HjPz5aBvLzjhcAM1N X-Received: by 2002:a17:906:1f08:: with SMTP id w8mr17083758ejj.535.1595951633612; Tue, 28 Jul 2020 08:53:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595951633; cv=none; d=google.com; s=arc-20160816; b=okTUVfDMH0B3QBfeLe4I5NT4Q+wYvsDdgQDdIIfL9aEKrnAma0YquSiQl6mAk46Arq zMEHkrloIWumhm8jhm2vNLRenRt+WoUuDqZkLJtQDWCnGCh3CQMoJL1cQe515zD7y3q5 cGIST/r3EcPqy+cU0+2w/BG3K+cOCrOcparZ6tM9Qz2sPWps+Bm12WaZTP9FJByYMMs2 hrTHWxi2lHOpem0KQIs1OFYZQ7bgG/su4t9PFGx5cIOCUjueiiGnS+/w7fKggqjvwBAx eXrb4wMgYxIDwMPOCZQ+1sjjyas25sslBvK1HVgqqhddGn7E1AbZihppJ/i+UGQZrQzw PI+w== 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:mime-version :message-id:date:subject:cc:to:from; bh=c5K2xUeH7GbXsyoJM0iE6vL0zEdrKOoDzqbZuSgOgsg=; b=VgtVwB9M6M63LN0qlKY7TphGkE8n46C/dQ4OExa9haUy6Vizs8MYuxQ3HMeQqnNrhq 6haGoGu9kC0+DA/Q+diczg/7LYZrw53TM8f0JAudHAwoBuct9jtwhCrqdj7MIyxIRjv2 OfWPz7F6MukHIJequIgggmeR8kL3rGjD3lH775tT0buFd4NNvvywO4A8iaJC7q8cBse3 QN6vtH0JJKJbc1NAGiCvV16Baao49v6Uyu5mBjcJxsoGIkVgyz0/IpeEyqTnBmeSveS/ /abvLWV3CEe2ZcgO7Ol8V0z70tJGBMFS7y6QDvnWggMX6tVygNVf+ee2JVg6YFeeg60N HuZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox17si3140461ejb.241.2020.07.28.08.53.31; Tue, 28 Jul 2020 08:53:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730963AbgG1PvK (ORCPT + 99 others); Tue, 28 Jul 2020 11:51:10 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59651 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730671AbgG1PvK (ORCPT ); Tue, 28 Jul 2020 11:51:10 -0400 Received: from 1.general.cascardo.us.vpn ([10.172.70.58] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k0Rsb-0007kg-96; Tue, 28 Jul 2020 15:51:01 +0000 From: Thadeu Lima de Souza Cascardo To: Michael Ellerman Cc: Shuah Khan , 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 Message-Id: <20200728155039.401445-1-cascardo@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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