From patchwork Thu Jun 2 21:48:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 578147 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp960476max; Thu, 2 Jun 2022 15:22:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5smbtiz5LkJNn6Qy546vEE8cz5MX0xoE2tltvHhTDDB0HjYxtbQQ6uweucUlpBVBjPgsr X-Received: by 2002:a37:8686:0:b0:6a6:73f5:e36e with SMTP id i128-20020a378686000000b006a673f5e36emr4100677qkd.132.1654208560243; Thu, 02 Jun 2022 15:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654208560; cv=none; d=google.com; s=arc-20160816; b=PFGzlCzRfzUr7sZQ1xMqKtYGr2tVdljtLKrMBh0rtBss2zSAgk5nSAAYkgs6v4BnMn fHfUwvhoyU2dCsOHKCGqMn4K6qCTjp34ggXnq4hGUTDeadNkhASc/5KXvvidDv3KIGs5 yyNMIlkyAB2gtoZDaUvZ+yeGaJ3HmF7s7j4IKbK2eUWU6cXb+sSoE1YygiV1r9c3gAlR 2UrHpVuedCzclFCvsah7ocq41BVFe3hHObGJ5erRgJYVYKfnFjD1IRhDlw5jpXN8ZxJI C11zQGAVnf0ZUoRo7FubQprpW8jx7UcveRfZ0Vju/mk+6+LVBpZJBLkSW9YpaZhhu5QX 8DNQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0kEodHx06fEclTgSZQr1FM7FKwrQ5Md0/7IEVtNiVsE=; b=eyzHamMjUTk+ouFH5F1QK5422mKWJuPGAwLHtidoiI/LiLctOIFn3qrypJbwXutsOR goJPMogvadIYiybfsc4htBx4eNI4/M5OSUl08e7Fxp/AYwMmdCBVHtiEZssp4tt2mYMK 9b9Iw35Yt+0/gqZuDHm/6OkuEnnxmQG/tu0fhE/MJ4NjF8sE6y9eJ5TFPCv4v4S+y+3K L7Re5kZtI3k9WPFfdlrNkTZcPG1p0uFlTrldgJoajL3N0qBVGTYrxwB5fDo7VT/Ia90h gsB8Ro96Sa5CJTF8kTUJ05Szo9dSSHFwvec8ai0HTRBRIBk7hKignu6V/sqrLGLuxtYk 6YcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rb/EeB/E"; 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=pass (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 b19-20020ae9eb13000000b0069f619960a6si2604310qkg.208.2022.06.02.15.22.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Jun 2022 15:22:40 -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=pass header.i=@linaro.org header.s=google header.b="Rb/EeB/E"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwtDD-0006ol-QT for patch@linaro.org; Thu, 02 Jun 2022 18:22:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwsgw-0004qS-Qp for qemu-devel@nongnu.org; Thu, 02 Jun 2022 17:49:18 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:44776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwsgv-0008Tw-1v for qemu-devel@nongnu.org; Thu, 02 Jun 2022 17:49:18 -0400 Received: by mail-pl1-x631.google.com with SMTP id h1so5510463plf.11 for ; Thu, 02 Jun 2022 14:49:16 -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 :mime-version:content-transfer-encoding; bh=0kEodHx06fEclTgSZQr1FM7FKwrQ5Md0/7IEVtNiVsE=; b=Rb/EeB/E2KaLKNbMwrl8y/jsEwm0gP3vyzOylYAyRD9YcCw1jKxvAbg0c58eGuOJE1 1CaIXgnMmCJyx84QQjlM/EWL9mJhz+JW730sQl6au1XJ5uKvrruOBtq/fX3BaCUn4okI FffM5mzDBx1qYsrqk/u6IV13Jw05Qvao9+ownGb9iMoGM1S3Ij0nL9izjYkXtwWYklS9 uTCa/xqtrlAP0sOPOO6e8LWt/KzP7lM1Prj4ppoV2PZaX61bSCJjRi4JAjko4EvEykLe TAC4RLvL89Ol8W2yxFKaEPa9vh/Aufz8icERDa5uzN2Dcu/9gapDI+Ejr7CADRR8gzCg k6ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0kEodHx06fEclTgSZQr1FM7FKwrQ5Md0/7IEVtNiVsE=; b=c6pwjWDIDZobLlAWMLA0vZXdNbLlwHs/ilWtw9BMHBCiICCH0uZZS0Rz5Php9oZ9Af QFt9BTzrFVFog7QluHYDNMRm5z7gRLEthRYsdpI96Y1dzjth3IRvy20+92R6AqMmZoGM ZK9iZO4MomFuOZx6C1iLeWHVybsvvZe6zr210zBrhbcOQqf91UaFzQoMRn6r5FIsUA7+ VZ8LVibPxKdNoaMfU+L9IzjBf7akv7rqDiyMI6RFCUDobNrmHZJ2hZYz01bPw7Mpeh0r Wuw4uhr9Wv/d2Z4Pka5b9ru3xgfHbU36uUCRheQL0SIsBgY12VejOYuVdjv1RRhs/Epa UWCg== X-Gm-Message-State: AOAM530/e6Hnw8yF9VDsffy0JZmoyaepCZPl3XO1Y13gCSxxLRs/hPmE AJI2IULkyeaXNVoCxb4te2Wdoz2TSDDmRA== X-Received: by 2002:a17:90b:1e46:b0:1e6:826e:73ea with SMTP id pi6-20020a17090b1e4600b001e6826e73eamr6611583pjb.68.1654206556182; Thu, 02 Jun 2022 14:49:16 -0700 (PDT) Received: from stoup.. (174-21-71-225.tukw.qwest.net. [174.21.71.225]) by smtp.gmail.com with ESMTPSA id bf7-20020a170902b90700b00163c6ac211fsm3988760plb.111.2022.06.02.14.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 14:49:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 25/71] target/arm: Add SVCR Date: Thu, 2 Jun 2022 14:48:07 -0700 Message-Id: <20220602214853.496211-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602214853.496211-1-richard.henderson@linaro.org> References: <20220602214853.496211-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" This cpreg is used to access two new bits of PSTATE that are not visible via any other mechanism. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 6 ++++++ target/arm/helper.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 31f812eda7..31b764556c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -258,6 +258,7 @@ typedef struct CPUArchState { * nRW (also known as M[4]) is kept, inverted, in env->aarch64 * DAIF (exception masks) are kept in env->daif * BTYPE is kept in env->btype + * SM and ZA are kept in env->svcr * all other bits are stored in their correct places in env->pstate */ uint32_t pstate; @@ -292,6 +293,7 @@ typedef struct CPUArchState { uint32_t condexec_bits; /* IT bits. cpsr[15:10,26:25]. */ uint32_t btype; /* BTI branch type. spsr[11:10]. */ uint64_t daif; /* exception masks, in the bits they are in PSTATE */ + uint64_t svcr; /* PSTATE.{SM,ZA} in the bits they are in SVCR */ uint64_t elr_el[4]; /* AArch64 exception link regs */ uint64_t sp_el[4]; /* AArch64 banked stack pointers */ @@ -1428,6 +1430,10 @@ FIELD(CPTR_EL3, TCPAC, 31, 1) #define PSTATE_MODE_EL1t 4 #define PSTATE_MODE_EL0t 0 +/* PSTATE bits that are accessed via SVCR and not stored in SPRS_ELx. */ +FIELD(SVCR, SM, 0, 1) +FIELD(SVCR, ZA, 1, 1) + /* Write a new value to v7m.exception, thus transitioning into or out * of Handler mode; this may result in a change of active stack pointer. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 98de2c797f..366420385a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6353,11 +6353,24 @@ static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, return CP_ACCESS_OK; } +static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + value &= R_SVCR_SM_MASK | R_SVCR_ZA_MASK; + /* TODO: Side effects. */ + env->svcr = value; +} + static const ARMCPRegInfo sme_reginfo[] = { { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, .access = PL0_RW, .accessfn = access_tpidr2, .fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) }, + { .name = "SVCR", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 2, + .access = PL0_RW, .type = ARM_CP_SME, + .fieldoffset = offsetof(CPUARMState, svcr), + .writefn = svcr_write, .raw_writefn = raw_write }, }; #endif /* TARGET_AARCH64 */