From patchwork Tue Jan 23 10:24:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 765188 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp1528565wrx; Tue, 23 Jan 2024 02:24:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDesFR8/C1vSXeVrJgS4pqBvaVgmSPvIxVg7hrq6TEPY46l4CBg/U3Fku9JsgVDXqC0Qq+ X-Received: by 2002:a81:6c8a:0:b0:5ff:cb49:5f47 with SMTP id h132-20020a816c8a000000b005ffcb495f47mr3601016ywc.28.1706005497500; Tue, 23 Jan 2024 02:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706005497; cv=none; d=google.com; s=arc-20160816; b=oAMXdMPjs0hKt7bL/le5laqHpnUP/kn1HiwhIgFVajntTurp2QQ7hyidgId03MmpTw BRrK3jlz0fM+SDsG5OTNH8uU8Rp5gwdbOZxy8Uk6XMWiIl3MCm7RENkiITTlWfdCSRrG xMuoc27Vw9SyPwWl27yhokehf/H++m21U9BLbFAVT2wmE4uPNk93QBLF0SYi+Umb8JH9 XsIXIyHUO1656PfvOsKWVZoxm71iG5FIhbUvgw5W4pVlaSR12ZsCf91sm4sWmhMr3KDw YaDcmZYiAMliPv1WfdHywsPVu+AYpSAcpnZ3UQ9yoXTRjs5hvsvOTmYrY+ejL6nMRW2Y 5Pyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CJwQ5ZzhzO00+g0UGwDiX0qf7mCAm8ExrbTS/sZFCpk=; fh=hnz9pG8FMO+tm2obdPt4dhu6yqTXgplMe/ouKJtcwQs=; b=X5uaIzGiUEs0JmTj361ndVBcdyyI9zLLOZAeFw5V8JCCnWAm9d1D2nUTPu4iJCcfgM yk3V1jT7RQN2PFGN8zz5fcnNXHgIv8CKtbo7sspsueJwkrF8cWr7K5IjGtBs8Rj/Kom/ 06X1PdMQK2w88uU0ge9INRzVmYJ6Z86oCgsWBZaBKtfZzrd4mg0OwopcgfVKr/QDRrOu egw3WhYLbxZyv+JjZfNcprhMLkfehQh5ePZKPQPHLXL2/Mh9Z3Rjuah7P+NaRRyFlNPl XFpp5l/5kQBcoyTvDiNoggrDClTz5Gx73w59ZJgZfKmnHP8JNslBIWmtRZBPivxrt45d iCjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wiw55JUk; 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 y15-20020a05622a004f00b0042a30cac628si7116965qtw.380.2024.01.23.02.24.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2024 02:24:57 -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=wiw55JUk; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSDxH-0000OO-JH; Tue, 23 Jan 2024 05:24:31 -0500 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 1rSDxF-0000Ni-Jn for qemu-devel@nongnu.org; Tue, 23 Jan 2024 05:24:29 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rSDxD-0004ct-GP for qemu-devel@nongnu.org; Tue, 23 Jan 2024 05:24:29 -0500 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6ddf1e88e51so3178686a34.0 for ; Tue, 23 Jan 2024 02:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706005466; x=1706610266; 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=CJwQ5ZzhzO00+g0UGwDiX0qf7mCAm8ExrbTS/sZFCpk=; b=wiw55JUkKxb5xsomSITLXgCKPi9KYKb6IFzsuwR0Tql8TdZSBa1BZxvpKdlcu1/2i/ RdTNxlnPh0WrSlm9Ma0czuaKYneKt8fBPgXY8VGSzSjJ48tEEQamGXs76n3SfrVMa8k5 LvhYRgQ+uITp0leEThapAYfLFBpfUoIPL+EAk4Az9Q3qFGLtiIeZ3Y0WbtsXCmNrngdv KGbcFv42/kRFKIVNQm92VdX60Lif522oVxoesYPH2fk8tuXs1JkGZYf1UYHCEqteAbBk sZzSttbqq5Eiiay11pQYnDWtrSlRPRZdkFYEvlV1Qu/ijZ2urwqUG3vgta//Hu3X4piJ VU1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706005466; x=1706610266; 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=CJwQ5ZzhzO00+g0UGwDiX0qf7mCAm8ExrbTS/sZFCpk=; b=ie2bAp2b233rw++bMA98DNTtHsu4+2iNyi1s85OpIuUN/u8JUx2YQNiV4Yy+QbFxnd nL56BmRdO1xntfHUyVrkJj/nKNAa4Ial4JIA+cLiS5mhZF+4Pck+M1i2g3yTzKxR3MUd DrmpoaUZ3HzaR8c5F3JzgIbdB9d56QmuBv0QG2Bjq6Btxds3NBo8iIMMjh8ZP2astRz7 Du2eIqbcUdQGr/hKcsj/StNwGh61dOVLsrwOH7Ex5RBwyWexYHPXQ7dtwkcl9LRIaAmO XukNhyYbve/uIJoa7PtNPA7+zIATENMqI0yyjWBDpObuto9SBM9zEGGJjjEJJzB9nefB zQ0g== X-Gm-Message-State: AOJu0Yyj+OkhLaGAQlDdXNKT90iz7A66Vhgls8ZPVBfsJMxWvBSTzJgo x3PUXo6Ybi37Jz4bdcqTKN6zzH+JjHwVqeUxvMPlDmER7UKFz9YI3z2uGEHeZVIBbI41BU0Cbia Pogo= X-Received: by 2002:a05:6359:6241:b0:175:c293:68d0 with SMTP id sd1-20020a056359624100b00175c29368d0mr2665045rwb.60.1706005466146; Tue, 23 Jan 2024 02:24:26 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-b8a0-0408-58be-7d2e.static.ipv6.internode.on.net. [2001:44b8:2176:c800:b8a0:408:58be:7d2e]) by smtp.gmail.com with ESMTPSA id d8-20020a62f808000000b006d9ce7d3258sm11072408pfh.204.2024.01.23.02.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 02:24:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Robbin Ehn , Palmer Dabbelt Subject: [PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS Date: Tue, 23 Jan 2024 20:24:07 +1000 Message-Id: <20240123102412.4569-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123102412.4569-1-richard.henderson@linaro.org> References: <20240123102412.4569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Robbin Ehn Commit f4e1168198 (linux-user: Split out host_sig{segv,bus}_handler) introduced a bug, when returning from host_sigbus_handler the PC is never set. Thus cpu_loop_exit_restore is called with a zero PC and we immediate get a SIGSEGV. Signed-off-by: Robbin Ehn Fixes: f4e1168198 ("linux-user: Split out host_sig{segv,bus}_handler") Reviewed-by: Palmer Dabbelt Message-Id: <33f27425878fb529b9e39ef22c303f6e0d90525f.camel@rivosinc.com> Signed-off-by: Richard Henderson --- linux-user/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index b35d1e512f..c9527adfa3 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -925,7 +925,7 @@ static void host_sigsegv_handler(CPUState *cpu, siginfo_t *info, cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc); } -static void host_sigbus_handler(CPUState *cpu, siginfo_t *info, +static uintptr_t host_sigbus_handler(CPUState *cpu, siginfo_t *info, host_sigcontext *uc) { uintptr_t pc = host_signal_pc(uc); @@ -947,6 +947,7 @@ static void host_sigbus_handler(CPUState *cpu, siginfo_t *info, sigprocmask(SIG_SETMASK, host_signal_mask(uc), NULL); cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); } + return pc; } static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) @@ -974,7 +975,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) host_sigsegv_handler(cpu, info, uc); return; case SIGBUS: - host_sigbus_handler(cpu, info, uc); + pc = host_sigbus_handler(cpu, info, uc); sync_sig = true; break; case SIGILL: