From patchwork Mon Sep 30 19:29:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174773 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp7554857ill; Mon, 30 Sep 2019 12:30:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbpmRgC1xQt/hmAHTAqOVL5gGBbJsx2A6e/0/WXznVVttpwmwMbrjLRoth2UDiZF243xHJ X-Received: by 2002:a0c:f3c1:: with SMTP id f1mr22193256qvm.165.1569871816144; Mon, 30 Sep 2019 12:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569871816; cv=none; d=google.com; s=arc-20160816; b=Ng70qcJsYx4sFqks+bT0b1JRzUyXGvqfzP3qRgxpeWIa/rgxjBtrxsJgCSTeO6hYGQ imWTdwffmTPySdOK5aH4bymGXm3ZDNdX5Kr1KYhyMho9nSLDRONYwdDZwowXmyf04qxK ZxNcvxVH85mCMVVVETOUqmGGH38g6zNc2H3ZSiriChCDfcxUpFGRRcwffEcAEd2LHC+d 48qa8AQ7k+dmtQYpx72Pdx8wwE5gdAYzDVsN7V1ute1KHsScGcrMHR2/o1ueUIhRfJPL wOpn5sjBTW+pmSRbFEOeA9ux/vgtdE+oL94xZU+azXIuEVHIWkfUwqueL7z1MQlpdlk9 cWWQ== 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:message-id:date:subject:to:from :dkim-signature; bh=6VIxvhctHYn2HNudFB87sMQ9fY/awxBLo6cIK/aR/R0=; b=SYRN3t4P0Wbmzt5Nmmu5i+32+7E2S3cHhvV19ppAxuXiZzTgboo8HOBiXpT9IA1gU1 QV/3fpGQ7yT4NWszX/DgF6lCE1iOIHP7Ojcg7lOD1JG8J4OPdC3kuPz7qNDZTYLX2kPY aZn3ZvmpTkSq9NSJpRLOJcVx5hVXHiCkMVfqTkgewRLlQUrVeQKwPr4oVSxfIN0454j1 m46uo635++tnc6az7RknlLBzr2hgOArVRqNnibwcTR4wPmxiCEjRRYB+eiKQW/N7Aka5 Z329KP4uRo1cdVG4qHMDYpk3nS73AAPbHcWvinOkSrmpC8uGfQV1JxLpLrhN+h0LDcOf shsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fT2RtDL7; 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 128si10810395qkn.196.2019.09.30.12.30.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2019 12:30:16 -0700 (PDT) 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=fT2RtDL7; 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]:56346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF1N9-0001bO-55 for patch@linaro.org; Mon, 30 Sep 2019 15:30:15 -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) 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-Received: by 2002:aa7:81d3:: with SMTP id c19mr23340598pfn.85.1569871773196; Mon, 30 Sep 2019 12:29:33 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 == 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=1757189 out of habit and then https://bugs.centos.org/view.php?id=16499 when I remembered that the system is running Centos not RHEL. --- accel/tcg/user-exec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.17.1 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, siginfo_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 page. + * Therefore, do not test info->si_code. */ - if (is_write && info->si_signo == SIGSEGV && info->si_code == SEGV_ACCERR && - h2g_valid(address)) { + if (is_write && info->si_signo == SIGSEGV && h2g_valid(address)) { switch (page_unprotect(h2g(address), pc)) { case 0: /* Fault not caused by a page marked unwritable to protect