Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4950411rwl; Sun, 8 Jan 2023 06:08:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXt2xKkGAgweadBPjaVTIvHrcogVqOXDxSsJTQtMGBHl9cviI6KXPI6L2KddPhaa8y9IFPWz X-Received: by 2002:a17:90b:104f:b0:226:fa8c:e50a with SMTP id gq15-20020a17090b104f00b00226fa8ce50amr4104120pjb.35.1673186929487; Sun, 08 Jan 2023 06:08:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673186929; cv=none; d=google.com; s=arc-20160816; b=aEAkhTs1N1TaawB33cVEdzGsHV6Ij1DGyUGEDXMgzcbYb+TkT1kcOGHvSt2X7jPWh4 GqeMlkD3wWf4CC3Zi9yg4pe7Ek6Pk2bJ/DybFGixKU2Ut8BG2k5wrviVuWSLw0SFZkLL KgLOo+JBdYPJSsfcI77MxJokX70PEc9AGXm83Qjja9QyRmfXoD1p84GKxg+MsPhJTOEo Wh5h4fthSozwcVYZirMZOVrDc/+3hKuefLOjEFsLEjMJjybrYAtlpNYcJ0sm/9Lb70On 7/kNM1AzBwoRkUkFJIbp8SeMmASuC+6EKjO+6CBVfnyIwuN91Vznp3nURTK5UniYUUHT 6Sbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AWGJ5g/vEooR1oxMbjdjehsv45OT01cYZH+PLv9f7C0=; b=NiDvhuxEHL3K66D+I0rXXX6uZNXgacX0zQi/+0RJBVpi/jKf/2UvUhQo44svSo1kjo 0Rgq7utSJIeDYnk1i2lusDARa+MdnryqGZcvJE8SfvmFmlNiYixBVVXox0KXKM7r/uOA BT/oEJoAJzp80Y9boJkmKOS9qcc6bMhnem2bZvd2fHcEFZxXzNYI9caMwJZ56PFjK0gk bVRuAHHrlA+oAraDvGFl6Ce3gSzYggLGuGe1jTdCZxboYM246p68epP2VpwH2rvQNUHR aDaBc/vVkVtsXjeS2hjfBQzjfmu3Mq/jQknl5+t8sGTUc6Atu89iNoJorMByBWjaBidA EKLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=FVpcN3GU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mn20-20020a17090b189400b00225b16285cbsi9958220pjb.168.2023.01.08.06.08.42; Sun, 08 Jan 2023 06:08:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=FVpcN3GU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbjAHN7S (ORCPT + 52 others); Sun, 8 Jan 2023 08:59:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231415AbjAHN7L (ORCPT ); Sun, 8 Jan 2023 08:59:11 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E236DE99; Sun, 8 Jan 2023 05:59:11 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.184]) by gnuweeb.org (Postfix) with ESMTPSA id 43D2B7E500; Sun, 8 Jan 2023 13:59:08 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673186351; bh=GTUZnCbGV/UWFXA7BcCYjMcKchB8a7OfQh/kkhPzwLA=; h=From:To:Cc:Subject:Date:From; b=FVpcN3GUI1xGzqnS0IYPQevi4phQ4IgCjHI5gq/WhWwKGWLjgUxuPnpHuTt9GWZsV +CEjy8ktVdHJb5xSYX8+e0ahe6H2f8pl7j6LInpZ59JhwwaRfTc6VldMChnCgFnuuA IGK+5QxBUkVktnk6Qju37UZrZFYwhhiJ02eRYQmWT5HnBGIxB/QavIWvalOG+ChSPO JWurRuoD9T5DSEwroXsVUaFbGisIJQ+qqBSp/O4kyQDBFpdLDDdtkaHj1J6yLCCKko dcha1wlK/2IgpBvBNQZwZLjJW1d9sNol+c9EOvIylSVpub2VwZ1PJ3Yk6bYCGgqJ3a q2XrSpnHaldOA== From: Ammar Faizi To: Willy Tarreau Cc: Ammar Faizi , Shuah Khan , "Paul E. McKenney" , Gilang Fachrezy , Alviro Iskandar Setiawan , GNU/Weeb Mailing List , Linux Kernel Mailing List , Linux Kselftest Mailing List Subject: [PATCH v3 0/5] nolibc signal handling support Date: Sun, 8 Jan 2023 20:58:59 +0700 Message-Id: <20230108135904.851762-1-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ammar Faizi Hi Willy, On top of the series titled "nolibc auxiliary vector retrieval support". The prerequisite patches of this series are in that series. This is v2 of nolibc signal handling support. It adds signal handling support to the nolibc subsystem: 1) Initial implementation of nolibc sigaction(2) function. `sigaction()` needs an architecture-dependent "signal trampoline" function that invokes __rt_sigreturn syscall to resume the process after a signal gets handled. The "signal trampoline" function is called `__restore_rt` in this implementation. The naming `__restore_rt` is important for GDB. It also has to be given a special optimization attribute "omit-frame-pointer" to prevent the compiler from creating a stack frame that makes the `%rsp` value no longer points to the `struct rt_sigframe` that the kernel constructed. 2) signal(2) function. signal() function is the simpler version of sigaction(). Unlike sigaction(), which fully controls the struct sigaction, the caller only cares about the sa_handler when calling the signal() function. signal() internally calls sigaction(). 3) More selftests. This series also adds selftests for: - fork(2) - sigaction(2) - signal(2) Side note for __restore_rt: This has been tested on x86-64 arch and `__restore_rt` generates the correct code. The `__restore_rt` codegen correctness on other architectures need to be evaluated as well. If it can't generate the correct code, it has to be written in inline Assembly. The current codegen for __restore_rt looks like this (gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0): 00000000004038e3 <__restore_rt>: 4038e3: endbr64 4038e7: mov $0xf,%eax 4038ec: syscall ## Changes since v2: - Fix unintentionally squashed patch. The signal() selftest patch was squashed into the sigaction selftest patch. ## Changes since RFC v1: - Separate getpagesize() series. - Write __restore_rt function in C instead of in inline Assembly. Signed-off-by: Ammar Faizi --- Ammar Faizi (5): nolibc/sys: Implement `sigaction(2)` function nolibc/sys: Implement `signal(2)` function selftests/nolibc: Add `fork(2)` selftest selftests/nolibc: Add `sigaction(2)` selftest selftests/nolibc: Add `signal(2)` selftest tools/include/nolibc/sys.h | 97 +++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 172 +++++++++++++++++++ 2 files changed, 269 insertions(+) base-commit: b6887ec8b0b0c78db414b78e329bf2ce234dedd5 prerequisite-patch-id: 8dd0ca8ecee1732d8f5c0b233f8231dda6ab0d22 prerequisite-patch-id: ff4c08615ebbdc1a04ce39f39f99387ee46b2b31 prerequisite-patch-id: af837a829263849331eb6d73701afd7903146055 -- Ammar Faizi