From patchwork Mon Aug 22 10:31:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 1668695 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MB7yD1KLkz1yg3 for ; Mon, 22 Aug 2022 20:34:12 +1000 (AEST) Received: from localhost ([::1]:47004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQ4l0-00056y-1C for incoming@patchwork.ozlabs.org; Mon, 22 Aug 2022 06:34:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQ4it-0004gg-LB; Mon, 22 Aug 2022 06:31:59 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]:56075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQ4ir-00053b-Pd; Mon, 22 Aug 2022 06:31:59 -0400 Received: from [192.168.16.115] (helo=iris.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1oQ4gz-00GyKO-Fs; Mon, 22 Aug 2022 12:31:24 +0200 From: "Denis V. Lunev" To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Helge Deller Subject: [PATCH 1/2] target/hppa: Fix proberi instruction emulation for linux-user Date: Mon, 22 Aug 2022 12:31:30 +0200 Message-Id: <20220822103131.381075-2-den@openvz.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220822103131.381075-1-den@openvz.org> References: <20220822103131.381075-1-den@openvz.org> MIME-Version: 1.0 Received-SPF: pass client-ip=130.117.225.111; envelope-from=den@openvz.org; helo=relay.virtuozzo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller The proberi assembler instruction checks the read/write access rights for the page of a given address and shall return a value of 1 if the test succeeds and a value of 0 on failure in the target register. But when run in linux-user mode, qemu currently simply returns the return code of page_check_range() which returns 0 on success and -1 on failure, which is the opposite of what proberi should return. Fix it by checking the return code of page_check_range() and return the expected return value. The easiest way to reproduce the issue is by running "/lib/ld.so.1 --version" in a chroot which fails without this patch. At startup of ld.so the __canonicalize_funcptr_for_compare() function is used to resolve the function address out of a function descriptor, which fails because proberi (due to the wrong return code) seems to indicate that the given address isn't accessible. Signed-off-by: Helge Deller --- target/hppa/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index cd304f051e..fbd80e4248 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -170,7 +170,7 @@ target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr, uint32_t level, uint32_t want) { #ifdef CONFIG_USER_ONLY - return page_check_range(addr, 1, want); + return (page_check_range(addr, 1, want) == 0) ? 1 : 0; #else int prot, excp; hwaddr phys;