From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 48C16385B50C for ; Mon, 13 Feb 2023 18:10:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48C16385B50C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 420B421DDB; Mon, 13 Feb 2023 18:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1676311802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WEGfgtaFj67ivjMy//jjoY1QFUePLQF9nBHkRrlL0Cw=; b=E6q+hAJlAlZKbh1PdLO2fIx+BW26eLJrDrDT41GkSEPnmuW/qmpbPn7VL0950qOvco0GHr h7qOK0ty5sugTh2gEK16vIqwZu/8jo34pG3xeGIDY/RJugOJdcIWvt4SXiQFh0w/RzedxH IBIIj5XEUA15YburbnMI1RKjoMP+rfI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1676311802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WEGfgtaFj67ivjMy//jjoY1QFUePLQF9nBHkRrlL0Cw=; b=Wk3IpaLeDnyBaybv35sHCp0J8xnHAGn6LuIppczjA4eSKAQS7Of+INuJf42AQBAa7J9nue 9q/JdWl09N8ToPBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 285681391B; Mon, 13 Feb 2023 18:10:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gQ+/CPp86mNhdAAAMHmgww (envelope-from ); Mon, 13 Feb 2023 18:10:02 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: "Markus T . Metzger" Subject: [PATCH] [gdb/testsuite] Add have_linux_btrace_bug Date: Mon, 13 Feb 2023 19:10:01 +0100 Message-Id: <20230213181001.25142-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The linux kernel commit 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output mode"), added in version v5.5.0 had a bug that was fixed by commit ce0d998be927 ("perf/x86/intel/pt: Fix sampling using single range output") in version 6.1.0. The bug manifested for intel microarchitectures Rocket Lake, Raptor Lake and Alder Lake. Detect this set of conditions in a new proc have_linux_btrace_bug, and use it in allow_btrace_tests. I was initially planning to do just a require !have_linux_btrace_bug in the failing test-cases, and that looked ok for PR30065 (with libipt) with just one test-case failing, but there are a lot of fails for PR30073 (without libipt). Tested on x86_64-linux. PR testsuite/30073 PR testsuite/30075 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30073 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30075 --- gdb/testsuite/lib/gdb.exp | 103 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 7f98f080328..a76397f50b8 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3851,6 +3851,10 @@ gdb_caching_proc allow_btrace_tests { gdb_exit remote_file build delete $obj + if { $allow_btrace_tests } { + set allow_btrace_tests [expr ![have_linux_btrace_bug]] + } + verbose "$me: returning $allow_btrace_tests" 2 return $allow_btrace_tests } @@ -9374,5 +9378,104 @@ proc has_dependency { file dep } { return [regexp $dep $output] } +# Return 1 if the linux kernel btrace bug introduced in kernel commit +# 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output +# mode"), may manifest. + +gdb_caching_proc have_linux_btrace_bug { + set me "have_linux_btrace_bug" + + if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } { + return 0 + } + + if { ![istarget *-*-linux*] } { + return 0 + } + + set res [remote_exec target "uname -r"] + set status [lindex $res 0] + set output [lindex $res 1] + if { $status != 0 } { + return 0 + } + + set re ^($::decimal)\\.($::decimal)\\.($::decimal) + if { [regexp $re $output dummy v1 v2 v3] != 1 } { + return 0 + } + set v [list $v1 $v2 $v3] + + set affected_version \ + [expr [version_compare [list 5 5 0] <= $v] \ + && [version_compare $v < [list 6 1 0]]] + if { ! $affected_version } { + return 0 + } + + # Compile a test program. + set src { + #include "nat/x86-gcc-cpuid.h" + + int main() { + unsigned int eax, ebx, ecx, edx; + + if (!__get_cpuid (0, &eax, &ebx, &ecx, &edx)) + return 0; + + int intel_p = (ebx == signature_INTEL_ebx + && ecx == signature_INTEL_ecx + && edx == signature_INTEL_edx); + + if (!intel_p) + return 0; + + if (! __get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return 0; + + unsigned int ex_fam_id = (eax >> 20) & 0xff; + unsigned int ex_mod_id = (eax >> 16) & 0xf; + unsigned int fam_id = (eax >> 8) & 0xf; + unsigned int model = (eax >> 4) & 0xf; + + if (fam_id == 6 || fam_id == 15) + model = model + (ex_mod_id << 4); + if (fam_id == 15) + fam_id = fam_id + ex_fam_id; + + if (fam_id == 6) + { + /* Rocket Lake. */ + if (model == 167) + return 1; + /* Alder Lake. */ + if (model == 151 || model == 154) + return 1; + /* Raptor Lake. */ + if (model == 183) + return 1; + } + + return 0; + } + } + + set flags "incdir=$::srcdir/.." + if { ! [gdb_simple_compile $me $src executable $flags] } { + return 0 + } + + set result [remote_exec target $obj] + set status [lindex $result 0] + set output [lindex $result 1] + if { $output != "" } { + set status 0 + } + + remote_file build delete $obj + + return $status +} + # Always load compatibility stuff. load_lib future.exp base-commit: 14d0e6818a022b72c265f15f63c8ccc2fc8c302a -- 2.35.3