From nobody Sun Nov 24 07:40:58 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=1725679434; cv=none; d=zohomail.com; s=zohoarc; b=U/kRUO170qmljKgfwoXi3Yn7Y0SLtXQtWJBOe2T28S2X6LhHb6vqeyJVgDTRlPPKKpzJYRyjKosu/DJr+y/K5Pj36N+c10egcDYiCKdj1YNu9QRkVPWfNX4V2wVtMojBJTV+s6UmzW2qgOdH/2nKXfS7CrPiT7HZuLaVOedl/v0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725679434; 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=gLmvNP49C5b/kT0V4XhI3r4sx3P+q2ZyUZTSiTzhXnZczW4pPOpTcH4IzVDhSW2ThwOeRVIO5lKQPp4kG+APaKwDFlKJxzDcxO3IRM9VH4UMSgsV/Jk9vxx5gjIX1CwVEcLFwinFhMc5Ecq+RaeR01H1yFK5fszMB5pJ95Am/3o= 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 1725679434716612.1882402283511; Fri, 6 Sep 2024 20:23:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smm1k-0006sE-Rh; Fri, 06 Sep 2024 23:22:21 -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 1smlzu-00045O-Cx for qemu-devel@nongnu.org; Fri, 06 Sep 2024 23:20:31 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smlzo-00056C-NC for qemu-devel@nongnu.org; Fri, 06 Sep 2024 23:20:26 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-718e482930bso156604b3a.2 for ; Fri, 06 Sep 2024 20:20:20 -0700 (PDT) Received: from localhost.localdomain (115-64-160-35.tpgi.com.au. [115.64.160.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f1d4c6sm1703745ad.187.2024.09.06.20.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 20:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725679219; x=1726284019; 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=Jna+ysd5KOlghVrEiBvM40bFyRAORfnpETeWd6JmActI02m7EmAOGVUNHaQAh+bt1b cSKe18XL7Hagj6LiCjWEYtEM6BXXk5BD/oArGYPuuHqmbZkKiUAdpHymcaMKWwPx+6Hp kYXbHhIEigDYr4bUGmW5xYvcytLO8SHvyj0wSjbO7h7VjjC0rqLiM97ar50CsE6Hi3V1 xO/x/euv1ZLWpWYauQJ5vdPdpe6Yj7iZDXVe/Ruwonh9eFwhO74geJRrK9C6m74M4FDa 1i8iJa4jbpDqNwLcjGbtEoj6Iwto65RcFAlBiIlkVo1w8w3Wh0xB+2MSkLv34uLT88i8 /lww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725679219; x=1726284019; 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=B9peipUvs/PkZc3H5O9rHsJv9liz2s2GFE9eVyOtFSt4Zk/sWmmqt6C+8nSKl645J+ gii6add8BgoPtKSpb000KoydCrArzCZZVhHGMDV9fjU7zsZ3QwrjJ9d0kE34rUKBHO4c am3ffnfXgQNFnxlxFDmtx3iSNnSAF5091rIM60fhOzv1iJPrR4cqS8QCzmhzZzx+8BLK 9oDRroFOp2r181ReC3wOfE+LI09MsCOWyPy+9SiU0GOWYcQnq3mdldiE8636r42l1mK1 avGP93cpdubZnHOJfaXxUIa+2I61WOnEsnsnqYMSQzvu50XLQC3P2H0fsb30vVV++GCu bBQg== X-Gm-Message-State: AOJu0YxBVhkDKhtz8Q2VPBKHzEucarwqT1CgvzkwMm5kH8mdoAut4RD3 CdFIns8kfitTB+AyFG2LwWOW+biEJTTOJO3t6NhnguR8eMWeaRSQKEVNEw== X-Google-Smtp-Source: AGHT+IHEVYGX6yWdt/WnKyBAsV1A9AGHbC3V9uiZXVIm2f0xT3fnLLra6KG8Qo3WiJhfRryRx7++BA== X-Received: by 2002:a17:903:2442:b0:202:32cf:5dbe with SMTP id d9443c01a7336-206f0673077mr66291785ad.58.1725679219049; Fri, 06 Sep 2024 20:20:19 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Mark Corbin , Ajeet Singh , Richard Henderson Subject: [PATCH v5 16/17] bsd-user: Implement set_mcontext and get_ucontext_sigreturn for RISCV Date: Sat, 7 Sep 2024 13:19:26 +1000 Message-Id: <20240907031927.1908-17-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031927.1908-1-itachis@FreeBSD.org> References: <20240907031927.1908-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::434; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x434.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: 1725679436697116600 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