From patchwork Tue Dec 21 02:50:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526586 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp4673668imb; Mon, 20 Dec 2021 18:51:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXfUO4AwJuPOAAe0+7d7Qp+1fovZ7Kxqxv6vhUXwl1pjyauyRoMofY9OBzwjLvRDiBFOzl X-Received: by 2002:a25:2c85:: with SMTP id s127mr1698708ybs.250.1640055098495; Mon, 20 Dec 2021 18:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640055098; cv=none; d=google.com; s=arc-20160816; b=kLVbsB90BdYokD9d/IUGEq+IV38+Bn+6rWvoCp0/Vkw8T9fLrpkoae1nAskOKsHWaD UUL8tAXulE9tRlwyKMov1dg60iMSQ2qzc2Q72n4EejiuEg/hJ6YTGUB6+UONRda/OoIa CbI+7Yw/fsqIaxRU99F5pYgh8UBWGqbIwbKHHhiMp0lVNFa/aOVl74/pco0R8imKgXzl +tUru2TNJvxcSnnoHka3C10DPLarNnBZstHqcLpZ+g01HCiBhJuNgS1Sni0h0CGsOgBX nzT+fk9ifj/OpYKnQ5TpzwptDWrQ1ej1tnX4fHKbpsxHZsMBgeTzK+aAsMqM9gv45GQI +blQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=F9yEwPrmR9xpxjbUMZcvWlIm4BrVKkXnEjUbM9qs6VM=; b=z9kvSoIYZVwxJnEEeOGdIB+HucO4e0n/QOXs+JRXtqTiqm4vbUSJA34qt67opSFGMo bkgvjVHFQWBHA39pEFAd5Y6low6Y9AqdjdimFY3Ef8j9VVo8ihrs7Au7Y+qHqRTV9UKw BHm7ZYh8sZWHSm919kAsRGThr6zlGGO7F6svHG+kuhH5XfjVCOiU8m9MCPfrk3hFMelq nX6WRNreP1H1dAfxhPEs4YXt0Z3lnqpBHH6A2So2Rs8sR33ayJTRxhGte/y0vFsF0YCs n4519MguK6zuBGihsqDREQ0KRAt8X5pfcXXgO5AX2wGGMYJexSqBPqFRLMWsh9nhQE0t OUjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8TZnIfL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d124si23972792ybd.289.2021.12.20.18.51.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Dec 2021 18:51:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8TZnIfL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzVFa-00053N-0I for patch@linaro.org; Mon, 20 Dec 2021 21:51:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzVEM-0003hK-5o for qemu-devel@nongnu.org; Mon, 20 Dec 2021 21:50:22 -0500 Received: from [2607:f8b0:4864:20::52d] (port=44924 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzVEK-0000C3-6z for qemu-devel@nongnu.org; Mon, 20 Dec 2021 21:50:21 -0500 Received: by mail-pg1-x52d.google.com with SMTP id m15so11016644pgu.11 for ; Mon, 20 Dec 2021 18:50:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F9yEwPrmR9xpxjbUMZcvWlIm4BrVKkXnEjUbM9qs6VM=; b=D8TZnIfLabC0AmpSuzjzLdtK0EWfT+HTror9COebxvSfFoRHkl1YGeEJyI0Wcpfxoe IjuOb7QEmLSp11PIsk2KsMdkFDSfGPVhPXzinYzwQ9nj9kdliJM877tGBU4w1hWmdlzZ QeVL4YaKjXkFb4YSMLWUMq8Pjwf8DaXbasXAJFu+jy6PzL47peoKYbrfqeZ96KHZrl40 qz/WnFLdnLd91tD4vn9cbOjKyswNDyKmZu55rpooIwdXXAelgnG+lsUWceOF8ft9vXEB SlCbkAn37tnMHG5PN+UAU51JThg43Ncg9iOLetSiURpF0e0DD7ZcjLh5zAlw2ySM9NUe wNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F9yEwPrmR9xpxjbUMZcvWlIm4BrVKkXnEjUbM9qs6VM=; b=HP4xgqSYHhllqXq6UHMdsyAFqPSEtNhWDzFb0FK8Xlrh8CByrPiclAz2saZZFw+EsF Z2q81Ye5FFDkXXEXcRi/+R3ly23l1D9J3SAocIAVfCBfhcTT00sPpQf7enoJDg0cDDjL vFOs84UOuPQ9vU8Y/07IfL5Uh4Op9C3dBy7t3ZhRw3p4MRJamj/ey2hKxbN2GzX53t7M 3mLTpKW/9qh+mb4S6iBKiRdyZlQB/16jFagJvQ73Q2XfzwYS6d6Eiu+P125fYMk2yaia KPIvmQhCbHvNAJLZsdnh30LKdCnMSRRvC++izXsuqZ5ljieoERWvtx8Njjj/87Io6o3G mexA== X-Gm-Message-State: AOAM530mPv2zzbIvAsxw3B5fWS/I7t0ok8JdEF6JLbVN1R6/CV31I+Fa ajkJAV7pZfpRIfp1FxQql/zaNEEU+5tY0g== X-Received: by 2002:a65:6411:: with SMTP id a17mr1043081pgv.203.1640055018869; Mon, 20 Dec 2021 18:50:18 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id bg23sm694025pjb.24.2021.12.20.18.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 18:50:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] linux-user/nios2: Fix EA vs PC confusion Date: Mon, 20 Dec 2021 18:50:10 -0800 Message-Id: <20211221025012.1057923-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221025012.1057923-1-richard.henderson@linaro.org> References: <20211221025012.1057923-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The real kernel will talk about the user PC as EA, because that's where the hardware will have copied it, and where it expects to put it to then use ERET. But qemu does not emulate all of the exception stuff while emulating user-only. Manipulate PC directly. This fixes signal entry and return, and eliminates some slight confusion from target_cpu_copy_regs. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/nios2/cpu_loop.c | 5 +---- linux-user/nios2/signal.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index de0fc63e21..1e93ef34e6 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -155,9 +155,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->regs[R_SP] = regs->sp; env->regs[R_GP] = regs->gp; env->regs[CR_ESTATUS] = regs->estatus; - env->regs[R_EA] = regs->ea; - /* TODO: unsigned long orig_r7; */ - - /* Emulate eret when starting thread. */ env->regs[R_PC] = regs->ea; + /* TODO: unsigned long orig_r7; */ } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index adbffe32e3..20b65aa06e 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_RA], &gregs[23]); __put_user(env->regs[R_FP], &gregs[24]); __put_user(env->regs[R_GP], &gregs[25]); - __put_user(env->regs[R_EA], &gregs[27]); + __put_user(env->regs[R_PC], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); } @@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, __get_user(env->regs[R_GP], &gregs[25]); /* Not really necessary no user settable bits */ __get_user(temp, &gregs[26]); - __get_user(env->regs[R_EA], &gregs[27]); + __get_user(env->regs[R_PC], &gregs[27]); __get_user(env->regs[R_RA], &gregs[23]); __get_user(env->regs[R_SP], &gregs[28]); @@ -181,7 +181,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[4] = sig; env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->regs[R_EA] = ka->_sa_handler; + env->regs[R_PC] = ka->_sa_handler; unlock_user_struct(frame, frame_addr, 1); }