From nobody Sun Oct 12 08:18:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569871942; cv=none; d=zoho.com; s=zohoarc; b=dVF8ftjYK2qecwl46TFBUyvTEU2xZLcuT4kOMlTh3Y6okr8rJk/Oj912A5CAm/5KF3PBjdLBo5bORvxOqzQd8pa50oAwop45ghekcTpRaz+WpzA+8ASyGIo8nygAx6q9k6eSYpko0aUft7MbHHI1Nt4z+Wldb3zTj1IjKUc2hMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569871942; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=6VIxvhctHYn2HNudFB87sMQ9fY/awxBLo6cIK/aR/R0=; b=fx+8x1pHQ9K9CT8kEkb7TGDHwvNH+7qrOJ74hif2eL2ZkQY5B9eL76QkTW03nTWWe/w8kpJbNin/OhxzNvZ9ETlqpDfBy7vveKsdhuQguEOerGOD2S2fuPtPp7m3+Hj/tBe+9I6/JZQLZg9v3g2N636/raoiAeoMef5/JKpylow= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569871941930993.4092614006026; Mon, 30 Sep 2019 12:32:21 -0700 (PDT) Received: from localhost ([::1]:56362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF1PA-00030a-Pr for importer@patchew.org; Mon, 30 Sep 2019 15:32:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38334) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF1MX-0001Wo-GC for qemu-devel@nongnu.org; Mon, 30 Sep 2019 15:29:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iF1MV-00068A-Hr for qemu-devel@nongnu.org; Mon, 30 Sep 2019 15:29:37 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:38541) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iF1MV-00067I-6j for qemu-devel@nongnu.org; Mon, 30 Sep 2019 15:29:35 -0400 Received: by mail-pf1-x444.google.com with SMTP id h195so6160105pfe.5 for ; Mon, 30 Sep 2019 12:29:34 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id l189sm18330145pgd.46.2019.09.30.12.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 12:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=6VIxvhctHYn2HNudFB87sMQ9fY/awxBLo6cIK/aR/R0=; b=fT2RtDL7jzboIO3JgHW4S0G208NT1qzYITZ/YwugSaaVD++lkNGVrJqhWpZh7qFaf4 4GeFA8TEdT7/8aPigXGqVKBs9abeC9LLyEWnyjKKrRIl7gx6cuzNwH0IfSeWFT0y/Jow iBx3dKLWg+tPntXMpqs7FXPXwlR89zYAqG/ePLTKUIg6sSA86lVfT0NCahZ9+zzK0vEp iPZklwOjkzFSrbTKSRjsJGQprv9jniSQLsnA8L7gPBNRL4A4cPRKDri0iUwOs/jElSaM kN8mvn8AWo4S7DxHBc2VbnTuq9n2wURRVDDCMcvRBtLbzZ7qAUzwZIy+RgLd30cK2IRJ 1/9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6VIxvhctHYn2HNudFB87sMQ9fY/awxBLo6cIK/aR/R0=; b=EHYpZXh6D16dL+c4PsDnZHqF9LrseM+utdGYiZWrqUsMVQIuDohSfOv/UISMTS4USj ic4hW6pDQNeeGFddhgAOl06zr8IvkEs+cihg2G2N6cG3HtgoHvr0k0CA8vv0yhD5Adut TgQciLUw3Jh10ybSlSLDDy9dZ7gfsTSWb1YuKoOwa01AsmFtgKkRCG89D0+XTohXz4bA tnJy8wVL+awgrBsZ4FkDUScbp9NOjrz0DOjIYvIEsvg7N8Bla1isl+X4o6aXVblB1eqY AHjv/jKuRYH67r3i0Gl0ilv9mIt80U+hTUlxa4BZVVhkP0cPH7pAXzBVhVF0hK7dsmEt 9GqA== X-Gm-Message-State: APjAAAU0L7V111duJF65ARkcOmj4Wj+kUku4FAAsqlDJAIOm1likUUg9 DNdYTz+1DDLZ3pBQyReRe+zn1O0LWkw= X-Google-Smtp-Source: APXvYqyoAw48T/NaiPe3NQQXH8BzZtGtW8vH7vMZ8ivxJ6Iqf19Op3rIHmPdhcIcoEjt3zqqIvFnTg== X-Received: by 2002:aa7:81d3:: with SMTP id c19mr23340598pfn.85.1569871773196; Mon, 30 Sep 2019 12:29:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH] user-exec: Do not filter the signal on si_code Date: Mon, 30 Sep 2019 12:29:31 -0700 Message-Id: <20190930192931.20509-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 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: laurent@vivier.eu, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is a workaround for a ppc64le host kernel bug. For the test case linux-test, we have an instruction trace IN: sig_alarm ... IN: 0x400080ed28: 380000ac li r0, 0xac 0x400080ed2c: 44000002 sc IN: __libc_nanosleep 0x1003bb4c: 7c0802a6 mflr r0 0x1003bb50: f8010010 std r0, 0x10(r1) Our signal return trampoline has, rightly, changed the guest stack page read-only. Which, rightly, faults on the store of a return address into a stack frame. Checking the host /proc/pid/maps, we see the expected state: 4000800000-4000810000 r--p 00000000 00:00 0 However, the host kernel has supplied si_code =3D=3D SEGV_MAPERR, which is obviously incorrect. By dropping this check, we may have an extra walk of the page tables, but this should be inexpensive. Signed-off-by: Richard Henderson --- FWIW, filed as https://bugzilla.redhat.com/show_bug.cgi?id=3D1757189 out of habit and then https://bugs.centos.org/view.php?id=3D16499 when I remembered that the system is running Centos not RHEL. --- accel/tcg/user-exec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 71c4bf6477..31ef091a70 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -143,9 +143,12 @@ static inline int handle_cpu_signal(uintptr_t pc, sigi= nfo_t *info, * for some other kind of fault that should really be passed to the * guest, we'd end up in an infinite loop of retrying the faulting * access. + * + * XXX: At least one host kernel, ppc64le w/Centos 7 4.14.0-115.6.1, + * incorrectly reports SEGV_MAPERR for a STDX write to a read-only pag= e. + * Therefore, do not test info->si_code. */ - if (is_write && info->si_signo =3D=3D SIGSEGV && info->si_code =3D=3D = SEGV_ACCERR && - h2g_valid(address)) { + if (is_write && info->si_signo =3D=3D SIGSEGV && h2g_valid(address)) { switch (page_unprotect(h2g(address), pc)) { case 0: /* Fault not caused by a page marked unwritable to protect --=20 2.17.1