From patchwork Thu May 21 19:15:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 187094 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp1830586ilb; Thu, 21 May 2020 12:22:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpsd/ubks8fugqWW7jWIrqKHaO1HaAcXyOgA0QvVIBA2q3rcUZojvQ86BM7MNqxmkcRX20 X-Received: by 2002:a37:77c4:: with SMTP id s187mr12008172qkc.174.1590088943413; Thu, 21 May 2020 12:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590088943; cv=none; d=google.com; s=arc-20160816; b=bjjGSvtMhKu9d+Hlt1cTXl2DmmVl1YScte+R0gIMQhpC2mIlMgOdsqcAi7fG6Erotp y3UnyBctQH+Fsn18jT44TcPnKsK9UYqnHduE2tOui1OM7wqCC17PD5XtR+dU4D6+b3ZG x6OvKiMiT3SkxSorNgVe/zpuZixDS81dOsjz/Xz0VFxspvYj3w1EysPcRY5KDtDpIQeB fXe2T6C2Mk8jgccZn5xcgUqOBuhoBj7XQAUzgrfcvas1mESUCIgoCr+JSHE572iLT3gk Q9hXXjKYxtDeudZvURA/tTUMCZVxz42eqk7lTLW0CEiJt7ujFfyii92ab+sU9Ee4dJpr zv+A== 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:to:from :dkim-signature; bh=SO0tJgJgn/EVNKJE79ekFtYmNOY8AvESSw03LMos9hM=; b=gSd3cX/jDXgwJVCxsGehxaBhX5YUMQMrrI/0GXkhHKtn9+2+wL2LT7TDuUbc3vxiCw enx7ZDZldJPVb/07IL0VukoZKnLljbCwrxNLd4CeAppSZWT2wHZ0MM+hv/zsJqk4tmSr HAgVj1NDPHqY9tDLVn0jGtTVz+km1ji6+YjC9d1dNTedQbz0JXpWz2mIC6jcSYdTstgW ih6BlpwRMErzBrXlceRyunnQnNG3Z6YMKQT6RnQb6FgZ6UIMU41DZnGe251MhSZ4/Ma9 KSqiT1zQj367K/K2OGlbbBaxw2wX+hcR9MskBcaPNAgmWfnYjGXIgv9k1tR1edSI/7Oi velQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fzpyOZJL; 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 f185si3926614qke.306.2020.05.21.12.22.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 12:22:23 -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=fzpyOZJL; 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]:60532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbqlq-0005xQ-SM for patch@linaro.org; Thu, 21 May 2020 15:22:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbqg6-0002Cq-HF for qemu-devel@nongnu.org; Thu, 21 May 2020 15:16:26 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbqg5-0000Qt-DC for qemu-devel@nongnu.org; Thu, 21 May 2020 15:16:26 -0400 Received: by mail-wr1-x444.google.com with SMTP id x14so2390848wrp.2 for ; Thu, 21 May 2020 12:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SO0tJgJgn/EVNKJE79ekFtYmNOY8AvESSw03LMos9hM=; b=fzpyOZJLlKmK5Yy561WQO4BU1pOaw0uW4dwrKR88etF5OV4L+0or4c7Y9C/1reZIcQ m8E42WjQ+wtcsVEi5SVPNa0eQMrkVacIGPSWZWGoLrMYss5DxLAmWDUxry0yOdxzhUKJ sAxddE7qPzUTTUINDeccQvk8lxD13mnyxeUeguQkx919rWd5Hljz3g8MAd9TWicmR+a9 6dlXbEMRY52nqPWnlw3FOD/P6KQIDjHQhJGYyJdAntFLZEl5A50X8jeNJ8uJTrAyj3ig BQYFUg86XLeRQnOt++t/w3Is3R2wyFuTnE0MeR8esOJWQ5wMXGsE6rFJmG4wPhBJc02e mm0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SO0tJgJgn/EVNKJE79ekFtYmNOY8AvESSw03LMos9hM=; b=f2Ai+9rq/N1Smto+Hi3FQ2r2m/o99nT+xM28mW1QIu2KizobdZ4S57vX0DDjHtGS70 xtrygQpP0xWaWnS6LM6uvL30UUmVAp3zIyRIWlYhj7sTKERpnwRztpLYsnpJLTEHv0gJ eOc8eDL7bJ1eXMmIE3qxJ4mwQMIN27mCwC9QRE7gChO4gT0i9YyuamIOuHUIbESjlOa3 +gmWS4z9aZEH1uI0xeF8dA/StfOnD+9vg07CSE+gtpH5y5YEXL0cE43OVxNarj4eNL94 c2ulaMyrhFmAT+vPSKJZPs1DOY+Y2uobtcn0x+HjDX5zSa45PxP/dUyU8L7mTL/bzoqz mJAg== X-Gm-Message-State: AOAM532QC8wo9l5eoh16pKp+sTIlQkqiDpT1C3E5nwEA7O/99d4G6eIb q5Uca3iDzQsRQq0frvR1O2oanoOBcUh0dQ== X-Received: by 2002:adf:f007:: with SMTP id j7mr101079wro.294.1590088583667; Thu, 21 May 2020 12:16:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id z124sm7335100wmg.20.2020.05.21.12.16.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 12:16:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/29] linux-user/arm: Handle invalid arm-specific syscalls correctly Date: Thu, 21 May 2020 20:15:50 +0100 Message-Id: <20200521191610.10941-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200521191610.10941-1-peter.maydell@linaro.org> References: <20200521191610.10941-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_PASS=-0.001, URIBL_BLOCKED=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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The kernel has different handling for syscalls with invalid numbers that are in the "arm-specific" range 0x9f0000 and up: * 0x9f0000..0x9f07ff return -ENOSYS if not implemented * other out of range syscalls cause a SIGILL (see the kernel's arch/arm/kernel/traps.c:arm_syscall()) Implement this distinction. (Note that our code doesn't look quite like the kernel's, because we have removed the 0x900000 prefix by this point, whereas the kernel retains it in arm_syscall().) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20200420212206.12776-4-peter.maydell@linaro.org --- linux-user/arm/cpu_loop.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 025887d6b86..df8b7b3fa96 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -332,10 +332,32 @@ void cpu_loop(CPUARMState *env) env->regs[0] = cpu_get_tls(env); break; default: - qemu_log_mask(LOG_UNIMP, - "qemu: Unsupported ARM syscall: 0x%x\n", - n); - env->regs[0] = -TARGET_ENOSYS; + if (n < 0xf0800) { + /* + * Syscalls 0xf0000..0xf07ff (or 0x9f0000.. + * 0x9f07ff in OABI numbering) are defined + * to return -ENOSYS rather than raising + * SIGILL. Note that we have already + * removed the 0x900000 prefix. + */ + qemu_log_mask(LOG_UNIMP, + "qemu: Unsupported ARM syscall: 0x%x\n", + n); + env->regs[0] = -TARGET_ENOSYS; + } else { + /* Otherwise SIGILL */ + info.si_signo = TARGET_SIGILL; + info.si_errno = 0; + info.si_code = TARGET_ILL_ILLTRP; + info._sifields._sigfault._addr = env->regs[15]; + if (env->thumb) { + info._sifields._sigfault._addr -= 2; + } else { + info._sifields._sigfault._addr -= 4; + } + queue_signal(env, info.si_signo, + QEMU_SI_FAULT, &info); + } break; } } else {