From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id oIbjBECXb2d/5AAAqHPOHw:P1 (envelope-from ) for ; Sat, 28 Dec 2024 06:14:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id oIbjBECXb2d/5AAAqHPOHw (envelope-from ) for ; Sat, 28 Dec 2024 07:14:24 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=uU2xDi0M; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=lLkQMJ5r; 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"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1735366464; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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:dkim-signature; bh=clnOWmrU1X/pUsj4qdIPSelB/8tIPDeHRWSK+mBnU5M=; b=NpGRuer3PP3oXn2/Sqv4owl8sDHTdd7bXEMaAUFCC6UfQ35mgPQk7WrXfIDBdgvfTkFI6o nlKdCZfP4lszFu7+n2mUTC0fGqko7K41hzP3vPoQjdBL4IPlKWW4m4ZEMyAVVF+ZrNF60+ PyRBJp12yo/DIfeNTUSvbhGxWPbD3xfgHZg8Xq+YCSVlueJQ7CRXcQAjbC+SltIkL2vMxU Hb3+tIJyZGLaofjlUdfHxCfyOYtc236GHbrQdRQ1sD2UbmIQUNk3U2SV+yQkNYFUNegFrR hFp6grNzyfU506/SAIKpoovWkkgQXG2xbSWUBZI4c/iv0JdQwXf0CkO9DkgnKw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=uU2xDi0M; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=lLkQMJ5r; 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"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1735366464; a=rsa-sha256; cv=none; b=WutZmZ9QlSFnHn2JOK5JbZ//4wTuUnZN9OqXIRMLO0y7O9rC6ddy6otHBf39d3YjrRiYus jegQYFdTwPhwQK2btFQEIOs3uXQyrBPDkeGkxA8I1rjoTWbOZXAJE/6lE5QFe78QXfWJxA ZKmRBorMF+E20mYJERchml5wyBQds/X2sfPwRGCaAcx2pZGFsTqX3a2/jd3eZYg+VESn9s bB8D/491TBAGnKmqTAXzZLQiaLSCRbjfqI1ea9ReRTI94KIAVnqcF+ClmYky+1TYCbjmH9 8IxAhqE/taqVNZScCMhjpEFQLS705ozkbSHGUsFMUItA/DnTkrGXKb0Mi5SNzQ== 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 CD97519F75 for ; Sat, 28 Dec 2024 07:14:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRQ5M-0001yJ-HK; Sat, 28 Dec 2024 01:14:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRQ5K-0001xd-M2 for guix-patches@gnu.org; Sat, 28 Dec 2024 01:14:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tRQ5K-0004zT-5s for guix-patches@gnu.org; Sat, 28 Dec 2024 01:14:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=clnOWmrU1X/pUsj4qdIPSelB/8tIPDeHRWSK+mBnU5M=; b=uU2xDi0MnleKKWQ5QlVEg06/ne4HKOxGWF7hfC5JlxVAX4X6FNmLNvtFgaiF2XfItj9q4//XeWIeCJeoqxMPXxc1rQdhM8mWeyQc8kAu5TZPZ/28w4oSX9fhxrHa9BLflsox77JPAgudShb3E76LXCkG+z2vRnRSqQEAz3EHQcou60uIsrXA1em7PKnCYJZj/FbiDIuJNHhKpyGDvWbDzwTx0FLoBVpvIpIrnaHSVyAsm3mWhDlshcbMkiVZh2fDG4ugcx+FBWM5NpSg0ytYrEEWjWRQvBvji3UMDQ4UYx4nKteyidSjzLaDAIW2ITa4bt+jP3TTxNTWRP7eJo4HUg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tRQ5J-0001Pz-N7 for guix-patches@gnu.org; Sat, 28 Dec 2024 01:14:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75027] [PATCH v2 1/3] syscalls: Add =?UTF-8?Q?=E2=80=98kexec-load-file=E2=80=99.?= Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 28 Dec 2024 06:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75027 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 75027@debbugs.gnu.org Received: via spool by 75027-submit@debbugs.gnu.org id=B75027.17353664035363 (code B ref 75027); Sat, 28 Dec 2024 06:14:01 +0000 Received: (at 75027) by debbugs.gnu.org; 28 Dec 2024 06:13:23 +0000 Received: from localhost ([127.0.0.1]:48460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRQ4h-0001OQ-1R for submit@debbugs.gnu.org; Sat, 28 Dec 2024 01:13:23 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:45209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRQ4d-0001O6-SX for 75027@debbugs.gnu.org; Sat, 28 Dec 2024 01:13:21 -0500 Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2161eb94cceso67906265ad.2 for <75027@debbugs.gnu.org>; Fri, 27 Dec 2024 22:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735366333; x=1735971133; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=clnOWmrU1X/pUsj4qdIPSelB/8tIPDeHRWSK+mBnU5M=; b=lLkQMJ5rwVVK6bm2FeKnbv+9IEe9hPxgj2FBzCI03gbpbKBqEfPHcR2GBfqq6+jBuV iRZkqB5BXGmjd5QlGiV0pA64MAflSgWoCOsJIiQ9ZjWDhOBnAYoB4zLw51mjldk/3Eb/ ns+EmTruAVsFCQUSNt08deU/NF8RWThlUMCq89s7nj7GuJ+1/Sd2ZypLdi+b4NfhdXNq iMd8zFSyLLtHGT474aG/P4KqFR9QUWJlf83S1myK/PTZuBhwiUBdIE1+0UmBi/v4aggo Fwbtho27UyMeMwNd7CauFq+4kMKF0N7mP20oHbmqwD3jhG1P6/knS9Nh5TPCmoWtk1+9 g3Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735366333; x=1735971133; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=clnOWmrU1X/pUsj4qdIPSelB/8tIPDeHRWSK+mBnU5M=; b=aTbZvBzkYH36WtkDsCJPZ6p2/LrAdJupm0qUVokDaulmfTXNs/IczvqwG8UeaLuvTQ zArq70uiL15HZM3vhPS1/kPCCHXypJ0YxkmdFBbFAP5eLyByG6mDQGxrKKS84ghwLErs K51krPGLQ7xiS2f9YhOoNwqRsL1Bc/K97pkjQK8dzWKNk7B0A657zEeOg/k/STnD+gW3 Ido2L+SkXR6//r/qod2TdxTr3xSi4r9FTKN7N+qFRmqE1Ed5dWh2HtALOrLaWZHPLFaN SORmqzCdp6sYyaPLa2hYfbO/DgMHka14/9duofcXAQDP3OOcA7y9atmxP/b+JXDDDf6F 2dCA== X-Gm-Message-State: AOJu0YzrFIgw+vRV/OJp38XGP7MagH0sSgxZr1MrFkKEiA2d7f5s8zMb JhBbeGHOrf5ucA7RcwLLT2gioweJHSeoDrpBXgj1ommQqNF8AgSm8QTfLB36 X-Gm-Gg: ASbGncv3o/Jp65V6+JTEM9gvGfIOwNbwuVMDe32xtQBhoof41aLfu2jBlMOmeDSnF8f D6HooljM8Ad58KrWr/jkJNjdhAzOr+A7XgA91t/Rhg6ukiaj10eI9cflIBiThab6/VKd40UNH6j o+RpNZYVJfqZbOl098lq+yz7PD30KyThtjZy6kIkqRTM0iXmetES4hUHcjab6mENdIEBLwger3w tDfTI0cHjOF6YB5WwCj1b1HBP7lJHoMw87mvZA9XeKPsp33tseoRQ== X-Google-Smtp-Source: AGHT+IHG0r27u4ibeCo4F63US/BIFGLB5K45qprHID3OE5U8P32xPtY3IyilhNTlsVGq4wituT6gmw== X-Received: by 2002:a17:902:c951:b0:216:4a06:e87a with SMTP id d9443c01a7336-219e6f12d84mr489682615ad.40.1735366333518; Fri, 27 Dec 2024 22:12:13 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f4477ec330sm18482339a91.24.2024.12.27.22.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 22:12:11 -0800 (PST) From: Maxim Cournoyer In-Reply-To: ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 26 Dec 2024 18:21:25 +0100") References: Date: Sat, 28 Dec 2024 15:12:02 +0900 Message-ID: <87ikr4s5e5.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.86 X-Spam-Score: -3.86 X-Migadu-Queue-Id: CD97519F75 X-Migadu-Scanner: mx10.migadu.com X-TUID: vdN6fTni+zJM Hi Ludovic, Ludovic Court=C3=A8s writes: > * guix/build/syscalls.scm (string->utf-8/nul-terminated) > (kexec-load-file): New procedures. [...] > +;; Constants from . > +(define KEXEC_FILE_UNLOAD #x00000001) > +(define KEXEC_FILE_ON_CRASH #x00000002) > +(define KEXEC_FILE_NO_INITRAMFS #x00000004) > +(define KEXEC_FILE_DEBUG #x00000008) > + > +(define kexec-load-file > + (let* ((proc (syscall->procedure int "syscall" > + (list long ;sysno > + int ;kernel fd > + int ;initrd fd > + unsigned-long ;cmdline length > + '* ;cmdline > + unsigned-long))) ;flags > + ;; TODO: Don't do this. Why this TODO? "Don't do this" is not explicit enough; what would be preferable to do here, but can't be done now for some reason? Could we instead detect the error as returned by the syscall when it's not implemented, and throw/report the error accordingly? I see that's kind of done below (a misc-error is raised) -- I think we can remove this special handling already and let the error be throw if it's not implemented -- this removes the need to remember to come back here to edit the list of supported systems the day they gain support. > + (syscall-id (match (utsname:machine (uname)) > + ("i686" 320) > + ("x86_64" 320) > + ("armv7l" 401) > + ("aarch64" 401) > + ;; XXX: There's apparently no support for ppc64le= and > + ;; riscv64. > + (_ #f)))) > + (lambda* (kernel-fd initrd-fd command-line #:optional (flags 0)) > + "Load for eventual use of kexec(8) the Linux kernel from > +@var{kernel-fd}, its initial RAM disk from @var{initrd-fd}, with the giv= en > +@var{command-line} (a string). Optionally, @var{flags} can be a bitwise= or of > +the KEXEC_FILE_* constants." > + (let*-values (((command-line) > + (string->utf-8/nul-terminated command-line)) > + ((ret err) > + (proc syscall-id kernel-fd initrd-fd > + (bytevector-length command-line) > + (bytevector->pointer command-line) > + flags))) > + (when (=3D ret -1) I checked 'man 2 kexec_file_load*' to make sure: On success, these system calls returns 0. On error, -1 is returned = and errno is set to indicate the error. So, looks good. --=20 Thanks, Maxim