From patchwork Thu Dec 16 06:41:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 49006 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F0D33858402 for ; Thu, 16 Dec 2021 06:41:49 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 157A23858D35 for ; Thu, 16 Dec 2021 06:41:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 157A23858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Content-Type:From:Reply-To:Subject:Content-ID: Content-Description:In-Reply-To:References:X-Debbugs-Cc; bh=hf3/OoI+O5I2A3S7HDZDJCd9oRTOvvYUgQqNsg/QhYM=; b=RZfJ0x3meSMaRUxHIRkQZKgK9w PHP5UaQBc8I55lfLc/umG9EoZL2xGMmLDQpmYDh4Nh+m+04c+dvkVbXqBij1NpdvvFwIJ4g/6y0Ph CohHiE25Teja3EZk/1KPeAhaAypoLkx1B1FcYgUQj/+ku56u/Rrh0gtK/xxnxx7K8qQQnYhkLuswb FSZFmsE3TkbGhRv0N/IkCAHTQkf5+2kA90l8aJjxON25WN4p/POkk58Uc6h+8hBiVeLDio37jQlzr JM6KAP/sCBlk5BoP1Vr4BCzZwmYzvd4ZEWB0TTW7O3xq5jBYmnuPKH7GFWLkWVWkEN9K7XEYkjq6J LsI+Onbg==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxkSN-00062g-Us; Thu, 16 Dec 2021 07:41:35 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.95) (envelope-from ) id 1mxkSN-001v4D-HD; Thu, 16 Dec 2021 07:41:35 +0100 From: Aurelien Jarno To: libc-alpha@sourceware.org Subject: [PATCH] elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704] Date: Thu, 16 Dec 2021 07:41:31 +0100 Message-Id: <20211216064131.457656-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aurelien Jarno Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" On KVM guests running on some AMD systems, the IBRS feature is reported as a synthetic feature using the Intel feature, while the cpuinfo entry keeps the same. Handle that by first checking the presence of the Intel feature on AMD systems. Fixes bug 28704. --- sysdeps/x86/tst-cpu-features-cpuinfo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (H.J. Lu: resending because I wrongly send it to you instead of sending it to the list and Cc:ing you. Sorry) diff --git a/sysdeps/x86/tst-cpu-features-cpuinfo.c b/sysdeps/x86/tst-cpu-features-cpuinfo.c index 2d4927f5e5..830aaca2ec 100644 --- a/sysdeps/x86/tst-cpu-features-cpuinfo.c +++ b/sysdeps/x86/tst-cpu-features-cpuinfo.c @@ -169,7 +169,14 @@ do_test (int argc, char **argv) else if (cpu_features->basic.kind == arch_kind_amd) { fails += CHECK_PROC (ibpb, AMD_IBPB); - fails += CHECK_PROC (ibrs, AMD_IBRS); + + /* The IBRS feature on AMD processors is reported using the Intel feature + * on KVM guests (synthetic bit). In both cases the cpuinfo entry is the + * same. */ + if (HAS_CPU_FEATURE (IBRS_IBPB)) + fails += CHECK_PROC (ibrs, IBRS_IBPB); + else + fails += CHECK_PROC (ibrs, AMD_IBRS); fails += CHECK_PROC (stibp, AMD_STIBP); } fails += CHECK_PROC (ibt, IBT);