From patchwork Fri Jan 25 22:57:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156649 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp918482jaa; Fri, 25 Jan 2019 15:18:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4PQ/n22ZOSVPYMn/gD1bTvmyvxIIN6Z9JoMVQb9ZZfk/z/iWAqzepidP9+1UsR12kFs2RA X-Received: by 2002:adf:b243:: with SMTP id y3mr13572565wra.184.1548458337556; Fri, 25 Jan 2019 15:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548458337; cv=none; d=google.com; s=arc-20160816; b=NxM6ssSRfTJm7F8Od9TZPPeOmKcLWkqmdANt/uyck+TJ2FRPqlheaeyTQZpTrkl/Qq dx4MQAzdOtcvG5W8vpBq90W8MYpQ4YvPoPGFBxybkUp125D1MdzRTLMHL2RAIAUc4Dmj NB4syu4DcxDqDcipAcjuqowNcIX7PiJJPHhddHAAQnRgSq1b9iDMLVAShbhvEiPjW/Xw J8i0er23GaA3LIBASztFLwx1qzv4TcSASCXvcM2INdaSZRDgP7tiNFQoIYdHWjUeEnWy snxSFkEnGFBGkaLQYIujBfFY3lxBr1Redf194H/fIQrnAUBAdLjarmQdC3E4/nm91cFf mlrg== 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=9CGDXRL9RJ71h8U2OmRVl+QRQuVLerVJq7UGYM/rjbk=; b=qXHwXIy8/gQRJhFdqie1vCnAmXdZSWUMhnfCRslCgCnNh4U7X61mXPPhJg8b7iYRhv cuOhnexpYmnpW3mfyEFiC5LIaYfcNZUPF0RpxhLdKTcr3ZOb5pt37wzsQmgUEc9h8MWg KzzUz3U/LfwXj46FAvQB4JUWhvdJho6DA5wqo9h9BR6JTMAjh8BKsl/kgLamL08aNYY0 O4ZTjePAiNK2DKrupgiAu6nhNkVZ6UBEw/ZXNmQCTDKUODxCqmsFun3dO33TvrOQCzqa dvtmkmRscgxyRT0Gqt7DT+O05PCO0mDeq/ycalHwY8PaeqlYUPUsiTz8wiKUC29PW8y9 y9lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SehOq6kZ; 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 d11si73206889wrq.145.2019.01.25.15.18.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 Jan 2019 15:18:57 -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=SehOq6kZ; 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]:52284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnAkS-0000zz-Fe for patch@linaro.org; Fri, 25 Jan 2019 18:18:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnAe7-0004QH-Tk for qemu-devel@nongnu.org; Fri, 25 Jan 2019 18:12:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnAPX-0005HB-SJ for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:57:20 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gnAPX-0005Fj-LZ for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:57:19 -0500 Received: by mail-pg1-x543.google.com with SMTP id j10so4797609pga.1 for ; Fri, 25 Jan 2019 14:57:19 -0800 (PST) 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=9CGDXRL9RJ71h8U2OmRVl+QRQuVLerVJq7UGYM/rjbk=; b=SehOq6kZpS2ZJGVppZlEa7HbNHywdMVKCBfC9SusxWUxCm/2+z6wWaBOIs/m9sf4GF Wu1fe5KqanGqdN04jy87zynHbZw6d0tVmqR9GLHJjD03hwBHxg71IlQVr6mUY7xbcdcn cBe3EWCfaDA+Vj3ENcKQri18fIx3jx6wQuH3Y= 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=9CGDXRL9RJ71h8U2OmRVl+QRQuVLerVJq7UGYM/rjbk=; b=LFEOgaLbNj9xj2aREMqqzXn/2XmnNQalHCqj9bW+cQ/opYOGqsZTLPfUzpR7Es7yEP K+sxE2XFv0YvTjolt9Hz9X1YX1oC9iWdPryE6LzxGsmafIoSIITVpnvxuExxjilq3tJq CkhY59KeYIzFybnxtzfgnVUz8w1oHJFUUzH9rTYa+YWF7Z4rs5GT8yQ/HeLpIbJdwVDZ BfBolUx/3bhssHBCDzUIk7zE+Mw4xLtlwmjqSFgF1++IqnSKVqIiYiCDdd2C0YdswLzX XeEdXBc/u7Y/cp9gxpITnucP+BVzLV7mxJl0UPyMwJam/MsNuxMys890GL6qjEG9Lhvd t9xg== X-Gm-Message-State: AJcUukfjR6Ukcjp1K2SFLqJEe0WO6lr3c+syp/gVWOnMpC6VBPHT8jHb waHgPNBvUy6aV8VUZlIxuO75NEdPg9s= X-Received: by 2002:a62:1484:: with SMTP id 126mr12623237pfu.257.1548457038194; Fri, 25 Jan 2019 14:57:18 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id c7sm39148321pfh.18.2019.01.25.14.57.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jan 2019 14:57:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2019 14:57:08 -0800 Message-Id: <20190125225714.10234-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190125225714.10234-1-richard.henderson@linaro.org> References: <20190125225714.10234-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::543 Subject: [Qemu-devel] [PATCH 1/6] 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- target/arm/cpu.c | 3 +++ target/arm/cpu64.c | 60 ---------------------------------------------- 2 files changed, 3 insertions(+), 60 deletions(-) -- 2.17.2 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7e1f3dd637..1e79b97a9c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -162,6 +162,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 e9bc461c36..303d0ef075 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;