From nobody Tue Feb 10 19:49:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593076398; cv=none; d=zohomail.com; s=zohoarc; b=lk6haknNZ2iBNu22dWhKLCxBRhnfNJfE8tXjI8OpCSgx+5OLgdEM+taiT+ncfASfEk60NR33/fR9ZLEWEnjz+FYttFzN3Vi7w8R55aj6v/eDmnOzeZSSe7PjndcATQadSMY8ZdlE+cW+825fod9szwSvwiEi5JnLDiNGiA8mimo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593076398; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=48nt5I7xKRnSIABHv8IYltrw5Ckwnaul30MOqgcyGHg=; b=WRJcoIAbwTGwbjVE0VtoYnC8B30Ws6CHPOTRtM4iayyght7gYcA4WfPm+pRCUuYPaX1NzKDpMjDxdvT2fu+AKmfl2wrTiWMPJhWaOpduOVrkxfiCLpsOoGxHB0fwshD9dm9y0RHMBBUKkCzeu+hK16NNuqfODCayitP64XayrGc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593076398424662.963801222163; Thu, 25 Jun 2020 02:13:18 -0700 (PDT) Received: from localhost ([::1]:60146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joNwb-0005a1-1B for importer@patchew.org; Thu, 25 Jun 2020 05:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joNvn-0004k9-0J for qemu-devel@nongnu.org; Thu, 25 Jun 2020 05:12:27 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:57525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joNvk-0007GH-9V for qemu-devel@nongnu.org; Thu, 25 Jun 2020 05:12:26 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N18MG-1irYvu1hog-012av1; Thu, 25 Jun 2020 11:12:12 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] linux-user/sparc64: Fix the handling of window spill trap Date: Thu, 25 Jun 2020 11:12:04 +0200 Message-Id: <20200625091204.3186186-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200625091204.3186186-1-laurent@vivier.eu> References: <20200625091204.3186186-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:haf5ZDw9BhvA7sVK9J7LHOxjRS2OcWVOhVraSDvOYty0T9DyXCk iHqJF137STJlLtUp45GZqu5BsgkematCpRvZRIwzgq0TSP4bUI9wdWXOYndikTTKpd5qgZy ydagMwUAgG47/meF37U9aXMCnQh33dndi932NTVuzb7PzDJ8iEZaV7vN4ub27T13WRPbH0R 6uRAo3AZ1BgUajkl+eoCA== X-UI-Out-Filterresults: notjunk:1;V03:K0:UjNgFKmgUzU=:dbZVwy+5NGZvhx11cCG3C0 crKUgYUOZRaXUS9/+/tgVB6NeQaGkJ4/Laj9kuqidQNX2QCoWMm4vxJ7UB17nmi7M0r1RUVvH HFlr0eEgsmtOvwYeBwLJThASChJeqjkctG85/qV1QE8HTz48p1EjvlSAakjiEqRHcvgYS/Fy2 2RBRehMPta5uV+3NVaMNObuPIIysyVwCThDejssHrqjOJn+8ce480UnmxJV3jju3t40Z3jBqN shCCFnBr+Y1acRWvLvXBcLUlmZtb4zlmDhnjb5IPlO5ZAyyGJqiCEOuPyCG9SUNr6H5K5SfJ/ +mYp89LOZYJnDcgtTnFAj7lAFwpWJxdTgAHAlA5K/J++SinoVKEM0Vpj3oLW34DrDrThpjO2q M2GSb8ETbep3kn0bLF+HZT5a4ws5ALJbuH91NciokmZf12tKSim/QHDk7YcNOiVBmEhSz8TYv AoQNnUrdPY+//vnPXpZ54boJ41YqQxGDNnCMDn721rh8FKySWDFqEMqhoTAy4lzCBuwban4eJ XiPmUjTqeCSn1d8+2nmMLAxoRZin1q1WGltZeeD7wMQvq5SqQJwwsxmTw1TDztPdb/tYoqcHC yyqzkpqjE7VWMl6HxUMfp+Lpp7CxXabY6gXy477oo5YIBsY6QTYM1SIDEWXwxs52qacZt7w7o hqo1DK3a19zqu4rIrtwkelT7ArlI1cjCvlNBZy87e2Au7Ih63qBavCqljVaZTk9kg51n/WGJM xOAMNqhybjOGwcYsVrWpLVO3yTiEdGVFNoowQxSc/vlEBxrcLlDnHSoWajbEFutJVupcOrgXY IVm07cFsx96JxnV6GuFQkHlgTuqUWHLlaifyrVB/8c1JJB1HOQ= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 05:12:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giuseppe Musacchio , Mark Cave-Ayland , Riku Voipio , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: LemonBoy Fix the handling of window spill traps by keeping cansave into account when calculating the new CWP. Signed-off-by: Giuseppe Musacchio Signed-off-by: Laurent Vivier --- bsd-user/main.c | 6 +++++- linux-user/sparc/cpu_loop.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0bfe46cff93e..ac40d79bfaac 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -413,7 +413,11 @@ static void save_window(CPUSPARCState *env) save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); env->wim =3D new_wim; #else - save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); + /* + * cansave is zero if the spill trap handler is triggered by `save` and + * nonzero if triggered by a `flushw` + */ + save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); env->cansave++; env->canrestore--; #endif diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7645cc04ca73..02532f198df8 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -69,7 +69,11 @@ static void save_window(CPUSPARCState *env) save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); env->wim =3D new_wim; #else - save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); + /* + * cansave is zero if the spill trap handler is triggered by `save` and + * nonzero if triggered by a `flushw` + */ + save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); env->cansave++; env->canrestore--; #endif --=20 2.26.2