From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:a17:505:8d87:b0:1be9:327d:8ee3 with SMTP id ri7csp3360654njc; Wed, 24 Jul 2024 15:07:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwFI+8q7MjhFEC2vu3HEFkjcdVkp/XCiEqwhDZ66Zlp5y0gR7eYHg2RN+0SRuP0awqI9sHs3WBFn4Fv1TV0Ugqc2JcRPUL X-Google-Smtp-Source: AGHT+IGI2XSRmCWoPHWOQmeIUbf4aQU0wwCoo/d7R9zv2SAoY5fOp+/aYPRDRFVSCYiKSljsl45U X-Received: by 2002:a05:620a:24d6:b0:7a1:c40d:5edb with SMTP id af79cd13be357-7a1d44fe538mr133271485a.35.1721858839714; Wed, 24 Jul 2024 15:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721858839; cv=none; d=google.com; s=arc-20160816; b=W+XthUDI7zWqOfy6rCYaUcuy2SpZ8UBOEiMBmu2fNOVrk6k4FiDMtGyLnHpTVUZKFa aE+EOW3EX0wqnsfT4P9x6SjofW4x3HuEUX5hjUOEYzVXRVMaQSYLrL0RRW9IMtgmv/vI 2US5bg3oQ3/a853Ec0XIrTSrvA3gyJVNZM0esPiOQ3slpKPR7Mr/HRkEl728qLW1y1nI WoPuxks4Rls+ONbhA0MyLahv03iD+Sg4HjnXcpV466JvCDayGUKSROnmIqHQRv+os3EJ 5PtJ3KiZlZbFIbST1m0kePtIrO8ogOBNgsB+hdDbFO+iCXHNn5BWfzvE28U3vpp86/xN BUMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6l2giQ2DgrY0GVfdS/Z1DlHyLIcTuXalMYf+UrzR91E=; fh=Ts1ll9/N/PmOv7OJLIuEoHDgg5DK5GvwaAxGiE7bQaE=; b=aazichMquIxTJaT3EhbpQnlwSERaDvnpyr6CNEZ7oO74Z2nCZL9sm26ie4rzHDd/ht Vu+nWTGdmjEAk4hnSqLFGaOP9qacIa+J6s6HkvEY4WqAA1T0hiHANMMqnJLPybJaKBiB WTCjUdUQr13gNb7Hw38OWRISLS5KTgeiN1AJLx2s4xkb6LzN4sBXefvTHV8eyQzAl06l vgg8s/ww0Ma436csCMoH5CF1H4RRCh1RDojFNpXmwxG1yWoGdP6ZRe4YgucR4IMiHcMn euAmEOPot3V/h7Z57r6Wc6VPin4OQnNnWnO+mxoYrHw0gfigJmoaH52PUy2FbuGgrQua UXlw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bsdimp-com.20230601.gappssmtp.com header.s=20230601 header.b=nQjP9orQ; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a1d739b743si18785185a.141.2024.07.24.15.07.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jul 2024 15:07:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@bsdimp-com.20230601.gappssmtp.com header.s=20230601 header.b=nQjP9orQ; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWk7z-0000QZ-Hh; Wed, 24 Jul 2024 18:06:32 -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 1sWk7v-0000Gy-KW for qemu-devel@nongnu.org; Wed, 24 Jul 2024 18:06:27 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWk7s-0006XJ-GH for qemu-devel@nongnu.org; Wed, 24 Jul 2024 18:06:27 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7fe8d029fbeso13825339f.3 for ; Wed, 24 Jul 2024 15:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1721858782; x=1722463582; 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=6l2giQ2DgrY0GVfdS/Z1DlHyLIcTuXalMYf+UrzR91E=; b=nQjP9orQDkXDCkAcCyRhkMCucwO+Zf49vf2d5bmVyyi/Lj86D8xH2AzrWb4rwpshaT oZA8uKepPeIy+LxSnMvCLCetIGz1bppjs+rTdCiAdGzP2BPPJpUSVDxFl9DRE911+tew /9yGmvlp5hBWwIBrpOM9011byLgwQtfihg2QZNr98siU5XE+uRePhNT9PwUlEtnNBn8C XB9Txhmh3YD8+l3vcHIpi6lsR5sM09mZXuhoMkpaQrd7F2rzmWiIWxe3+EzwhCoYkMac qltaZ5+CgVxIaiSPzRsIUaEa8Gs6mVeaaby4wPPinUUDSIBGX/c3q4yn80G4F9jxeGIQ IKyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721858782; x=1722463582; 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=6l2giQ2DgrY0GVfdS/Z1DlHyLIcTuXalMYf+UrzR91E=; b=eLZtbbgmUlJtQIkjauT28ZPYXT3Gg+0lGN0eu2bT3TrknPyFSQotSqysOoGWGyelTJ DhfRjT1/Czat2t62sTK+ReAbLKJLKA1N1RV51Fv1FOJuAESjwFVPxvlILbu6XirmjCLY fzvWxBJ388HIwBq9cKM3rnTV6Biae3POQPa8nzNFyzwJYJbC4kF2nphQh7TYGmUJ2blR tziEzSt0JAtv2iaFmY5WtbF2RAROE+I2MfiYBPcqvVrnKcj63DgbIOXvLOk8bCZp5wn7 J32SauabQwIb4CYE2FQmoXNqBkyfCCzzqIXRU+hzdyEPJzfMCBrZD/oGYM62DdBHqxMf UTEg== X-Gm-Message-State: AOJu0YywjPX/TPHsqSCphZCYpgbdCjISaaAss4oQ3PDPQl4YoaeLZAcL awnL0KtmsH+x40obOFPGwHrjDfkywMuQ7iDb9s60GNE/ei/B95uB1d+czcr224hTWPrzX5K63V4 zKmI= X-Received: by 2002:a05:6602:1695:b0:7fa:56f0:ad87 with SMTP id ca18e2360f4ac-81f7e430a4bmr16774839f.10.1721858782394; Wed, 24 Jul 2024 15:06:22 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c29fa983f8sm10086173.47.2024.07.24.15.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 15:06:21 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Kyle Evans , qemu-arm@nongnu.org, Peter Maydell , Warner Losh , Stacey Son , Ajeet Singh , Kyle Evans , Richard Henderson Subject: [PULL 05/15] bsd-user:Add get_mcontext function for ARM AArch64 Date: Wed, 24 Jul 2024 16:04:38 -0600 Message-ID: <20240724220449.10398-6-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240724220449.10398-1-imp@bsdimp.com> References: <20240724220449.10398-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable 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+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: WkeBoASthpcS From: Stacey Son function to retrieve machine context,it populates the provided target_mcontext_t structure with information from the CPUARMState registers. Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Co-authored-by: Kyle Evans Reviewed-by: Richard Henderson Message-Id: <20240707191128.10509-6-itachis@FreeBSD.org> Signed-off-by: Warner Losh --- bsd-user/aarch64/signal.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bsd-user/aarch64/signal.c b/bsd-user/aarch64/signal.c index 98861f9ab3b..ab3bf8558ab 100644 --- a/bsd-user/aarch64/signal.c +++ b/bsd-user/aarch64/signal.c @@ -51,3 +51,33 @@ abi_long set_sigtramp_args(CPUARMState *regs, int sig, return 0; } + +/* + * Compare to get_mcontext() in arm64/arm64/machdep.c + * Assumes that the memory is locked if mcp points to user memory. + */ +abi_long get_mcontext(CPUARMState *regs, target_mcontext_t *mcp, int flags) +{ + int err = 0, i; + uint64_t *gr = mcp->mc_gpregs.gp_x; + + mcp->mc_gpregs.gp_spsr = pstate_read(regs); + if (flags & TARGET_MC_GET_CLEAR_RET) { + gr[0] = 0UL; + mcp->mc_gpregs.gp_spsr &= ~CPSR_C; + } else { + gr[0] = tswap64(regs->xregs[0]); + } + + for (i = 1; i < 30; i++) { + gr[i] = tswap64(regs->xregs[i]); + } + + mcp->mc_gpregs.gp_sp = tswap64(regs->xregs[TARGET_REG_SP]); + mcp->mc_gpregs.gp_lr = tswap64(regs->xregs[TARGET_REG_LR]); + mcp->mc_gpregs.gp_elr = tswap64(regs->pc); + + /* XXX FP? */ + + return err; +} -- 2.45.1