From patchwork Wed Jun 5 20:57:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 165928 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7862204ili; Wed, 5 Jun 2019 14:07:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgZI5qEAJgpvcp3VOR5GX9+hU/uE6yLmcC59OOOi2lBk+ivs9CcUiDG1KStbXfXQCDukJ+ X-Received: by 2002:a37:7786:: with SMTP id s128mr34962247qkc.63.1559768821888; Wed, 05 Jun 2019 14:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559768821; cv=none; d=google.com; s=arc-20160816; b=aBKSAKaXOi8SoWEigxSojInl9nqpYL31I0S71YTb1SgYANTtl47Zik00cIPquWzK5u sXBrDdv0FIBaXbF7cpF5VvxJzQSWzhmyGStovbRP9afDb7tCaiwZvdbn1qLwyyUAoyKu eOvYG+u+3yH9roy9emXBzMC+iq2Gq9w2bWBYzO+bl7BfY1Fr4j5RAiDGW5zheC0HblhP WtqvH8DJV7woHI9gfJ5EB3af48bjLwWXpNc1O9zLyVMX34+i4Oo8BUPBxLrEkR4oecht WMs+6MxG8mZiz+HK070FhvJeLzMvvF5kZ2uVeRlAXOcyMvHDWz42grN3HvGbo0IQgtqX CBag== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=VGvFhyg+EUZksh+VTROd86GaO53VcnzMT3R6u6jPQAY=; b=hCJx2P68l6G38mVY1shna5DATH79SQi+IAs1HiOsqyPGgHHsJ3xgSBdlFTWxMe2WbA oJ4+aiGv0JxwHRpYQh5nX+gPfNURQasEDk5vzkngSD1oEN4jt4zPLfWtSWdkEnksn6sV JlVCZzw8jyEOEpc7F3GRpvAXgbkG17FXlfCYkeizVE3k/xTLdtIARkF4VJZeVXSX+6IZ I4x5q1BK7D6I80tr1lV4Uss4uCL6xOlBh2sAUpHEYsiY0+vrpvkuQE6mr9ANx3w2fTVs 8pwefx4+aCCtTmK1aXiiPOqnSK1XwLK3QuBiku08HQNDVcrWbaEIUHP9KexZ5mSoyI5S 7PEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OoIeqPmZ; 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=fail (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 n14si8167533qkg.165.2019.06.05.14.07.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Jun 2019 14:07:01 -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=fail header.i=@linaro.org header.s=google header.b=OoIeqPmZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:50045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYd7d-0005Mv-CQ for patch@linaro.org; Wed, 05 Jun 2019 17:07:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYcyB-0006A4-Lx for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYcyA-00087R-9p for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:57:15 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:35086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hYcyA-00085J-5G for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:57:14 -0400 Received: by mail-oi1-x243.google.com with SMTP id y6so59282oix.2 for ; Wed, 05 Jun 2019 13:57:14 -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:in-reply-to:references; bh=VGvFhyg+EUZksh+VTROd86GaO53VcnzMT3R6u6jPQAY=; b=OoIeqPmZjHB3rL9pqVkgC//djxrxRKMbvTLI/lNj/jUKtpVZU24+DJwHFfk8rkB9Et 7VZQU9GvIwyFNUNQPGcg/9eZOzeoBIBK983oq242StsYqiZ//A15cr/9Afk+f4rxa4XB lYxTPX/3mEyYWtPYY23n1eqvuhL/Gxnl7drwrlPsrThBz2/Cdt+0Gbo7+JcSMohL32uc KmQOxb9+xAszytdDLr+/TbaKY/r27in9EW5QvLNcH6YJrgzYcKWQbNS8BSXrhoLfzJog UvSZaazsPsbp/cpi5i+WyC49uDxok4v9bzoPw685T020BnOWZkmNao9ZCerC8zeR0alH 8yLw== 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:in-reply-to :references; bh=VGvFhyg+EUZksh+VTROd86GaO53VcnzMT3R6u6jPQAY=; b=da7zeKHRXv186AJGtKi31/l6LP6uxkKJAxU+xwy2HthsCANmrYOFySs0/jZE07WCrB OSAValXkCp/nsv3/2MXF/4KjWjsWH7VOfjmJt0YUqEhveuwErIR77dm+xW2dZlH4BSzX Ng+IUlmdASFRE9njkpwpE3loiiPC0k6KgJo30cfyKLpoC5+ICZcMhB43cgI07YAWRE3z bwmr1t+rM6m2ECQ/y+sF21WNucp/pczsg2p2Rd8Svfb2+pjZ/I35VmUss9TFKlM5U0CY oPi1U//eMYWYtTaFko7SlE+KSIeIRxSDbGqDu944ALjJJi0NWgvjcE3cJPW7zUwWIj2J zgvQ== X-Gm-Message-State: APjAAAWKTAXwM7DdoDm1lea6WWNIqOTnYVgf9v8Xb+JtAhBJQ3Vho9r1 lqQBFayInSGtsDcZQTyAlZ7ON43a9yulig== X-Received: by 2002:aca:ef43:: with SMTP id n64mr10168835oih.79.1559768233178; Wed, 05 Jun 2019 13:57:13 -0700 (PDT) Received: from localhost.localdomain (200-56-192-86-cable.cybercable.net.mx. [200.56.192.86]) by smtp.gmail.com with ESMTPSA id f5sm7414155otl.51.2019.06.05.13.57.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 13:57:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 5 Jun 2019 15:57:01 -0500 Message-Id: <20190605205706.569-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605205706.569-1-richard.henderson@linaro.org> References: <20190605205706.569-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::243 Subject: [Qemu-devel] [PATCH v6 1/6] linux-user/aarch64: Reset btype for syscalls and signals X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, Dave.Martin@arm.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The value of btype for syscalls is CONSTRAINED UNPREDICTABLE, so we need to make sure that the value is 0 before clone, fork, or syscall return. The kernel sets btype for the signal handler as if for a call. Signed-off-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 7 +++++++ linux-user/aarch64/signal.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 2f2f63e3e8..1f68b13168 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -86,6 +86,13 @@ void cpu_loop(CPUARMState *env) switch (trapnr) { case EXCP_SWI: + /* + * The state of BTYPE on syscall entry is CONSTRAINED + * UNPREDICTABLE. The real kernel will need to tidy this up + * as well. Do this before syscalls so that the value is + * correct on return from syscall (especially clone & fork). + */ + env->btype = 0; ret = do_syscall(env, env->xregs[8], env->xregs[0], diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index f84a9cf28a..5605d404b3 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -506,10 +506,16 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, + offsetof(struct target_rt_frame_record, tramp); } env->xregs[0] = usig; - env->xregs[31] = frame_addr; env->xregs[29] = frame_addr + fr_ofs; - env->pc = ka->_sa_handler; env->xregs[30] = return_addr; + env->xregs[31] = frame_addr; + env->pc = ka->_sa_handler; + + /* Invoke the signal handler as if by indirect call. */ + if (cpu_isar_feature(aa64_bti, arm_env_get_cpu(env))) { + env->btype = 2; + } + if (info) { tswap_siginfo(&frame->info, info); env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info);