From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id SLxmIQSdA2IzyAAAgWs5BA (envelope-from ) for ; Wed, 09 Feb 2022 11:52:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8P8AHgSdA2KMYAAAauVa8A (envelope-from ) for ; Wed, 09 Feb 2022 11:52:52 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3213547ABD for ; Wed, 9 Feb 2022 11:52:52 +0100 (CET) Received: from localhost ([::1]:38650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHkah-0002dG-DP for larch@yhetil.org; Wed, 09 Feb 2022 05:52:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHk9n-0002qY-LV for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHk9n-0001j3-1n for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHk9m-00085y-Ju for guix-patches@gnu.org; Wed, 09 Feb 2022 05:25:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53895] [PATCH 5/5] WIP: guix: cpu: Add detection for aarch64 CPUs. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 10:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53895@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 53895-submit@debbugs.gnu.org id=B53895.164440228731081 (code B ref 53895); Wed, 09 Feb 2022 10:25:02 +0000 Received: (at 53895) by debbugs.gnu.org; 9 Feb 2022 10:24:47 +0000 Received: from localhost ([127.0.0.1]:49976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk9X-00085F-El for submit@debbugs.gnu.org; Wed, 09 Feb 2022 05:24:47 -0500 Received: from flashner.co.il ([178.62.234.194]:50082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHk9V-000851-Gi for 53895@debbugs.gnu.org; Wed, 09 Feb 2022 05:24:45 -0500 Received: from localhost (unknown [37.46.46.251]) by flashner.co.il (Postfix) with ESMTPSA id B9901403CD; Wed, 9 Feb 2022 10:24:39 +0000 (UTC) From: Efraim Flashner Date: Wed, 9 Feb 2022 12:21:51 +0200 Message-Id: <26894a74e7a1ed861a170239e26d13f1298fe5ac.1644401681.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644403972; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=Cdff529DenBYTp5mjSDUJWE/qcxWf6s08U0ftyNNlHY=; b=FMMyJ9jywiUzE2ZLh0PY8WyQHSswhWAmvKtkTXn25JyJiWbZpDDWqITgjYHAlLoNrXuJrD YHzS8ZV1Nt7uXDfNydlvyEDEg8SBdfAI+lHjQPqQdVIAUlHDKRg73k2i5/Bpjtz702VDbw UH0A3ilD47UETvfCOrJ6Q79KHNP4sTwhnp3pAJr3e3Q/vfZr0e7iAIBX9d9xErRUKqyb60 Mg33TMi4euANtA3uQoF12sqUbjb8CEDUY7zPJ1z3zUGw376wPXiq8uf6grrRAmWEj/QB5O gXUGzdh5r2H0Ge4Z1QuSk9RWL7nocdY39iI61oQaoRpF28nzUwOXXbKSW9dfZA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644403972; a=rsa-sha256; cv=none; b=tQQd00p+VOSG5UGdQ71dmAjG+FfoApKMFsoqfBSlFm+6KY+i47FFO0YsUhJbUzD7Sai2Wu TT+Upi57+OaKEheJJDfoIjCzJYcK18UXperJunnc37u72cXMX/kIEStyrp8StmxOxWe3iL dvUq6BKRwphwgpm/Ci6ERHhA1GKkBqyAvl+SZC8RfhEYT62cv2CzbPFbbk2mj/xBmB+b/F hXA23jObuRBOVD9atXEFMdeE6L7Y8vHtGtOxthEYC4XTKu2+o8NZ4zqfwd/L2gD+T8DxcW 9jn2o3cZMT0I5Vd4p1xVjcEvvQyWMvtiL+U7zLICysRRvsgpK2NR87+1hVm6EA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.63 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 3213547ABD X-Spam-Score: -1.63 X-Migadu-Scanner: scn1.migadu.com X-TUID: tQhHcKkZwYpT * guix/cpu.scm (current-cpu): Extend existing implementation to also read cpuinfo from aarch64 machines. (cpu->gcc-architecture): Add case for aarch64. --- guix/cpu.scm | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/guix/cpu.scm b/guix/cpu.scm index 6d44599822..d4dbd5f6b8 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -66,25 +66,47 @@ (define (prefix? prefix) (match (read-line port) ((? eof-object?) #f) + ;; vendor for x86_64 and i686 ((? (prefix? "vendor_id") str) (match (string-tokenize str) (("vendor_id" ":" vendor) (loop vendor family model)))) + ;; vendor for aarch64 and armhf + ((? (prefix? "CPU implementer") str) + (match (string-tokenize str) + (("CPU" "implementer" ":" vendor) + (loop vendor family model)))) + ;; family for x86_64 and i686 ((? (prefix? "cpu family") str) (match (string-tokenize str) (("cpu" "family" ":" family) (loop vendor (string->number family) model)))) + ;; model for x86_64 and i686 ((? (prefix? "model") str) (match (string-tokenize str) (("model" ":" model) (loop vendor family (string->number model))) (_ (loop vendor family model)))) + ;; model for aarch64 and armhf + ((? (prefix? "CPU part") str) + (match (string-tokenize str) + (("CPU" "part" ":" model) + (loop vendor family (string->number (string-append "#x" (string-drop model 2))))) + (_ + (loop vendor family model)))) + ;; flags for x86_64 and i686 ((? (prefix? "flags") str) (match (string-tokenize str) (("flags" ":" flags ...) (cpu (utsname:machine (uname)) vendor family model (list->set flags))))) + ;; flags for aarch64 and armhf + ((? (prefix? "Features") str) + (match (string-tokenize str) + (("Features" ":" flags ...) + (cpu (utsname:machine (uname)) + vendor family model (list->set flags))))) (_ (loop vendor family model)))))))) @@ -192,6 +214,54 @@ (define (cpu->gcc-architecture cpu) ;; TODO: Recognize CENTAUR/CYRIX/NSC? "x86_64")) + ("aarch64" + (pk (cpu-architecture cpu)(cpu-vendor cpu)(cpu-family cpu) (cpu-model cpu)(cpu-flags cpu)) + ;; Currently returns ("aarch64" #f #f #f #< vhash: # insert: # ref: #>) + ;; Transcribed from GCC's list of aarch64 processors in aarch64-cores.def + (match (cpu-vendor cpu) + ("0x41" + (match (cpu-model cpu) + ((or #xd02 #xd04 #xd03 #xd07 #xd08 #xd09) + "armv8-a") + ((or #xd05 #xd0a #xd0b #xd0e #xd0d #xd41 #xd42 #xd4b #xd46 #xd43 #xd44 #xd41 #xd0c #xd4a) + "armv8.2-a") + (#xd40 + "armv8.4-a") + (#xd15 + "armv8-r") + ((or #xd46 #xd47 #xd48) + "armv9-a"))) + ("0x42" + "armv8.1-a") + ("0x43" + (match (cpu-model cpu) + ((or #x0a0 #x0a1 #x0a2 #x0a3) + "armv8-a") + ((or #x0b0 #x0b1 #x0b2 #x0b3 #x0b4 #x0b5) + "armv8.2-a") + (#x0b8 + "armv8.3-a"))) + ("0x46" + "armv8.2-a") + ("0x48" + "armv8.2-a") + ("0x50" + "armv8-a") + ("0x51" + (match (cpu-model cpu) + (#xC00 + "armv8-a") + (#x516 + "armv8.1-a") + (#xC01 + "armv8.4-a"))) + ("0x53" + "armv8-a") + ("0x68" + "armv8-a") + (_ + "armv8-a")) + "armv8-a") (architecture ;; TODO: AArch64. architecture))) -- 2.34.0