From patchwork Sat Mar 30 00:58:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161479 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2705437jan; Fri, 29 Mar 2019 18:04:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyZOnDOzehkP8iDCUc+T8boici4tA+Wi3jSjiAe4wFA9AHE4zuovBfhcOZDj8UgZikHjMz X-Received: by 2002:a24:3905:: with SMTP id l5mr7803056ita.43.1553907899568; Fri, 29 Mar 2019 18:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553907899; cv=none; d=google.com; s=arc-20160816; b=iFSPFe3MdvVhjSUSpQfChpujQjjOs3PPCuCWpd1Khi+Wcu1bORe9nTCR2eM4/njt+4 5ck3IrF8V4aqGPChNxSHrn6NXXsnCe246yyJr5/cruVRfSejqTXxEbkXr19TEe2OYTM+ PVmEmWgzkmVkFFP7xJ/kWhzzREWcNFL3WW+Wm9e4z1mzdRs9MfKLU019AXd8X6jd6J5e K4g+Pn2ulXtU/u92NZcT9EcEvkdOsuCiXHCUrF0sWgrwI0xhvlw+l7Ue27o1yk29W49M sK+YM2iVGNDNd6aBBgirZyNsoK7uFxzTxwrtjiR00SlbZZRmXoNZVArtzFfMAF7lFp71 ppEg== 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=kqHe5v2q79iXufkRdD9H4UM2SE/bcUFqYqqxTH4VdfM=; b=euItYYX8r+E252ETrhzefhMqqvnHMMNEcpYcFutABSsO4GjGXC8zSU2ZdaO1b31ZvB nilr/XBDOvroD4aUXT5/8ps+eCV9UPmGe0kShh4M+Vri1KFuGHB7D2bgFN3rfKcC/xcj zOnLO5sX0895oDrmZl7Jik2yUeiBtotHei1FdY+2GxJo/y+MxaCIdAUfOR5ysX+39Tq2 t7y/RB8XXu+VSu9Ciuhlm591Ee+XzucQlz52kYGK57T8OTvItuwV0SAsA+REO/FsjndP Pp70pr6R+pkfZREK9jWFuEVoTOCln83Lw7spNr7LAyFvvvk0U+j8kzIvokeE/rddAr6G i4tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S4w3Un0R; 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 t2si2013240jai.35.2019.03.29.18.04.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Mar 2019 18:04:59 -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=S4w3Un0R; 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]:40662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hA2QW-00079S-EN for patch@linaro.org; Fri, 29 Mar 2019 21:04:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hA2Ky-00078P-4R for qemu-devel@nongnu.org; Fri, 29 Mar 2019 20:59:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hA2Kx-0001c8-5h for qemu-devel@nongnu.org; Fri, 29 Mar 2019 20:59:08 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hA2Kw-0001bi-UW for qemu-devel@nongnu.org; Fri, 29 Mar 2019 20:59:07 -0400 Received: by mail-pf1-x442.google.com with SMTP id c207so1812056pfc.7 for ; Fri, 29 Mar 2019 17:59:06 -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=kqHe5v2q79iXufkRdD9H4UM2SE/bcUFqYqqxTH4VdfM=; b=S4w3Un0Rq4/9VpjfA1fLt75IUql4Dro1RWJPoZGa3FRa3WqDEzfHTRFUSChykiwO9i 0Rairegi/5eRJ9ZATbJ1YX4L8vHTTPnopbhlKsLcGKrLk5OedOESEtNrNZfw/3YO7G8y vTQE13tZ2lQZVTBqU+CGGI4Isht/V7sVdE+YVe0CjwHdkOe/KxKknw45OWVdeQODuDZu dgvjKsH1cBN3x+jncxa7vYo1n0ovWVhw5RfcrRu+cZlvpDt8ysid7Wx2bNhLCQVh3x55 v3JC5llq73ppsdxNEu2twqZpz1kfch3d6xCvWopli2+3uevcDdgSp49aYP8mHE80EheB U22g== 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=kqHe5v2q79iXufkRdD9H4UM2SE/bcUFqYqqxTH4VdfM=; b=pn4iKXOl50IbZ7GoVSbjsv/Mnl8ON3KjopRu3Z/JlUVFc7JRARZZ2mTo8ErdTxrHJ5 hlemYAOzKCaj3qBFs7BQ/Qn1yAzRivJEmkSMZzdlK+GtD2LRX08dg77m8eCd8477golg Woqcr9IlbbaebBdqJdElLwVYAClISRDeUeSl9KlnmVne9U2tizPysARc7pn3uY/z9OMF N4/iiTSxsx6SmmFjuxd3E/xhcTxpB6b+VJiqzxTfJpPX26pVSd1ljLi0ckcYKusDQaBb Dap2twmvYGqsbHbovGUe0gAzG2TbzTx8ZyoTSquitWSFcCJP45/xR4TWSJpMNMXCIu3g /JkA== X-Gm-Message-State: APjAAAUIzKeniD1GxH5WSTsXbuC/Ae8tQkf1OVEahH/BrI6yABohV6rd 5eoJiFVj1EnJFrdHreeLKjt2ECIc6hk= X-Received: by 2002:a63:1a1b:: with SMTP id a27mr40889978pga.59.1553907545626; Fri, 29 Mar 2019 17:59:05 -0700 (PDT) Received: from cloudburst.ASUS (cpe-66-75-72-255.hawaii.res.rr.com. [66.75.72.255]) by smtp.gmail.com with ESMTPSA id e1sm2229900pfn.187.2019.03.29.17.59.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 17:59:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 29 Mar 2019 14:58:57 -1000 Message-Id: <20190330005900.17282-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330005900.17282-1-richard.henderson@linaro.org> References: <20190330005900.17282-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::442 Subject: [Qemu-devel] [PATCH v4 1/4] 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, alex.bennee@linaro.org, ramana.radhakrishnan@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 value of btype for signals is defined, but it does not make sense for a SIGILL handler to enter with the btype set as for the indirect branch that caused the SIGILL. Signed-off-by: Richard Henderson --- v4: Do not clear btype in signal frame. --- linux-user/aarch64/cpu_loop.c | 7 +++++++ linux-user/aarch64/signal.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index d75fd9d3e2..f5cce4769d 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -85,6 +85,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..078873c4a5 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -506,10 +506,11 @@ 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; + env->btype = 0; if (info) { tswap_siginfo(&frame->info, info); env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info);