From nobody Sun Nov 24 12:24:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1723828372; cv=none; d=zohomail.com; s=zohoarc; b=dDkJIp/CZHMJn6sx2mK5AU6+a8axxER27nMtIim+5hVM6s8vvA5/YkUGq84/y/+8g8dMeAOG2EKI01zZmpwsBSzFIDoHiSqBMFDMosfXP5soJo6qSZCZ5HpeUvxEi2GPqNfhZ6DffKgamKtNLwkfPZRGdRVCsRl1Jd2dMHCU0Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723828372; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9FVE9uwE5SGNsSu9ob6L64WLDml4rbiZ/hyx7tyV/IQ=; b=AWAoTqjAZfTsOCR7TFn+QvYoOGLgn4b6F06MJbyl9k5/NANusxrvQcpf95kCtGEb/4t6P6Cwma7FEdeHw0fwe3WiQt38AxKwzLAEBwJmRZzH2ktuGsAWOQXnPCr44LbgTJSlT0talI3UIqZtw0yE1lXlekwzZeuwL3yK93wFnJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1723828372719193.7466873249689; Fri, 16 Aug 2024 10:12:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sf0TP-00079B-KI; Fri, 16 Aug 2024 13:10:47 -0400 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 1sf0TN-0006sa-Em for qemu-devel@nongnu.org; Fri, 16 Aug 2024 13:10:45 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sf0TL-0007QG-Gq for qemu-devel@nongnu.org; Fri, 16 Aug 2024 13:10:45 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2d3d58d6e08so1249360a91.3 for ; Fri, 16 Aug 2024 10:10:43 -0700 (PDT) Received: from localhost.localdomain (121-45-122-195.tpgi.com.au. [121.45.122.195]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3ac7ca33dsm5988407a91.6.2024.08.16.10.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 10:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723828242; x=1724433042; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9FVE9uwE5SGNsSu9ob6L64WLDml4rbiZ/hyx7tyV/IQ=; b=lO0yHw0Zx2HgnGb9bPj1j3uJPc5YuM2NOaUF8M+Y3JKualGVX0iuSyZPTxmqLIaFgz 6vaXruoQNjWHxbrZ3BaU/H3JFQ19jMXcN900PTGUd/KF+a7ZBmeSXD8ie0GBke/ixA5t yiyoYDynNZaq40wHokf0Yp4lOwddiTZLui/Eupt8/YAAZUFnlYWxR4tsOUvVap+65m5q ESqjBBDqGmXxJ6B5/J9QjYXTEywp271dhJU96UJ5vTTRTY/1qd+0CuROs5WdzWhQzy06 uJJjhw2akUFRZSNxvjUTGsWRIDqZ1pEzkXAfO5o/viy6X+M/ibH3SQA00ZSKDN4jo4OM nnFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723828242; x=1724433042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9FVE9uwE5SGNsSu9ob6L64WLDml4rbiZ/hyx7tyV/IQ=; b=HThDqOpd1ltYtHi6ud4pnMoB/dej3yMRsQ5BtFQ2fRs8y1r6xK3EwJQvsfl5UYQx8C xllupwvNgWnsGucE+jqANnbF5CeMHXgqEuhJRIUaMA7uRBgbU2NVASZi3/D/8M0kP2Pg q/5a3RIZOiMZr1RB4jozmn5566NKWRowtVcJ5RykDIcyHo0kahCj5M+iWxjtpf+OuGIh IwwnzHp0FfmKxBgNZKCHQ82I427XXR7xFJSuW7mM8eyGQ/8qtJsbxZy++koG3a85GFRt 8nGI1wEgfpRXmN2SqS6Np7HoweGvIXU+DBcKi3gfyBJus+XB3FO8sDjWVsL/TsvAi0pg hSpw== X-Gm-Message-State: AOJu0YzOG3zuwJW33E+IKqGhggnpXmdUL3QI4skCAQe99okdQZ85i/2t OaJ4RDHig71yMQyPjg3XrTDkb+q+8V49nAYPmO7KqxFJf4qk9WAuV9p8QL6VI7Q= X-Google-Smtp-Source: AGHT+IHCdkp83Tf3RAfLPd3k05qhiYDKxUNBopRMx+YMIARDpcjcvtuerIeX6f2Q2SdA7K1xYVEnDg== X-Received: by 2002:a17:90a:df04:b0:2c9:7aa6:e15d with SMTP id 98e67ed59e1d1-2d3dffe2e82mr3855566a91.20.1723828241546; Fri, 16 Aug 2024 10:10:41 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Mark Corbin , Warner Losh , Ajeet Singh , Richard Henderson Subject: [PATCH v2 16/17] bsd-user: Implement set_mcontext and get_ucontext_sigreturn for RISCV Date: Sat, 17 Aug 2024 03:09:48 +1000 Message-Id: <20240816170949.238511-17-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240816170949.238511-1-itachis@FreeBSD.org> References: <20240816170949.238511-1-itachis@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=itachis6234@gmail.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1723828374194116600 Content-Type: text/plain; charset="utf-8" From: Mark Corbin Added implementations for 'set_mcontext' and 'get_ucontext_sigreturn' functions for RISC-V architecture, Both functions ensure that the CPU state and user context are properly managed. Signed-off-by: Mark Corbin Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Co-authored-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/riscv/signal.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/bsd-user/riscv/signal.c b/bsd-user/riscv/signal.c index 072ad821d2..10c940cd49 100644 --- a/bsd-user/riscv/signal.c +++ b/bsd-user/riscv/signal.c @@ -114,3 +114,57 @@ abi_long get_mcontext(CPURISCVState *regs, target_mcon= text_t *mcp, =20 return 0; } + +/* Compare with set_mcontext() in riscv/riscv/exec_machdep.c */ +abi_long set_mcontext(CPURISCVState *regs, target_mcontext_t *mcp, + int srflag) +{ + + regs->gpr[5] =3D tswap64(mcp->mc_gpregs.gp_t[0]); + regs->gpr[6] =3D tswap64(mcp->mc_gpregs.gp_t[1]); + regs->gpr[7] =3D tswap64(mcp->mc_gpregs.gp_t[2]); + regs->gpr[28] =3D tswap64(mcp->mc_gpregs.gp_t[3]); + regs->gpr[29] =3D tswap64(mcp->mc_gpregs.gp_t[4]); + regs->gpr[30] =3D tswap64(mcp->mc_gpregs.gp_t[5]); + regs->gpr[31] =3D tswap64(mcp->mc_gpregs.gp_t[6]); + + regs->gpr[8] =3D tswap64(mcp->mc_gpregs.gp_s[0]); + regs->gpr[9] =3D tswap64(mcp->mc_gpregs.gp_s[1]); + regs->gpr[18] =3D tswap64(mcp->mc_gpregs.gp_s[2]); + regs->gpr[19] =3D tswap64(mcp->mc_gpregs.gp_s[3]); + regs->gpr[20] =3D tswap64(mcp->mc_gpregs.gp_s[4]); + regs->gpr[21] =3D tswap64(mcp->mc_gpregs.gp_s[5]); + regs->gpr[22] =3D tswap64(mcp->mc_gpregs.gp_s[6]); + regs->gpr[23] =3D tswap64(mcp->mc_gpregs.gp_s[7]); + regs->gpr[24] =3D tswap64(mcp->mc_gpregs.gp_s[8]); + regs->gpr[25] =3D tswap64(mcp->mc_gpregs.gp_s[9]); + regs->gpr[26] =3D tswap64(mcp->mc_gpregs.gp_s[10]); + regs->gpr[27] =3D tswap64(mcp->mc_gpregs.gp_s[11]); + + regs->gpr[10] =3D tswap64(mcp->mc_gpregs.gp_a[0]); + regs->gpr[11] =3D tswap64(mcp->mc_gpregs.gp_a[1]); + regs->gpr[12] =3D tswap64(mcp->mc_gpregs.gp_a[2]); + regs->gpr[13] =3D tswap64(mcp->mc_gpregs.gp_a[3]); + regs->gpr[14] =3D tswap64(mcp->mc_gpregs.gp_a[4]); + regs->gpr[15] =3D tswap64(mcp->mc_gpregs.gp_a[5]); + regs->gpr[16] =3D tswap64(mcp->mc_gpregs.gp_a[6]); + regs->gpr[17] =3D tswap64(mcp->mc_gpregs.gp_a[7]); + + + regs->gpr[1] =3D tswap64(mcp->mc_gpregs.gp_ra); + regs->gpr[2] =3D tswap64(mcp->mc_gpregs.gp_sp); + regs->gpr[3] =3D tswap64(mcp->mc_gpregs.gp_gp); + regs->gpr[4] =3D tswap64(mcp->mc_gpregs.gp_tp); + regs->pc =3D tswap64(mcp->mc_gpregs.gp_sepc); + + return 0; +} + +/* Compare with sys_sigreturn() in riscv/riscv/machdep.c */ +abi_long get_ucontext_sigreturn(CPURISCVState *regs, + abi_ulong target_sf, abi_ulong *target_uc) +{ + + *target_uc =3D target_sf; + return 0; +} --=20 2.34.1