From patchwork Mon Jun 17 18:57:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0D820C27C79 for ; Mon, 17 Jun 2024 18:59:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYh-0003yI-N3; Mon, 17 Jun 2024 14:58:27 -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 1sJHYg-0003y4-B9 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:26 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYe-0004vt-J8 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:26 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-705e9e193caso1749147b3a.2 for ; Mon, 17 Jun 2024 11:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650703; x=1719255503; 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=/RYBeS7YMWG5zCOUP6t7XOOwmqZaXoAkyXHOLEzgJdI=; b=bV5RjFcq7BBUkxSZ1ezRBHzcKCsRjQfW8Q0GV4OtZCAcFYaU7eGMCkT4+wWNjhBaZ3 U22x4XD0vDrlWD1JOvQRFkw2pLg8HXuXhhA/javLI+MPwklZELTqeIYJbWjTKFL3mjoG 4gzxzBVDiWvOIfakKMguRAUQGZoqC1E+hk1Oa9UhMYwTK2T7EVEfAQRE28vB8WRY3Yrs 0+h4mvGLhmnUIsjrM+9llpbX+EBylIDxRxhyIFqbiCjNzkxjQlHxhBpPRJ3rYYhKSHo3 ZJTrz5MN9+Sa81Vw/fgzDCl0m1AUnmkncONxNbNedkOIem5wsTtc62Z4yHalvsj8Z1QJ aO2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650703; x=1719255503; 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=/RYBeS7YMWG5zCOUP6t7XOOwmqZaXoAkyXHOLEzgJdI=; b=JTlZ+DDftKBBbLLXRvrJEYInVzu4BD+5PRtvbPA7AUbnAnrEe6hljw7Ownl8CtLX3J MA59IlPo87ScTQg9uZYg+PDlHYh/yhIPQnupnMUjkjb1jqOfoaMMZoSr+/tFwkHnGfNO i0UgWy4nwO/P5gyAD9mitYwokB0FTgx+kFR9zoywDaL2Ar4AEmoUjdazNz6/H4Pugo2e RHrnyoJTUzLExPMJWEgQ6Tl/Pi2cjYflXHgo8PzMaD6wRBjenZ4qMmyQIImeAYXUTvys 2sKP29Ieis+ey3apzh+rao4R00jx8Ar5EoRFvSzhKBINL1EvuBAS9AUoJGKRTXhXoSBn vRtg== X-Gm-Message-State: AOJu0Ywv+a7M9Lw/sVt1/gbelfkJAgNg4MuMnTGhNYzB0PkP3EClit5z be5vhZqHi5H7RTr1dGaH+6iINQvxMyfxdta2WYOPbFkgBvMaDEFRVagQ2VzHufE= X-Google-Smtp-Source: AGHT+IF5LB5NTjbLsChGJTJVAn6dQkh1KOyI3qYI/CPKzkhkA4UbiluEtO7/wRCxmPq7juRzYBf1rw== X-Received: by 2002:a05:6a00:cc:b0:705:9cf6:bc21 with SMTP id d2e1a72fcca58-705d70f7276mr9973918b3a.12.1718650702418; Mon, 17 Jun 2024 11:58:22 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:22 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 01/23] Add CPU initialization function Date: Tue, 18 Jun 2024 00:27:42 +0530 Message-Id: <20240617185804.25075-2-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42d.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Addded function to initialize ARM CPU and to check if it supports 64 bit mode Signed-off-by: Ajeet Singh Signed-off-by: Stacey Son Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/aarch64/target_arch_cpu.h | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_cpu.h diff --git a/bsd-user/aarch64/target_arch_cpu.h b/bsd-user/aarch64/target_arch_cpu.h new file mode 100644 index 0000000000..db5c7062b9 --- /dev/null +++ b/bsd-user/aarch64/target_arch_cpu.h @@ -0,0 +1,42 @@ +/* + * ARM AArch64 cpu init and loop + * + * Copyright (c) 2015 Stacey Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_CPU_H +#define TARGET_ARCH_CPU_H + +#include "target_arch.h" +#include "target/arm/syndrome.h" + +#define TARGET_DEFAULT_CPU_MODEL "any" + +static inline void target_cpu_init(CPUARMState *env, + struct target_pt_regs *regs) +{ + int i; + + if (!(arm_feature(env, ARM_FEATURE_AARCH64))) { + fprintf(stderr, "The selected ARM CPU does not support 64 bit mode\n"); + exit(1); + } + for (i = 0; i < 31; i++) { + env->xregs[i] = regs->regs[i]; + } + env->pc = regs->pc; + env->xregs[31] = regs->sp; +} From patchwork Mon Jun 17 18:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5BB7DC27C79 for ; Mon, 17 Jun 2024 19:01:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYk-00044W-0H; Mon, 17 Jun 2024 14:58:30 -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 1sJHYj-00042K-2d for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:29 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYh-0004wP-8M for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:28 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-704189f1225so4131483b3a.0 for ; Mon, 17 Jun 2024 11:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650705; x=1719255505; 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=cXJTs0J9+UWD2AkXsLlcdFj04Dwj/u1B6kCGoJ8H+e8=; b=D5zkQnmuYOaXmsFgffK3pY2E7kvLCYl6bdTjhztEPNfY7ci3jfpHMqpcR2GGHFblUi 3E3bito/vmQ99yc4Rshpj/3TzOVPbDpy5cFpVgv35ABRgSVmkCsHQ3SXXJyAEfABtUS4 KNuBgRc9Th3cg+c+pLSQKVbTYXgw+xBbac/Df6vvulX8Sf3gI/YGtlNwYHmuOpCgj83H oUdW/27c3GcvR5z8Ks8hXCYWtVhyPPE2eYtFYgGUAkgeXv5Z/xFeeSsupxwQe3D3gsvW olFXdRuNJFOad/1XW5uJZRCndrxOXFZpd9NGM/ha59AdTwBu4vnBlj9Yw4oANrT+J+wH ZgSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650705; x=1719255505; 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=cXJTs0J9+UWD2AkXsLlcdFj04Dwj/u1B6kCGoJ8H+e8=; b=ZB8G1SaMVwTKJtRX8ae+6ykA2c2Kp3qhIzC8IF3K4JkbKCsGf5+l63nLMjIboY9a2Z GkE/uuhUqPBtSnbFYGXzfjtld2xFb67ve2DUZvytUaxzxVeRw/g9m0NPSr75kEpicOHL ZHdBo0oxKd7kOxhkK3W8GtII5+I8abCyL/rrng24PR96EEFVm/DiPg5ZXSXDVqM5Klrc 6GFtvZjB//5xR30RqX9C/ZjJKyWrZD6KmL5PAjdSQ5Sofbui37vGBMCRmpwU5SHMbGnK J/heFHaQGYILGRbd/6bBPC0UerovEAybYV/qA/QmOM7VNqyIHnla7ilokbGP/gMZmH0U B6lg== X-Gm-Message-State: AOJu0Yx2wG3uRr/gGufx19THYh9jYxYJHn3hOU23tqJ7YGzgn7XCSuK7 o4gPHoXiwsRh33wy7qI7YiU2/WtROXL/TblydyRuczOIM2VEp1Aa9swCdhAk4Gc= X-Google-Smtp-Source: AGHT+IF9YCPk869H7ThvJc0nHDnSauwHqFWHmlzQDT8wBpY6zC6pDQldExWTVNIpbwmLdyTx/1mzHA== X-Received: by 2002:aa7:8e92:0:b0:705:a450:a9a9 with SMTP id d2e1a72fcca58-705d70e3e1emr10489681b3a.1.1718650705172; Mon, 17 Jun 2024 11:58:25 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:24 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Kyle Evans , Sean Bruno , Jessica Clarke Subject: [PATCH 02/23] Added CPU loop function Date: Tue, 18 Jun 2024 00:27:43 +0530 Message-Id: <20240617185804.25075-3-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son CPU loop function to handle exceptions and emulate execution of instructions Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Co-authored-by: Kyle Evans Co-authored-by: Sean Bruno Co-authored-by: Jessica Clarke --- bsd-user/aarch64/target_arch_cpu.h | 132 +++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/bsd-user/aarch64/target_arch_cpu.h b/bsd-user/aarch64/target_arch_cpu.h index db5c7062b9..1962d2c99b 100644 --- a/bsd-user/aarch64/target_arch_cpu.h +++ b/bsd-user/aarch64/target_arch_cpu.h @@ -40,3 +40,135 @@ static inline void target_cpu_init(CPUARMState *env, env->pc = regs->pc; env->xregs[31] = regs->sp; } + + +static inline void target_cpu_loop(CPUARMState *env) +{ + CPUState *cs = env_cpu(env); + int trapnr, ec, fsc, si_code, si_signo; + uint64_t code, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; + uint32_t pstate; + abi_long ret; + + for (;;) { + cpu_exec_start(cs); + trapnr = cpu_exec(cs); + cpu_exec_end(cs); + process_queued_cpu_work(cs); + + switch (trapnr) { + case EXCP_SWI: + /* See arm64/arm64/trap.c cpu_fetch_syscall_args() */ + code = env->xregs[8]; + if (code == TARGET_FREEBSD_NR_syscall || + code == TARGET_FREEBSD_NR___syscall) { + code = env->xregs[0]; + arg1 = env->xregs[1]; + arg2 = env->xregs[2]; + arg3 = env->xregs[3]; + arg4 = env->xregs[4]; + arg5 = env->xregs[5]; + arg6 = env->xregs[6]; + arg7 = env->xregs[7]; + arg8 = 0; + } else { + arg1 = env->xregs[0]; + arg2 = env->xregs[1]; + arg3 = env->xregs[2]; + arg4 = env->xregs[3]; + arg5 = env->xregs[4]; + arg6 = env->xregs[5]; + arg7 = env->xregs[6]; + arg8 = env->xregs[7]; + } + ret = do_freebsd_syscall(env, code, arg1, arg2, arg3, + arg4, arg5, arg6, arg7, arg8); + /* + * The carry bit is cleared for no error; set for error. + * See arm64/arm64/vm_machdep.c cpu_set_syscall_retval() + */ + pstate = pstate_read(env); + if (ret >= 0) { + pstate &= ~PSTATE_C; + env->xregs[0] = ret; + } else if (ret == -TARGET_ERESTART) { + env->pc -= 4; + break; + } else if (ret != -TARGET_EJUSTRETURN) { + pstate |= PSTATE_C; + env->xregs[0] = -ret; + } + pstate_write(env, pstate); + break; + + case EXCP_INTERRUPT: + /* Just indicate that signals should be handle ASAP. */ + break; + + case EXCP_UDEF: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->pc); + break; + + + case EXCP_PREFETCH_ABORT: + case EXCP_DATA_ABORT: + /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ + ec = syn_get_ec(env->exception.syndrome); + assert(ec == EC_DATAABORT || ec == EC_INSNABORT); + + /* Both EC have the same format for FSC, or close enough. */ + fsc = extract32(env->exception.syndrome, 0, 6); + switch (fsc) { + case 0x04 ... 0x07: /* Translation fault, level {0-3} */ + si_signo = TARGET_SIGSEGV; + si_code = TARGET_SEGV_MAPERR; + break; + case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ + case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ + si_signo = TARGET_SIGSEGV; + si_code = TARGET_SEGV_ACCERR; + break; + case 0x11: /* Synchronous Tag Check Fault */ + si_signo = TARGET_SIGSEGV; + si_code = /* TARGET_SEGV_MTESERR; */ TARGET_SEGV_ACCERR; + break; + case 0x21: /* Alignment fault */ + si_signo = TARGET_SIGBUS; + si_code = TARGET_BUS_ADRALN; + break; + default: + g_assert_not_reached(); + } + force_sig_fault(si_signo, si_code, env->exception.vaddress); + break; + + case EXCP_DEBUG: + case EXCP_BKPT: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); + break; + + case EXCP_ATOMIC: + cpu_exec_step_atomic(cs); + break; + + case EXCP_YIELD: + /* nothing to do here for user-mode, just resume guest code */ + break; + default: + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", + trapnr); + cpu_dump_state(cs, stderr, 0); + abort(); + } /* switch() */ + process_pending_signals(env); + /* + * Exception return on AArch64 always clears the exclusive + * monitor, so any return to running guest code implies this. + * A strex (successful or otherwise) also clears the monitor, so + * we don't need to specialcase EXCP_STREX. + */ + env->exclusive_addr = -1; + } /* for (;;) */ +} + +#endif /* TARGET_ARCH_CPU_H */ From patchwork Mon Jun 17 18:57:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 60B19C27C79 for ; Mon, 17 Jun 2024 19:02:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYm-00049T-NW; Mon, 17 Jun 2024 14:58: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 1sJHYk-00044p-Jy for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:30 -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 1sJHYj-0004wY-3A for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:30 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-705c739b878so3731708b3a.1 for ; Mon, 17 Jun 2024 11:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650707; x=1719255507; 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=kmiGU0XGOgkNkeKrlW4wG8IDU2PioKKg7Y5d+i/ULYE=; b=jTxHPqyQQkEFVako2s8NLJbsDmO0eX6kJgKcKVJ7WR40DguifIJ1aFPQ0Fbqh514Xz Q1exrHYZWb0ZOgs8XGFRG5dpz4bWXpiVfvh7RH81A6SwpV1x4LzMLL/17TApRq6zXKzz 9sEAKNbRrNjXmVhIn1D2A3MUksmqTd5Nh7ndzUu9VwMw/K8gVWj47yqKd/KjNy+bbJoJ g2STylLymFR9iddLtB50jEIKWXqIz+Y4YeE01m/0FN+welvkG+2cmiYo33kIiAhyWpZH AXJCiXBLvdCpeaD//4Qxw4frODyVwAu9bQ/YsjkRnbNyZ2tue7Y8Boj2J7VQHh5nTKEf 7gXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650707; x=1719255507; 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=kmiGU0XGOgkNkeKrlW4wG8IDU2PioKKg7Y5d+i/ULYE=; b=nA/572UE2sFb5lkdZxqFV1TVYtcVW9G+7nV/FrLiGN1Qo/MTvoOBUXqXKwJAHZVc9K XPcTwGMrHULte/i4Y9wwga5nF+7ignJ7ToOw9rA2HVh7LxFU7TiIjs+bhp2J4MZOHOsG Pvi+FA8Ddod/EI985/vg4Ki1Ttwv5cK/grZ+Fb+9rZDWdQNgW4R3EHCo0rcW+nRBqrPg nk7i1cFWiLV+ZhsSQXUWYHdGnncs2V63x1AYmezPB5bU+y8MMpSZ4DMd8y+u4SZq+Ixh poG/UMMee8HaVptrz63AGA3Owv0q98iMKZAM/ddzrfNJoHi/XGMYUp9VABQVjZ7EPR0f OHCw== X-Gm-Message-State: AOJu0YxKKhmiHbdJSancrzoU9Insv027DNYbWub64JWWr1v4nCwPKBFK D5y0l2e+7lE3FpTeWCMGOL7lW1AWqH2bWsOyRLmYc73WFGTNv+qqAlnsFfqbU1I= X-Google-Smtp-Source: AGHT+IFK2TgqUuHnvf3PHdJbDqbq54NEpzQq5HOcHRcDHcrV1+l1KI4ggxTOxN8svyLso7qjSTt+9A== X-Received: by 2002:a05:6a20:a924:b0:1ba:ee32:e7f0 with SMTP id adf61e73a8af0-1bcaafaf6dfmr694283637.4.1718650707243; Mon, 17 Jun 2024 11:58:27 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:26 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 03/23] Added function to clone CPU state Date: Tue, 18 Jun 2024 00:27:44 +0530 Message-Id: <20240617185804.25075-4-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Function can copy cpu state to create new thread Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_cpu.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bsd-user/aarch64/target_arch_cpu.h b/bsd-user/aarch64/target_arch_cpu.h index 1962d2c99b..4e950305d3 100644 --- a/bsd-user/aarch64/target_arch_cpu.h +++ b/bsd-user/aarch64/target_arch_cpu.h @@ -171,4 +171,21 @@ static inline void target_cpu_loop(CPUARMState *env) } /* for (;;) */ } + +/* See arm64/arm64/vm_machdep.c cpu_fork() */ +static inline void target_cpu_clone_regs(CPUARMState *env, target_ulong newsp) +{ + if (newsp) { + env->xregs[31] = newsp; + } + env->regs[0] = 0; + env->regs[1] = 0; + pstate_write(env, 0); +} + +static inline void target_cpu_reset(CPUArchState *env) +{ +} + + #endif /* TARGET_ARCH_CPU_H */ From patchwork Mon Jun 17 18:57:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 83B4EC2BA1A for ; Mon, 17 Jun 2024 18:59:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYp-0004NL-FE; Mon, 17 Jun 2024 14:58:35 -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 1sJHYn-0004BA-0a for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:33 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYl-0004wq-6Z for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:32 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-705e9e193caso1749191b3a.2 for ; Mon, 17 Jun 2024 11:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650709; x=1719255509; 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=dwK71C7tTjhNtrxFdTarX2bhgrmlVdQhmyIGbCJ+smo=; b=A8p3KcKiivlXvSuMdCceRgr/OiUbb/rKjx0CYD4zLmlOtMnwhBQtPbSRCGHZkgReXo MIVXbLMkP1mD+WKZ8D0Nol02nUWHORUizYhtxd/WxpyaIFhXPu9zmIBxnHoimGT+1Jn9 LqJapfBMZCCSMeK/KhIkl44Ho9egd4xhIFNwlOYFw2LnwaXXsZ4PXU9qaxbHouwkapNG bBGbJlKnQOmc2re/EhSwp2j1MLjViuPvVqRHPH436teQ1Za3Z5HaM3Aw+k0LLPHmS23/ fuKinW16K02vJZMq5gVncDZ192Ue6EFriLUze+eh+xopTrXfNP9/L6x1DAp73TLJLyD6 EUlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650709; x=1719255509; 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=dwK71C7tTjhNtrxFdTarX2bhgrmlVdQhmyIGbCJ+smo=; b=Gn1ExcUaDa9nyLDf5L3ykwwPzb/0GASO1dCySUWKZUrqUD53sKN4uWt0yx27rVl0FX GcelUenhF/KgD33dx1utLOPrN89YHQUzre5ElSE0WjVoVRhVN62GdFunO5i330QKpM/w PB+KoPSQFi2NhmyuxY5/0X6dtDse8GkPqKuNoa4JNnnxRw6K5F7aTfGpA+H/Idbkeedw Fja5TqRT5wPMJKmE9I4Ud+bIIs1wZ0xJ/y3it9KJbTCoEXqP/XAzvKxfcPhUE6AqzXzI Evy9TWKaobFelPEFxAeqqDICVGJ4BX776BarWm7qGFXR4d4jG0nkukQd36K1eoqmUtLy u8KQ== X-Gm-Message-State: AOJu0YxUQvPYtMkZbwKS0+OwqlLnAxjgRIfy74x85v6F2KVy7XJI+BDi udft30ujMLxVfZ08RPA4XsuyCKowFAacHx/OU/SB0mpBxaYq/qm9Ctw5zs0GeyU= X-Google-Smtp-Source: AGHT+IFqgN6h2P/8K0byogXjl41jdzz+l0KsyXEjxQI9vH7AUIwNfcdLQUoHOhAtN3EkOIJFXsHPpg== X-Received: by 2002:a05:6a00:178e:b0:705:b0c0:d7d7 with SMTP id d2e1a72fcca58-705d70e3f01mr15639141b3a.7.1718650709331; Mon, 17 Jun 2024 11:58:29 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:29 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 04/23] AArch64 specific CPU for bsd-user Date: Tue, 18 Jun 2024 00:27:45 +0530 Message-Id: <20240617185804.25075-5-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x430.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Function to set and recieve thread-local-storage value from tpidr_el0 register Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_cpu.c | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_cpu.c diff --git a/bsd-user/aarch64/target_arch_cpu.c b/bsd-user/aarch64/target_arch_cpu.c new file mode 100644 index 0000000000..70ef651827 --- /dev/null +++ b/bsd-user/aarch64/target_arch_cpu.c @@ -0,0 +1,34 @@ +/* + * ARM AArch64 specific CPU for bsd-user + * + * Copyright (c) 2015 Stacey Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#include "qemu/osdep.h" + +#include "target_arch.h" + +/* See cpu_set_user_tls() in arm64/arm64/vm_machdep.c */ +void target_cpu_set_tls(CPUARMState *env, target_ulong newtls) +{ + + env->cp15.tpidr_el[0] = newtls; +} + +target_ulong target_cpu_get_tls(CPUARMState *env) +{ + + return env->cp15.tpidr_el[0]; +} From patchwork Mon Jun 17 18:57:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 93C50C27C79 for ; Mon, 17 Jun 2024 18:59:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYx-0004Xe-Ca; Mon, 17 Jun 2024 14:58:43 -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 1sJHYq-0004O6-2x for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:36 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYn-0004xQ-Fc for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:35 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-705c739b878so3731769b3a.1 for ; Mon, 17 Jun 2024 11:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650712; x=1719255512; 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=wZAkE2x+3rn50ou2R0RV1RQgcl9m9dXIeubdRtD95RA=; b=D2VvmA/HxodUXhiR52QsmwJHMoU4RI1ql9lkLKZQys1O1bq7Sijt70VmWjCmVb24ED RlFHra5jIwvNtEkvDAUDLHs31p5DG3pDRvl+GOCjf464uFoad62cUcrug6z9ruEZiEW3 tYvR3AyJqC3uu3Be2UI3Y73N30UXmO8gys7uYRmBYMmo0uBz7lHdyzjGG3X1B4WdB7ps 5SS6fPk5Rqi7qgSNYqABk4YRDmNgpVENTVjk8gf0mdodXzhyW9QTPeI6+LU2564xnkeB h5Tl6FIzV/Z2ABGkgYD0gMNI/A2T2VYMiltL2F7yoa5oyAgohDxsfS5SM4c3jrn+ZWUk 9CAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650712; x=1719255512; 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=wZAkE2x+3rn50ou2R0RV1RQgcl9m9dXIeubdRtD95RA=; b=kJgK3pwUiJGc1RYizGFwzxW/v6oQ7SqCnI0Shgt9JGI3wx76aJMTQu6gTOHVi9wbz1 FXVQdqikjErre/UfHSOQxgkhGwbeVC4SCg3fHYPJo2RNojzx1hNPCZ2bZFEK1uBV6xNI WD6VUfwRESXmfXKcAak65oA52eTcJ1Qc2YE7VjXCpUdRawNPEU4T/UvgzFGPMra/57qE 2SrHMIrTwTUiV3fwHBljBHrae1tdr7QsKwS7+TLrqdeT549ejl+Gk2LN01gMIcoBt6Lo yNkaeSCCBUlpFhKwUA43SA5AIAbfv+F5YUGlm6WNk/BxvITFy8WxeE7lepcXvA07HU1/ MnyQ== X-Gm-Message-State: AOJu0YwJM6oPh6BcOq0YhcKFncFZ6fbTPD59ue/Kq5qnHX6ZAn0y9WYQ M9bSvbFc1TjFKtqj+SHV/O/iUORQwpGuwLSXRzE71WbWr9QIsr3jx8gv+BuqKr0= X-Google-Smtp-Source: AGHT+IHRbFlCvKBEpVFR2cz9r34zw2KyjxSwv+TKD93wEBRq+yIk2O0b4TwQXgKzQAag03a9z2GYnw== X-Received: by 2002:a05:6a20:aa82:b0:1b7:bdb3:7bb6 with SMTP id adf61e73a8af0-1bcaadd3da5mr741610637.0.1718650711553; Mon, 17 Jun 2024 11:58:31 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:31 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Sean Bruno Subject: [PATCH 05/23] Managing CPU register for BSD-USER Date: Tue, 18 Jun 2024 00:27:46 +0530 Message-Id: <20240617185804.25075-6-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Added structure for storing register states Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Co-authored-by: Sean Bruno Acked-by: Richard Henderson --- bsd-user/aarch64/target_syscall.h | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bsd-user/aarch64/target_syscall.h diff --git a/bsd-user/aarch64/target_syscall.h b/bsd-user/aarch64/target_syscall.h new file mode 100644 index 0000000000..08ae913c42 --- /dev/null +++ b/bsd-user/aarch64/target_syscall.h @@ -0,0 +1,51 @@ +/* + * ARM AArch64 specific CPU for bsd-user + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef BSD_USER_AARCH64_TARGET_SYSCALL_H +#define BSD_USER_AARCH64_TARGET_SYSCALL_H + +/* + * The aarch64 registers are named: + * + * x0 through x30 - for 64-bit-wide access (same registers) + * Register '31' is one of two registers depending on the instruction context: + * For instructions dealing with the stack, it is the stack pointer, named rsp + * For all other instructions, it is a "zero" register, which returns 0 when + * read and discards data when written - named rzr (xzr, wzr) + * + * Usage during syscall/function call: + * r0-r7 are used for arguments and return values + * For syscalls, the syscall number is in r8 + * r9-r15 are for temporary values (may get trampled) + * r16-r18 are used for intra-procedure-call and platform values (avoid) + * The called routine is expected to preserve r19-r28 + * r29 and r30 are used as the frame register and link register (avoid) + * See the ARM Procedure Call Reference for details. + */ +struct target_pt_regs { + uint64_t regs[31]; + uint64_t sp; + uint64_t pc; + uint64_t pstate; +}; + +#define TARGET_HW_MACHINE "arm64" +#define TARGET_HW_MACHINE_ARCH "aarch64" + +#endif /* BSD_USER_AARCH64_TARGET_SYSCALL_H */ From patchwork Mon Jun 17 18:57:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1198EC27C79 for ; Mon, 17 Jun 2024 18:58:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZ1-0004hm-U4; Mon, 17 Jun 2024 14:58:49 -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 1sJHYr-0004P2-8k for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:37 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYp-0004y8-DW for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:36 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-705b9a89e08so4054919b3a.1 for ; Mon, 17 Jun 2024 11:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650714; x=1719255514; 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=dzc68h1Ua4UnQlWlrtm3BT2YNpP7DWO6KFC5L451s7M=; b=PnZiXsaa/+IHj+XfhJRuqgmIec7M7y2ZdLeITcRM2gmHvfHY/Dx6Bp6Wxjl+IKVaR6 EQTPNA/l18p+eUNItLDXlAOFNjHB7PN00KfwBZapQo0jyl1wW4wbJE66B7riGUaKR6cG lF2+duerN6/3QJt8uo2S/15qriOhd+SPXb+8XO/GYOGvRc+Fkd2Mio9Is+/Zm8M6MOz1 z6M0M4x3qDzhsVWujxkPxc8YseG83X9CcnTbUth74P/tI69WrtIQO3SmTKq9FvTb3Rzd 0dDioxVH9/WbbgA4Q89KkNT5S151Aep5rfvNs2kWaoYRbCdn/cUieX3xF8lozaF8+Ql2 YcrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650714; x=1719255514; 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=dzc68h1Ua4UnQlWlrtm3BT2YNpP7DWO6KFC5L451s7M=; b=u2NGdPSYfJqRQwh8HlZaAMxKnGgCeVTlbWLU4OimrgBCKRbDYr4ZYvhKoxEGl4fXwD oGZsK2Dt4i/9TCufJ6M/r4AzqBVHuHR25b5AMwfwSNx9Uk5HhdTPcJ8BGhBlqj/MDQY4 5jhz1VLZl+yDXpBKysrN9kDKiW9zPVgf4b/cKYwy+SnrLk+Qwqm2tqIBRIdY0SjFkNky BvC+NkSjWXYiyOdQpPo9/VFvX8Nfz0gD98hy/h07KaxtaNJiUzXBP1lWyK9lSZ5u4I5U 06/UhT7yaxAB/TNWuV5YxXQ6YcEkTolnj2CT92QiJ4b5qPGbXQ/f13URzEm0nXkYgJjX iqCw== X-Gm-Message-State: AOJu0YyMJX4K1DObhk2Sql8YZkq8xLypwx6CyEWg+WZ0YSCiLgwD8UVj lBGgK3MGoB15GSXOvCrfI+qoC2WWA7aH5laM2JGY4QrMnR5tZN26sD+KtNJfcSc= X-Google-Smtp-Source: AGHT+IEm89zSSI9qpDrXwyBv1Iz+uCiI0Hu/9U2j9Lihg9g4w0hn8lPi/9e5C8qTwtApRtsaWODDeQ== X-Received: by 2002:a05:6a00:38cc:b0:705:f5c0:8ba2 with SMTP id d2e1a72fcca58-705f5c08bf9mr5667571b3a.2.1718650713675; Mon, 17 Jun 2024 11:58:33 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:33 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 06/23] Add Aarch64 register handling Date: Tue, 18 Jun 2024 00:27:47 +0530 Message-Id: <20240617185804.25075-7-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Header file for managing CPU register states in FreeBSD user mode Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh --- bsd-user/aarch64/target_arch_reg.h | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_reg.h diff --git a/bsd-user/aarch64/target_arch_reg.h b/bsd-user/aarch64/target_arch_reg.h new file mode 100644 index 0000000000..5c7154f0c1 --- /dev/null +++ b/bsd-user/aarch64/target_arch_reg.h @@ -0,0 +1,56 @@ +/* + * FreeBSD arm64 register structures + * + * Copyright (c) 2015 Stacey Son + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef TARGET_ARCH_REG_H +#define TARGET_ARCH_REG_H + +/* See sys/arm64/include/reg.h */ +typedef struct target_reg { + uint64_t x[30]; + uint64_t lr; + uint64_t sp; + uint64_t elr; + uint64_t spsr; +} target_reg_t; + +typedef struct target_fpreg { + __uint128_t fp_q[32]; + uint32_t fp_sr; + uint32_t fp_cr; +} target_fpreg_t; + +#define tswapreg(ptr) tswapal(ptr) + +static inline void target_copy_regs(target_reg_t *regs, CPUARMState *env) +{ + int i; + + for (i = 0; i < 30; i++) { + regs->x[i] = tswapreg(env->xregs[i]); + } + regs->lr = tswapreg(env->xregs[30]); + regs->sp = tswapreg(env->xregs[31]); + regs->elr = tswapreg(env->pc); + regs->spsr = tswapreg(pstate_read(env)); +} + +#undef tswapreg + +#endif /* TARGET_ARCH_REG_H */ From patchwork Mon Jun 17 18:57:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 887F3C2BA1A for ; Mon, 17 Jun 2024 19:02:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZ3-0004jv-R5; Mon, 17 Jun 2024 14:58:51 -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 1sJHYt-0004RN-1Q for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:39 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYr-0004yQ-B9 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:38 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-705b9a89e08so4054948b3a.1 for ; Mon, 17 Jun 2024 11:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650716; x=1719255516; 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=BKxS0/De0h1OuVT3aoFJuagPA3gXdMM1tQtaPW9ssyc=; b=DWl1C3y7+cJD2iq0nAY8eXr8cymqcRF06S3OxfL4Y8Muym2pCXbm4NGRZyvQVBIPvN rxR5fNhII6yqybwoFonpwko2J2jUgbDwPkY3ikO7POkg+bHEgdr/MsDH0rzw5v1YVTxW RnI6tJYPxfDDUz1g36s3/l3yzBOT34Ek/RVpCJ/5VRtoBTdSWYSFiLb7h0o12FmRbimy zejsmW9C/1D7UepvnvZeVs6qWcwS+szdPxSyf9S0Mshs9ZuJwataR5RY8XFtzk8TLNHW cW0sFjvpTd4MGxk8aY/rZTOyArxWYaswYhQRck9QX3R/+x1AOXuK3KMFiuPclm8/ie5C MC5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650716; x=1719255516; 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=BKxS0/De0h1OuVT3aoFJuagPA3gXdMM1tQtaPW9ssyc=; b=NtqbQF9K1i6CRtF7NnIQis2utIt+15VLsYGZv9gGfUwj7PmCQchailyAav/a2L761K aokIZlvb2aSm2oqt93DL7zuxriqZxIZ9gRVs+dU21ClivZ8pF8SVpFWik6A6FhN9GFuu yPtOBEerZMi2BHCq6M7hSVHbeZzdEj71Exq7CMU6MA7g5ja2ycPiGiehdYJVWJ+8oukS rSvksUR2PQRs8EOYvyA3YaiQ1yZ3IV0XhdwN+ev2pu75v6795thU3IJqvFKN5SpYI4ck LWTwy0O8bAuJ4SmoQfYHS3Rh1B2VYZvmqWnPT2t9ve56CCz12sSMSdc6LEq47lJtU/nM 7Bvw== X-Gm-Message-State: AOJu0YzbOSQ6JjngDIEcas/4d6YRyEpOut3IFpOe0P+e4COVRwYDTZCz DQ1xS6GrWZ5MVfrIE/Es/zn4gFhON9kt1XH9ii1Bcq0rmE/XScqfH29WmMOBs0M= X-Google-Smtp-Source: AGHT+IFXPx9+NnaJ12o3LRv0Xz/+IIYcKeMMRBkz8ZkjeebPlQdTK5wiL/yH2MRlsiT/OSRULEb2cw== X-Received: by 2002:aa7:91cc:0:b0:705:c310:60b0 with SMTP id d2e1a72fcca58-705d719331cmr10467354b3a.25.1718650715747; Mon, 17 Jun 2024 11:58:35 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:35 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 07/23] Add ARM AArch64 TLS Management Prototypes for BSD-User Date: Tue, 18 Jun 2024 00:27:48 +0530 Message-Id: <20240617185804.25075-8-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Prototypes for setting and getting TLS( thread local storage) Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Acked-by: Richard Henderson --- bsd-user/aarch64/target_arch.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bsd-user/aarch64/target_arch.h diff --git a/bsd-user/aarch64/target_arch.h b/bsd-user/aarch64/target_arch.h new file mode 100644 index 0000000000..27f47de8eb --- /dev/null +++ b/bsd-user/aarch64/target_arch.h @@ -0,0 +1,28 @@ +/* + * ARM AArch64 specific prototypes for bsd-user + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_H +#define TARGET_ARCH_H + +#include "qemu.h" + +void target_cpu_set_tls(CPUARMState *env, target_ulong newtls); +target_ulong target_cpu_get_tls(CPUARMState *env); + +#endif /* TARGET_ARCH_H */ From patchwork Mon Jun 17 18:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2E005C41513 for ; Mon, 17 Jun 2024 19:03:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZD-0005am-FG; Mon, 17 Jun 2024 14:58:59 -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 1sJHYv-0004aw-2U for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:43 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYt-0004zr-Bx for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:40 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-705c739b878so3731839b3a.1 for ; Mon, 17 Jun 2024 11:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650718; x=1719255518; 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=CFGck5ZAtQivWI4UcF8No9idstaPGejMMjqzgwxQWSo=; b=jU9HNdRQVM/6WGGdnaJ1H0gzeSgy5ixX9XhISONvogun2Y7s/0dmEcqkAMCl5taeq7 wCLdM643SUKeOS348ON9SnC3mHRALTWoVSkxzKK7+DAqxmrzJvmCD3U2gNtRPRpjY/15 LckdCMAkayXKpOphnKmxjEgEleFaa6/m9nWbOYXTB6DUYN9lOweMUOEU+4Q+vKrr/zm2 zFbp1VEhaUzLCuT8I2kTYpGGr5Rj202O7Eq3lJcs8CvGln4hsS9I/1mH4f0QlhIOSxsO 6+9OOpWm3ORFSnpb8czKpGbO88+MNncWURFc7sbhJLCT0xRn7Ar+1dsrMcaD42QSm+lZ rnUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650718; x=1719255518; 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=CFGck5ZAtQivWI4UcF8No9idstaPGejMMjqzgwxQWSo=; b=Fce38joghTlIAP2NzHLzsOrRIEH/QygunOzpcIf4jN9wGVLPIDX5oppLBYMkBuTbj4 n/FTeArrxWCJtoorR9mWCvxERp0yPGrW13oGpF+8dl1eYzekORei6KaJclpJtVgWPZES oyx18AiKmaAxhJDpdpreBnUrMKyuh5t9mPZuwevXJueUBmVDF7M39FjGoWuqeXSuX8jY RcEoaQsxF2ocfzeBIwn1PIK6nitssDGqUtuQf3CzdlFLAjXMKM7uFUuNJtKP0GkzNF6y 70gaFCCIDw606EmSOEQ4GF7rLOMxdc8XwiUC04D5CS6ORM7FC8/ee3X6hAD20/5uhnQT fpMg== X-Gm-Message-State: AOJu0YxEsxcu34JndOi9nnvUxH9TWIpVTt8lIwcvesmbY/WnFokN/Dqn VAkE0N3bxq9y+T/KOEvtu3WoOpi132Y83ZLN5ThHA9UELJZobNqYRE996kO1tqs= X-Google-Smtp-Source: AGHT+IHICLmSRbKJLVYswBzwTbT1DC+Xy3kjeUSZxPKppfHbgt4tqPbp5cGP22gTyTfyYP3rHZ8zMA== X-Received: by 2002:a05:6a20:dc90:b0:1b4:a478:2275 with SMTP id adf61e73a8af0-1bcab0a6537mr660857637.29.1718650717808; Mon, 17 Jun 2024 11:58:37 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:37 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 08/23] Add Aarch64 sysarch() system call emulation for BSD-USER Date: Tue, 18 Jun 2024 00:27:49 +0530 Message-Id: <20240617185804.25075-9-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Initial implementation of sysarch() syscall and a printing function Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_sysarch.h | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_sysarch.h diff --git a/bsd-user/aarch64/target_arch_sysarch.h b/bsd-user/aarch64/target_arch_sysarch.h new file mode 100644 index 0000000000..b003015daf --- /dev/null +++ b/bsd-user/aarch64/target_arch_sysarch.h @@ -0,0 +1,42 @@ +/* + * ARM AArch64 sysarch() system call emulation for bsd-user. + * + * Copyright (c) 2015 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_SYSARCH_H +#define TARGET_ARCH_SYSARCH_H + +#include "target_syscall.h" +#include "target_arch.h" + +/* See sysarch() in sys/arm64/arm64/sys_machdep.c */ +static inline abi_long do_freebsd_arch_sysarch(CPUARMState *env, int op, + abi_ulong parms) +{ + int ret = -TARGET_EOPNOTSUPP; + + fprintf(stderr, "sysarch"); + return ret; +} + +static inline void do_freebsd_arch_print_sysarch( + const struct syscallname *name, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) +{ +} + +#endif /* TARGET_ARCH_SYSARCH_H */ From patchwork Mon Jun 17 18:57:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8C1C2C27C79 for ; Mon, 17 Jun 2024 19:03:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZD-0005c4-I6; Mon, 17 Jun 2024 14:58:59 -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 1sJHYy-0004ju-BM for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:47 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYw-00050R-Hs for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:44 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70423e8e6c9so4092860b3a.0 for ; Mon, 17 Jun 2024 11:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650720; x=1719255520; 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=bzNcNJmcxrM8qrvXWwUv5T4AhCFaFoLPFz7e7Bb3WVY=; b=AyCRXuhbDPtECBCyEtb96Yk/+EPvkAv62BFu5b/jY+M27mA6Jh73FOVdvXVNP3Kg5e 8rlsszRnbfkEEykVknJKiEsus4IyTBh0TniSEJizINODJeQGVurb1L9Kwol7wxt2e09w vclqYNJ41nJoJ5KSOOe872qsZYxdcBYhZ754g2hXJFsJOGvWthAN1q+fHts5boRB16dO PeZIyLANDTaEnAja9eXtZZhTvolbiSxjgA4pHNtcJ49/rAmr8Bwx8fAeRncu1e6+jzvc LtJTP5PIhE3P5ViHsePfeJpaxLkKW1QKJPS0+gzJR31znHJWBJFd2t3IKpCmHUnGbGWs tr3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650720; x=1719255520; 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=bzNcNJmcxrM8qrvXWwUv5T4AhCFaFoLPFz7e7Bb3WVY=; b=NjNaIwu4K/VBL4p4Dk83lv4vfROIIEzMg2DluC1A7xIUcO3mdxYrlsGqVJF6aogE3m BJ4jzYQLp3rd023BGOlvGZaMTNHr+hKs4S+JEzGHvzVrJgJq/ValLNbWynohYwQwnr3f Y4hz2JOHjDa5jXrwVW6l9aTn8pnkVZjXZCv/g0wJgPkJeIWpUNXfKafWNIWI8X5k51RE 6ThbSfedKfsfdWLke9rcaLHG2jzeCwJQaGWdodotjq+NTxK+bCMHS19neIQNWWGK9WZc X5RQdePk0XECHXx1frWFWOOi6RJB7gOV046uLoyTMUNiKflnCOc+K3PHDUxhl9KadLcL Gc2g== X-Gm-Message-State: AOJu0YyiawcnqUIn+WNj0fsXUznIgduy4tWUiFIPMbcYA48I0Z1ezofL PEJ8lfP0b62UeIEgXAcqasNWLgtrUnttjIqPICU4jrAb7A1XikpYsvNbGFW8ynU= X-Google-Smtp-Source: AGHT+IHlNMDpZ/3SvXQxrUSYTW3x5sB9I83m8tDse7ckkDNvuGf1DVXq2GPJanDwmYAOQoadSpH+Ww== X-Received: by 2002:a05:6a00:1310:b0:705:dddf:bb46 with SMTP id d2e1a72fcca58-705dddfbdaemr9720103b3a.14.1718650720045; Mon, 17 Jun 2024 11:58:40 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:39 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Jessica Clarke Subject: [PATCH 09/23] Add thread setup for BSD-USER Date: Tue, 18 Jun 2024 00:27:50 +0530 Message-Id: <20240617185804.25075-10-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x431.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Function for setting up thread upcall which will add thread support to BSD-User Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Co-authored-by: Jessica Clarke --- bsd-user/aarch64/target_arch_thread.h | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_thread.h diff --git a/bsd-user/aarch64/target_arch_thread.h b/bsd-user/aarch64/target_arch_thread.h new file mode 100644 index 0000000000..d2f2dea7ce --- /dev/null +++ b/bsd-user/aarch64/target_arch_thread.h @@ -0,0 +1,45 @@ +/* + * ARM AArch64 thread support for bsd-user. + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_THREAD_H +#define TARGET_ARCH_THREAD_H + +/* Compare to arm64/arm64/vm_machdep.c cpu_set_upcall_kse() */ +static inline void target_thread_set_upcall(CPUARMState *regs, abi_ulong entry, + abi_ulong arg, abi_ulong stack_base, abi_ulong stack_size) +{ + abi_ulong sp; + + /* + * Make sure the stack is properly aligned. + * arm64/include/param.h (STACKLIGN() macro) + */ + sp = (abi_ulong)(stack_base + stack_size) & ~(16 - 1); + + /* sp = stack base */ + regs->xregs[31] = sp; + /* pc = start function entry */ + regs->pc = entry; + /* r0 = arg */ + regs->xregs[0] = arg; + + pstate_write(regs, PSTATE_MODE_EL0t); +} + +#endif /* TARGET_ARCH_THREAD_H */ From patchwork Mon Jun 17 18:57:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 23B31C27C79 for ; Mon, 17 Jun 2024 19:03:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZK-0006kd-3G; Mon, 17 Jun 2024 14:59:06 -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 1sJHZ0-0004uJ-BQ for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:47 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYy-00050g-3Y for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:46 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-701b0b0be38so4189589b3a.0 for ; Mon, 17 Jun 2024 11:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650722; x=1719255522; 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=EYrmA0vk2Zd3/clu1etzd70moyuztxZzOi8TsOsOvYU=; b=lrU7Hiph/155Gua7+3tiEt/GajwCI8xVvGvA5SFhhBHMdKFrGxRVt9Hw7E9Xd1uekC +wk0DBu0434YzJ0rXgyWdP8iNmAN3BsgainXiH6fw/ISuiWoSepDdy6zRnZabLisBsDv Oc97bOl+wzfsHoum31KsdpRl9+IK2Gx86B0WgppNfWhLw6g4HALORamtDkxK3orQ3FpN q+MV5I7RyAujt8qXjhGk9/pY4e1Vj1CIQ2fcgYsETYifvjM+1zBtS3PiA7BRVUDxKcQl O+y78dUxj8vW+g9vw/tWoIwduAAuSOqYHBE+P3cWcYS13DC1YiIO7m6nEuw+mu0OpUpe 4wnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650722; x=1719255522; 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=EYrmA0vk2Zd3/clu1etzd70moyuztxZzOi8TsOsOvYU=; b=ML2ZrbiAFQNIcAAar5eJhjd/LR0tdK2UsgVrxQ8AboqP2HEUDidvXtjOgTWX+beX0z q6ip77x7l4PT87xaUi6QiDxZSxe2t+F9bmhvb8KSR/TXoN7Lzbgng9iEChEjhSBi2mCN XxHPC9PQGo9IyWWDI43ImLm+RxNFb5o3adEg21o4sHzNRt9Owny8xQfDnaO9/YSSK09A 1VUJm0f5DQhi6C+NB5GJXftDeO+jfP2vOnelVmL8OuRCxUfovvBT9EsVmYrHDd1dff7A DBMAxDXwd6kg8eWZP42i3+Ryliflbs7Cl+QnYFZDIbu1rj7UDEv/qMNa9sv2Lm4ICFE6 1t9w== X-Gm-Message-State: AOJu0YzUp+8Gfe8wSwH0SyN4IzfizYIM+5z7Jg7ezflSJ3IskVc/kc8o D2QMLwcrthd4/nSXnNyFESMJjBCEdM4rGug6ITe29kg6DSA9AlilE6RWcn4UjkQ= X-Google-Smtp-Source: AGHT+IE3+z5PYLzh3MyGQGqM79KRSmOhWdAle+kbNEKnvUZlFLZtUszy56tS/DkoRgoAJ3+chVQvaA== X-Received: by 2002:a05:6a20:7489:b0:1b8:622a:cf8f with SMTP id adf61e73a8af0-1bae82c1a36mr11850309637.57.1718650722335; Mon, 17 Jun 2024 11:58:42 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:42 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Jessica Clarke Subject: [PATCH 10/23] Add thread initialization for BSD-USER Date: Tue, 18 Jun 2024 00:27:51 +0530 Message-Id: <20240617185804.25075-11-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Initializes thread's register state Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Co-authored-by: Jessica Clarke Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_thread.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bsd-user/aarch64/target_arch_thread.h b/bsd-user/aarch64/target_arch_thread.h index d2f2dea7ce..bfc9050cb1 100644 --- a/bsd-user/aarch64/target_arch_thread.h +++ b/bsd-user/aarch64/target_arch_thread.h @@ -42,4 +42,20 @@ static inline void target_thread_set_upcall(CPUARMState *regs, abi_ulong entry, pstate_write(regs, PSTATE_MODE_EL0t); } +static inline void target_thread_init(struct target_pt_regs *regs, + struct image_info *infop) +{ + abi_long stack = infop->start_stack; + + /* + * Make sure the stack is properly aligned. + * arm64/include/param.h (STACKLIGN() macro) + */ + + memset(regs, 0, sizeof(*regs)); + regs->regs[0] = infop->start_stack; + regs->pc = infop->entry; + regs->sp = stack & ~(16 - 1); +} + #endif /* TARGET_ARCH_THREAD_H */ From patchwork Mon Jun 17 18:57:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C7C69C27C79 for ; Mon, 17 Jun 2024 18:59:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZI-0006ex-Sm; Mon, 17 Jun 2024 14:59:04 -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 1sJHZ3-00053M-Lw for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:49 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZ0-00050s-KZ for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:48 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-70599522368so3239788b3a.2 for ; Mon, 17 Jun 2024 11:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650725; x=1719255525; 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=BAd8HJ17iktB7tRhvtL5nkQqb3WYzbcst6424yQv9pA=; b=m3KXzpR1ApjwfOGUeJ+Q7Ua702rZZqJNhE0YhYYdfEvRI4jjNR58EkHb4gHBJysuuB qFp8jVyrx9V/q93YaPwVJGql3t6nPyRCiil79nak/YbnkHIsfSpZPnbYmZMYe/+WcsSq 3BlNitaenkTLzmSESTDTTm7XiZeu69c9ro9WAXphjaQ2rLpaP2vd+Z/uWjIbl+iGnqjQ JKGYyKUHe53mRM6V5D9bddh9WAGOeVrzW11vXFBqCHLF/ETYyMOcWLGl9KUU0W+EbUfA D1GM+9GmgiPUnBrD+C2WwMZQ+wGJTF2VO2wczMrHCZqxjdP8OfFDXS6XdE7m5x9V8OK8 IXKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650725; x=1719255525; 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=BAd8HJ17iktB7tRhvtL5nkQqb3WYzbcst6424yQv9pA=; b=MoHdx375U1dVcl63VtHY6zwGood7LVcEncKIFmfKEwMqOW8IQG/K3ppsj/2SrJNSN5 q9iWM6ihsNT5sECBV4hziMKLtiOOG/ydTj5V77fbG32SeaDoSZLNlolkA5LaIyJ/6Zfa yyes1n4ccnutffDjINaMRkm/g4YVmo+pkirVJr4N7EjUV5rTxRd0Qgfe85eyb9eHmjRc AVI6D8un1VBYqQwFTnH8uymZzf9oaV9xpn3LZ0WucDinZIbiIAn+fBA76K406VuTTGUA RWTRBQG/5yz3tyRR4LapaXaYd88e0sMOig1TBrojxS39qNXqPWbRcH/sUEMhLCw3ohtw uQWA== X-Gm-Message-State: AOJu0YzOsQFxB/cgqW6LofRD1ay/dwSWnj4gYFVJnOvacyQPpqwL8iOZ zi53QLL2JD/GC1a3rrzSaH5q897RqZv8xuFsxOlmPRvW1yfRlD76961Yk7n6uEo= X-Google-Smtp-Source: AGHT+IHWUFWvbNiCzT9J2QIDgji/4PIdsFY1BYIQgFWTTXCdfdhCCOiJcYTTvFt2CW6aGJZdg9jx5w== X-Received: by 2002:a05:6a21:78a8:b0:1b8:14aa:b594 with SMTP id adf61e73a8af0-1bae7ba33c9mr10481320637.0.1718650724595; Mon, 17 Jun 2024 11:58:44 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:44 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Sean Bruno Subject: [PATCH 11/23] Update ARM AArch64 VM parameter definitions for bsd-user Date: Tue, 18 Jun 2024 00:27:52 +0530 Message-Id: <20240617185804.25075-12-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Defined address spaces for FreeBSD/arm64 and added function for getting stack pointer from CPU and setting a return value. Signed-off-by: Stacey Son Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Co-authored-by: Sean Bruno Co-authored-by: Warner Losh Acked-by: Richard Henderson --- bsd-user/aarch64/target_arch_vmparam.h | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_vmparam.h diff --git a/bsd-user/aarch64/target_arch_vmparam.h b/bsd-user/aarch64/target_arch_vmparam.h new file mode 100644 index 0000000000..dc66e1289b --- /dev/null +++ b/bsd-user/aarch64/target_arch_vmparam.h @@ -0,0 +1,68 @@ +/* + * ARM AArch64 VM parameters definitions for bsd-user. + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_VMPARAM_H +#define TARGET_ARCH_VMPARAM_H + +#include "cpu.h" + +/** + * FreeBSD/arm64 Address space layout. + * + * ARMv8 implements up to a 48 bit virtual address space. The address space is + * split into 2 regions at each end of the 64 bit address space, with an + * out of range "hole" in the middle. + * + * We limit the size of the two spaces to 39 bits each. + * + * Upper region: 0xffffffffffffffff + * 0xffffff8000000000 + * + * Hole: 0xffffff7fffffffff + * 0x0000008000000000 + * + * Lower region: 0x0000007fffffffff + * 0x0000000000000000 + * + * The upper region for the kernel, and the lower region for userland. + */ + + +/* compare to sys/arm64/include/vmparam.h */ +#define TARGET_MAXTSIZ (1 * GiB) /* max text size */ +#define TARGET_DFLDSIZ (128 * MiB) /* initial data size limit */ +#define TARGET_MAXDSIZ (1 * GiB) /* max data size */ +#define TARGET_DFLSSIZ (128 * MiB) /* initial stack size limit */ +#define TARGET_MAXSSIZ (1 * GiB) /* max stack size */ +#define TARGET_SGROWSIZ (128 * KiB) /* amount to grow stack */ + + /* KERNBASE - 512 MB */ +#define TARGET_VM_MAXUSER_ADDRESS (0x00007fffff000000ULL - (512 * MiB)) +#define TARGET_USRSTACK TARGET_VM_MAXUSER_ADDRESS + +static inline abi_ulong get_sp_from_cpustate(CPUARMState *state) +{ + return state->xregs[31]; /* sp */ +} + +static inline void set_second_rval(CPUARMState *state, abi_ulong retval2) +{ + state->xregs[1] = retval2; /* XXX not really used on 64-bit arch */ +} +#endif /* TARGET_ARCH_VMPARAM_H */ From patchwork Mon Jun 17 18:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E5479C27C79 for ; Mon, 17 Jun 2024 19:03:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZE-0005nQ-DG; Mon, 17 Jun 2024 14:59:00 -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 1sJHZ3-00053N-Lw for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:49 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZ1-000511-Vd for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:49 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-705c0115192so4002569b3a.1 for ; Mon, 17 Jun 2024 11:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650726; x=1719255526; 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=mSb4ge/oi7N04tkudfzAy1LJjUNLVfIVt+fkT6uQ/zo=; b=Vd8txHPTe5/dEI8YHWunZU1tTMsFciwVKGp8jLPnDyT8LacA6FZ1Z+nlqOFbaiV5IB 7lhUYk4VQ7NoPNnMcrg+BvHFw2Ar9FKMrhi6P0v/G5Z9/1g5M6dN7MSXVFxHQJwCiCGW h6yqD+JaL6S6hRqQlt+dERf2UgJWh6DMC3MNa+0FzUoFX5lQuCn2LR+KoEyeje/HcuzC GBlZSGd/jraTylrhZiWYvKLXSNfAyVtUjPsSwuNOKCoOh7PE5ncRFXSWqjX2ZYK1yFJK li9731JpqFoycaVLAkSmBFr+aGt0E7Q0gZPCE88cfTygJwKbM86VN+7fMrSGjIGFYvJ1 JCoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650726; x=1719255526; 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=mSb4ge/oi7N04tkudfzAy1LJjUNLVfIVt+fkT6uQ/zo=; b=bPe65eCwfjsBTSBITPOoWDLiRl+2QRUtWRlpcB/G2ntTiRfiuAnSre2QwVF+5f5888 l+tJOzUb3JmuoaBXh4uZCQOSIEm3AY1jfdNBB1TuotHMem1l1mbqoNGbLgcqJ1kYbPic ukLRPnyCVFelJtNEI4a7Lb1x+nm8izZVmVuBOMQwV4m3157JxuVJjDRgnsEyY/Qya+fa 6nMELSrY5l5xiWuwfbSC/3k6g+YKNmqQX1HZaIH0ccnw6K9sF7t79u26NRB1ZhqsmjYl Jx+DeXH200hrSJ3OvLNc+bRhNyQyhHLsymEhR332RzGphyPOkFuT6VcHHQR2SB489CL/ EHYQ== X-Gm-Message-State: AOJu0Yxu//LHuGAmypGzYDnoffVNmyRnpryWRM3DLtv4HgCDph+Dc3hK tt/wN3bGV3Nx68kxZ2o4A7ChpWzjlRo3LUeM7SBVtjHdmrVQF6ey1RGD2OTRbmI= X-Google-Smtp-Source: AGHT+IHiXp1QbDanXfoL1XJhppOzPqy3C5996vD1ONIrkyBLaTMCD8wrWZnQOIG7gy/pIkw4Hu+Ivg== X-Received: by 2002:a05:6a21:3a4b:b0:1b4:82eb:61b8 with SMTP id adf61e73a8af0-1bae8002278mr14043670637.45.1718650726438; Mon, 17 Jun 2024 11:58:46 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:46 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Ajeet Singh Subject: [PATCH 12/23] Add ability to get rval2 Date: Tue, 18 Jun 2024 00:27:53 +0530 Message-Id: <20240617185804.25075-13-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x435.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Warner Losh Function accesses the x1 register which holds the value Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh --- bsd-user/aarch64/target_arch_vmparam.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bsd-user/aarch64/target_arch_vmparam.h b/bsd-user/aarch64/target_arch_vmparam.h index dc66e1289b..0c35491970 100644 --- a/bsd-user/aarch64/target_arch_vmparam.h +++ b/bsd-user/aarch64/target_arch_vmparam.h @@ -65,4 +65,10 @@ static inline void set_second_rval(CPUARMState *state, abi_ulong retval2) { state->xregs[1] = retval2; /* XXX not really used on 64-bit arch */ } + +static inline abi_ulong get_second_rval(CPUARMState *state) +{ + return state->xregs[1]; +} + #endif /* TARGET_ARCH_VMPARAM_H */ From patchwork Mon Jun 17 18:57:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AD05EC27C79 for ; Mon, 17 Jun 2024 18:59:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZF-0005v4-3l; Mon, 17 Jun 2024 14:59:01 -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 1sJHZ7-0005EM-Tu for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:53 -0400 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZ4-000519-My for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:53 -0400 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5ba33b08550so2187045eaf.2 for ; Mon, 17 Jun 2024 11:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650729; x=1719255529; 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=KXCAWBNkEFL7RtMWqPmqBDwDa9EwuUs2bp+eoNQh6Bc=; b=EAhUfXnRT15utVQeZavQjJzStymB9ZeIxuMIOTE34/Thz0/dxS9BjY5/DABxO9SI3Y i2eY7Y2HHoKa20lznccn5spjmFOO8F0NDAifDirwIjCK7qJ/UEd1CdMqUAs4wiKRL7/v uY/L11fwdHx835s7DLaPFbAKTB5VoZEw/kmhwoMHpzfkmxHCma7Ie+52bQI4Avvk5N8Q +r8dCQmU2Do92lGsYwJkcBQJLdY7gjcePJykYZm52/vCOaO+Uqeiyds8S3tIUTT4UZzx pCXQ0wc2oxGlesul5C1b1sHZXUUYY3xum1cC7viJxTSOUBXwDC4vtz9cpUwW44lwb+0x bedw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650729; x=1719255529; 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=KXCAWBNkEFL7RtMWqPmqBDwDa9EwuUs2bp+eoNQh6Bc=; b=gX9oXG/vuC1+zRfXDAMIuotugxAFZXIJcE76hNqR10SQobSZhx3KH455ntmo7EIKod OUbUxHQAKlZ0tdN81ueUHGIKrF6Xo8t/vTHXcZXikYOIsDRPmWtp2rhbxTqczd0QSiaE uxboI4N27BFhr4Z5FLrsN33InGG5P/Z6Ek+tX0GbSlYT+KVfXdWQnIWihT/zVDfFx4LO IGDH3vfI0hLV2wUq9I991SIADXHmvT7Aap4Pixc6C/Ltz3YM3AZivtSBjvmkZc/xPyeO ULyuoGjxeGF1K46IwsGtsCNUgwauyDxywNiFdJexVKMVSVir83ze6ZVwDF0j+wYilciF e84A== X-Gm-Message-State: AOJu0YyA7yu2+RN1MUhTZwTK7jq2S63o+mg7rn6oLmJj1p7XIYCRbiBq beqJzBRMIT5toIhG4lQWaZ4juIuxUIOb+rwgFHVAcoQp3KHDwaDOoCib05h8m2Q= X-Google-Smtp-Source: AGHT+IHocEAvQVGqvIPHrRScbgVTQEHVre3JJn9syRoleAFMoZNti/IJZodQYbrYZd+hjpaqvMcRsQ== X-Received: by 2002:a05:6870:a18a:b0:24c:ae57:b4ab with SMTP id 586e51a60fabf-25842893a0fmr11304216fac.11.1718650728678; Mon, 17 Jun 2024 11:58:48 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:48 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Kyle Evans Subject: [PATCH 13/23] Add ARM AArch64 ELF definitions for bsd-user Date: Tue, 18 Jun 2024 00:27:54 +0530 Message-Id: <20240617185804.25075-14-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c31; envelope-from=itachis6234@gmail.com; helo=mail-oo1-xc31.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Defined mmap and dynamic load adresses and set various elf parameters Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Co-authored-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_elf.h | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_elf.h diff --git a/bsd-user/aarch64/target_arch_elf.h b/bsd-user/aarch64/target_arch_elf.h new file mode 100644 index 0000000000..6d0fa3525f --- /dev/null +++ b/bsd-user/aarch64/target_arch_elf.h @@ -0,0 +1,37 @@ +/* + * ARM AArch64 ELF definitions for bsd-user + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_ELF_H +#define TARGET_ARCH_ELF_H + +#include "target/arm/cpu-features.h" + +#define ELF_START_MMAP 0x80000000 +#define ELF_ET_DYN_LOAD_ADDR 0x100000 + +#define elf_check_arch(x) ((x) == EM_AARCH64) + +#define ELF_CLASS ELFCLASS64 +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_AARCH64 + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +#endif /* TARGET_ARCH_ELF_H */ From patchwork Mon Jun 17 18:57:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 19327C2BA1A for ; Mon, 17 Jun 2024 19:00:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZG-00068G-Ad; Mon, 17 Jun 2024 14:59:02 -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 1sJHZ9-0005Iv-9t for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:55 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZ6-00051Q-PM for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:55 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-705cffc5bcfso4140551b3a.3 for ; Mon, 17 Jun 2024 11:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650731; x=1719255531; 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=3ZnUZJJN2MV366z+thWmZWNKuTtD9XL71TMXojIgFvQ=; b=AJPnA2Hocqw+RJDI+zqTaT1lVF1CVBd3Om0KXm9jdj3muTeIxlWLLAHG9Kuahd5V7u pCIr6wIKiDrnDpYlTs5RPLCwFhPia5xUWljZMlOYzrl8NeJGzJNJqWMorSGyytevf3Ze tqZlhhTAsleDjAinkg5Ntz9sl1IyBp3R3Oqtln0ertgyjozi5AH+6zH+lTI1M/xiEDjh Anuzp5w5qNPF2TImiE2hmoZy22fpS+nC+1nVu/8rqKKiTiiqA7f4PaGCJ7vlwUC7YXBg wWM8FMIHiW3NMqcOE0aDJKA41YALK6sKNt2mOImR8h98R2vNXl/Uvu9yECPUO9WZsDai wr2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650731; x=1719255531; 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=3ZnUZJJN2MV366z+thWmZWNKuTtD9XL71TMXojIgFvQ=; b=vsQygqNGWP1hURfTEBuoIVNbYv0FuOnEpFhrhwPC/iKrCmDbn8Rg4VMHj6NVDJztx/ P3bb3xT0KUnuKB72VVaidjVd7ygIhz8vYb5osWQ2SCUcixGVzELP2FXpw2aSA0GnOf4Q ZD4c6TKnT7S24MVUD8p9/Jme3od5RHVpLFD3Eca61t7NUgRlFA55BpqZqF/6i5qv5xXh pbx1cn4O1b+W1j+wztNHMS5CXxyM6DrK8aPIGcqZ6AtobJ9Su96qxmG+wC5qgVikuXjw EhR8HYk04pYJ4Q/Ab80uyckFov2vs8PzK5mMKcPQQT6/TMJfhThu+aUaKNRlmB77IUDh xn7w== X-Gm-Message-State: AOJu0YxAa8Wn5Vj6BxBAPble7rkFpWqDS5pIajiZ12D49NwSAIbuQL9b UwgXjEXzGu5YUqWU5jrIhVoJ6W/XPBjlRZDBeuz5ScRRoGxftI4cyE/yXlIOaes= X-Google-Smtp-Source: AGHT+IFVhdOyA4UB2jekNwUAFq8rHRvP00nS2YUpulnrOU8HmEhY5fqEDHp7gPfJXnR/Y8NU9wlXaQ== X-Received: by 2002:a05:6a00:cd4:b0:705:de1d:f7f9 with SMTP id d2e1a72fcca58-705ff8e59f8mr6807297b3a.0.1718650730518; Mon, 17 Jun 2024 11:58:50 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:50 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Ajeet Singh Subject: [PATCH 14/23] Add ARM AArch64 hardware capability definitions Date: Tue, 18 Jun 2024 00:27:55 +0530 Message-Id: <20240617185804.25075-15-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42d.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, UPPERCASE_50_75=0.008 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Warner Losh Defined a huge list of hardware capabilites and added macros for retrieving hwcap flags Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Acked-by: Richard Henderson --- bsd-user/aarch64/target_arch_elf.h | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/bsd-user/aarch64/target_arch_elf.h b/bsd-user/aarch64/target_arch_elf.h index 6d0fa3525f..41afa5a9da 100644 --- a/bsd-user/aarch64/target_arch_elf.h +++ b/bsd-user/aarch64/target_arch_elf.h @@ -34,4 +34,65 @@ #define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 +enum { + ARM_HWCAP_A64_FP = 1 << 0, + ARM_HWCAP_A64_ASIMD = 1 << 1, + ARM_HWCAP_A64_EVTSTRM = 1 << 2, + ARM_HWCAP_A64_AES = 1 << 3, + ARM_HWCAP_A64_PMULL = 1 << 4, + ARM_HWCAP_A64_SHA1 = 1 << 5, + ARM_HWCAP_A64_SHA2 = 1 << 6, + ARM_HWCAP_A64_CRC32 = 1 << 7, + ARM_HWCAP_A64_ATOMICS = 1 << 8, + ARM_HWCAP_A64_FPHP = 1 << 9, + ARM_HWCAP_A64_ASIMDHP = 1 << 10, + ARM_HWCAP_A64_CPUID = 1 << 11, + ARM_HWCAP_A64_ASIMDRDM = 1 << 12, + ARM_HWCAP_A64_JSCVT = 1 << 13, + ARM_HWCAP_A64_FCMA = 1 << 14, + ARM_HWCAP_A64_LRCPC = 1 << 15, + ARM_HWCAP_A64_DCPOP = 1 << 16, + ARM_HWCAP_A64_SHA3 = 1 << 17, + ARM_HWCAP_A64_SM3 = 1 << 18, + ARM_HWCAP_A64_SM4 = 1 << 19, + ARM_HWCAP_A64_ASIMDDP = 1 << 20, + ARM_HWCAP_A64_SHA512 = 1 << 21, + ARM_HWCAP_A64_SVE = 1 << 22, + ARM_HWCAP_A64_ASIMDFHM = 1 << 23, + ARM_HWCAP_A64_DIT = 1 << 24, + ARM_HWCAP_A64_USCAT = 1 << 25, + ARM_HWCAP_A64_ILRCPC = 1 << 26, + ARM_HWCAP_A64_FLAGM = 1 << 27, + ARM_HWCAP_A64_SSBS = 1 << 28, + ARM_HWCAP_A64_SB = 1 << 29, + ARM_HWCAP_A64_PACA = 1 << 30, + ARM_HWCAP_A64_PACG = 1UL << 31, + + ARM_HWCAP2_A64_DCPODP = 1 << 0, + ARM_HWCAP2_A64_SVE2 = 1 << 1, + ARM_HWCAP2_A64_SVEAES = 1 << 2, + ARM_HWCAP2_A64_SVEPMULL = 1 << 3, + ARM_HWCAP2_A64_SVEBITPERM = 1 << 4, + ARM_HWCAP2_A64_SVESHA3 = 1 << 5, + ARM_HWCAP2_A64_SVESM4 = 1 << 6, + ARM_HWCAP2_A64_FLAGM2 = 1 << 7, + ARM_HWCAP2_A64_FRINT = 1 << 8, + ARM_HWCAP2_A64_SVEI8MM = 1 << 9, + ARM_HWCAP2_A64_SVEF32MM = 1 << 10, + ARM_HWCAP2_A64_SVEF64MM = 1 << 11, + ARM_HWCAP2_A64_SVEBF16 = 1 << 12, + ARM_HWCAP2_A64_I8MM = 1 << 13, + ARM_HWCAP2_A64_BF16 = 1 << 14, + ARM_HWCAP2_A64_DGH = 1 << 15, + ARM_HWCAP2_A64_RNG = 1 << 16, + ARM_HWCAP2_A64_BTI = 1 << 17, + ARM_HWCAP2_A64_MTE = 1 << 18, +}; + +#define ELF_HWCAP get_elf_hwcap() +#define ELF_HWCAP2 get_elf_hwcap2() + +#define GET_FEATURE_ID(feat, hwcap) \ + do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) + #endif /* TARGET_ARCH_ELF_H */ From patchwork Mon Jun 17 18:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A8A67C27C79 for ; Mon, 17 Jun 2024 18:59:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZG-00064y-2T; Mon, 17 Jun 2024 14:59:02 -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 1sJHZA-0005Jj-1P for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:57 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZ8-00051c-HD for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:55 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70413de08c7so3360851b3a.0 for ; Mon, 17 Jun 2024 11:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650732; x=1719255532; 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=iwdwkyILIZzUSkN36LJeX98rjpRL4TLtxBZLomRK6og=; b=PDDj6pE0rkiEo7pGYMZ5b4FGXPsAlF7yMLLKhkfq7Ne/sAciBEnP31yroXf++KpCb6 tioeG1XpV7V/V9VofbuTuvLOOs6jJ/RNDgjkBxTqKaHrmcK73F65zIFAnrDj5UgnuqCP 9QIZAqdUFzCqi5/ZXsxbcfOEwojCpubyfF/IA3QWGVLx5poAXwO2PbDs4DUVAmoS3raA 9aO7nVkx4WFLR+N9czPfd3KpdB6MkEFd5aO4jzAnucZ3sq4ETJt6eJWnoFFMUKhLJPj6 K7W4ELz6oI9qgfD3J/eIf0yuJuX9saiMeD+4xIONN1dA9s4RKAz7mdwmh8YISeAiY9fm 5ztA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650732; x=1719255532; 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=iwdwkyILIZzUSkN36LJeX98rjpRL4TLtxBZLomRK6og=; b=fVZXHSJ/QprjjBZKsxk1AtyuxfUoZiuykmuE/hiWHCcLizYqv7+c7Dv4r1a9PHXARu mB6FxI5f7awrYCRM2oyxrrPFyscKfekyrdeYKB/lbwmZZOhgjfrgg64tiY7XYycX+aZp xj3vDXFiSzaTKrXPN/Sf+3uLrT1d0D0pwZqfL1PK6dKihWChu2uFC3FmoS0lM55S573e T78chAf6qglfStQFWvdRKuxkmCBRnpKgPQQLdeX2rk9im4klSU1yNfKH6mWTBxGoUBiF 55+wqmAHu6TCfHjy5JA0kjC5aRjyq879s3tKpkGZKrN3iZtD29haT93FB1hlT7OVI3AI mcOA== X-Gm-Message-State: AOJu0YzO9m2HIlQJuDbfxKShFYNIh9rSenTBWrnvdznPHfEqQT56UHhK d4tjboMgP/lNrdZZ6UIudp7cNk7IdUBpylaBsxArTrQ76vK1kKZCpRHARA0sBCo= X-Google-Smtp-Source: AGHT+IEtvYs0UYPv/dfgTvtwxcG8vJ886jL3Ds++XE554L2q/S9h1t9Fk9GuohNfGWHXaFdaY2T8AA== X-Received: by 2002:aa7:8f8f:0:b0:704:2152:e4d2 with SMTP id d2e1a72fcca58-705d7177310mr9549459b3a.17.1718650732367; Mon, 17 Jun 2024 11:58:52 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:52 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Ajeet Singh Subject: [PATCH 15/23] Add function to retrieve ARM AArch64 hardware capabilities Date: Tue, 18 Jun 2024 00:27:56 +0530 Message-Id: <20240617185804.25075-16-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x436.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Warner Losh The function initializes default hardware capabilities and finds additional features using the `GET_FEATURE_ID` macro Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_elf.h | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bsd-user/aarch64/target_arch_elf.h b/bsd-user/aarch64/target_arch_elf.h index 41afa5a9da..ed2419408e 100644 --- a/bsd-user/aarch64/target_arch_elf.h +++ b/bsd-user/aarch64/target_arch_elf.h @@ -95,4 +95,42 @@ enum { #define GET_FEATURE_ID(feat, hwcap) \ do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) +static uint32_t get_elf_hwcap(void) +{ + ARMCPU *cpu = ARM_CPU(thread_cpu); + uint32_t hwcaps = 0; + + hwcaps |= ARM_HWCAP_A64_FP; + hwcaps |= ARM_HWCAP_A64_ASIMD; + hwcaps |= ARM_HWCAP_A64_CPUID; + + /* probe for the extra features */ + + GET_FEATURE_ID(aa64_aes, ARM_HWCAP_A64_AES); + GET_FEATURE_ID(aa64_pmull, ARM_HWCAP_A64_PMULL); + GET_FEATURE_ID(aa64_sha1, ARM_HWCAP_A64_SHA1); + GET_FEATURE_ID(aa64_sha256, ARM_HWCAP_A64_SHA2); + GET_FEATURE_ID(aa64_sha512, ARM_HWCAP_A64_SHA512); + GET_FEATURE_ID(aa64_crc32, ARM_HWCAP_A64_CRC32); + GET_FEATURE_ID(aa64_sha3, ARM_HWCAP_A64_SHA3); + GET_FEATURE_ID(aa64_sm3, ARM_HWCAP_A64_SM3); + GET_FEATURE_ID(aa64_sm4, ARM_HWCAP_A64_SM4); + GET_FEATURE_ID(aa64_fp16, ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); + GET_FEATURE_ID(aa64_atomics, ARM_HWCAP_A64_ATOMICS); + GET_FEATURE_ID(aa64_rdm, ARM_HWCAP_A64_ASIMDRDM); + GET_FEATURE_ID(aa64_dp, ARM_HWCAP_A64_ASIMDDP); + GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA); + GET_FEATURE_ID(aa64_sve, ARM_HWCAP_A64_SVE); + GET_FEATURE_ID(aa64_pauth, ARM_HWCAP_A64_PACA | ARM_HWCAP_A64_PACG); + GET_FEATURE_ID(aa64_fhm, ARM_HWCAP_A64_ASIMDFHM); + GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT); + GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB); + GET_FEATURE_ID(aa64_condm_4, ARM_HWCAP_A64_FLAGM); + GET_FEATURE_ID(aa64_dcpop, ARM_HWCAP_A64_DCPOP); + GET_FEATURE_ID(aa64_rcpc_8_3, ARM_HWCAP_A64_LRCPC); + GET_FEATURE_ID(aa64_rcpc_8_4, ARM_HWCAP_A64_ILRCPC); + + return hwcaps; +} + #endif /* TARGET_ARCH_ELF_H */ From patchwork Mon Jun 17 18:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2D1CEC2BA1A for ; Mon, 17 Jun 2024 19:02:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZH-0006Cn-2i; Mon, 17 Jun 2024 14:59:03 -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 1sJHZC-0005NI-0i for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:58 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZ9-00051n-Vm for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:57 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70436048c25so3565429b3a.0 for ; Mon, 17 Jun 2024 11:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650734; x=1719255534; 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=GAGICjPOsf8qlBYaZrf0UehAmpN+2Vvp/a0MWtmp8us=; b=i/FIa7h0VQbLu4R/wKa17W54LUmV19KACOECYtzP1tGtNJjSgl3K1ht37jnc91HJxD iyV9Ld5Bk4hR4io5kE72H3Cr9nm0YrNnL/xBKeQeanPOzJHqUv+Dmp4fTAttoJl8eE0O KwRnhYLOI8VdTNMl18v6SbWRUsDwv2TrvbtzUxKbA8YAdBfwt7uNNoR4yBs8vNJG7dl1 HJ46VH51vCVSiyVD7/JkBBlh3RDkYeoxBF7vsKZYKcranw7Ld4EcnYRJ+9LQe96x6wSc ik3zBwONTocUl8p4zSuMAvCMKuuKSG5/2Z2d3zKLhFIHi1O+tBgdA6Eysi/2IzBTDMQv 2kEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650734; x=1719255534; 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=GAGICjPOsf8qlBYaZrf0UehAmpN+2Vvp/a0MWtmp8us=; b=GOpY0FzzOHyxB6D3AAQKdvFUyOkuME6yTp2MYcMck4VUR/SgfDQ8JIzsSkuIW+3+c+ ZC5P+tZvbF++ZFX/kV+Z9txLqpWX8P94dbWO8WnkA6hzqx2J843FVG7md3szx19UtdyG ZWr6rd3XIH5Ebg2fhUa8glkIuNAeseAvxoLw4ZCHuvVZDyPZ1LiGHZwaXzoVdhSkRDeM 0SzF21ESz+laWzWlQuZ3eqGRL6oSV6PndI24jHXAhZLraCUzSMieeKybEJb7QJW/U7ui Ai1+oiYa2Ror2dKbSlNGh9oOV9q3E+vA6rUotzyF0oxD6MgcJ7CtTpGjAPFDT9TooLv5 UFwA== X-Gm-Message-State: AOJu0YySz+PFkmtwGXX6HzV3idO/X24Y4vSsOkclPvfmZFaNljK4wOpt qhQdVQ/cHMY1f4bnkFyLJ2UpYDvrXZPKagfg4oPAoLdiIkfsKZtfO/cgsENf8C8= X-Google-Smtp-Source: AGHT+IFY9pAHmOb3hrJQx+wHnCY8wSifWr+1gCkV7w5tgE1Ur0akp+t027UL68BxPhvAnPWuGoP4Gw== X-Received: by 2002:a05:6a21:9988:b0:1b6:da8b:9c with SMTP id adf61e73a8af0-1bae7f142demr10584627637.28.1718650734208; Mon, 17 Jun 2024 11:58:54 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:54 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Ajeet Singh Subject: [PATCH 16/23] Add function to retrieve additional ARM AArch64 hwcap Date: Tue, 18 Jun 2024 00:27:57 +0530 Message-Id: <20240617185804.25075-17-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x433.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Warner Losh Function to retrieve the extended hardware capability flags Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_elf.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/bsd-user/aarch64/target_arch_elf.h b/bsd-user/aarch64/target_arch_elf.h index ed2419408e..7202cd8334 100644 --- a/bsd-user/aarch64/target_arch_elf.h +++ b/bsd-user/aarch64/target_arch_elf.h @@ -133,4 +133,33 @@ static uint32_t get_elf_hwcap(void) return hwcaps; } +static uint32_t get_elf_hwcap2(void) +{ + ARMCPU *cpu = ARM_CPU(thread_cpu); + uint32_t hwcaps = 0; + + GET_FEATURE_ID(aa64_dcpodp, ARM_HWCAP2_A64_DCPODP); + GET_FEATURE_ID(aa64_sve2, ARM_HWCAP2_A64_SVE2); + GET_FEATURE_ID(aa64_sve2_aes, ARM_HWCAP2_A64_SVEAES); + GET_FEATURE_ID(aa64_sve2_pmull128, ARM_HWCAP2_A64_SVEPMULL); + GET_FEATURE_ID(aa64_sve2_bitperm, ARM_HWCAP2_A64_SVEBITPERM); + GET_FEATURE_ID(aa64_sve2_sha3, ARM_HWCAP2_A64_SVESHA3); + GET_FEATURE_ID(aa64_sve2_sm4, ARM_HWCAP2_A64_SVESM4); + GET_FEATURE_ID(aa64_condm_5, ARM_HWCAP2_A64_FLAGM2); + GET_FEATURE_ID(aa64_frint, ARM_HWCAP2_A64_FRINT); + GET_FEATURE_ID(aa64_sve_i8mm, ARM_HWCAP2_A64_SVEI8MM); + GET_FEATURE_ID(aa64_sve_f32mm, ARM_HWCAP2_A64_SVEF32MM); + GET_FEATURE_ID(aa64_sve_f64mm, ARM_HWCAP2_A64_SVEF64MM); + GET_FEATURE_ID(aa64_sve_bf16, ARM_HWCAP2_A64_SVEBF16); + GET_FEATURE_ID(aa64_i8mm, ARM_HWCAP2_A64_I8MM); + GET_FEATURE_ID(aa64_bf16, ARM_HWCAP2_A64_BF16); + GET_FEATURE_ID(aa64_rndr, ARM_HWCAP2_A64_RNG); + GET_FEATURE_ID(aa64_bti, ARM_HWCAP2_A64_BTI); + GET_FEATURE_ID(aa64_mte, ARM_HWCAP2_A64_MTE); + + return hwcaps; +} + +#undef GET_FEATURE_ID + #endif /* TARGET_ARCH_ELF_H */ From patchwork Mon Jun 17 18:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 02BA9C2BA1A for ; Mon, 17 Jun 2024 18:59:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZJ-0006iZ-GI; Mon, 17 Jun 2024 14:59:05 -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 1sJHZD-0005e2-JZ for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:59 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZB-000521-PS for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:59 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70109d34a16so4087160b3a.2 for ; Mon, 17 Jun 2024 11:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650736; x=1719255536; 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=TkBZ3A0IOrNIHfqd0dlYxwhWxjtHcw7wNSmdm0xN6gQ=; b=cTp8Btfbcur1h848cwzLEaybjGKyyO89tTlqzmjNSlourqZepHPZUaIbbQZgpBrFjB 7PvvaP71hMdk29YTrq4Xf12wnvPRWc8ROsrXbIKYD3UAfhqq/ZzSRw5J00k+WFlrUQ9e 0yEgl89ETmHEV8O4v8YXeg6+umqMIWojsYG75boKHCZUr7gL1Nu0c5Gy2pzImYW7QvBm XzB1AaIXBkGgbqY8jTkVgwsJUEAwU5KplLoG4SiysPHYquibOvZNChHM5fQL/BrKPVAh ZmPIbcl+E8Tii/ZFilm8TqMUVkpzUSVl5T1mTtVY9jE6sv3XhYxvrKU7RgI9T0jt7eYy op1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650736; x=1719255536; 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=TkBZ3A0IOrNIHfqd0dlYxwhWxjtHcw7wNSmdm0xN6gQ=; b=KDka+e0oaUTWcZOq6lL65z82zzyT63aXZzmv7ng8tDQ1P4ec2TH9XqC3tRWhRaYrgT P0nhaEDHAji954C0jMFn8ebG6xnqTPbxXflnkqpXi7xScFqRURWwOWOQoPh9ZoTuDDtm Qxzq53u/ONVOXgAOt/dQTtVrX21kG7/YXPXVcHri39WDxgjNkO7Afve9rXSbBYsRhXNg WJffpRhWegzqNXH3//UvjBLaBtLBBEixoWFurNOVDs7EecqbORBTWvsLihkiXXCkSYU9 E1apDiMHAus7z7RwNTjMNzEFeUqLvGSrQpftnc2w7WL+gBCWkyb4+bix7+e1mrS/hOK3 PEhQ== X-Gm-Message-State: AOJu0YzAbVAKQiBpNBSoKeVnfZyrdg20FteeTxVZl8vv73kelGQdZAOU rvpW3bVDaKAqKmqWqN5FWiLPIrQRjP+/dgF4wWGFIRqHc2dOArWPUrxt5VCtDX4= X-Google-Smtp-Source: AGHT+IFCBY+zQk7ULjw1BHIaSJPTmTVrjIahFmIUJ9jzz/tuCl+zghFOBOPnaxokWBroXRJCVSvYdA== X-Received: by 2002:a62:e814:0:b0:705:c0a1:61de with SMTP id d2e1a72fcca58-705d71441a5mr10745870b3a.8.1718650736207; Mon, 17 Jun 2024 11:58:56 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:56 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 17/23] Add ARM AArch64 sigcode setup function for bsd-user Date: Tue, 18 Jun 2024 00:27:58 +0530 Message-Id: <20240617185804.25075-18-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x436.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son signal trampoline function initializes a sequence of instructions to handle signal returns and exits, and copies this code to the target offset. Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh --- bsd-user/aarch64/target_arch_sigtramp.h | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_sigtramp.h diff --git a/bsd-user/aarch64/target_arch_sigtramp.h b/bsd-user/aarch64/target_arch_sigtramp.h new file mode 100644 index 0000000000..8cdd33b621 --- /dev/null +++ b/bsd-user/aarch64/target_arch_sigtramp.h @@ -0,0 +1,48 @@ +/* + * ARM AArch64 sigcode for bsd-user + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_SIGTRAMP_H +#define TARGET_ARCH_SIGTRAMP_H + +/* Compare to ENTRY(sigcode) in arm64/arm64/locore.S */ +static inline abi_long setup_sigtramp(abi_ulong offset, unsigned sigf_uc, + unsigned sys_sigreturn) +{ + int i; + uint32_t sys_exit = TARGET_FREEBSD_NR_exit; + + uint32_t sigtramp_code[] = { + /* 1 */ 0x910003e0, /* mov x0, sp */ + /* 2 */ 0x91000000 + (sigf_uc << 10), /* add x0, x0, #SIGF_UC */ + /* 3 */ 0xd2800000 + (sys_sigreturn << 5) + 0x8, /* mov x8, #SYS_sigreturn */ + /* 4 */ 0xd4000001, /* svc #0 */ + /* 5 */ 0xd2800028 + (sys_exit << 5) + 0x8, /* mov x8, #SYS_exit */ + /* 6 */ 0xd4000001, /* svc #0 */ + /* 7 */ 0x17fffffc, /* b -4 */ + /* 8 */ sys_sigreturn, + /* 9 */ sys_exit + }; + + for (i = 0; i < 9; i++) { + tswap32s(&sigtramp_code[i]); + } + + return memcpy_to_target(offset, sigtramp_code, TARGET_SZSIGCODE); +} +#endif /* TARGET_ARCH_SIGTRAMP_H */ From patchwork Mon Jun 17 18:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A2925C2BA1A for ; Mon, 17 Jun 2024 19:02:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZI-0006OR-1v; Mon, 17 Jun 2024 14:59:04 -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 1sJHZF-00066G-Vv for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:02 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZE-00052I-2p for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:01 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-705c424ebbbso4397898b3a.1 for ; Mon, 17 Jun 2024 11:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650738; x=1719255538; 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=u9i4EEFGzjqehEnuQgpeD/IRBLzE2eNmHoKEYKqac6c=; b=cC7AVQI9BY89JyQruEmw0ngEt3KPq9Ax5t0zUlyeqsW8jLotXzxmRK/DuvYeP6czA7 zmarIjQFBvginAjI2pt8Iv8bx9TghY2iG7iHJL+M2C5IM0wNjVhB6q9D4ychiBa6Pn0k /QDRKuu2WQm6P8TWokko9/kZHWaVLdiHDQI+akETEofbxO0VMP98v+om3A6QtvpbgVtZ xCHFiyVVIpYh9Fxr6jMkA3HGi/ByA2Ugr0OhAxnVWbFTyKocWh9KRR/4Euhfm3TDCKPe WleuRJLR+S+hrl2g3vHlaATy0JAGJupKRUeNvS6lt56Af0CuorIj0E5t++bakWmUfbsF v73w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650738; x=1719255538; 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=u9i4EEFGzjqehEnuQgpeD/IRBLzE2eNmHoKEYKqac6c=; b=Af53MIcxSYt4jLE6e8V+EdVwEaUOpbaJnvn80HyeXwBSoPU7Uou58K4qJ8C9wRjVxv YbBr1yy8bQodZstS8pe6V1/aoZHsfUBUuohDMGp22IBvSX2IwwM5buoUWqrXIeZZooBg j9GIhqNqaGyLGTK7Ba4mfxZsQZszXIa6wCSJO4RBbf3qe5trsEDzqcc/3eNSakV7pdxl Nf+eQCM5/Q+G4xvFM+jfSvWMzTu/FEF54+0znGQwYw1O4iAp5ENec0DUHZDW0yVZp79p 4TGaI4IWuKK91xNEkAGlXw/8GqTHgniTvQ0aLy0ciW4peOBQS7KmZ1LCIyudr8U/4HbQ E9bQ== X-Gm-Message-State: AOJu0Yz2ptA4t9cn2KlAe+C9FNTtMqdOLkAvT4CvPxbBgK8X36zAUycu kYc+YLmJi7CeU/dfNVIdtsmdtJh13s2ToG4Ut9LK+N9WShgnbHMfmsW6q9z8SU0= X-Google-Smtp-Source: AGHT+IEHwtnhPtyCvr43fEjeDcaZ2ZaNSt2DkRJejf5UjglIp3v8tI0FRHPusVUEZmDp2CoFiEAQ8A== X-Received: by 2002:aa7:8c0f:0:b0:705:b0aa:a6bf with SMTP id d2e1a72fcca58-705d710501bmr13230699b3a.2.1718650738239; Mon, 17 Jun 2024 11:58:58 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:58:58 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 18/23] Add ARM AArch64 specific signal definitions for bsd-user Date: Tue, 18 Jun 2024 00:27:59 +0530 Message-Id: <20240617185804.25075-19-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Defined register indices and sizes,introduced structures to represent general purpose registers, floating point registers, and machine context Signed-off-by: Stacey Son Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Co-authored-by: Warner Losh --- bsd-user/aarch64/target_arch_signal.h | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 bsd-user/aarch64/target_arch_signal.h diff --git a/bsd-user/aarch64/target_arch_signal.h b/bsd-user/aarch64/target_arch_signal.h new file mode 100644 index 0000000000..df17173316 --- /dev/null +++ b/bsd-user/aarch64/target_arch_signal.h @@ -0,0 +1,80 @@ +/* + * ARM AArch64 specific signal definitions for bsd-user + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARCH_SIGNAL_H +#define TARGET_ARCH_SIGNAL_H + +#include "cpu.h" + +#define TARGET_REG_X0 0 +#define TARGET_REG_X30 30 +#define TARGET_REG_X31 31 +#define TARGET_REG_LR TARGET_REG_X30 +#define TARGET_REG_SP TARGET_REG_X31 + +#define TARGET_INSN_SIZE 4 /* arm64 instruction size */ + +/* Size of the signal trampolin code. See _sigtramp(). */ +#define TARGET_SZSIGCODE ((abi_ulong)(9 * TARGET_INSN_SIZE)) + +/* compare to sys/arm64/include/_limits.h */ +#define TARGET_MINSIGSTKSZ (1024 * 4) /* min sig stack size */ +#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768) /* recommended size */ + +/* struct __mcontext in sys/arm64/include/ucontext.h */ + +struct target_gpregs { + uint64_t gp_x[30]; + uint64_t gp_lr; + uint64_t gp_sp; + uint64_t gp_elr; + uint32_t gp_spsr; + uint32_t gp_pad; +}; + +struct target_fpregs { + __uint128_t fp_q[32]; + uint32_t fp_sr; + uint32_t fp_cr; + uint32_t fp_flags; + uint32_t fp_pad; +}; + +struct target__mcontext { + struct target_gpregs mc_gpregs; + struct target_fpregs mc_fpregs; + uint32_t mc_flags; +#define TARGET_MC_FP_VALID 0x1 + uint32_t mc_pad; + uint64_t mc_spare[8]; +}; + +typedef struct target__mcontext target_mcontext_t; + +#define TARGET_MCONTEXT_SIZE 880 +#define TARGET_UCONTEXT_SIZE 960 + +#include "target_os_ucontext.h" + +struct target_sigframe { + target_siginfo_t sf_si; /* saved siginfo */ + target_ucontext_t sf_uc; /* saved ucontext */ +}; + +#endif /* TARGET_ARCH_SIGNAL_H */ From patchwork Mon Jun 17 18:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1AE9BC27C79 for ; Mon, 17 Jun 2024 19:02:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZK-0006ob-Jg; Mon, 17 Jun 2024 14:59:06 -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 1sJHZI-0006PC-1p for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:04 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZG-00052S-5x for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:03 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-704313fa830so3580891b3a.3 for ; Mon, 17 Jun 2024 11:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650740; x=1719255540; 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=/fzCyFPBesaMQSSyYvgJsbwN+BoXVnIEOpNMGEgrfSA=; b=cOJVpLSf4tHTxdk8R0MeulafszTUDb6PhKpzy6kzmqhiEERVoeo/hE/ZvsBmjsC9sZ mY3/lW+mtgNWlYqu7aJTc72mV9/YGYuGduejpfTTV1QxP4ADnbQ2pFLMXjpiggWa0NfS Sduw+CJIC1MsLDvQHK7BfjQb3l7+Xh1A/Y23GiKj4SOe/CXQY+mmt3N3h/6VEkO8aMiZ AtVgI32USGVYuglne8y+ThRPRNuw9Juvapia4pIr89t4WqC6u52AkhqpGAa5xLaA7JAI 17WZqp6IVHgXSIZ314TKkImISEcJEl6hsMVgybfajlGalJ+ho8NsFcWZfAw3GiP1fvAd gTEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650740; x=1719255540; 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=/fzCyFPBesaMQSSyYvgJsbwN+BoXVnIEOpNMGEgrfSA=; b=GrO9XLVtHin2j+Bq4XNp69ActFOkEEMpaepA9fkBqo6r/WDkQjXd4iUH2F+TEfPoGY DkWaDOGpKZ99Ckt3+ysgQbwk1avHYt4LH4NJO9if4pneAX2ttUzNlMcPtvSXpHrk1h99 KZjfK2wFCj/wIkS95s0yObxycuJ6qYNgfZoXI/Ms1M9Tn9w8A9MfKdnOSwF3c3K4qEKJ RTlA0zSDbK0IrstJpPn4wqqSBQuSB/20Uv3hCe+zNlPFV5BCNI55k/U9Ihkw1jqYPwI6 Yq65dFBy/yOKHi7JNFyfb57V/EipMdRHMljpREpZDayTw4y504+QDnbE1BxBtaF7P4Vw 8oqw== X-Gm-Message-State: AOJu0YyEGQ6cXctnR/nAvwyqM1GpXAhaDNGun3LfGFlxCwdvc0xNF7dr VpqiVRv9PIxGXyjZGGJIG5JdS/CRTWvjZJF+BxkzZnbXWsUrIW4eahsYTTKPzn0= X-Google-Smtp-Source: AGHT+IF6tGJ9xx3DM92CnTu3HnUjTzh/CkVIZXgzKdcEiMU9asbEsj7uVr4kPJO5tMp1CK/HIHwNSQ== X-Received: by 2002:a05:6a20:2584:b0:1b7:8fe2:439f with SMTP id adf61e73a8af0-1bae828ee1cmr11545410637.38.1718650740317; Mon, 17 Jun 2024 11:59:00 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:59:00 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 19/23] Add ARM AArch64 signal trampoline argument setup for bsd-user Date: Tue, 18 Jun 2024 00:28:00 +0530 Message-Id: <20240617185804.25075-20-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son function to set up signal handler arguments it populates register values in `CPUARMState` based on the provided signal, signal frame, signal action, and frame address Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/signal.c | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 bsd-user/aarch64/signal.c diff --git a/bsd-user/aarch64/signal.c b/bsd-user/aarch64/signal.c new file mode 100644 index 0000000000..98861f9ab3 --- /dev/null +++ b/bsd-user/aarch64/signal.c @@ -0,0 +1,53 @@ +/* + * ARM AArch64 specific signal definitions for bsd-user + * + * Copyright (c) 2015 Stacey D. Son + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#include "qemu/osdep.h" + +#include "qemu.h" + +/* + * Compare to sendsig() in sys/arm64/arm64/machdep.c + * Assumes that target stack frame memory is locked. + */ +abi_long set_sigtramp_args(CPUARMState *regs, int sig, + struct target_sigframe *frame, + abi_ulong frame_addr, + struct target_sigaction *ka) +{ + /* + * Arguments to signal handler: + * x0 = signal number + * x1 = siginfo pointer + * x2 = ucontext pointer + * pc/elr = signal handler pointer + * sp = sigframe struct pointer + * lr = sigtramp at base of user stack + */ + + regs->xregs[0] = sig; + regs->xregs[1] = frame_addr + + offsetof(struct target_sigframe, sf_si); + regs->xregs[2] = frame_addr + + offsetof(struct target_sigframe, sf_uc); + + regs->pc = ka->_sa_handler; + regs->xregs[TARGET_REG_SP] = frame_addr; + regs->xregs[TARGET_REG_LR] = TARGET_PS_STRINGS - TARGET_SZSIGCODE; + + return 0; +} From patchwork Mon Jun 17 18:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 70B29C27C79 for ; Mon, 17 Jun 2024 19:03:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZL-0006sS-IS; Mon, 17 Jun 2024 14:59:07 -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 1sJHZJ-0006lx-UP for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:05 -0400 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZI-00052f-9b for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:05 -0400 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5b9778bb7c8so2381222eaf.3 for ; Mon, 17 Jun 2024 11:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650742; x=1719255542; 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=n1ZNdfkD296PLmViWh+uFcrYLRqsmpQNhISj3YpSETo=; b=FlxBEp5uYZi5wTWtUXvmY6o7v4IyY0MIsmnr4UtH5P5z/ZPRQCkEL+CzUODrE0je5W 4COD7VX955a/c6NCqoiIkLXWXWkFeLTsFXpfVguW4Kj18RIDwZEgi7SxcBB4uy2+ZAgc 7BNnWIkO9cs4p7zRUYp7AkPoJvrSDL8OAXB14qqIl00Xob6jW1AmhYah0ghEDp5q5h0i KEmFflVD6QlAjDWAQXEGqRZxP6OBKyHkZecnq16PzahMg8EGeInUn2X5CLEnvF2bBqQQ 4nAZu3oFKyR+SpP5agNLvPKVnPwd6zWUNBCuzlicy1hEjx2G+R3xK0Ck44sENv1xTz4X R9gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650742; x=1719255542; 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=n1ZNdfkD296PLmViWh+uFcrYLRqsmpQNhISj3YpSETo=; b=SH9DsDUviFJya/tlOrZ7/x2h/0Ns/dBigLotxHVEjA7rBNMD2zOpH1yt0lDodK3bde VMpoDT8v3AK1aKXjSjs+oGaJ3UHVKYZlFMaRrR2nYZ0X4vchPwaMwJzLdXP6Qe2a8olK ov3GtnoChaELLHRri1lNz1rdQw2b8qNO5Gbbwu08+SrR1G0zBSCFUIN4LGbH1/LRcdeh P54qdH61Y8yZ4b3hBlXM+3WlxQgMvSN6WKtZ56beE1yQI+eiZ86SZwkVjC/Y64ct04Vk TbU4OJ5HY9D8I+recGfGT8yO8mP2GaqyGFjSm67gpQL/58ugutTWjTPrZ21chgEPAo2K lGEg== X-Gm-Message-State: AOJu0YxIIIjN96hkkub3ZJ5zk2VelTP4StGNwMVfI2NTdMX9yS0H/8RN mYC4Jh7dxffSUVoZ8LJ6J0OEH8B57wpLWAKR3JgDxmREdM9ySH7bBU+wzE3fEhA= X-Google-Smtp-Source: AGHT+IFxH+j1o7/vxpe2HMoUYXx9INhS7yfHpU4MAT7kZbvuEvwWRDfq6OJzEFdH1ZkcPyT8erK01A== X-Received: by 2002:a05:6871:58d:b0:254:b74e:d654 with SMTP id 586e51a60fabf-2584290fc96mr11589378fac.22.1718650742565; Mon, 17 Jun 2024 11:59:02 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:59:02 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh , Kyle Evans Subject: [PATCH 20/23] Add get_mcontext function for ARM AArch64 in bsd-user Date: Tue, 18 Jun 2024 00:28:01 +0530 Message-Id: <20240617185804.25075-21-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c32; envelope-from=itachis6234@gmail.com; helo=mail-oo1-xc32.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- 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 98861f9ab3..ab3bf8558a 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; +} From patchwork Mon Jun 17 18:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CB119C27C79 for ; Mon, 17 Jun 2024 19:00:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZN-000754-DM; Mon, 17 Jun 2024 14:59:09 -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 1sJHZL-0006se-IS for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:07 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZK-00052t-0C for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:07 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7041053c0fdso3154840b3a.3 for ; Mon, 17 Jun 2024 11:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650744; x=1719255544; 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=RS52m5Rtxu4YyXgEJCG8PR37BWo6RzXvr9iG3e006XM=; b=R+LxjGRJO+FCfK44DNy8MDOvef7BoG9TPopd4fZzDzdYNKWtmxK8yVsF5OiwvaLwCX hMsYhQadgsfRtwsGXyzloHT1G3B8jJsaeg4JEetTEeof3bXtmMkbnSUib9jje7caG72h 2ZwZuEERHK6+38SoZeT08IhA/NARYtRNpNba/lDxWv7HA28lOqUMngtWvQjpbR06ytnj VsrVidBtF83VkxLV93ZC40y9fvBcHjegkcCFRhVT8XwtxgwzCiKn9hJfqoJdGGfSzwzZ Du4T3CXi0mNQkPdDPslMMOOJz3ATiQcPwA/rSgs6VJScADKA+C0p8T6JcRrCyX9yr3TF zSwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650744; x=1719255544; 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=RS52m5Rtxu4YyXgEJCG8PR37BWo6RzXvr9iG3e006XM=; b=qeTg3Tth8T8+7MIlrtjFAMjEcCA5DPcDzlaXGwTzlHd4jRcvtcGq8wgAhJEY+hEgg0 pzArk7TiaYle8bBHNLh17gOMyeNZFj5oSFMdU7CfF5yvZ3Ooyexhi8tDnRMcZaDAqney lYhi10IiDeEErsFgTIsN0ueCpS5P0dKX9K9/rNHtEC733vhDqF/Q25TyCbqGSwb1Ub0n Pc1O1JkJIenRnH/WjYl8anIETL55gKmc6pqAUWI3exmgsCa16/C6ncMaucjhuxpTZ/A2 X7+J+eIoLsTdRpSq1KD6vamtoSzoEFGMiv0XCiY1GxfEX1Ni1RcoE+RCW2UKc1yZVfJs 8yGQ== X-Gm-Message-State: AOJu0YzC9JINBb3E53nSUljnNihjnZrtlI2ECCSI2SlvDyTbADfEwT/J OrHgv3b6qAl9RhHJ+miy1rHLFsKUi5c3SQy0MY9As1vATdM/usVwSuGSat9svho= X-Google-Smtp-Source: AGHT+IFxIq0b/W3Kcd5CLPPgBeZea3DOF76vTJei6zxr/pk+elRk8k5TyyDtiiYYjMhkPj4K9/EmeA== X-Received: by 2002:a05:6a21:4603:b0:1b5:d172:91e8 with SMTP id adf61e73a8af0-1bae800c427mr10780039637.49.1718650744396; Mon, 17 Jun 2024 11:59:04 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:59:04 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Ajeet Singh Subject: [PATCH 21/23] Add setup_sigframe_arch function for ARM AArch64 in bsd-user Date: Tue, 18 Jun 2024 00:28:02 +0530 Message-Id: <20240617185804.25075-22-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Warner Losh The function utilizes the `get_mcontext` function to retrieve the machine context for the current CPUARMState Signed-off-by: Warner Losh Signed-off-by: Ajeet Singh Reviewed-by: Richard Henderson --- bsd-user/aarch64/signal.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bsd-user/aarch64/signal.c b/bsd-user/aarch64/signal.c index ab3bf8558a..43c886e603 100644 --- a/bsd-user/aarch64/signal.c +++ b/bsd-user/aarch64/signal.c @@ -81,3 +81,17 @@ abi_long get_mcontext(CPUARMState *regs, target_mcontext_t *mcp, int flags) return err; } + +/* + * Compare to arm64/arm64/exec_machdep.c sendsig() + * Assumes that the memory is locked if frame points to user memory. + */ +abi_long setup_sigframe_arch(CPUARMState *env, abi_ulong frame_addr, + struct target_sigframe *frame, int flags) +{ + target_mcontext_t *mcp = &frame->sf_uc.uc_mcontext; + + get_mcontext(env, mcp, flags); + return 0; +} + From patchwork Mon Jun 17 18:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2187EC2BA1A for ; Mon, 17 Jun 2024 19:03:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZP-0007MA-Bc; Mon, 17 Jun 2024 14:59:11 -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 1sJHZN-00076O-Io for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:09 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZL-00053B-Vn for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:09 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6f6a045d476so3601428b3a.1 for ; Mon, 17 Jun 2024 11:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650746; x=1719255546; 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=e0dzrd+ciGxDD70aSvLklNlGUxbQ7sp9bKeESCi0z6s=; b=ZgLXrQHe+kBKAnv0yVYDf8+3M4VcxEakv+QB0BXfBXK9n0E0+eaz4LFP03lFqx69q2 BdGBRlQQkUzeKE1YIsHQAtbGANgoiMH2/uoOSwY/lzjTj9y9H9DP6OOQFgoQmc275CzZ ohI2CDnHDrYEMrKNLLAUmBTaeP4Fky45a5m9ro9+6r5kY6SbJrYg/Imai2X1LPmnZXmD Nn+WLz/tqMzDxj/LdUE8ACyZuQNeSLgj5BjDmz009JKB9ZmbTpfvKVjPI4Ui2PG6deH/ LAVxKGPXg0KdrPPmV/U2OG0KL7ueszxYimffZBI5ugpl8popAMtrd11ZEPK7s/kLUsKg ol5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650746; x=1719255546; 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=e0dzrd+ciGxDD70aSvLklNlGUxbQ7sp9bKeESCi0z6s=; b=eA6l3suF6gv4Na3CNjbaUzBHi5yMIRWBJsA+PiHW+X2QKQdwZibRxd4LRzULqU0D+/ 9TrILj3ShckbQ4qzgrfgIWGnPsEZ0cHnegt7MRYmPIN13pIJs2KGC3d2xrXED9VEtCa6 8t1NuLGN0HepOsP23hv+AABDmdGpaKbWgNdISsHubPEI4EhTGGFxryYmHkVM3l0NG90x J3AbifoLH50Os4pIJNtgyA9JwRJZ2uAd70YjybY9dqhStlmgIyfQrgcbLKtrpwUPzM0E odvZzjyAuaDDxvZyzcmU81rig2nF3Sm1fLu9K0MptFWeD+KxvxYtQCr8KFZE9AT4n7DV vc0g== X-Gm-Message-State: AOJu0YxBqpO5ZNMreRoqxNRoUanvMqJ3oMVUBpHFcydKn3+828nOaAHs Df6Xxf1iR6UJ+wsJJQzhl21QIbHcjvgbd8uljesJdH8V6YeNVUirs+VrpifmGyc= X-Google-Smtp-Source: AGHT+IHbZvh05bXQRENKWWwIc+1eTP/T+hYJlk6yj29WGdDosCvzL6U+y0BZ64OOeQz0Eh9BLag8oQ== X-Received: by 2002:a05:6a20:4327:b0:1b7:406c:1081 with SMTP id adf61e73a8af0-1bae7e293e1mr10756463637.7.1718650746452; Mon, 17 Jun 2024 11:59:06 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:59:06 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 22/23] Add set_mcontext function for ARM AArch64 in bsd-user Date: Tue, 18 Jun 2024 00:28:03 +0530 Message-Id: <20240617185804.25075-23-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x433.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son The function copies register values from the provided target_mcontext_t structure to the CPUARMState registers Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh --- bsd-user/aarch64/signal.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bsd-user/aarch64/signal.c b/bsd-user/aarch64/signal.c index 43c886e603..13faac8ce6 100644 --- a/bsd-user/aarch64/signal.c +++ b/bsd-user/aarch64/signal.c @@ -95,3 +95,25 @@ abi_long setup_sigframe_arch(CPUARMState *env, abi_ulong frame_addr, return 0; } +/* + * Compare to set_mcontext() in arm64/arm64/machdep.c + * Assumes that the memory is locked if frame points to user memory. + */ +abi_long set_mcontext(CPUARMState *regs, target_mcontext_t *mcp, int srflag) +{ + int err = 0, i; + const uint64_t *gr = mcp->mc_gpregs.gp_x; + + for (i = 0; i < 30; i++) { + regs->xregs[i] = tswap64(gr[i]); + } + + regs->xregs[TARGET_REG_SP] = tswap64(mcp->mc_gpregs.gp_sp); + regs->xregs[TARGET_REG_LR] = tswap64(mcp->mc_gpregs.gp_lr); + regs->pc = mcp->mc_gpregs.gp_elr; + pstate_write(regs, mcp->mc_gpregs.gp_spsr); + + /* XXX FP? */ + + return err; +} From patchwork Mon Jun 17 18:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajeet Singh X-Patchwork-Id: 13701320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2777FC2BB85 for ; Mon, 17 Jun 2024 19:03:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHZR-0007c4-2a; Mon, 17 Jun 2024 14:59:13 -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 1sJHZP-0007Oc-Kt for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:11 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHZO-00053U-55 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:59:11 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-705cffc5bcfso4140877b3a.3 for ; Mon, 17 Jun 2024 11:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718650748; x=1719255548; 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=ZCkbHRdTwhc461NzNM6M57ey0Qv/rYSZmL7pQTY6Emk=; b=CRSuF4lX3V+2w0F6WQiY7PInPi0BvdzWLSS9u5t3lRFYCGkheWw6BVnEFUsmxz6MHZ 4W4XdcHsWtRWqD+ZVJxCvJu4qb3wmHaj/vHK9NQGPBAXIxUuMV3u+GHC2ObrLC3LqoOz YA8cTnjf/UU++fAksTWuL1TvPE3Sc9pUJF8d8lfeDgMiaPxTkScrx5ru+vtRmUl7wB8S 8sAmyUbqtxMKZNA7trBQ18A8bHpVwyRhKhQ+AyUmfXpFw/9mRfJfWMu1xc5UbG7T0Ile 8v5ew8iDtidjAfJf0HNIbNxrCtIOH/kYscNSDcsrBiJYz78q5ruco69+F1Z+Pth+S27r B+Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718650748; x=1719255548; 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=ZCkbHRdTwhc461NzNM6M57ey0Qv/rYSZmL7pQTY6Emk=; b=Vqa/LmH9JFj4ytMivSPYhyf223QOdVJsxx1gSnFvsMWSPE/zjPvU8kDbv0zuZJc/VU 3hcqiDc6nwqi1It3JmCb1O3gYYPLbi/zCWo/qVJGn159OpU1Lc5dhukA4mKuucTZ+O/c ZuF0BIYCCPCSAj/p0PxhFaB9lJt+0bSst88Zj5opUx1xyi4ZfORNFIeeijzGSu4cbaRc 0B5BLzMKIi7xZh5lLUJqTqzv7H0JoyMtOPMs3Yx+tVmeHhQYZEcCw5NMotMEdkXrgb/q 0cgRR21NUhzyghItlUxNXokZUexV92KRo7wbmVEQ9jrwxvSMTUV8YtKgjXrn56OK5V86 +vGQ== X-Gm-Message-State: AOJu0YwAJ+Us+ZnaqbtUnA/BQI2Jdwjncvl4bcMy77Ae/aCVW38pjGqt rVvweU+KO21UUpiU6i7djQJeQOO9XJRPcvnSthdGZkZUsM5W2TxxoNbZJmVrk7E= X-Google-Smtp-Source: AGHT+IFKZJvGXHGMopQTrmrydALK/e3vBu0P0zekshvTkWMZHZtxIxb6W2RUDjeoLBQa7uoU5gN1DQ== X-Received: by 2002:a05:6a20:1595:b0:1af:f514:6d96 with SMTP id adf61e73a8af0-1bae7ddafe4mr14498289637.16.1718650748527; Mon, 17 Jun 2024 11:59:08 -0700 (PDT) Received: from localhost.localdomain ([106.222.222.115]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb4aa4fsm7660637b3a.131.2024.06.17.11.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:59:08 -0700 (PDT) From: Ajeet Singh X-Google-Original-From: Ajeet Singh To: qemu-devel@nongnu.org Cc: Warner Losh , Ajeet Singh , Stacey Son , Ajeet Singh Subject: [PATCH 23/23] Add get_ucontext_sigreturn function Date: Tue, 18 Jun 2024 00:28:04 +0530 Message-Id: <20240617185804.25075-24-itachis@FreeBSD.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617185804.25075-1-itachis@FreeBSD.org> References: <20240617185804.25075-1-itachis@FreeBSD.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=itachis6234@gmail.com; helo=mail-pf1-x429.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stacey Son Function checks the processor state to ensure that the current execution mode is EL0 and no flags indicating interrupts or exceptions are set Signed-off-by: Stacey Son Signed-off-by: Ajeet Singh --- bsd-user/aarch64/signal.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bsd-user/aarch64/signal.c b/bsd-user/aarch64/signal.c index 13faac8ce6..ad81531ec5 100644 --- a/bsd-user/aarch64/signal.c +++ b/bsd-user/aarch64/signal.c @@ -117,3 +117,21 @@ abi_long set_mcontext(CPUARMState *regs, target_mcontext_t *mcp, int srflag) return err; } + +/* Compare to sys_sigreturn() in arm64/arm64/machdep.c */ +abi_long get_ucontext_sigreturn(CPUARMState *regs, abi_ulong target_sf, + abi_ulong *target_uc) +{ + uint32_t pstate = pstate_read(regs); + + *target_uc = 0; + + if ((pstate & PSTATE_M) != PSTATE_MODE_EL0t || + (pstate & (PSTATE_F | PSTATE_I | PSTATE_A | PSTATE_D)) != 0) { + return -TARGET_EINVAL; + } + + *target_uc = target_sf; + + return 0; +}