From patchwork Fri Feb 1 16:06:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 157277 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp642442jaa; Fri, 1 Feb 2019 08:27:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN6ZvcM1mBNR+mdl0whu+rmZgUyaeMD/t/px6HMEJi7ny4/sxqsru2E8qY98LFyI9G8J00F4 X-Received: by 2002:a81:2916:: with SMTP id p22mr38370224ywp.176.1549038450885; Fri, 01 Feb 2019 08:27:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549038450; cv=none; d=google.com; s=arc-20160816; b=Fnqpg7ouN7Vs9cxmayElJvuu79DMnZuOv808DHRHwwwT4RLsEnjyf8BmUKIt5edxdj QJFTwNDxjS1Q5GKgK4ddJErD0ivfunaIfJUfIxML8vVWFH9Vfj7ID5yrdZPmGdS7hcWH G83Gr553VL4fRrSkYM78yxqjXHqZ3vZWZ6gB4Z3A9vR5RH6xalHriDogkJ473VET3tNd 3nGRuLMSzzGb1FcOqcSiKokxBvLcZgu5zzNI7Saix65oq/YSRqORpCaniy8NEqUZASw8 GwuHLnaBo1hxhwUacN9TgtkmB1pWzBtBBU5tnv34+AqcCru5u3YXMaIAEhVUiORQP6RU Ytpw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gL7tT39M0mky0cT3h2GpEvbcsFM8wyQLjGzWrz90zqE=; b=zaYO81BGFr7AFDvmZh+sDr2vbLyCISsiHQkr4el31JfBzSIIEg6yCdd3WoucOnDdUR 6gp0/vsVFKhlgbtmv05zmNTT37FKk4aeydKd2y+TS8lnam23uessMrP2vNDdav6bWJVk fTBzEHaIxqsS+xIy7rGnB4uoHWWSYtwhRUDdDD8XccMOBIFJG7FAYW3v4GUYBYewy665 xGz1o8p7dNT1ZOFRrvMCAQNTnBzXtFwC2Lr1XRQgNmrZszrWdgFuTog/C4/sxp3ul4eq rY5MLqDPesT6k2A708Wl9ThOTAhyKZp2uL/w9LJ6dh6rSjMgSfwdffxotoVin3wWqWoe pZOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ULgfSR+Z; 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 s20si2801476ybe.220.2019.02.01.08.27.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 08:27:30 -0800 (PST) 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=ULgfSR+Z; 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]:57530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbf8-000877-AF for patch@linaro.org; Fri, 01 Feb 2019 11:27:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbMD-0008Gp-SC for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbMA-0003iy-Kf for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:57 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:38172) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbMA-0003dh-8r for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:54 -0500 Received: by mail-wm1-x32b.google.com with SMTP id m22so6782427wml.3 for ; Fri, 01 Feb 2019 08:07:46 -0800 (PST) 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=gL7tT39M0mky0cT3h2GpEvbcsFM8wyQLjGzWrz90zqE=; b=ULgfSR+ZlBqRbnCtugP9sYFONSVZ+lUpaKH0mOIgdqvYmDk0PNAD4neQ+GMeGtdg1m 34IWQk496d6uw6cKtGetMn4klHF0CbuSlPljMI4rsFHYVs31r3SZ9gfqaFCxWEMKvi1E ZRQ0JbA/NFvg58zjkXpJU/GqBsUJs6RQpyr1o= 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=gL7tT39M0mky0cT3h2GpEvbcsFM8wyQLjGzWrz90zqE=; b=sAZtmFZ7ZsI7AkbEQiXjl9vdWRHtWyU3R57OLg8p5v7tp2eug++TlJdFb95oUdsIvP 0KZ9+uwXbC1ZS5Clsfkpi/jWU2GmQpU4Zt9IP8Nl/bF8Ya4gouCKhy1JHT7ZWmVPXM2U IK/bXsvnWAg5pMSdSv/AjlJbyDW94yt/Wz6wvt6TtS9cnGlSoUS5l2Y0VtiilttR2HIQ YnJm5noq/Irhu58ahR/OSa3d0kf/hp9PSWMVIbQxHLKm4mxw5FCG92WhdnECKK/dUNZZ Bda2umH62u3okkOizMkdXdDtduxZadgmWyXpJgcGbjmqnl4lHbUox3tLyPAzgZvGzdOB KA+w== X-Gm-Message-State: AHQUAuakrdWKhZsKTXNxC3wyjDdZxm9Qi7sTEv2RBMdFnwCpuqE6mJr6 GIVrwq+XTL5f2CsHM0d5BMidZRkd1g7xKg== X-Received: by 2002:a1c:1688:: with SMTP id 130mr2962359wmw.86.1549037265175; Fri, 01 Feb 2019 08:07:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n6sm2847250wmk.9.2019.02.01.08.07.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:45 +0000 Message-Id: <20190201160653.13829-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201160653.13829-1-peter.maydell@linaro.org> References: <20190201160653.13829-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b Subject: [Qemu-devel] [PULL 39/47] target/arm: Always enable pac keys for user-only 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Drop the pac properties. This approach cannot work as written because the properties are applied before arm_cpu_reset, which zeros SCTLR_EL1 (amongst everything else). We can re-introduce the properties if they turn out to be useful. But since linux 5.0 enables all of the keys, they may not be. Fixes: 1ae9cfbd470 Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/cpu.c | 3 +++ target/arm/cpu64.c | 60 ---------------------------------------------- 2 files changed, 3 insertions(+), 60 deletions(-) -- 2.20.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index f00d450d0bd..3874dc98754 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -185,6 +185,9 @@ static void arm_cpu_reset(CPUState *s) env->pstate = PSTATE_MODE_EL0t; /* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */ env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE; + /* Enable all PAC keys. */ + env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB | + SCTLR_EnDA | SCTLR_EnDB); /* Enable all PAC instructions */ env->cp15.hcr_el2 |= HCR_API; env->cp15.scr_el3 |= SCR_API; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 8653cecd032..7107ec8d7eb 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -281,38 +281,6 @@ static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, error_propagate(errp, err); } -#ifdef CONFIG_USER_ONLY -static void cpu_max_get_packey(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - ARMCPU *cpu = ARM_CPU(obj); - const uint64_t *bit = opaque; - bool enabled = (cpu->env.cp15.sctlr_el[1] & *bit) != 0; - - visit_type_bool(v, name, &enabled, errp); -} - -static void cpu_max_set_packey(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - ARMCPU *cpu = ARM_CPU(obj); - Error *err = NULL; - const uint64_t *bit = opaque; - bool enabled; - - visit_type_bool(v, name, &enabled, errp); - - if (!err) { - if (enabled) { - cpu->env.cp15.sctlr_el[1] |= *bit; - } else { - cpu->env.cp15.sctlr_el[1] &= ~*bit; - } - } - error_propagate(errp, err); -} -#endif - /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); * otherwise, a CPU with as many features enabled as our emulation supports. * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; @@ -388,34 +356,6 @@ static void aarch64_max_initfn(Object *obj) */ cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ cpu->dcz_blocksize = 7; /* 512 bytes */ - - /* - * Note that Linux will enable enable all of the keys at once. - * But doing it this way will allow experimentation beyond that. - */ - { - static const uint64_t apia_bit = SCTLR_EnIA; - static const uint64_t apib_bit = SCTLR_EnIB; - static const uint64_t apda_bit = SCTLR_EnDA; - static const uint64_t apdb_bit = SCTLR_EnDB; - - object_property_add(obj, "apia", "bool", cpu_max_get_packey, - cpu_max_set_packey, NULL, - (void *)&apia_bit, &error_fatal); - object_property_add(obj, "apib", "bool", cpu_max_get_packey, - cpu_max_set_packey, NULL, - (void *)&apib_bit, &error_fatal); - object_property_add(obj, "apda", "bool", cpu_max_get_packey, - cpu_max_set_packey, NULL, - (void *)&apda_bit, &error_fatal); - object_property_add(obj, "apdb", "bool", cpu_max_get_packey, - cpu_max_set_packey, NULL, - (void *)&apdb_bit, &error_fatal); - - /* Enable all PAC keys by default. */ - cpu->env.cp15.sctlr_el[1] |= SCTLR_EnIA | SCTLR_EnIB; - cpu->env.cp15.sctlr_el[1] |= SCTLR_EnDA | SCTLR_EnDB; - } #endif cpu->sve_max_vq = ARM_MAX_VQ;