From patchwork Fri Dec 7 10:36:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153126 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp344492ljp; Fri, 7 Dec 2018 02:49:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/V8ciQSu+gszVlcVsmVoCh9MsG6xUsvvC9wplhl8gzIBg/8Up1gt4tswiolHKXa854PbmdJ X-Received: by 2002:a37:5257:: with SMTP id g84mr1338515qkb.76.1544179778960; Fri, 07 Dec 2018 02:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544179778; cv=none; d=google.com; s=arc-20160816; b=GeAyfhjtUuPZ763wK3gitvYSAO8IKhoH3Ub7EawjrgPYWQOtbUXpE5JPjbY4GKjRUQ 9k6Sn+IBaTjdHn1sUjH/s3v2s8Xi5XakjZxSHAXdp27iCq0DxV+ywG5YocO64JXwYftS 1DSMZHl3eMwIaNLkQtspqkTwQxhrH4f4QCrpxhi5a/GZbVYsZGx91Zqr4nVHxVmOBmib 6dS9plEdF8EIM8mM2Ql2xxmOUm+2FBEJ1QKjpfIjZJupTPAIiyjDXme7IP1XY4+Vfdkw PbgRO4kJah5F+1s4Q9nVS1tFEt6mhjkhz1Syt8kETSKBxoB5fSJ6ZoWj+JDJTIlk9QYZ gVNQ== 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=vKZBxe3wDrlJ4/VJOPG7grSwXuHqjLEI0JsXXyswkOE=; b=A0TYqdy5TniSxJ0deUigApreNc2rMoNDEWfjQIEfRser6AyucfrnPS/u3sWXYrpdQO bNCtDgbYCY9I39REXIZ3pnhImvN04tG1LgkJCcOl2FcXxym+WqSC4lJTF5LEfthNQ6hk f+jvRy28ol/Kc3sXXXCMHc7lgrPL2Q4xJj1OPkJpsgZ2mn7zdh0wn+DBKHJtsBPUfUyD xxrawID9oLFY30zk4ngD2IO8JnKunYkxLPb5cZ89Bi9mHFcJPY204In6Ux4bcUotg4Sk T0is4X+kfKgj2LoMVc+0IzANh8MMxDli4x1lP8FYAN7bL8fKCmlN18A7R53AE+/wfFB7 toig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="D4L+SE/8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c66si1930167qkf.32.2018.12.07.02.49.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 07 Dec 2018 02:49:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="D4L+SE/8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:45316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDhS-00070S-Bf for patch@linaro.org; Fri, 07 Dec 2018 05:49:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDVQ-0008Pg-UJ for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVDVP-00080p-7Q for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:12 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:33402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gVDVP-00080C-15 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:11 -0500 Received: by mail-ot1-x342.google.com with SMTP id i20so3387094otl.0 for ; Fri, 07 Dec 2018 02:37:10 -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=vKZBxe3wDrlJ4/VJOPG7grSwXuHqjLEI0JsXXyswkOE=; b=D4L+SE/8ydM+X2OOotOHvvXhwQT50/FHw35HakJ6RI+Jz+WgJWNNX9OiXojpUBjrSi 1UtTTkRb1yuWwIZmW9LQ2D0URCEipqcdqhe/mgXLq2EHTHnE8EO5qIn9rruBiUT3YDNF BdbQC2Oi+XHpslyET4zgAuw0AJttp6uXEqJgc= 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=vKZBxe3wDrlJ4/VJOPG7grSwXuHqjLEI0JsXXyswkOE=; b=HfbbKWrQJAK36TQtlPth3AR04pS89UTKC3FYyPkSf5KNUoZv3KqmiqlrUutE/BpAuD 67t9LPTInbfViJVT5AIaDm5Jf77LD8n8RAiFYuUt24J1HHpFgOZzAMcEksdyBdNW/RJg OgxsYevcnkBTUrcSCkwKHqnHBNSeHEutCFWXjgLow2OpoKRIFJgJ3XC2jCTQUhMmorjD IdKC1EZy1GdLTiFWfcsSWZuCkGA8ZMthYGB/lxM7HqR6X/hFywDRM6B256UyVHGcgBEi UfQqwlRoxHcL8C9ndTCS1QlhuBY0+/zIDbON69LLeWKMQ6jVn2HrR4vEmd69rJb4W2nb Gu9w== X-Gm-Message-State: AA+aEWb9E5Y9PZlNZSTLchyi5px05HLrTtvQNB7Ueyn1s/hy6A2ynrgF ZE5GM6lqR2cRkb650mMC5ori0HE97XI= X-Received: by 2002:a9d:6a41:: with SMTP id h1mr1122962otn.332.1544179029563; Fri, 07 Dec 2018 02:37:09 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id c19sm2037594otl.16.2018.12.07.02.37.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 02:37:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 04:36:28 -0600 Message-Id: <20181207103631.28193-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181207103631.28193-1-richard.henderson@linaro.org> References: <20181207103631.28193-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::342 Subject: [Qemu-devel] [PATCH 23/26] target/arm: Add PAuth system registers 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, ramana.radhakrishnan@arm.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) -- 2.17.2 diff --git a/target/arm/helper.c b/target/arm/helper.c index c73525f813..f466c174e6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5071,6 +5071,66 @@ static CPAccessResult access_lor_other(CPUARMState *env, return access_lor_ns(env); } +#ifdef TARGET_AARCH64 +static CPAccessResult access_pauth(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + int el = arm_current_el(env); + + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_APK)) { + return CP_ACCESS_TRAP_EL2; + } + if (el < 3 && (env->cp15.scr_el3 & SCR_APK)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static const ARMCPRegInfo pauth_reginfo[] = { + { .name = "APDAKEYLOW_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 0, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apda_key[0]) }, + { .name = "APDAKEYHI_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 1, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apda_key[1]) }, + { .name = "APDBKEYLOW_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 2, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apdb_key[0]) }, + { .name = "APDBKEYHI_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 3, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apdb_key[1]) }, + { .name = "APGAKEYLOW_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 0, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apia_key[0]) }, + { .name = "APGAKEYHI_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 1, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apia_key[1]) }, + { .name = "APIAKEYLOW_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 0, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apia_key[0]) }, + { .name = "APIAKEYHI_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 1, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apia_key[1]) }, + { .name = "APIBKEYLOW_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 2, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apib_key[0]) }, + { .name = "APIBKEYHI_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, + .access = PL1_RW, .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apib_key[1]) }, + REGINFO_SENTINEL +}; +#endif + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -5855,6 +5915,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_one_arm_cp_reg(cpu, &zcr_el3_reginfo); } } + +#ifdef TARGET_AARCH64 + if (cpu_isar_feature(aa64_pauth, cpu)) { + define_arm_cp_regs(cpu, pauth_reginfo); + } +#endif } void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)