From patchwork Sat Aug 3 18:47:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170476 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2340914ile; Sat, 3 Aug 2019 11:48:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzFGCO/g7RWSno3ElA2Ray5jgcvVLheD84ZgDCRGVTEBeKx53baTuOni4K+XEQQB5CtT+W X-Received: by 2002:a50:b6ce:: with SMTP id f14mr120316936ede.236.1564858138709; Sat, 03 Aug 2019 11:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858138; cv=none; d=google.com; s=arc-20160816; b=fxqufbLU2fIGczDad/YPdlxHsHKJB/OF0Nyw8gOBrvfytTDHfAiqgBONisDkesXvlg g9Zp4GIGEthIvpKJrSw7P2dUCYxuPgCHKkCudKf6cgOyRFTi8nVa4V3nKlvaYCfeCfpg YznT2d3dc/IKMg4K/ILUMrO18V3mbeBlXy6DmSreisAZHe7dkx3RwVWETe1YKK8s/mhO SzKyt3V+l34spcpUkW3OMfTkreozRbPQz8kIGRamwtoQMZCSmqxqcd+Pk/PSzqI04AJF eddJQ57ewBiiaKWrxktRLcIE+x73AVWZWDUkQ0GXIjo3+rUnHpvLgzZoougGQczeizk/ uDcQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=3Vv1PJfuLW2Q3y6jhZwS+VA5WdsiwenJEhdiHqcPU8E=; b=tF/ayUReUEiaz5ISLIqytW1ogY3TNlxWe/gu0tgVD6NKxU71n6PY2rTV0xRRiF8Qpy zW6pPZjS85xkw0EJJR7n6Aj1cU+m/UbFA1ZsbfpoW1FXBnZmkjKTJZ3j2SiVzOI4/4nO 4UsnytitReCIIAJUvuV8a+fUPSQxeddgA59dWNUeN0bGNc9PednIkJPtMjj1ZSuOwGkh G6T7dSOO5u/3UhxlBB1nP3Nhw7e+7LKF55S5FXNXNjxl+Xo8QSTpa/Hmv1qviG6vPy5n ctWNvHDYlPWvGUfBJZC0Hnb+MeDiXFnTZRmLfppCdSAJNrCU1sF1fLNx+FdZVfG0rLVS GgGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y6m4R1Ug; 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 u20si23754838ejt.309.2019.08.03.11.48.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:48:58 -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=Y6m4R1Ug; 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 ([::1]:41344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5N-0006sa-MT for patch@linaro.org; Sat, 03 Aug 2019 14:48:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60470) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4Z-0005td-0m for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4X-00074d-Lo for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:06 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:46739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4X-00073T-GR for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:05 -0400 Received: by mail-pl1-x643.google.com with SMTP id c2so34860457plz.13 for ; Sat, 03 Aug 2019 11:48:05 -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=3Vv1PJfuLW2Q3y6jhZwS+VA5WdsiwenJEhdiHqcPU8E=; b=Y6m4R1UgmbocM8caPBMrteJtERSrOeJiLGnM3FPGwmGvHF1A8Jb61r+XJbxj43PlWF B5y6PhvJZrCKursx25LMzydByDVTzhvucAfy446c2Q4hxyNzGTI8d8WiqCWUdberr7Kj XkF89KpMLlQBNygZxWlYdoksgbNQP0iXwFpIz+R4zrGbvRErBodIME22Cm1l62poJiTx qc6O0x1PhiJGWaM6/owU9OxUYbJU6znzRCJNW9CYcJz2fWPj0HeIH0BnErk4XUS4pGCl pH7HGPzyFuuQ/6bX9YtBHNn4C6+JGOb6+kj8V1s07E3xuoVEJ7tmN814k5Qex7Knr9cr 6kTA== 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:mime-version:content-transfer-encoding; bh=3Vv1PJfuLW2Q3y6jhZwS+VA5WdsiwenJEhdiHqcPU8E=; b=jtRLRRyCxOzXSGzDunW5m7B3FauPoC9I5pl+566EmjEDJ/fjUP4CAOqtqCPBv9yE8h 0qneSCocOLE6loq+SmRbiOGai8B8kdEoYEDOMqqZEI8hSl66dj/aGjs3I35QB+LQ2cm4 psAzNjcYyRQOJGr0SpQwJxZMSy+wMhtmGGThC5AK/qtiXzxfrgHawpxoVmqE6bbsgViO CjyEQ6EzRzCEywM+1XvfJG022vFjMHABYQpgVbTWFtxoKLhWg0iBECzeLqWWlcbDuGdQ VS0d4LM2/7k34swRDuBYDQ7inhh+N/NDCgeSvsYfZYu2ZI0rfF3CtSAYHvTjwVzbum/S Yn7g== X-Gm-Message-State: APjAAAWYbgU6BspKQtHH2TdLLQw0zZUBuWfge2423v0ZDc+tbuZpfui0 NPtqzFoJ0Ym13hitq2pi8OwC5jUeTV4= X-Received: by 2002:a17:902:f082:: with SMTP id go2mr143791348plb.25.1564858084208; Sat, 03 Aug 2019 11:48:04 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:27 -0700 Message-Id: <20190803184800.8221-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v3 01/34] cputlb: Add tlb_set_asid_for_mmuidx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Although we can't do much with ASIDs except remember them, this will allow cleanups within target/ that should make things clearer. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- v2: Assert cpu_is_self; only flush idx w/ asid mismatch. v3: Improve asid comment. --- include/exec/cpu-all.h | 11 +++++++++++ include/exec/cpu-defs.h | 2 ++ include/exec/exec-all.h | 19 +++++++++++++++++++ accel/tcg/cputlb.c | 26 ++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 536ea58f81..40b140cbba 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -439,4 +439,15 @@ static inline CPUTLB *env_tlb(CPUArchState *env) return &env_neg(env)->tlb; } +/** + * cpu_tlb(env) + * @cpu: The generic CPUState + * + * Return the CPUTLB state associated with the cpu. + */ +static inline CPUTLB *cpu_tlb(CPUState *cpu) +{ + return &cpu_neg(cpu)->tlb; +} + #endif /* CPU_ALL_H */ diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 9bc713a70b..b42986d822 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -169,6 +169,8 @@ typedef struct CPUTLBDesc { size_t n_used_entries; /* The next index to use in the tlb victim table. */ size_t vindex; + /* The current ASID for this tlb, if used; otherwise ignored. */ + uint32_t asid; /* The tlb victim table, in two parts. */ CPUTLBEntry vtable[CPU_VTLB_SIZE]; CPUIOTLBEntry viotlb[CPU_VTLB_SIZE]; diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 16034ee651..9c77aa5bf9 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -225,6 +225,21 @@ void tlb_flush_by_mmuidx_all_cpus(CPUState *cpu, uint16_t idxmap); * depend on when the guests translation ends the TB. */ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); +/** + * tlb_set_asid_for_mmuidx: + * @cpu: Originating cpu + * @asid: Address Space Identifier + * @idxmap: bitmap of MMU indexes to set to @asid + * @depmap: bitmap of dependent MMU indexes + * + * Set an ASID for all of @idxmap. If any previous ASID was different, + * then we will flush the mmu idx. If a flush is required, then also flush + * all dependent mmu indicies in @depmap. This latter is typically used + * for secondary page resolution, for implementing virtualization within + * the guest. + */ +void tlb_set_asid_for_mmuidx(CPUState *cpu, uint32_t asid, + uint16_t idxmap, uint16_t dep_idxmap); /** * tlb_set_page_with_attrs: * @cpu: CPU to add this TLB entry for @@ -310,6 +325,10 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap) { } +static inline void tlb_set_asid_for_mmuidx(CPUState *cpu, uint32_t asid, + uint16_t idxmap, uint16_t depmap) +{ +} #endif #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index bb9897b25a..c68f57755b 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -540,6 +540,32 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, target_ulong addr) tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS); } +void tlb_set_asid_for_mmuidx(CPUState *cpu, uint32_t asid, uint16_t idxmap, + uint16_t depmap) +{ + CPUTLB *tlb = cpu_tlb(cpu); + uint16_t work, to_flush = 0; + + /* It doesn't make sense to set context across cpus. */ + assert_cpu_is_self(cpu); + + /* + * We don't support ASIDs except for trivially. + * If there is any change, then we must flush the TLB. + */ + for (work = idxmap; work != 0; work &= work - 1) { + int mmu_idx = ctz32(work); + if (tlb->d[mmu_idx].asid != asid) { + tlb->d[mmu_idx].asid = asid; + to_flush |= 1 << mmu_idx; + } + } + if (to_flush) { + to_flush |= depmap; + tlb_flush_by_mmuidx_async_work(cpu, RUN_ON_CPU_HOST_INT(to_flush)); + } +} + /* update the TLBs so that writes to code in the virtual page 'addr' can be detected */ void tlb_protect_code(ram_addr_t ram_addr) From patchwork Sat Aug 3 18:47:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170477 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2341275ile; Sat, 3 Aug 2019 11:49:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxizRAAmbVQ0sIKEGyZt4Qk3Vg1zhRfn7ZOFlfEZfPepl7na4el/YA9MsLtn446gZVx6EBi X-Received: by 2002:a17:906:19d3:: with SMTP id h19mr10116883ejd.300.1564858171873; Sat, 03 Aug 2019 11:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858171; cv=none; d=google.com; s=arc-20160816; b=QE8I7WGWcjw3ygbQePvnK7Bkja9EShMQ85qUqC0Wu3Ch7+uDaIOQFhjbpxGampneBq DOxtcKKA/JiUPIA8VAeTdWD3jqVsEEzfOyWluGVOg8z0vE5ust7uow4XqtIh+lgMrEoh E1tg606NFtIEaDBdB4OArIt5XEW20ISG8+/+TmnXYRytawjJbs6PhRdZ2UDkwik1dN6S b0FmEr+nYtqHU8PyuzePWASZPYL0SzdKVuULLuhXHhXpqgLU82X5jf7eNmuoFwDRAVml 4Rl7VmCyx55puJDew8qw4oiEtnA8aX8HE8APKj0maRp9EpynXomxdocXnoa8/v8Zre6M v6RQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=OzH9oAANiLbbz3MZqOd0740wSKDkRIpOzsZLTONmMZs=; b=R/g9SyEZBVi8Gkm8IBo/EPMngoxNULdAm6AGF2oKfp0XbfpDkbghxhNCGjsB6LQ/is EVztMn2iDMiuhywhBQ1R1tvEA2zqvmXeAaPgOlw3NcByb/Fgs0kYcLinEy4gZVuKxPsE CkJ9I7j/Z/9q4anqO8/Qcp7E51tk+GrhQlMNNfHG3u4YcCJ+gv7S/ABeJ6R1OVWSxPht AaiW1ioN/Db9v1zLeZA87GrEOHhUldhA/M2V27QqZKLJ6YZZ7FgHZgN9ysa6dQXTgNv1 ez8pcvB3InDSrsYHu183XQkK1sPDS6Bz3CakdCZEhHLtxVGfUYN+xxtuqb3KXp202gOQ KLsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=POoyQ7p+; 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 q3si23533895ejt.89.2019.08.03.11.49.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:49:31 -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=POoyQ7p+; 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 ([::1]:41350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5u-0008BB-Td for patch@linaro.org; Sat, 03 Aug 2019 14:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60495) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4a-0005vH-3K for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4Y-00075V-OO for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:08 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4Y-00074y-J2 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:06 -0400 Received: by mail-pf1-x443.google.com with SMTP id p184so37618535pfp.7 for ; Sat, 03 Aug 2019 11:48: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 :mime-version:content-transfer-encoding; bh=OzH9oAANiLbbz3MZqOd0740wSKDkRIpOzsZLTONmMZs=; b=POoyQ7p+raLFWdXdMAzpyzaP2JaDBIv6nyVaZb9BfgIy2h7Mrrv6IJN3cSSEJntlw5 fyjBeZs76EWn/Or6CbrU6PLJ1BCKSmRURYCh4ha3iDIM+5H4TlNZPQdCdwiX5W9Fp0Ee aswnR4wlqWtWQXx2paH4aGQY1c09aAtCPGHlqIQFNTe5xZgzADjy6HMgjLbaiCAlDmRs hhe/82vasY2whCT2XBPfo/RsXzWAh3RH9J/ywRIinWZ58/xgy3dkpNzVgCKgV8FvkYcC 4iXcMs8vs3kMvuW0wVWCymak7Ouftt5En+eVh42Dr1EM1IHppVJKxWULZeme/RoHJKWT a2uw== 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:mime-version:content-transfer-encoding; bh=OzH9oAANiLbbz3MZqOd0740wSKDkRIpOzsZLTONmMZs=; b=G8Vwueu4DCcV72hxMCKddVYazxtV8S5YDmepDfcefUUOu+X6syHDkLlHzckFCKlL/a K61eU/cIVD+EQSSkNQjM1VUjj5MiuQoGo2PuiLPvE7S6UM3UAMpeLX0H10osPkVTmzCF lWrTJlth9pqod6gU4rcnLvmyDd0OyZEFkSdmBDAZlcu6fU0U2dAcR4pHRgGREWqaLHkW JlQj06HQDigybmgcE3pkGdau5ZGvoc6ccYwrF2cW/DVeVFcqS35kT2ye1WIMywirn++4 lLrbmKrXDBfnz9nRErHyTOMIZzGM8VDWgOcKfX3Sx91qjyuRpA4cgAb20FQz41L8PRCL QuSg== X-Gm-Message-State: APjAAAWG7EZI1rfZsQBlinFBFpdz6SNc1gEdUoKgwLO4+CiOknTCPjmx mLSqjI5CKeNw44tc6PG56DcKCpjo4g8= X-Received: by 2002:a63:8a49:: with SMTP id y70mr35691142pgd.271.1564858085297; Sat, 03 Aug 2019 11:48:05 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:28 -0700 Message-Id: <20190803184800.8221-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v3 02/34] cputlb: Add tlb_flush_asid_by_mmuidx and friends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since we have remembered ASIDs, we can further minimize flushing by comparing against the one we want to flush. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 16 ++++++++++++ include/qom/cpu.h | 2 ++ accel/tcg/cputlb.c | 55 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) -- 2.17.1 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 9c77aa5bf9..0d890e1e60 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -240,6 +240,22 @@ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); */ void tlb_set_asid_for_mmuidx(CPUState *cpu, uint32_t asid, uint16_t idxmap, uint16_t dep_idxmap); +/** + * tlb_flush_asid_by_mmuidx: + * @cpu: Originating CPU of the flush + * @asid: Address Space Identifier + * @idxmap: bitmap of MMU indexes to flush if asid matches + * + * For each mmu index, if @asid matches the value previously saved via + * tlb_set_asid_for_mmuidx, flush the index. + */ +void tlb_flush_asid_by_mmuidx(CPUState *cpu, uint32_t asid, uint16_t idxmap); +/* Similarly, broadcasting to all cpus. */ +void tlb_flush_asid_by_mmuidx_all_cpus(CPUState *cpu, uint32_t asid, + uint16_t idxmap); +/* Similarly, waiting for the broadcast to complete. */ +void tlb_flush_asid_by_mmuidx_all_cpus_synced(CPUState *cpu, uint32_t asid, + uint16_t idxmap); /** * tlb_set_page_with_attrs: * @cpu: CPU to add this TLB entry for diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5ee0046b62..c072dd4c47 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -285,12 +285,14 @@ typedef union { unsigned long host_ulong; void *host_ptr; vaddr target_ptr; + uint64_t uint64; } run_on_cpu_data; #define RUN_ON_CPU_HOST_PTR(p) ((run_on_cpu_data){.host_ptr = (p)}) #define RUN_ON_CPU_HOST_INT(i) ((run_on_cpu_data){.host_int = (i)}) #define RUN_ON_CPU_HOST_ULONG(ul) ((run_on_cpu_data){.host_ulong = (ul)}) #define RUN_ON_CPU_TARGET_PTR(v) ((run_on_cpu_data){.target_ptr = (v)}) +#define RUN_ON_CPU_UINT64(i) ((run_on_cpu_data){.uint64 = (i)}) #define RUN_ON_CPU_NULL RUN_ON_CPU_HOST_PTR(NULL) typedef void (*run_on_cpu_func)(CPUState *cpu, run_on_cpu_data data); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index c68f57755b..62baaa9ca6 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -540,6 +540,61 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, target_ulong addr) tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS); } +static void tlb_flush_asid_by_mmuidx_async_work(CPUState *cpu, + run_on_cpu_data data) +{ + CPUTLB *tlb = cpu_tlb(cpu); + uint32_t asid = data.uint64; + uint16_t idxmap = data.uint64 >> 32; + uint16_t to_flush = 0, work; + + assert_cpu_is_self(cpu); + + for (work = idxmap; work != 0; work &= work - 1) { + int mmu_idx = ctz32(work); + if (tlb->d[mmu_idx].asid == asid) { + to_flush |= 1 << mmu_idx; + } + } + + if (to_flush) { + tlb_flush_by_mmuidx_async_work(cpu, RUN_ON_CPU_HOST_INT(to_flush)); + } +} + +void tlb_flush_asid_by_mmuidx(CPUState *cpu, uint32_t asid, uint16_t idxmap) +{ + uint64_t asid_idx = deposit64(asid, 32, 32, idxmap); + + if (cpu->created && !qemu_cpu_is_self(cpu)) { + async_run_on_cpu(cpu, tlb_flush_asid_by_mmuidx_async_work, + RUN_ON_CPU_UINT64(asid_idx)); + } else { + tlb_flush_asid_by_mmuidx_async_work(cpu, RUN_ON_CPU_UINT64(asid_idx)); + } +} + +void tlb_flush_asid_by_mmuidx_all_cpus(CPUState *src_cpu, + uint32_t asid, uint16_t idxmap) +{ + uint64_t asid_idx = deposit64(asid, 32, 32, idxmap); + + flush_all_helper(src_cpu, tlb_flush_asid_by_mmuidx_async_work, + RUN_ON_CPU_UINT64(asid_idx)); + tlb_flush_asid_by_mmuidx_async_work(src_cpu, RUN_ON_CPU_UINT64(asid_idx)); +} + +void tlb_flush_asid_by_mmuidx_all_cpus_synced(CPUState *src_cpu, + uint32_t asid, uint16_t idxmap) +{ + uint64_t asid_idx = deposit64(asid, 32, 32, idxmap); + + flush_all_helper(src_cpu, tlb_flush_asid_by_mmuidx_async_work, + RUN_ON_CPU_UINT64(asid_idx)); + async_safe_run_on_cpu(src_cpu, tlb_flush_asid_by_mmuidx_async_work, + RUN_ON_CPU_UINT64(asid_idx)); +} + void tlb_set_asid_for_mmuidx(CPUState *cpu, uint32_t asid, uint16_t idxmap, uint16_t depmap) { From patchwork Sat Aug 3 18:47:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170480 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2342257ile; Sat, 3 Aug 2019 11:51:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaSrOItyo+nY1ucY2HGiUEt6I5bezZN+RVlOSsqC1pmSaY+46FpZkpFxCC8RhKlRheqMwE X-Received: by 2002:ac8:2f66:: with SMTP id k35mr100241735qta.174.1564858265769; Sat, 03 Aug 2019 11:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858265; cv=none; d=google.com; s=arc-20160816; b=W+AcWCtzYe+eAOLnvDifnBPZ2vIGirmpWwD31XxPmRRHV0NW+zOsb4UlyoNOP/cN7/ fgNMiSxjCndZRiUDmpl1QuhPmriZuoa8CPJ1d5moRcn8RswUUdlrdxKRtFJRqi8OVkKt pklpylN0iIL6I/tPYWlwpbvNHu3mLXnU5+lPPswqq5xhvKggygl1araNHGoyj5QYnkG9 vR+FaLrYi+fXpV3eF6wVyXlO/mEEhF6MCYD9JZ8tXeofBRlMP40VhzTesR9LjWfxES/T rpthO83kVsSEXjJQ63WsKiBWO362cJoU9SlYr5wOoV/dNtfL0Kim0Ynq1Gs31K2gzZTe syCg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZRDl/Ha+kclTizhs/nHDa+7096PsBT003cOS/ic3LTY=; b=wc1qSgjYxReTGqRZmBMfcbgT2rR50w0xGIGmsT3VfDKfKF7lhJvaCdBAUuw3EAZ9zU BHvVFY25qQAtKOjH3JjdDwMYa9RW0eQJTnfKEYFhh0DmuBmJwGptUmzzoGicqEGgTX5j d8PPsMPJmMpwQ+4GwzxkzHUu9oc/5zkqzamLF1PUN2hQk2/tD/WyykIu7s8iMvXTM6cv X6ZT6p6NymgrV3vpOzR73LdjVizRD+8AjI+Hq/b0nxwbBxdirDFuS6dculnd7SHcHjpc /CYxgYyFJOqWhLYnvFfjFMum2F96UYVb1+TlSdNVm9DyOojy8/ctaFRz6jEx5WIOsmsn bZKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gO1RyuEd; 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 y2si31020056qtb.137.2019.08.03.11.51.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:51:05 -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=gO1RyuEd; 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 ([::1]:41372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz7R-0002FM-Bm for patch@linaro.org; Sat, 03 Aug 2019 14:51:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60533) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4b-0005yU-9m for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4Z-000763-P5 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:09 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:36212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4Z-00075j-JG for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:07 -0400 Received: by mail-pl1-x643.google.com with SMTP id k8so34907917plt.3 for ; Sat, 03 Aug 2019 11:48:07 -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=ZRDl/Ha+kclTizhs/nHDa+7096PsBT003cOS/ic3LTY=; b=gO1RyuEd4amyO2ZioV4wbCAXOswiL3HZaFPh3uZiBfDdBs1Hxj4qjpDVT1qE0w/Y/2 TCd2HoUEIsZPPem9Sz4MGxM/lb1njDYhPyBetZ/OwHnPIEzVBjbKvUEgzkOgoR7OROsX 6ZpH958pzmLMtWIKbj5Y4qSTIb//ClcMqUwrWF171EWHWOApxSfxo3aGH5/NWGz9Mkcf 7tGdzP7xNMG3EGKmDxY9z/BV/WmykaIb3Ly0LCXkcQ69cDzoIi3wfnUrz/9eFRauToxG 4zQ6QIJUBVIpNf21r0pUdtcFJya++VW7hA8RaVngSFKC9duw8Agsy07xLAL5UiIw99KD xv1A== 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:mime-version:content-transfer-encoding; bh=ZRDl/Ha+kclTizhs/nHDa+7096PsBT003cOS/ic3LTY=; b=JPhRNJPyK7BD2gA73Y8EYBCvOnTVVbW3P7OxudxFbDibcK+cGTAOI1psqxuGrVC56h YGpqC+EsJak9sn6OuF/ekeEdQZ0J8f/wJN/6IqOznfkFJMUstcH6EXbbSv4PKpejI9ZF QuWdUe/zB54GDWnSFVgXOVpa9xYbUCNn9n/RbnKT5em/vYw4Rou/XOyf5deWaO0L5oFD ua8B+iMKnVRASbdVWLhT+hAov9CSxDOCmqGu1nBNcLJ+tlQeEwqb8K2rj4zbBgIprj8G JegF+bdjH4MW+/Ieahbhlk11KIGdSmLqZTj7PiGTWaLJZadk9zOK7yGns+zxsk7YVB6U IhWg== X-Gm-Message-State: APjAAAVPoUEUkLFREKb8LxArpqz8KYHjuGfEcsQeSYy1OGQ5XTdlyWVv wkxWc1hkjYIYUadbV3N6Un8CXOjsQao= X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr139797676plo.88.1564858086446; Sat, 03 Aug 2019 11:48:06 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:29 -0700 Message-Id: <20190803184800.8221-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v3 03/34] target/arm: Install ASIDs for long-form from EL1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In addition to providing the core with the current ASID, this minimizes both the number of flushes due to non-changing ASID as well as the set of mmu_idx that are affected by each flush. In particular, updates to the secure mode registers flushes only the relevant secure mode mmu_idx's, and similarly non-secure updates only affect non-secure mmu_idx's. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 73 +++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index b74c23a9bc..2a65f4127e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3327,6 +3327,36 @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = { REGINFO_SENTINEL }; +/* Called after a change to any of TTBR*_EL1 or TTBCR_EL1. */ +static void update_lpae_el1_asid(CPUARMState *env, int secure) +{ + CPUState *cs = env_cpu(env); + uint64_t ttbr0, ttbr1, ttcr; + int asid, idxmask; + + switch (secure) { + case ARM_CP_SECSTATE_S: + ttbr0 = env->cp15.ttbr0_s; + ttbr1 = env->cp15.ttbr1_s; + ttcr = env->cp15.tcr_el[3].raw_tcr; + /* Note that cp15.ttbr0_s == cp15.ttbr0_el[3], so S1E3 is affected. */ + /* ??? Secure EL3 really using the ASID field? Doesn't make sense. */ + idxmask = ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0 | ARMMMUIdxBit_S1E3; + break; + case ARM_CP_SECSTATE_NS: + ttbr0 = env->cp15.ttbr0_ns; + ttbr1 = env->cp15.ttbr1_ns; + ttcr = env->cp15.tcr_el[1].raw_tcr; + idxmask = ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + break; + default: + g_assert_not_reached(); + } + asid = extract64(ttcr & TTBCR_A1 ? ttbr1 : ttbr0, 48, 16); + + tlb_set_asid_for_mmuidx(cs, asid, idxmask, 0); +} + static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -3363,18 +3393,16 @@ static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); TCR *tcr = raw_ptr(env, ri); - if (arm_feature(env, ARM_FEATURE_LPAE)) { - /* With LPAE the TTBCR could result in a change of ASID - * via the TTBCR.A1 bit, so do a TLB flush. - */ - tlb_flush(CPU(cpu)); - } /* Preserve the high half of TCR_EL1, set via TTBCR2. */ value = deposit64(tcr->raw_tcr, 0, 32, value); vmsa_ttbcr_raw_write(env, ri, value); + + if (arm_feature(env, ARM_FEATURE_LPAE)) { + /* The A1 bit controls which ASID is active. */ + update_lpae_el1_asid(env, ri->secure); + } } static void vmsa_ttbcr_reset(CPUARMState *env, const ARMCPRegInfo *ri) @@ -3392,24 +3420,19 @@ static void vmsa_ttbcr_reset(CPUARMState *env, const ARMCPRegInfo *ri) static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); - TCR *tcr = raw_ptr(env, ri); - - /* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */ - tlb_flush(CPU(cpu)); - tcr->raw_tcr = value; + raw_write(env, ri, value); + /* The A1 bit controls which ASID is active. */ + update_lpae_el1_asid(env, ri->secure); } -static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, - uint64_t value) +static void vmsa_ttbr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) { - /* If the ASID changes (with a 64-bit write), we must flush the TLB. */ - if (cpreg_field_is_64bit(ri) && - extract64(raw_read(env, ri) ^ value, 48, 16) != 0) { - ARMCPU *cpu = env_archcpu(env); - tlb_flush(CPU(cpu)); - } raw_write(env, ri, value); + if (cpreg_field_is_64bit(ri)) { + /* The LPAE format (64-bit write) contains an ASID field. */ + update_lpae_el1_asid(env, ri->secure); + } } static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3455,12 +3478,12 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { .fieldoffset = offsetof(CPUARMState, cp15.esr_el[1]), .resetvalue = 0, }, { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, - .access = PL1_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, + .access = PL1_RW, .writefn = vmsa_ttbr_el1_write, .resetvalue = 0, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), offsetof(CPUARMState, cp15.ttbr0_ns) } }, { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1, - .access = PL1_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, + .access = PL1_RW, .writefn = vmsa_ttbr_el1_write, .resetvalue = 0, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), offsetof(CPUARMState, cp15.ttbr1_ns) } }, { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, @@ -3715,12 +3738,12 @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), offsetof(CPUARMState, cp15.ttbr0_ns) }, - .writefn = vmsa_ttbr_write, }, + .writefn = vmsa_ttbr_el1_write, }, { .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1, .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), offsetof(CPUARMState, cp15.ttbr1_ns) }, - .writefn = vmsa_ttbr_write, }, + .writefn = vmsa_ttbr_el1_write, }, REGINFO_SENTINEL }; From patchwork Sat Aug 3 18:47:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170478 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2341492ile; Sat, 3 Aug 2019 11:49:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd585l9sgNRdgyYsWfMA4zYtYrsTmUGsa1bLcoG36BMxexaXLbTUohGR01cHuvvCz/LOZA X-Received: by 2002:a05:620a:15e5:: with SMTP id p5mr49555163qkm.409.1564858196771; Sat, 03 Aug 2019 11:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858196; cv=none; d=google.com; s=arc-20160816; b=1E/rZtZ527h/FmSIE3s/TATCySyC9nS6YYuHDm1KWesByozXvkaROtrSIHgJabvc2Q DgXlP9AwbC1jsKfPjWPWS+5HHMHpL2V+YWIJoK6Nyz6MmozN0eiceJQ5nSSFSbM3g2lI U4umNNvhPcDvZabg2MYjUWPmu5EMKJoOeiU9gHIPpp1jsj+jGrfRh0sIlBu4BrhCCp0G /0dCexT5V87i+l77C02nxUit0zfrCSg/pZ+vu3s79pPkYEMVL4z/9ix0GLFBWchV/I0L TlwusHLAY93Y7k3svIDfeVnwXI2dvMNG6OGnjyXUIQXWG6h7wOfW4PlPSwJPO09ViQw0 XDoQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7Rs0ix/SYQKzQx2FXXQO106tmFBYyCQIrr3vAmMEheQ=; b=fv8Jms6dIpk4L33VBa9Y93NCZl4Fivdx6NMrZgKGhCLA9hxzvST3jEeZrdS/X+2BZG u3FR5hE6s4uqtP/iFuT7JarIDkW883I2dZGyhnhUAwaD068l60bQdxQB49SV8HRrWNDR W9eXOKsCowy4cDzXf39yQU5WgFMSJwC06exNsMDSv/QvydtZgc4TezS2BZydgry7Lxjo 7m2Tah3Gj+DKCC3fAlUe5UNnV1YnCQ1ZlbTIlgIjvQezDulfmq4wbHqetvXWdFkdYQ30 HtyhfNrYcAb6yfznXM8Fh/WyXgbYOq7PxLTRFss1GzWqIl6IjTzqHu70pS8Q8SI7BFC3 XIWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vPvHAofj; 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 l23si25313009qve.12.2019.08.03.11.49.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:49:56 -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=vPvHAofj; 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 ([::1]:41358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz6K-0001BS-C8 for patch@linaro.org; Sat, 03 Aug 2019 14:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60549) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4c-00061C-0o for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4a-000777-Uv for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:09 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4a-00076R-Pe for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:08 -0400 Received: by mail-pg1-x543.google.com with SMTP id x15so27322524pgg.8 for ; Sat, 03 Aug 2019 11:48:08 -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=7Rs0ix/SYQKzQx2FXXQO106tmFBYyCQIrr3vAmMEheQ=; b=vPvHAofjDh13cvA96WTwyjFAdTULJbdQ9ybEFKJfgyYtqSaKhbOjXvki83K0xHqo11 MtokYAYkf6sRn5wnU8jQawtxscZaTYUt+AZIExuMd1wZejf8tNQ1Sfi6yxddylozCGR/ KI3d3Rybp77SktK7y2d1h68Tj9aKww6QaRRuuj7ZE2Xy+9SpsnqN9lAlrxLWQFKD7vEE I2URa8cgSieAlS83ATnACU2iiRE5N6FtxZip8dABXOGRbmKe4f+YImVa8ivdnw9kphBN CKon3LMB/w6/XtDeZ5S1GPpYRfDlXnJscrpe8roUK+OHwU7g6ePJvDppWqhMq/fls1hc zdZA== 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:mime-version:content-transfer-encoding; bh=7Rs0ix/SYQKzQx2FXXQO106tmFBYyCQIrr3vAmMEheQ=; b=gQDFDBUKwyjrmJNxdsNzOfsPuQelXkxar2cyk05AbzOw3g4mGgDB/oeOkXdwGQ9wzU hthGnm6TL8WRZuCxgxQ4qHtO5R+VMz6EXFDRsqjbI2VcKxtryZdUzaTQOqYLyUudVeod DVuxxM7Q13qa99+Oy6sNtOT/5m0AZldm947YdmP3OqAU7kjNfRo9kgiwBTxmwblZXxBr Nv0D1S3dW4roaug4NqjAu796pqWo+CfSCjYJNRKlPKmKeojkqY/Q8TloFJ0+ZNG5rwHm JJmdGouK4hS5LqpUla0I+N4TkwwUbIB85C5eB/eu655S8FlSD82gMgSTstRX0MJlTY9A wk7g== X-Gm-Message-State: APjAAAWQ52FFqrnek7zauEwPhM6j6/Xz245CAFVAUade1F1Cy4xpupkM SMB2IfGqxkl+lgsPvC+azcyh85NFWu4= X-Received: by 2002:aa7:97b7:: with SMTP id d23mr68186838pfq.203.1564858087487; Sat, 03 Aug 2019 11:48:07 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:30 -0700 Message-Id: <20190803184800.8221-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v3 04/34] target/arm: Install ASIDs for short-form from EL1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is less complex than the LPAE case, but still we now avoid the flush in case it is only the PROCID field that is changing. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 2a65f4127e..c0dc76ed41 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -551,17 +551,31 @@ static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); - - if (raw_read(env, ri) != value && !arm_feature(env, ARM_FEATURE_PMSA) - && !extended_addresses_enabled(env)) { - /* For VMSA (when not using the LPAE long descriptor page table - * format) this register includes the ASID, so do a TLB flush. - * For PMSA it is purely a process ID and no action is needed. - */ - tlb_flush(CPU(cpu)); - } raw_write(env, ri, value); + + /* + * For VMSA (when not using the LPAE long descriptor page table format) + * this register includes the ASID. For PMSA it is purely a process ID + * and no action is needed. + */ + if (!arm_feature(env, ARM_FEATURE_PMSA) && + !extended_addresses_enabled(env)) { + CPUState *cs = env_cpu(env); + int asid = extract32(value, 0, 8); + int idxmask; + + switch (ri->secure) { + case ARM_CP_SECSTATE_S: + idxmask = ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + break; + case ARM_CP_SECSTATE_NS: + idxmask = ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + break; + default: + g_assert_not_reached(); + } + tlb_set_asid_for_mmuidx(cs, asid, idxmask, 0); + } } /* IS variants of TLB operations must affect all cores */ From patchwork Sat Aug 3 18:47:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170475 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2340835ile; Sat, 3 Aug 2019 11:48:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8ldsLC51ZIUvNpZidF8qM4PpjnDpAQEOQ4BFmS9cpgwRgyCYo3pGpL7huaz+C7j1zn8Uk X-Received: by 2002:a50:d0d6:: with SMTP id g22mr126923771edf.250.1564858132854; Sat, 03 Aug 2019 11:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858132; cv=none; d=google.com; s=arc-20160816; b=FHj5TMZpWH7bzz5BT/Omnx4Ga2lEqiZttZ1E6ugcVVAtRRBjoaSnQF9hjE+OANVbil upxFKbOxfP3QXhiT49jiMpjFgYemHLnDsfEGeDgNh2OGu4IJYkiVI44hNrFAygeuyRSe OjbBlQrA40E/N4zawWRVpQdqZlcEnC38+QF8dMAM1dxfSNkI4l237QLqFCme/+gB76ph hnBRU4UIhbfDYlzFD3Iq9S3yF8urFmbY7D+2gVW2Gn4mWjvJse7dbo+SZyabDiCTlvOE T7qhyrCTXxHE1QEMM7bJDVq/rAQ74PbE2VkG3WBjLny1Pea5GqEdpIlYnHQkbipvxEaq f2sQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=hV2eslCkM9+11E22XGBDo1tPxuDz+vxwGvc3iXR5Q+U=; b=jS7HvuJramjNgL9qsPlVZ7J/vjvEsm6dvcpgR7V7Jb4OGrnfOKjcVw+enrB5aQNS3D rJ+uziSyC7IBl8J7mVgvlKc2c75ZSW00p6vohoMRogYdbkjGpNn4uQGY4ZspB6YThmLG B/WoiOHmpvFHV2HSCOWa/YwuWunSPu8kX0L+3Qe7qSGedgRAyaNZdNvnCtyreOPwWMNw sXVAROk6MVnYKeHpsa3MwJSIxKbtAQ0xig54flN8XuYs737tDoifgipIk0jZAyoUzZa7 onVdF0e4FQ5+xKjsOk9ErI7Qs4ge//93LWkwUUzGttOraXD2yNZ4t4rkgIyYWU1WEwvr BSQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zeuwLZaL; 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 qw10si24457565ejb.58.2019.08.03.11.48.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:48:52 -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=zeuwLZaL; 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 ([::1]:41340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5H-0006TB-RR for patch@linaro.org; Sat, 03 Aug 2019 14:48:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60581) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4c-00063Q-T8 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4b-00077s-TD for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:10 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4b-00077L-OA for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:09 -0400 Received: by mail-pf1-x443.google.com with SMTP id q10so37607192pff.9 for ; Sat, 03 Aug 2019 11:48:09 -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=hV2eslCkM9+11E22XGBDo1tPxuDz+vxwGvc3iXR5Q+U=; b=zeuwLZaLsuKqWvo0H7Lao3Xmq/IJ/PIq5u1FH0Yo7+Ni0P3R68YJHjwxjMrTtuaWjv 6UIrxJop+hOjmQMKQmGyUtp6T3hEuNYSt7wzQQZMeD4Whyg71621DfHr+ZDL3FNabgcM Ei6YZ1Qjm2qvwsPMXDbAodapGHrzDuKJ3WFjUAlA8hwRKF4hZoqaVeY8Cy4Zf5EQD70Q toso8YjoLAGaQ0ePImuSya6uKEGRuNX4Z83FoB9B2hX682K7shVPM9hj7y+Jn0ZN4wQE 8sVIe+ORce9HBYoAAavsZ0O0+Lb03HwTAA2v7x85Sf2HmI6PUWezWG7TUkVOBoRkMEhK GWZw== 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:mime-version:content-transfer-encoding; bh=hV2eslCkM9+11E22XGBDo1tPxuDz+vxwGvc3iXR5Q+U=; b=gm5CXamxZzmKFIFap4ZPFWc2mAuJjcqKYvxBE35igQ7PR1wHlBAQ4icG7YwMO65iUo guviJeT0CgEFFyEpAySZ2nXQjbwblf1tiRwtowtqACC9MaCWIDWrRpamIO02tp5wyw6r SUyNwv0Of8o+/eDTFWi30T4En4ZiYJrDhOr8k3OHl0VQHhg8IEIrCUZq1fm7uKqHEeVI 7qD8zF1l2GuXEecSyHfD0sNdxwrRpIkzjIvUjRYdnacvmpISX+EKoe+qKMlftEauGgP5 mVpfzYY81wQ2wHg7do5eSmc80gUq4G+GVvBbGzkmEf/JCpspwf8RofDRPSURZ6RPj/SL Oxsg== X-Gm-Message-State: APjAAAV/nyIJ4/7OsdaTYCwg+53KuMvCKMsFxz+Hr/+RkPHkrFTXruxv 18UVAwwLb49aYTnNBIXkdojX0T3YAYw= X-Received: by 2002:a62:8246:: with SMTP id w67mr67312952pfd.226.1564858088554; Sat, 03 Aug 2019 11:48:08 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:31 -0700 Message-Id: <20190803184800.8221-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v3 05/34] target/arm: Install ASIDs for EL2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The VMID is the ASID for the 2nd stage page lookup. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index c0dc76ed41..65e3ffbb43 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3452,17 +3452,23 @@ static void vmsa_ttbr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int vmid; - /* Accesses to VTTBR may change the VMID so we must flush the TLB. */ - if (raw_read(env, ri) != value) { - tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | - ARMMMUIdxBit_S2NS); - raw_write(env, ri, value); - } + raw_write(env, ri, value); + + /* + * TODO: with ARMv8.1-VMID16, aarch64 must examine VTCR.VS + * (re-evaluating with changes to VTCR) then use bits [63:48]. + */ + vmid = extract64(value, 48, 8); + + /* + * A change in VMID to the stage2 page table (S2NS) invalidates + * the combined stage 1&2 tlbs (S12NSE1 and S12NSE0). + */ + tlb_set_asid_for_mmuidx(cs, vmid, ARMMMUIdxBit_S2NS, + ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0); } static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { From patchwork Sat Aug 3 18:47:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170479 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2341654ile; Sat, 3 Aug 2019 11:50:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1wYBAdWNa3G8AZDiYiSc7pwzbUuKEfj2P5RZIRcda9HK78dUr1n33KnlYqD8Lw1TfQp+c X-Received: by 2002:ac8:26d5:: with SMTP id 21mr100267918qtp.266.1564858210632; Sat, 03 Aug 2019 11:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858210; cv=none; d=google.com; s=arc-20160816; b=pfom5LxBojDn4KqffoO5ZexX7mmnlS2eyGFcOXLSrKkcEBjyi1NAJWFKtZw07yHunZ te/nNi8m3bJIDA4Xd3jeK8DfRBFmntHaHP/qvOgRO06ZoKuerGyrlKBuO8KblaBzWQGM 3uC3A+xIvl/un7osfaO7elLCxIlG59IkICFFrQhBxCK0ercv0SwILdhSRvNnBdKYzs9u weYGrrJPiWb2GsGJF77n5GJA33braZNwt2mnLXw6d/HPznUlis30hqQiDIqXFD0IZ8+K XIW2XQNbDjyt0j+0/unZZxFL+r0m90+O0ghojmUdNvlWNvNcUvXJMBNNWmf2AFmA9kkF 29xA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=6IeFtwkeZbBPVLT5Rmllb3ExAsBhlKcdIq9EZhAeEOQ=; b=G7EijuNqGnb01JZdvQukso8Kok/jbxE7oL1OCGi1zxQaUfqfTx79v2aQCxG2eFvw+V 18KcPdpmXqEgOVMX+GZsbcYLuPrvdowf98y5GLRXZuxM/6qpXbVDfZ1GQO0VdZhP7j23 +JjFT7wXs8GKVW/0v8Rj0+5eOTcNo2+H0RmMXgB6K7l7GK8scZpnSlZdNw3C+aSUl+Aj yMCAGtKu+bCYJ3swt6PtKr9OIBTGnZEp5shr83v7h22fy9phfjqPKriTH95UUea+Q8MW 335DZn5K7/nyb+7EM+PrWU+UoB0i2UexbOLQGTw5VkCBArzrnzw/N3YWI3mabn+IYadY CCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EsBd2ZXy; 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 h4si17712819qvk.167.2019.08.03.11.50.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:50:10 -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=EsBd2ZXy; 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 ([::1]:41370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz6Y-0001xQ-8i for patch@linaro.org; Sat, 03 Aug 2019 14:50:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60614) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4e-00066g-AI for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4d-000792-B7 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:12 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:35702) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4d-00078X-6U for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:11 -0400 Received: by mail-pf1-x442.google.com with SMTP id u14so37642037pfn.2 for ; Sat, 03 Aug 2019 11:48:11 -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=6IeFtwkeZbBPVLT5Rmllb3ExAsBhlKcdIq9EZhAeEOQ=; b=EsBd2ZXyAs12YJkUflSxdyWDy4dQ1VA7S1sjPBpz/feC0S7PjxPutW98hpXE48BQqZ duze6YgLkmYtrK/9qzMMjqatC1CnyovW9Detsfq/azWI7VgxbyYirVQXMBjlehgbmcJY HfD0KpZXBfFvIAEmRtEXUO08hR5q6CKDMYULvli7jPWnoV3G828NSM8kGVuPxfXO3OPh PJhqZ3T4pSzJaVcrVBP52obs3ZUOSQESU5L4W+37vtXyru47NuaJCbF5BVYq754WLFDi d5+Lr6uoqePJXIa+64fy6wIuJIy/7nc3ggwjX93XLCoF3qE/rU07bekJKepVfBI8MAtS 7KTQ== 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:mime-version:content-transfer-encoding; bh=6IeFtwkeZbBPVLT5Rmllb3ExAsBhlKcdIq9EZhAeEOQ=; b=cf9eId0d4xND7iDdrhWFiLjvakS92V4+czPW4EvFxsBFpALFqL2HiqzXmReZiyj4lG G1i1rn2g56WdpL7nmE4Kso88KEQaTj2sg0cBLFzRQGb264MZxDgJ70XG+aFxflMm0+4/ CPXAP+5dVmSWNvDScfYERSwzAZ/ClV3f+83pLekJo8pEWgl0UseJgVEX6XlLq8wDUFsw 30ZtKSGZCC0jemKHL6LfhI7tntQb30FrMBLqZqdpH5Q1QtOyPed9E1EJFwqqwMzTXreZ wbdYVIfLn7VrONypKqHTKZ35kRA6x2qqIvQsU5gZl/O3s3PygMDNziTomB+vLYEeOkuw WPvQ== X-Gm-Message-State: APjAAAX+9o0x5rPs4V6RFa8B6h20EFKVQcT+Rzz3egxBwK5rbZTl/oFf mNYHJlX/NSpiQfCryIHEDHZApIVWjyU= X-Received: by 2002:a62:28b:: with SMTP id 133mr65294339pfc.251.1564858090005; Sat, 03 Aug 2019 11:48:10 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:32 -0700 Message-Id: <20190803184800.8221-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v3 06/34] target/arm: Define isar_feature_aa64_vh X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 94c990cddb..e6a76d14c6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3573,6 +3573,11 @@ static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; } +static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; +} + static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; From patchwork Sat Aug 3 18:47:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170481 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2342629ile; Sat, 3 Aug 2019 11:51:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPBDwCGn551sT6GNm8sGLHgXT0XlH5b8nVkm3AtqHfEgexzwEqX1u9Sx15w4B291jM3je/ X-Received: by 2002:a37:c247:: with SMTP id j7mr96229040qkm.94.1564858303176; Sat, 03 Aug 2019 11:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858303; cv=none; d=google.com; s=arc-20160816; b=KtGRPJQqIrpYL0DXxDldXlQPs4VjWSx/lho4Jui0I3jEHGk6RXjUNkyhHdc5Te845W aimK/s3fpA3yo6bF8FPeozqzvkNqDVWBlZWJu94whR1R0wbV1zN7Cf/BKq8neSyIxPf7 7Upx1WfKS+R9bwkJCmmxuyzT2ggXmNg81/fXNM8eQc/VYmWa4dgJpHW+z/BC9nyqHGJ/ vmiJjhEDte6eVuBqJfsXDZzac8Mk48QtaC3ZfMaM4D5aupjQGfGsZe9vkiv+mhBi+lUa LuQf+js5SRM565eldjHaEP3if8cchOIs9UFm5+R416pRwCwP2AhG9CY43LGtT9zl1jZU R3KQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=VC440BcwSuqOKz+Fo7ui0w+dupEF68UzkVylEVc+WDs=; b=jIZlkZD4P26hz2MVzW2R4WmSf2azOnovXxlB/vvmQa3jDL0CCbmG70ugZmf/rKCPfu cm+NsXVRNMztmgwnznLwlFPikMz7qgHHDmDd17gdUS03l/G+DQdazBXWuEr2dDw2b52k fzdapXhrcOlOBTM8R7tz1eMS2c8s0KBKYi1pv8eFNEmuO65xWy96kAeE0+Younxuk5dQ YaoMk1rTsu4aWfJiCp1KpewraRudJP+o2D1hksh1HrnuAzcdjoOfp97gVPpl6o9rzMMH 7j/s+oDs+DpJkXmX4x9pPq0v6/xkeWSWfIM8raXm+n0MU7iUgstSY0mMWpNVnFmmaGUv eV1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xYQqIug3; 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 p57si46605690qtc.217.2019.08.03.11.51.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:51:43 -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=xYQqIug3; 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 ([::1]:41384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz82-0003fX-QH for patch@linaro.org; Sat, 03 Aug 2019 14:51:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60644) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4h-0006CX-5p for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4e-00079o-R3 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:15 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:45989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4e-00079M-MD for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:12 -0400 Received: by mail-pf1-x444.google.com with SMTP id r1so37612157pfq.12 for ; Sat, 03 Aug 2019 11:48:12 -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=VC440BcwSuqOKz+Fo7ui0w+dupEF68UzkVylEVc+WDs=; b=xYQqIug3gmfLrgPuAZoKA+vetM7unvOZ/ZGAnj/U508vBjOOKgPiRgD1Kqn26Kleay mnfIK+wozNSd+s4VKGGZldx3aH3FaWGxLPvZSzApdwKxKPn/w3P1WTLmiXsteqysDCl9 5qMHusOO+bNqRwvYOx5bHMiJTfGTve3JxSHWI5s4Fc/AU/EgdvoZDV1W5lK1Hvt6AJyn QjDuCJJieLrHL2oW5lE9Rye5CAhZ1gL07/LDHjywbVZQNj36hHP4+cLTKme9MziVU2eT nury2BWc68bWSp+ZCFqKt7H4fT0FRLejKjejROKZDnI2jgExCs0AaBwKMV86gRws5EIh ialA== 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:mime-version:content-transfer-encoding; bh=VC440BcwSuqOKz+Fo7ui0w+dupEF68UzkVylEVc+WDs=; b=V9/DNaJ+/rXuQq0xAXqOjqdt5ztjvEcCjLcnjNwWT6+WkUK1v4lxTz1bqUgEWkn8wI GvBsXSUeQfqT/maGwUE2dA1ZPI4Wd1OtNQed59aMNOt/3iygLq6WtFILOn9F2oPNQH5H aeBUOYpTS2xwAjf4/SqwnI1uSoIgzm4h/y3bIM3dhdmPX2RRrD5T8uDd66m1NPI6pgg2 Pa5/igTRa6EZtgqChDxINjkn6yvoKf1Ja65SVjytcmSnYe7wkpwPufDXFOV3A5XpDy5z x8lf19Cb9KQP18hmagu13c+6ZQQzkDmdvDjIvmXt9dK+Nb/C3YTQhTsANa3/Ct9UBVf/ 1zGQ== X-Gm-Message-State: APjAAAWVZX+plKFWIvWQJ6uBhDaX2zsUIN1uzlqsJOkXhF7Nwwmfg5vy +A0nRetZyaRFfT1zAW3ezIagl4pnxCM= X-Received: by 2002:a62:5c47:: with SMTP id q68mr66933851pfb.205.1564858091413; Sat, 03 Aug 2019 11:48:11 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:33 -0700 Message-Id: <20190803184800.8221-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v3 07/34] target/arm: Enable HCR_E2H for VHE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/cpu.h | 7 ------- target/arm/helper.c | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e6a76d14c6..e37008a4f7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1366,13 +1366,6 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) #define HCR_ATA (1ULL << 56) #define HCR_DCT (1ULL << 57) -/* - * When we actually implement ARMv8.1-VHE we should add HCR_E2H to - * HCR_MASK and then clear it again if the feature bit is not set in - * hcr_write(). - */ -#define HCR_MASK ((1ULL << 34) - 1) - #define SCR_NS (1U << 0) #define SCR_IRQ (1U << 1) #define SCR_FIQ (1U << 2) diff --git a/target/arm/helper.c b/target/arm/helper.c index 65e3ffbb43..9a18ecf8f6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4623,7 +4623,8 @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); - uint64_t valid_mask = HCR_MASK; + /* Begin with bits defined in base ARMv8.0. */ + uint64_t valid_mask = MAKE_64BIT_MASK(0, 34); if (arm_feature(env, ARM_FEATURE_EL3)) { valid_mask &= ~HCR_HCD; @@ -4637,6 +4638,9 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) */ valid_mask &= ~HCR_TSC; } + if (cpu_isar_feature(aa64_vh, cpu)) { + valid_mask |= HCR_E2H; + } if (cpu_isar_feature(aa64_lor, cpu)) { valid_mask |= HCR_TLOR; } From patchwork Sat Aug 3 18:47:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170485 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2343357ile; Sat, 3 Aug 2019 11:52:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMdi2455lwuyU2ih/25K/iwQZZLwfv8caikyTzLVjroPrS3GrvC3oi8iGW62QRneIz3gsK X-Received: by 2002:a0c:d94e:: with SMTP id t14mr99121061qvj.18.1564858370279; Sat, 03 Aug 2019 11:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858370; cv=none; d=google.com; s=arc-20160816; b=K0hw4VOqXmpkHZfDcS5y8yIP7/nVLR/JTWaJSUA8bsTQO3CHNvomnah2VZHyBMRmIm knydahhSwS6hUUFkA4t6k6PjHU/8W4vj/rk2FBXYJMHN4y23JhDUj9tJmN2u5npXf86n eqdLl0SV9pqaJFWmzB1k7bq9oHE0nqf53F/jB8oOsnVmhWUjw63TwDAOXoOqdCLGdZ10 VwL6GvCtja2gQXaK434gg6T8muUcUOjfqxm3l3WoW6UpI60ql87Pnrg7dok52/cl09nV aPt/qn/v9+fahn93Wqe0YYkWVgGX0gPES/KqicEQhST7VLcZUCYGBhLSIk0VCv/jrucL 9wsw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=UXfquYo4jedlrPKGUGGz5+yEbpc/txGBR5GoujNYRkjyAqPPG0Gmuv40BNG6GB7FRJ IIPUfNzu6vEJ424ABLyqVsAKUVVo4jjt8dQbT209sm2IBI5kE9VX4TAgNVD5prfqbTx2 1F8NKallA6AXirYQZTvxObOc59jsY++9B+QLK/Eahpw9T0KPpqMsFnZT/eWgnvB/62ud e6/dTYc4kAiOtuN0gXpiqYrexSakfrQg4seEkdo7AYQFALngV8JTpV65092L5vv4BKJL J9AFOkoW+N8EKawwGUmzyj4udlZ0pA/fFDUl/bbmwz8h5yOzJoppD7bfpaFRDM+Ae2Zt iyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XOuKwYgo; 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 d26si49549585qvd.200.2019.08.03.11.52.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:52:50 -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=XOuKwYgo; 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 ([::1]:41422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz97-0007xg-Ti for patch@linaro.org; Sat, 03 Aug 2019 14:52:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60690) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4k-0006EG-6L for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4i-0007B1-06 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:18 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4h-00079z-3Y for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:15 -0400 Received: by mail-pl1-x641.google.com with SMTP id az7so34857647plb.5 for ; Sat, 03 Aug 2019 11:48:13 -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=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=XOuKwYgouGDpkaX6L6Uu/ztO4LamAjukWRR1TU+AbO+9d8EmzEJYGDgd3wbWL+1eQn FoDehmYmUS91lcRg8bfPfB94G6o/PJLpxhj86ESqDCIBvqYfIH3+AH9bJvaa+UdX7iPk jvuhHyVBQD1BGOx1IIU+wgGZN8QBO/0omjs6XaXVN7XIdVAHGJE8Qnc7KKnvmQV+/jyF FLW5nklHtdH2xKYULu3K82i8NFlqdfNFh2giImdOFsgyivibizZVPqg62mqkrvHKEIF4 Vq7/+zZCwlmLTqkj/DomwraVUncNHLrHbGLpQc1/lczLH+39ypVYm5oRoVo0WJvRuhQZ bXSw== 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:mime-version:content-transfer-encoding; bh=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=eek/sgSSHBqLoqQ61ey7tPAVSrFCZqSMNbcg0P1ROrCa0tFSGpp172eQqKLnRH32MO zJv53T8xwScPcXCmDMPh26VqINfIoGk2pquaQL6LJWvp3ZYi9Ro2Op8uXh5/egakL9T7 5qMSrdjJHTslIU9onrw0Yx6yzYmiqmsKI70QI0eplGGrIRgbSMadYCdvoZQ7VezPm+bl nUGmmxXOWp3erhG5dfAU0urwN4/XOlOwr/aui4dx5WL0UUVVxldJrrdPf6xlPIIPfFnZ dxOQ88d++/rgbT2d/EA837q2HgNZD2yAkmm2A+ka5Q/ptUOUpoxmaFVYWLbB05FD18AX lGiw== X-Gm-Message-State: APjAAAV5fIwryGzznebbwrsmIkyhh2nUIUfGORQCFXEYv6rAGyfwgEJc zDE6q2fq8BnEqjeyEm6bShQNuGqO/NM= X-Received: by 2002:a17:902:bc83:: with SMTP id bb3mr140601680plb.56.1564858092641; Sat, 03 Aug 2019 11:48:12 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:34 -0700 Message-Id: <20190803184800.8221-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v3 08/34] target/arm: Add CONTEXTIDR_EL2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Not all of the breakpoint types are supported, but those that only examine contextidr are extended to support the new register. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/debug_helper.c | 50 +++++++++++++++++++++++++++++---------- target/arm/helper.c | 11 +++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index dde80273ff..2e3e90c6a5 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -20,6 +20,7 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) int ctx_cmps = extract32(cpu->dbgdidr, 20, 4); int bt; uint32_t contextidr; + uint64_t hcr_el2; /* * Links to unimplemented or non-context aware breakpoints are @@ -40,24 +41,44 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) } bt = extract64(bcr, 20, 4); - - /* - * We match the whole register even if this is AArch32 using the - * short descriptor format (in which case it holds both PROCID and ASID), - * since we don't implement the optional v7 context ID masking. - */ - contextidr = extract64(env->cp15.contextidr_el[1], 0, 32); + hcr_el2 = arm_hcr_el2_eff(env); switch (bt) { case 3: /* linked context ID match */ - if (arm_current_el(env) > 1) { - /* Context matches never fire in EL2 or (AArch64) EL3 */ + switch (arm_current_el(env)) { + default: + /* Context matches never fire in AArch64 EL3 */ return false; + case 2: + if (!(hcr_el2 & HCR_E2H)) { + /* Context matches never fire in EL2 without E2H enabled. */ + return false; + } + contextidr = env->cp15.contextidr_el[2]; + break; + case 1: + contextidr = env->cp15.contextidr_el[1]; + break; + case 0: + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + contextidr = env->cp15.contextidr_el[2]; + } else { + contextidr = env->cp15.contextidr_el[1]; + } + break; } - return (contextidr == extract64(env->cp15.dbgbvr[lbn], 0, 32)); - case 5: /* linked address mismatch (reserved in AArch64) */ + break; + + case 7: /* linked contextidr_el1 match */ + contextidr = env->cp15.contextidr_el[1]; + break; + case 13: /* linked contextidr_el2 match */ + contextidr = env->cp15.contextidr_el[2]; + break; + case 9: /* linked VMID match (reserved if no EL2) */ case 11: /* linked context ID and VMID match (reserved if no EL2) */ + case 15: /* linked full context ID match */ default: /* * Links to Unlinked context breakpoints must generate no @@ -66,7 +87,12 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) return false; } - return false; + /* + * We match the whole register even if this is AArch32 using the + * short descriptor format (in which case it holds both PROCID and ASID), + * since we don't implement the optional v7 context ID masking. + */ + return contextidr == (uint32_t)env->cp15.dbgbvr[lbn]; } static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) diff --git a/target/arm/helper.c b/target/arm/helper.c index 9a18ecf8f6..8baeb3f319 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6801,6 +6801,17 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, lor_reginfo); } + if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { + static const ARMCPRegInfo vhe_reginfo[] = { + { .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, + .access = PL2_RW, + .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) }, + REGINFO_SENTINEL + }; + define_arm_cp_regs(cpu, vhe_reginfo); + } + if (cpu_isar_feature(aa64_sve, cpu)) { define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); if (arm_feature(env, ARM_FEATURE_EL2)) { From patchwork Sat Aug 3 18:47:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170482 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2342682ile; Sat, 3 Aug 2019 11:51:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMprot1FdJBynbljQ0rp8WRCfsyrUo4TEq+EB9qt+8V3qsXpdI9tkFlm1g1OYMoJ3m0cTF X-Received: by 2002:ae9:f303:: with SMTP id p3mr94411056qkg.320.1564858309036; Sat, 03 Aug 2019 11:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858309; cv=none; d=google.com; s=arc-20160816; b=MH9cUI0KLW7bDocmdFRGg8JtkOkD+Z7kHnDmVjWabwjD3+LP8n1FVBiDeWkDoeiP9b QJ8RYPXJhHNonryDYM9QNJI3Aha+Goxk9r6UDh8SM1nmeDT9GhAqssIjy+Ci1HsxN472 xMKI3IdlhrYFssRnNH4NV9hIMi1AxJ/dRjtZw9vo8ZgDKDGZiY6maMws/JTQrVc3+DI+ m3kzpWrvVFcPgOAl/oiB26V8iaLEdj9s1ZSbReI6uvSMDobrC0UeWj3Cuu3uHmGl93Mq r8kdxgV0PrYJORzNCjiN9qtu6fk9sKaClMH7H3sNtwDPIdTl7GYST+99ddkx31Ozm69e TbkA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eXztB5+CPZYWvtJqCXCkkbobp/U8zAPLQueishTnE64=; b=Whseg2AIoJ3ba0zc2jxyCohmMwJ+D612cJyTGIhz+H2GvRoWS89n5dDV9kKdQigAoh dOZjHi7uUhk/3UWyIN4y7YHTZ+uuLuIOAqRzkUFXIovJPaDN1xmW4amBzFaTWKg5qyjE veU2ca9sfnpHa1jihXMZteBxL4ZFK7bLqI94NOObQziIvMCA1X5PrgTqVQTDnzrEsTi3 yG4Z+jLFl7wUuj1vDN6nR00WOtCbEeF1w0aHDJD47QKeKmk1hKizdLU2GF6Qm7/tP8N7 WXoP3UdiRJ47bPPYj5ZR6xGHzpCPvUK2zydlpHNeUoZ7QzvI2qZXcnsyXixxmDSHpjDB a8kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AJ98DjJu; 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 n37si812778qte.331.2019.08.03.11.51.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:51:49 -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=AJ98DjJu; 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 ([::1]:41392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz88-00050C-Jh for patch@linaro.org; Sat, 03 Aug 2019 14:51:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60692) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4k-0006EH-6a for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4i-0007B7-0G for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:18 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:36583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4h-0007AJ-5O for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:15 -0400 Received: by mail-pf1-x441.google.com with SMTP id r7so37626311pfl.3 for ; Sat, 03 Aug 2019 11:48:14 -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=eXztB5+CPZYWvtJqCXCkkbobp/U8zAPLQueishTnE64=; b=AJ98DjJuyQa8Lr5B1/KRUNoK+ILQGZEY9Jv3+Ww03P6WGufe/CvR8wyHMj88ptaIR4 r0bz8uvJn0E8vEGQoHbmsxXpve9cfB66rxvlVOkP9ljpopFmHG1HcxbH8MWz7/H6q3M6 u95D3jILdArc0uyivXitYvp/ISBhXCsXQvaDnNABaopop/5PgGllnE99riLxlLbRUUc8 2uo3HYe/J1G0KDBaQFEyXM7aXMX/W/5LTHVOxlT+NvzzmkBDKDJxrQZBOVYCfq3ezmxW fV87C/o1zBtN9yOn+zD50rUqX+VBxjFC3dQUVAaej+TKRJgx1ZB5eCkudDlyeWXz1YUf Jtsw== 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:mime-version:content-transfer-encoding; bh=eXztB5+CPZYWvtJqCXCkkbobp/U8zAPLQueishTnE64=; b=LJubyNOzmPZGytdygDInN26K8MV3kp6LWEKzNHdvT9t04GdwXiB5bLMJQtjYCS+Vlt KKZ4GTrIpDf2/4WI9hwR0pDGpbkumqrA7kXKe581B6czCyE1hEfwrkZtseVB+Me+47vO C3UvPcpdqkR4mqGa1RJhmw3R6rubMsbouQVn9r9CD1V8/CXhZDmJZHbJDEG6K6NWMoaf deoRb4zXrC4MQ7lprV5HgVOlpbiJthFRFzCvEWPZTs8pnp4LvQLz26BFjSfkL1x2q+A7 5hbYGudtBOjnLAcI0mYMXKQWFi4OfZNY1FBC6BUOvyijDQCrOpaP9caa4T0wHImNZn5t Kkpg== X-Gm-Message-State: APjAAAVG0ukj01I3v6Oyygki7KRQkg/NvpgiT940F1Fj5h+UeQPAmkZA eA6ObP9X77QGzZmgpDI2ByYYpUWpz6s= X-Received: by 2002:a62:750c:: with SMTP id q12mr67644200pfc.59.1564858093677; Sat, 03 Aug 2019 11:48:13 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:35 -0700 Message-Id: <20190803184800.8221-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v3 09/34] target/arm: Add TTBR1_EL2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the same time, add writefn to TTBR0_EL2 and TCR_EL2. A later patch will update any ASID therein. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 8baeb3f319..8d8b3cc40e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3449,6 +3449,12 @@ static void vmsa_ttbr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, } } +static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -4844,10 +4850,8 @@ static const ARMCPRegInfo el2_cp_reginfo[] = { .resetvalue = 0 }, { .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2, - .access = PL2_RW, - /* no .writefn needed as this can't cause an ASID change; - * no .raw_writefn or .resetfn needed as we never use mask/base_mask - */ + .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, + /* no .raw_writefn or .resetfn needed as we never use mask/base_mask */ .fieldoffset = offsetof(CPUARMState, cp15.tcr_el[2]) }, { .name = "VTCR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2, @@ -4881,7 +4885,7 @@ static const ARMCPRegInfo el2_cp_reginfo[] = { .fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[2]) }, { .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, - .access = PL2_RW, .resetvalue = 0, + .access = PL2_RW, .resetvalue = 0, .writefn = vmsa_tcr_ttbr_el2_write, .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el[2]) }, { .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2, .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, @@ -6807,6 +6811,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) }, + { .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1, + .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, + .fieldoffset = offsetof(CPUARMState, cp15.ttbr1_el[2]) }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vhe_reginfo); From patchwork Sat Aug 3 18:47:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170486 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2343495ile; Sat, 3 Aug 2019 11:53:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxW/Mn3bBMulO5LsnZWoG1JtbyrbDNutThDv5wGVOwjp2t1+5A9X7qoB3CmyMSzxtQGD3SF X-Received: by 2002:a50:ed07:: with SMTP id j7mr127098848eds.107.1564858383877; Sat, 03 Aug 2019 11:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858383; cv=none; d=google.com; s=arc-20160816; b=l/vhJYgfz4mVOs3ttTPLEv0dmQdXYjZPH6zOfGGym6wg2OeEJV3X7GJz2rKckXratE R5BclV5vn+TKGAyT0yYuXV7oFNJRNoqviDRrW+hO8t/hwUZAKLPt+NbzkLQP13HR11yN S4NNy1wuat9Bwu0Xx9Y7n17L3XUOHR6UbSbFx1jHX0TcjSvtZNKPcytnCFNyKE5+WIgh zSlMhnhdmMpGVmSkzaKeSegceo6QleljHnOhv/WCy3R7jUa9KswGRcGxjOH/iF0JOa2Y BWvWHv3Mm8W1QxfJ8Y0IQ22QU7tSCGM+awFRx19x0EBXcXqfqA11c40T4hJmCqWVznZm A0Dw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ebweW1bxG4mlr4zUkxD0Pv+fcpZzn603jNjjqkso5Rc=; b=ywtDSL0YWLhLQgC9JducWt5vvhMrqRIQz43di+jTl4KaywnYqn33FAGfCdVJ6q5p5n U31UTNjTgAPdm7LxgP+FVWck/WemPAo2BX3XjHfjaHylUujwX/X1EaaiDn7vpk2dK8ws VxRey/SbkqVq2KYV1FsyDOq5G2TIk3SH0g7QAMivQEwxZXs0a9LXFjtdC/fgKK3uykrG 41UspQDQeTCjb6MY4s5J5oi0TrVSHfB6KCqFQtMZ2rPb9TA08gzP3C5NsYImJouFsVha sNfScuWolke4V6/JwV6DpcLXwC3/lpdArCo9TVM/558MpTnCFHX2CKffGrUvoaHHbnay 0UWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dO8sJijZ; 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 o7si24896341ejr.13.2019.08.03.11.53.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:53:03 -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=dO8sJijZ; 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 ([::1]:41428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz9K-0008WQ-Sv for patch@linaro.org; Sat, 03 Aug 2019 14:53:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60726) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4l-0006FM-L1 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4k-0007C8-4W for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:19 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4i-0007Aq-9e for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:16 -0400 Received: by mail-pg1-x541.google.com with SMTP id o13so37653042pgp.12 for ; Sat, 03 Aug 2019 11:48: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=ebweW1bxG4mlr4zUkxD0Pv+fcpZzn603jNjjqkso5Rc=; b=dO8sJijZ1OJHBbtBkNrBGZwgxZqhDR3pnZ17F4RG48Q+rZ2YYG+zmyWKMdUWJgYasD npGZFmyiQ+SppHzUz0YshpFHT2cj/buuGGrgh6aROftTUI9XolXqun8J9P5EhmWip+ze Bp0dYd2RLKbOSIOmH3ZOElHSGMHsJ0a+RudWjmrdPGtZNqYbT3WSKKumXM3D5Q5ZjFeg f0fLiQwKRm/adsq7n+R+xANG4DA6lWtGQfIIjrlDHkyRD2yTYz1fACiEGO3OxFEHVpED oErG27FbDZuX3lNsJGA1vopDmV4jeiHvqNwZlt49WL/y73eqCBV908eDQtKxRA7afIxZ eaEA== 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:mime-version:content-transfer-encoding; bh=ebweW1bxG4mlr4zUkxD0Pv+fcpZzn603jNjjqkso5Rc=; b=j4nJ2iRDrxfC3uSWE9vlq507Eae+3Aa/heUaIM94opmX0YQ2lKK57JEOBJg2k5TDCK 57qr7D3cB/u2Oi+AjZqj7bqYhyTNSowC3dtiHKH8ox5QPoPV+qwq8te6YFdUC0zD5aU6 Z7nlKHrVgOB7FnCVUBgeuV2yCcYf0QZxDf395fFHB/NMjQq7bdqPn/Fy1nDHHMUz6l9K s4vBGZJiEQbwt/p8vMVtahkRlvNOoxUAX8hiW5IV62eX8rGPOuPZm/XhDdz7s+M6puYz a86edMYTBRry1AGEnvsbY/rFk4N6vOO2mAoeyQoCXZEiWqR9xGYgGZmAhI3nlQK1UMCa 4BqQ== X-Gm-Message-State: APjAAAXlyAzyCljjN0FFmL2Ily5HyhZhMVTt94OuIBeP6GSW66tMEVNK ULaRzfo9VOk/48LIv/lAsz+NT/XyML4= X-Received: by 2002:a62:e710:: with SMTP id s16mr67733969pfh.183.1564858095005; Sat, 03 Aug 2019 11:48:15 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:36 -0700 Message-Id: <20190803184800.8221-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v3 10/34] target/arm: Update CNTVCT_EL0 for VHE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The virtual offset may be 0 depending on EL, E2H and TGE. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 8d8b3cc40e..e2fcb03da5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2484,9 +2484,31 @@ static uint64_t gt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) return gt_get_countervalue(env); } +static uint64_t gt_virt_cnt_offset(CPUARMState *env) +{ + uint64_t hcr; + + switch (arm_current_el(env)) { + case 2: + hcr = arm_hcr_el2_eff(env); + if (hcr & HCR_E2H) { + return 0; + } + break; + case 0: + hcr = arm_hcr_el2_eff(env); + if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + return 0; + } + break; + } + + return env->cp15.cntvoff_el2; +} + static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) { - return gt_get_countervalue(env) - env->cp15.cntvoff_el2; + return gt_get_countervalue(env) - gt_virt_cnt_offset(env); } static void gt_cval_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -2501,7 +2523,13 @@ static void gt_cval_write(CPUARMState *env, const ARMCPRegInfo *ri, static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, int timeridx) { - uint64_t offset = timeridx == GTIMER_VIRT ? env->cp15.cntvoff_el2 : 0; + uint64_t offset = 0; + + switch (timeridx) { + case GTIMER_VIRT: + offset = gt_virt_cnt_offset(env); + break; + } return (uint32_t)(env->cp15.c14_timer[timeridx].cval - (gt_get_countervalue(env) - offset)); @@ -2511,7 +2539,13 @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, int timeridx, uint64_t value) { - uint64_t offset = timeridx == GTIMER_VIRT ? env->cp15.cntvoff_el2 : 0; + uint64_t offset = 0; + + switch (timeridx) { + case GTIMER_VIRT: + offset = gt_virt_cnt_offset(env); + break; + } trace_arm_gt_tval_write(timeridx, value); env->cp15.c14_timer[timeridx].cval = gt_get_countervalue(env) - offset + From patchwork Sat Aug 3 18:47:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170490 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2345021ile; Sat, 3 Aug 2019 11:55:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaf29OMeIYzzpBPliiJ+WidUV2sHRF6k0S2r+lg1W7PSotORzTlB85Pflq+DbG+5Y3egMX X-Received: by 2002:aa7:c149:: with SMTP id r9mr122960788edp.92.1564858537359; Sat, 03 Aug 2019 11:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858537; cv=none; d=google.com; s=arc-20160816; b=LdNlSsNvle66uyjyUDh1PuoesYDoynCDVAYBaSVMQX4s3jO0zFqBQxd4nWlgVdTxEO X9sSdNAWTYwgJAA8Et2DWy68jyRjQaW1ZqDoxPKOIQaGVp3sKqN/0Qn/kow4FTqjBCnN lgbpaaWKi42nBVORmzd0tM0hNwKW67vo8lBFI8gxtXitrMzRLs+T/95NCuD5aT7Jtb43 PXdwbbdxM/CnpfaLz+D2rqCVA8UG4iLIohCxmvs18yhQGWWtGgX8LEmwZ6NtxJa0VPzs 2XRur2qGbXI3YnYFeeWyKl6Aoz9OJSifdSfu3fm9Z5MD7qpk6dVdwGYN9wxFZ7VGK9PH jTmA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=XQAThtHXgFyxyKRl2tP3DLgR3ROFgj6xArwRDkS66hw=; b=wS4jDEzuMwQxcMKh6nJYqchKNWHcgxalyka2aUQpmsIrkITOJ7KsN4t0+/sW0huz7h aLyX1f8sEFF7E+1YocgQmzr+7JL6yesjcFDd5IlkKM/mF9tvaUp0dwx9f8yHpz24fIF0 xuoZ4U2waMOyMQJViXxlS7OfppRGExnQ9mYzLlHlIUtLYjwSBYSwGPzNW3z1g1KACCrt Xs1wXihZFLq7+fiTD707jtzpj4n/kObgS7iNpkevI1KDMr1UukUiO3oVzIV4juuU+DTL n+++WkoMDzbhPMgNGdTd9KyCH1KBa1a3eR4HTa1/ilr86gpJ3791pL74OuHeQgMj6QeE AHSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HYzJtc4U; 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 w41si26688156eda.9.2019.08.03.11.55.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:55:37 -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=HYzJtc4U; 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 ([::1]:41464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzBo-0003pb-CD for patch@linaro.org; Sat, 03 Aug 2019 14:55:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60761) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4o-0006H5-0Z for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4l-0007DO-KB for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:21 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:36974) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4k-0007Bb-8h for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:18 -0400 Received: by mail-pf1-x441.google.com with SMTP id 19so37616100pfa.4 for ; Sat, 03 Aug 2019 11:48:17 -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=XQAThtHXgFyxyKRl2tP3DLgR3ROFgj6xArwRDkS66hw=; b=HYzJtc4UILsYqHR3YMKJ2c7daYwFs9zPhg1eV7Vi3ygCUyRnRaa+lx3zvB/6jGWc9m 7XWhIeW7l7bq3zr103Lm1lmY0xHzB4UkCej5+WuiIMpY9qHPs3EdhEMsgyqCqhTj2dHY +j2AssPsadGFSRo8gYavQ7kqEpfVer3Up2+R2ylIzJKdGbBg91DkbEJo80ixMASFFP15 KjE8cs5rqFJ6epB/Ns0k8ol004Ii6zOgbEpSnHFGw4KxEAN9D2bB2kuh0bISBmBSlhFH hvtvr9m7D3gRupu/E207j72Q7X7b8iAsFAMW9Co+hPP4DNjON0RqMyRBOg44xR+RH8yr J3sg== 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:mime-version:content-transfer-encoding; bh=XQAThtHXgFyxyKRl2tP3DLgR3ROFgj6xArwRDkS66hw=; b=F1M5DTc6IqdDdzJZbyF2zPPF9TInj5oLwOTr88gvqqRPBqjIgu5g0PJZR+XjBHJ33F 6HeXfGTSqUxYO9fJPljxWn9paIM/g5nipIbn29h3t72QKmuceI7eVDYJ9tFhjskC6K73 xLPTTXP+b4bNF3UzRH5WlyJ1PprV+KAOQjq/oZsivL/3slbqLsq+YGOGmoBCim1XF06o LJ0w68b8z5gr2k6xL/4/pOZdhzcrMe+0VtmEtls41DpXXLRqKjxt3IPBtCuqpELsvITS 6ELA9S0E3HWTdnDHOma+ztHcd4OO3QJAICfjkgfNFcu780WJgIZVlPDVOSWP0Timo7as IRIw== X-Gm-Message-State: APjAAAWiQYhhNDG6sza67X1Wh5eRSOEC0bkSlXGBxs59ci1hzpUGvGAw YX31pDg3hpBbjV7HZ6Hgi5h69KT7v/s= X-Received: by 2002:aa7:8102:: with SMTP id b2mr24660458pfi.105.1564858096083; Sat, 03 Aug 2019 11:48:16 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:37 -0700 Message-Id: <20190803184800.8221-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v3 11/34] target/arm: Add the hypervisor virtual counter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 1 + target/arm/cpu.h | 11 +++++---- target/arm/cpu.c | 2 ++ target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 2049fa9612..43fc8296db 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -76,6 +76,7 @@ void arm_gt_ptimer_cb(void *opaque); void arm_gt_vtimer_cb(void *opaque); void arm_gt_htimer_cb(void *opaque); void arm_gt_stimer_cb(void *opaque); +void arm_gt_hvtimer_cb(void *opaque); #define ARM_AFF0_SHIFT 0 #define ARM_AFF0_MASK (0xFFULL << ARM_AFF0_SHIFT) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e37008a4f7..bba4e1f984 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -144,11 +144,12 @@ typedef struct ARMGenericTimer { uint64_t ctl; /* Timer Control register */ } ARMGenericTimer; -#define GTIMER_PHYS 0 -#define GTIMER_VIRT 1 -#define GTIMER_HYP 2 -#define GTIMER_SEC 3 -#define NUM_GTIMERS 4 +#define GTIMER_PHYS 0 +#define GTIMER_VIRT 1 +#define GTIMER_HYP 2 +#define GTIMER_SEC 3 +#define GTIMER_HYPVIRT 4 +#define NUM_GTIMERS 5 typedef struct { uint64_t raw_tcr; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ec2ab95dbe..4431330c2e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1226,6 +1226,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) arm_gt_htimer_cb, cpu); cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, arm_gt_stimer_cb, cpu); + cpu->gt_timer[GTIMER_HYPVIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, + arm_gt_hvtimer_cb, cpu); #endif cpu_exec_realizefn(cs, &local_err); diff --git a/target/arm/helper.c b/target/arm/helper.c index e2fcb03da5..e0f5627218 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2527,6 +2527,7 @@ static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, switch (timeridx) { case GTIMER_VIRT: + case GTIMER_HYPVIRT: offset = gt_virt_cnt_offset(env); break; } @@ -2543,6 +2544,7 @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, switch (timeridx) { case GTIMER_VIRT: + case GTIMER_HYPVIRT: offset = gt_virt_cnt_offset(env); break; } @@ -2698,6 +2700,34 @@ static void gt_sec_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, gt_ctl_write(env, ri, GTIMER_SEC, value); } +static void gt_hv_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + gt_timer_reset(env, ri, GTIMER_HYPVIRT); +} + +static void gt_hv_cval_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_cval_write(env, ri, GTIMER_HYPVIRT, value); +} + +static uint64_t gt_hv_tval_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + return gt_tval_read(env, ri, GTIMER_HYPVIRT); +} + +static void gt_hv_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_tval_write(env, ri, GTIMER_HYPVIRT, value); +} + +static void gt_hv_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_ctl_write(env, ri, GTIMER_HYPVIRT, value); +} + void arm_gt_ptimer_cb(void *opaque) { ARMCPU *cpu = opaque; @@ -2726,6 +2756,13 @@ void arm_gt_stimer_cb(void *opaque) gt_recalc_timer(cpu, GTIMER_SEC); } +void arm_gt_hvtimer_cb(void *opaque) +{ + ARMCPU *cpu = opaque; + + gt_recalc_timer(cpu, GTIMER_HYPVIRT); +} + static const ARMCPRegInfo generic_timer_cp_reginfo[] = { /* Note that CNTFRQ is purely reads-as-written for the benefit * of software; writing it doesn't actually change the timer frequency. @@ -6849,6 +6886,26 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1, .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, .fieldoffset = offsetof(CPUARMState, cp15.ttbr1_el[2]) }, +#ifndef CONFIG_USER_ONLY + { .name = "CNTHV_CVAL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 3, .opc2 = 2, + .fieldoffset = + offsetof(CPUARMState, cp15.c14_timer[GTIMER_HYPVIRT].cval), + .type = ARM_CP_IO, .access = PL2_RW, + .writefn = gt_hv_cval_write, .raw_writefn = raw_write }, + { .name = "CNTHV_TVAL_EL2", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 3, .opc2 = 0, + .type = ARM_CP_NO_RAW | ARM_CP_IO, .access = PL2_RW, + .resetfn = gt_hv_timer_reset, + .readfn = gt_hv_tval_read, .writefn = gt_hv_tval_write }, + { .name = "CNTHV_CTL_EL2", .state = ARM_CP_STATE_BOTH, + .type = ARM_CP_IO, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 3, .opc2 = 1, + .access = PL2_RW, + .fieldoffset = + offsetof(CPUARMState, cp15.c14_timer[GTIMER_HYPVIRT].ctl), + .writefn = gt_hv_ctl_write, .raw_writefn = raw_write }, +#endif REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vhe_reginfo); From patchwork Sat Aug 3 18:47:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170489 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2344758ile; Sat, 3 Aug 2019 11:55:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlN8b/8nXdVNS2mcRIM8GtV8PldMU8JVcv2CSDx7r1NJTfDM4Sk4UrEJgEUTKAoJnRwzmQ X-Received: by 2002:ac8:1183:: with SMTP id d3mr38688767qtj.53.1564858509123; Sat, 03 Aug 2019 11:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858509; cv=none; d=google.com; s=arc-20160816; b=Hwztenlwkc0PQlRHTrh5l3YQhcqj7oCl6Rf3b452qn/Ns91Vml2WuxQ1pEdQBNudIr J+VUlyTXWtM6ya9Adi8OTwhghknsCoZ2hg3uVTju+Tm/G9JEu332oQgiZLbWs5mIdWHF WInB7HUpWm490ieZR1fiqx8I6k+Q0ipfj9z9gU8IZXzMEQ8AVs+PUzPsn+Vf92F3tq/t tQf7BSZ/4rfjx0fNyoYiL4G+GgnCzk8AGenZ6qdwz1YbHTb2wnIQGQgiaR9qTWi61TCd qZ1MZ746aPJFH3JClxzWsGZY/JnczL2rHl2ZnqECyb8iWTFLFHhNRJfmgqOBZMtSnMg6 8RNg== 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=mRFuXKk2Gwl0/7zE7hzogtQkhwOwZ57w0oxCxJ+Y7Jc=; b=TsGr4o9bYJT4bpi1IOIAesIWrUxq5wkT0ztgoFi3scUVIOMEuhJzLChXwVE1CcFyAv pbxgGuemS2oZSbX5hl5p9UF/mTzpkg5idkwz2TJxrwyDUPj8k5z6NtroG+ru4VRxfcYf 0jZxlI0q+F3Wp18MjNIzRM84cXZb0K47xYI42ARMbjAfqW0eCKdMmz4trtGCoI4ERz1u UqHTMz3417neVSzD7Gdh0Ga8P2syoFfHZjMAqXQZOEhJDlyddDGrlXjlwm6PLCH6mN7p rhLCaj0Ndnhc5vuJysYfWBGsvRNwVv9eR6N6SCuoQrHOTskJS9EVRnwbgJdvhHVlRXgB 7xaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Asj8oSC1; 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 m13si46573712qtm.376.2019.08.03.11.55.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:55:09 -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=Asj8oSC1; 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 ([::1]:41456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzBM-00030B-Kj for patch@linaro.org; Sat, 03 Aug 2019 14:55:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60795) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4q-0006IN-2z for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4n-0007EF-UV for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:23 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:32975) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4l-0007C0-Iv for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:20 -0400 Received: by mail-pf1-x441.google.com with SMTP id g2so37628857pfq.0 for ; Sat, 03 Aug 2019 11:48:18 -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=mRFuXKk2Gwl0/7zE7hzogtQkhwOwZ57w0oxCxJ+Y7Jc=; b=Asj8oSC11y4yxglFP8DeXNnuNbhJ5H8rd7ioNjaWzuzsCowqC1mNAPiEIsUeSCozYS dvCD/nEkWGZ8z1TAKV8W3HsN+S4Y/tMkc4ZLw06az1z/oR0o9l8VwaC2l8PsSA4m2DJA s1mMwV8fYotSxu0bHPk1IPSVEBcwht6j43yPtEBeyC/eaTFzkX/54dYZtFnj3Aj/GZNa RYBr6joVWEoXJIEQJj6yvTOcOxG2BzC2OcPcKzW+gClcwfjKwSc05sPG72kV7akdEADY 6OkX88XnwjFA6iLV5UIgHBLBiFk+TcEWMiDi0p3lNvuB7NHxqxu9/owgAmRzCDNkDVRE 9Avw== 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=mRFuXKk2Gwl0/7zE7hzogtQkhwOwZ57w0oxCxJ+Y7Jc=; b=J9vKje4YqTkezCESL6jK2xgdVx5yuUezIwXYTyw6GjxZFc0sgma3KzwuqiO++5jm+z 60t71mXo2umbGUd4Ygnp65a+fumD4Ht0rfa70yblSa7kDaaeF0Mhnvjk4sJjbH/w0Kqc 4ZZvLlAGlNDB9L82Z7UGjmlHKqZJG6no4CxWqbZKvLgi3sCa3sbADRQkBFPO4e/Fz8Cj LaK1bWXuaQQzoV3MmSrTRyJsW3QviKBUTZj7Bv3mp3qq+a31/j8cTJZtqnXiqvs5Tq3X Q1bd95ITHWB4iONjB3Ky0kE7xT4I4R6gq9BPVW7+OSRB3LmwTPri8qSBSCR6Yah6xVva FXfA== X-Gm-Message-State: APjAAAXXKgZcB4CTjLxzqpLGDJ1vuWHyXcef9sTmckEhND1SIAJe15p4 LWGr3ZPCl0m4H/gSC+zYXPAiRPfasQ0= X-Received: by 2002:aa7:9407:: with SMTP id x7mr68060916pfo.163.1564858097201; Sat, 03 Aug 2019 11:48:17 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:38 -0700 Message-Id: <20190803184800.8221-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::441 Subject: [Qemu-devel] [PATCH v3 12/34] target/arm: Add VHE system register redirection and aliasing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Several of the EL1/0 registers are redirected to the EL2 version when in EL2 and HCR_EL2.E2H is set. Many of these registers have side effects. Link together the two ARMCPRegInfo structures after they have been properly instantiated. Install common dispatch routines to all of the relevant registers. The same set of registers that are redirected also have additional EL12/EL02 aliases created to access the original register that was redirected. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 44 +++++++---- target/arm/helper.c | 175 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+), 13 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/target/arm/cpu.h b/target/arm/cpu.h index bba4e1f984..a0f10b60eb 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2455,19 +2455,6 @@ struct ARMCPRegInfo { */ ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ - /* Offsets of the secure and non-secure fields in CPUARMState for the - * register if it is banked. These fields are only used during the static - * registration of a register. During hashing the bank associated - * with a given security state is copied to fieldoffset which is used from - * there on out. - * - * It is expected that register definitions use either fieldoffset or - * bank_fieldoffsets in the definition but not both. It is also expected - * that both bank offsets are set when defining a banked register. This - * use indicates that a register is banked. - */ - ptrdiff_t bank_fieldoffsets[2]; - /* Function for making any access checks for this register in addition to * those specified by the 'access' permissions bits. If NULL, no extra * checks required. The access check is performed at runtime, not at @@ -2502,6 +2489,37 @@ struct ARMCPRegInfo { * fieldoffset is 0 then no reset will be done. */ CPResetFn *resetfn; + + union { + /* + * Offsets of the secure and non-secure fields in CPUARMState for + * the register if it is banked. These fields are only used during + * the static registration of a register. During hashing the bank + * associated with a given security state is copied to fieldoffset + * which is used from there on out. + * + * It is expected that register definitions use either fieldoffset + * or bank_fieldoffsets in the definition but not both. It is also + * expected that both bank offsets are set when defining a banked + * register. This use indicates that a register is banked. + */ + ptrdiff_t bank_fieldoffsets[2]; + + /* + * "Original" writefn and readfn. + * For ARMv8.1-VHE register aliases, we overwrite the read/write + * accessor functions of various EL1/EL0 to perform the runtime + * check for which sysreg should actually be modified, and then + * forwards the operation. Before overwriting the accessors, + * the original function is copied here, so that accesses that + * really do go to the EL1/EL0 version proceed normally. + * (The corresponding EL2 register is linked via opaque.) + */ + struct { + CPReadFn *orig_readfn; + CPWriteFn *orig_writefn; + }; + }; }; /* Macros which are lvalues for the field in CPUARMState for the diff --git a/target/arm/helper.c b/target/arm/helper.c index e0f5627218..e9f4cae5e8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5225,6 +5225,171 @@ static const ARMCPRegInfo el3_cp_reginfo[] = { REGINFO_SENTINEL }; +#ifndef CONFIG_USER_ONLY +/* Test if system register redirection is to occur in the current state. */ +static bool redirect_for_e2h(CPUARMState *env) +{ + return arm_current_el(env) == 2 && (arm_hcr_el2_eff(env) & HCR_E2H); +} + +static uint64_t el2_e2h_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + CPReadFn *readfn; + + if (redirect_for_e2h(env)) { + /* Switch to the saved EL2 version of the register. */ + ri = ri->opaque; + readfn = ri->readfn; + } else { + readfn = ri->orig_readfn; + } + if (readfn == NULL) { + readfn = raw_read; + } + return readfn(env, ri); +} + +static void el2_e2h_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + CPWriteFn *writefn; + + if (redirect_for_e2h(env)) { + /* Switch to the saved EL2 version of the register. */ + ri = ri->opaque; + writefn = ri->writefn; + } else { + writefn = ri->orig_writefn; + } + if (writefn == NULL) { + writefn = raw_write; + } + writefn(env, ri, value); +} + +static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) +{ + struct E2HAlias { + uint32_t src_key, dst_key, new_key; + const char *src_name, *dst_name, *new_name; + bool (*feature)(const ARMISARegisters *id); + }; + +#define K(op0, op1, crn, crm, op2) \ + ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, crn, crm, op0, op1, op2) + + static const struct E2HAlias aliases[] = { + { K(3, 0, 1, 0, 0), K(3, 4, 1, 0, 0), K(3, 5, 1, 0, 0), + "SCTLR", "SCTLR_EL2", "SCTLR_EL12" }, + { K(3, 0, 1, 0, 2), K(3, 4, 1, 1, 2), K(3, 5, 1, 0, 2), + "CPACR", "CPTR_EL2", "CPACR_EL12" }, + { K(3, 0, 2, 0, 0), K(3, 4, 2, 0, 0), K(3, 5, 2, 0, 0), + "TTBR0_EL1", "TTBR0_EL2", "TTBR0_EL12" }, + { K(3, 0, 2, 0, 1), K(3, 4, 2, 0, 1), K(3, 5, 2, 0, 1), + "TTBR1_EL1", "TTBR1_EL2", "TTBR1_EL12" }, + { K(3, 0, 2, 0, 2), K(3, 4, 2, 0, 2), K(3, 5, 2, 0, 2), + "TCR_EL1", "TCR_EL2", "TCR_EL12" }, + { K(3, 0, 4, 0, 0), K(3, 4, 4, 0, 0), K(3, 5, 4, 0, 0), + "SPSR_EL1", "SPSR_EL2", "SPSR_EL12" }, + { K(3, 0, 4, 0, 1), K(3, 4, 4, 0, 1), K(3, 5, 4, 0, 1), + "ELR_EL1", "ELR_EL2", "ELR_EL12" }, + { K(3, 0, 5, 1, 0), K(3, 4, 5, 1, 0), K(3, 5, 5, 1, 0), + "AFSR0_EL1", "AFSR0_EL2", "AFSR0_EL12" }, + { K(3, 0, 5, 1, 1), K(3, 4, 5, 1, 1), K(3, 5, 5, 1, 1), + "AFSR1_EL1", "AFSR1_EL2", "AFSR1_EL12" }, + { K(3, 0, 5, 2, 0), K(3, 4, 5, 2, 0), K(3, 5, 5, 2, 0), + "ESR_EL1", "ESR_EL2", "ESR_EL12" }, + { K(3, 0, 6, 0, 0), K(3, 4, 6, 0, 0), K(3, 5, 6, 0, 0), + "FAR_EL1", "FAR_EL2", "FAR_EL12" }, + { K(3, 0, 10, 2, 0), K(3, 4, 10, 2, 0), K(3, 5, 10, 2, 0), + "MAIR_EL1", "MAIR_EL2", "MAIR_EL12" }, + { K(3, 0, 10, 3, 0), K(3, 4, 10, 3, 0), K(3, 5, 10, 3, 0), + "AMAIR0", "AMAIR_EL2", "AMAIR_EL12" }, + { K(3, 0, 12, 0, 0), K(3, 4, 12, 0, 0), K(3, 5, 12, 0, 0), + "VBAR", "VBAR_EL2", "VBAR_EL12" }, + { K(3, 0, 13, 0, 1), K(3, 4, 13, 0, 1), K(3, 5, 13, 0, 1), + "CONTEXTIDR_EL1", "CONTEXTIDR_EL2", "CONTEXTIDR_EL12" }, + { K(3, 0, 14, 1, 0), K(3, 4, 14, 1, 0), K(3, 5, 14, 1, 0), + "CNTKCTL", "CNTHCTL_EL2", "CNTKCTL_EL12" }, + { K(3, 3, 14, 2, 0), K(3, 4, 14, 2, 0), K(3, 5, 14, 2, 0), + "CNTP_TVAL_EL0", "CNTHP_TVAL_EL2", "CNTP_TVAL_EL02" }, + { K(3, 3, 14, 2, 1), K(3, 4, 14, 2, 1), K(3, 5, 14, 2, 1), + "CNTP_CTL_EL0", "CNTHP_CTL_EL2", "CNTP_CTL_EL02" }, + { K(3, 3, 14, 2, 2), K(3, 4, 14, 2, 2), K(3, 5, 14, 2, 2), + "CNTP_CVAL_EL0", "CNTHP_CVAL_EL2", "CNTP_CVAL_EL02" }, + { K(3, 3, 14, 3, 0), K(3, 4, 14, 3, 0), K(3, 5, 14, 3, 0), + "CNTV_TVAL_EL0", "CNTHV_TVAL_EL2", "CNTV_TVAL_EL02" }, + { K(3, 3, 14, 3, 1), K(3, 4, 14, 3, 1), K(3, 5, 14, 3, 1), + "CNTV_CTL_EL0", "CNTHV_CTL_EL2", "CNTV_CTL_EL02" }, + { K(3, 3, 14, 3, 2), K(3, 4, 14, 3, 2), K(3, 5, 14, 3, 2), + "CNTV_CVAL_EL0", "CNTHV_CVAL_EL2", "CNTV_CVAL_EL02" }, + /* + * CNTHV_CVAL is a special case because there is no separate + * AArch32 EL2 register to which CNTV_CVAL may be directed. + * The effect can be achieved via CNTHV_CVAL_EL2. + */ + { ENCODE_CP_REG(15, 1, 1, 0, 14, 3, 0), K(3, 4, 14, 3, 2), 0, + "CNTV_CVAL", "CNTHV_CVAL_EL2", NULL }, + + /* + * Note that redirection of ZCR is mentioned in the description + * of ZCR_EL2, and aliasing in the description of ZCR_EL1, but + * not in the summary table. + */ + { K(3, 0, 1, 2, 0), K(3, 4, 1, 2, 0), K(3, 5, 1, 2, 0), + "ZCR_EL1", "ZCR_EL2", "ZCR_EL12", isar_feature_aa64_sve }, + + /* TODO: ARMv8.2-SPE -- PMSCR_EL2 */ + /* TODO: ARMv8.4-Trace -- TRFCR_EL2 */ + }; +#undef K + + size_t i; + + for (i = 0; i < ARRAY_SIZE(aliases); i++) { + const struct E2HAlias *a = &aliases[i]; + ARMCPRegInfo *src_reg, *dst_reg; + + if (a->feature && !a->feature(&cpu->isar)) { + continue; + } + + src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key); + dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key); + g_assert(src_reg != NULL); + g_assert(dst_reg != NULL); + + /* Cross-compare names to detect typos in the keys. */ + g_assert(strcmp(src_reg->name, a->src_name) == 0); + g_assert(strcmp(dst_reg->name, a->dst_name) == 0); + + /* None of the core system registers use opaque; we will. */ + g_assert(src_reg->opaque == NULL); + + /* Create alias before redirection so we dup the right data. */ + if (a->new_key) { + ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); + uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t)); + bool ok; + + new_reg->name = a->new_name; + new_reg->type |= ARM_CP_ALIAS; + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ + new_reg->access &= 0xf0; + + ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); + g_assert(ok); + } + + src_reg->opaque = dst_reg; + src_reg->orig_readfn = src_reg->readfn; + src_reg->orig_writefn = src_reg->writefn; + src_reg->readfn = el2_e2h_read; + src_reg->writefn = el2_e2h_write; + } +} +#endif + static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) { @@ -6942,6 +7107,16 @@ void register_cp_regs_for_features(ARMCPU *cpu) : cpu_isar_feature(aa32_predinv, cpu)) { define_arm_cp_regs(cpu, predinv_reginfo); } + +#ifndef CONFIG_USER_ONLY + /* + * Register redirections and aliases must be done last, + * after the registers from the other extensions have been defined. + */ + if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { + define_arm_vh_e2h_redirects_aliases(cpu); + } +#endif } void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) From patchwork Sat Aug 3 18:47:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170484 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2343068ile; Sat, 3 Aug 2019 11:52:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRxCGk+o5SZ4lmvx8vq87SSda8DTXPMiJ3Lf5GF/mGld0c4aWeawibTevMTFHTdI8t+kkx X-Received: by 2002:a0c:b909:: with SMTP id u9mr103368539qvf.10.1564858341226; Sat, 03 Aug 2019 11:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858341; cv=none; d=google.com; s=arc-20160816; b=mpxPemPeKeXkKm2+jJUyzK2OUwAnH5UYJAYMlPMlJTkWgoVqWNMYAPqsZVndju6mY0 Fmoke8ekwDKjTiuxQJ2uFAwf4UEpZgnj7qE4AHb7rBJWg6Z4m2SAxYWTjynCkGJ1m8Ni bLi9te9nrdJ8PT+L1cjuLpml4OSJ/p2ur9M79xJkOIF7beyFNDAkktGP52zia88gsfkM 5ExIsfXInmapfOqqvU9FoUrzK0C7bELqEermQQrni+uuomkfaHGVi8OCebvxVQtaxtJu tKVFd+IaZBkEGZvlMwrrve99Qots6PT/1yzigRMFElKORcX9E8cri/hHpP5SSoCUN6gk PlUQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=h3dhwpfe86udFJHT5d1QRrLfJzUV39xxz0iIkIlTtJQ=; b=pWnys8CbgnD5Xdzxt4ofwyXZylklSL/DzfZjHUkLrc5mWB8ydcb4fyjmb27c5bzzL2 +zBFoQKMbMfluRpw2Uv79btYLs0pvl91kV9P9cmCafucSKsRvxPgELC7sOgHejHpGRig TsjBZdBdlj/AVMwdPrIx0x94w5NpWarH9a27EyjPr1/pJ44UuX1ejl42mJhptxXzo0Ws DChJJhUtTNjth9XMXwU9GEKx3vhg4rvYhklQLKaYmc1csMjT8Wy8i7/FWrMyW61FLsCD HvA6wLoq09IWxCmp1uSBC1lQ2hPvvp/WowNuET43vc9t+UJ+VXsnyEdaviImQEpaEEpt SygQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=p4d9sTav; 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 v54si48521627qtv.88.2019.08.03.11.52.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:52:21 -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=p4d9sTav; 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 ([::1]:41404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz8e-0005kE-Pm for patch@linaro.org; Sat, 03 Aug 2019 14:52:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60796) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4q-0006IS-37 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4n-0007EX-Vx for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:23 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:36584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4m-0007Cu-0O for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:21 -0400 Received: by mail-pf1-x442.google.com with SMTP id r7so37626353pfl.3 for ; Sat, 03 Aug 2019 11:48:19 -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=h3dhwpfe86udFJHT5d1QRrLfJzUV39xxz0iIkIlTtJQ=; b=p4d9sTavIeM8PY758QFUeYiC9aPL9OxLqab6D6paLIN1R9hY6kTAp5ovqdcPtJEjFs hbtdKLSserCSJ/lKcNfOs4V5QAN547FeosbSDBPkxAGsELf7n1MbJljPhzGog2AsaHMY 3nk9SnMVuAA1PEi+xkRi0Tn4O4FhBcFpLAe/9ZaLPJciZ3JYgbXzhnt4AzBpEh9te9VQ HrV+HbTcXO6rt+mncHeJ56b3fi1f6IrPQFr4MrdKEq18q5J6di5FlnDtKybQqoWmoRtG M7ENyc1n5qV71FmxzE7YP/gGg5k97J776Lbxvlt/GuGZtDxttjFTbd0RRdA1QO0q59EX yDKg== 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:mime-version:content-transfer-encoding; bh=h3dhwpfe86udFJHT5d1QRrLfJzUV39xxz0iIkIlTtJQ=; b=j2cDFzqmkewQK27Fz99RDk5BfXRBuFIqbxCz9hVrMAMvwNRETUvrvtZGC0WnerDPsq dXAHzmA1aZv0sq8JB1ZGBu3lOu9GG2x7RcwoUISvPfss8haihSaPsphXd9oyhBxm4Q8c kJOJLJdk71C5gvX8JFLV0Cp8QbkeMpNkf3Vy7ghxJyWCy1mPQGWIErcfF66D/H0GaqJi h+hzkkFGzwA/SczxztI78PNAWyemNZ2oFysAt9W/VE3uq2KOfL6x+5iG8UwXrfONFqYN 6m1xfoYpEu90Eyg0Jby5xLEVKR5xyCNWDWW94xjF+JTZb3Gb7ZxlHpzEIciln9X5cr5l at4Q== X-Gm-Message-State: APjAAAW/2qFMEBAR/EzHsH4wRDR+zmI5eCU1tbVfA/h8AqXnq8jBsenf mn6ZxYJHJV+bFnclIhB72CrHFMeL0Jo= X-Received: by 2002:a63:b20f:: with SMTP id x15mr21319515pge.453.1564858098347; Sat, 03 Aug 2019 11:48:18 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:39 -0700 Message-Id: <20190803184800.8221-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v3 13/34] target/arm: Split out vae1_tlbmask, vmalle1_tlbmask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" No functional change, but unify code sequences. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 118 ++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 81 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index e9f4cae5e8..7ecaacb276 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3898,70 +3898,61 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, * Page D4-1736 (DDI0487A.b) */ +static int vae1_tlbmask(CPUARMState *env) +{ + if (arm_is_secure_below_el3(env)) { + return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + } else { + return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + } +} + static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { CPUState *cs = env_cpu(env); - bool sec = arm_is_secure_below_el3(env); + int mask = vae1_tlbmask(env); - if (sec) { - tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S1SE1 | - ARMMMUIdxBit_S1SE0); - } else { - tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0); - } + tlb_flush_by_mmuidx_all_cpus_synced(cs, mask); } static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { CPUState *cs = env_cpu(env); + int mask = vae1_tlbmask(env); if (tlb_force_broadcast(env)) { tlbi_aa64_vmalle1is_write(env, NULL, value); return; } + tlb_flush_by_mmuidx(cs, mask); +} + +static int vmalle1_tlbmask(CPUARMState *env) +{ + /* + * Note that the 'ALL' scope must invalidate both stage 1 and + * stage 2 translations, whereas most other scopes only invalidate + * stage 1 translations. + */ if (arm_is_secure_below_el3(env)) { - tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S1SE1 | - ARMMMUIdxBit_S1SE0); + return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + } else if (arm_feature(env, ARM_FEATURE_EL2)) { + return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0 | ARMMMUIdxBit_S2NS; } else { - tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0); + return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; } } static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - /* Note that the 'ALL' scope must invalidate both stage 1 and - * stage 2 translations, whereas most other scopes only invalidate - * stage 1 translations. - */ - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int mask = vmalle1_tlbmask(env); - if (arm_is_secure_below_el3(env)) { - tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S1SE1 | - ARMMMUIdxBit_S1SE0); - } else { - if (arm_feature(env, ARM_FEATURE_EL2)) { - tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | - ARMMMUIdxBit_S2NS); - } else { - tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0); - } - } + tlb_flush_by_mmuidx(cs, mask); } static void tlbi_aa64_alle2_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3985,28 +3976,10 @@ static void tlbi_aa64_alle3_write(CPUARMState *env, const ARMCPRegInfo *ri, static void tlbi_aa64_alle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - /* Note that the 'ALL' scope must invalidate both stage 1 and - * stage 2 translations, whereas most other scopes only invalidate - * stage 1 translations. - */ CPUState *cs = env_cpu(env); - bool sec = arm_is_secure_below_el3(env); - bool has_el2 = arm_feature(env, ARM_FEATURE_EL2); + int mask = vmalle1_tlbmask(env); - if (sec) { - tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S1SE1 | - ARMMMUIdxBit_S1SE0); - } else if (has_el2) { - tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | - ARMMMUIdxBit_S2NS); - } else { - tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0); - } + tlb_flush_by_mmuidx_all_cpus_synced(cs, mask); } static void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4056,20 +4029,11 @@ static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri, static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); - bool sec = arm_is_secure_below_el3(env); + CPUState *cs = env_cpu(env); + int mask = vae1_tlbmask(env); uint64_t pageaddr = sextract64(value << 12, 0, 56); - if (sec) { - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1SE1 | - ARMMMUIdxBit_S1SE0); - } else { - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0); - } + tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, mask); } static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4080,8 +4044,8 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, * since we don't support flush-for-specific-ASID-only or * flush-last-level-only. */ - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int mask = vae1_tlbmask(env); uint64_t pageaddr = sextract64(value << 12, 0, 56); if (tlb_force_broadcast(env)) { @@ -4089,15 +4053,7 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, return; } - if (arm_is_secure_below_el3(env)) { - tlb_flush_page_by_mmuidx(cs, pageaddr, - ARMMMUIdxBit_S1SE1 | - ARMMMUIdxBit_S1SE0); - } else { - tlb_flush_page_by_mmuidx(cs, pageaddr, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0); - } + tlb_flush_page_by_mmuidx(cs, pageaddr, mask); } static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, From patchwork Sat Aug 3 18:47:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170483 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2343029ile; Sat, 3 Aug 2019 11:52:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2mxHLd+I30My1q7QojnWGr5jIBBXDTGrSnQ4yXC8H2SpJV1qum4AlhGMLbtjNP7lOHhYy X-Received: by 2002:ac8:156:: with SMTP id f22mr54624632qtg.58.1564858337045; Sat, 03 Aug 2019 11:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858337; cv=none; d=google.com; s=arc-20160816; b=rleY+/tmEQQvAyE+h+53qiFB5KfRA+LU8Afwjri3OpTxx1gyDkTLLNxpBic/X4JcC+ 1GdlX7rgPKjTrQD/Y79jZYI3xUl1xORSxeHXDRijKzAAvzUx4ikqwpzsl9Fn+r7xTdDB Abdl+QGSi923srnBPcXe2T7cC64OQP5av+/TKwvZqhFydKmm4csrDNTZBE5WidCX6r28 IZnR4DTVO0E5WxwIciPeu04M2ykxTyvIteBUvpTeyMO6dePdEjW98p4LuvYnnTh9I0qb NlDaWyc37mBJMRYlIoWs5LT7WbNh+Rvq2YGTL+j6iC39ds0rvvdsVokO+EpMPi2OK3c3 LMSA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=RHV3vStI8hqe3CeMRucY7WZ1UFpWZPYBbhdsWvPNW30=; b=BTzkpJPkIk+iFyRBgCicpBhW1Zh+f2/JfKmfmXgwylJQVU7GZgnyZFUynXStVIbuhw xTKG03xuxb1ATR6FbcqR2wnTkU1328SILcqwWM+ACEuepfiN2S2+ix6V3L86VeqxYMTl kL5xsPXGUsoQVu3uWPrjlGtdmOf0dd1ojuvY5vYqIWKIOTGi3ZeEUH3jIW3G8q1RhRY6 w/RUe+tcYn0a9HxL51F3GUuwtJG/Fp0BwhVs6aBm10i/T9QN4W0jPlaZEupQLCi8hHlj NLnZOf9YSwkVr5d4BnGP6N6hsLtGusmwyzOKtirUN8tA+JKjfds7MpCWZ791KNn1rw93 /x/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CilkG14h; 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 h20si8838234qtb.397.2019.08.03.11.52.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:52:17 -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=CilkG14h; 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 ([::1]:41410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz8a-0006bR-Lm for patch@linaro.org; Sat, 03 Aug 2019 14:52:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60836) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4s-0006KE-2L for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4q-0007Ff-1T for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:25 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:40447) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4n-0007Dk-V6 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:23 -0400 Received: by mail-pg1-x544.google.com with SMTP id w10so37670426pgj.7 for ; Sat, 03 Aug 2019 11:48:20 -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=RHV3vStI8hqe3CeMRucY7WZ1UFpWZPYBbhdsWvPNW30=; b=CilkG14hXuLfs3ajiEUbNrYQSzWSF+gJ0pP3dZAsMY0qkc2tphjlBXylPEoqETFJG4 quVMsgfQEyspFWXAEvAb4V2h7VtD1CJ/zYaMLelO4BGFvg8576uVPz49Wz3cznrWteXi lKtAY/OkT0O2bc24rV8/K0JRpwX9/XC4OlGh4TMTJ+vZiPvQ3S8HYpgaph0RzcGGwe+O IkAN7JCBC6QrUdqYnJQou3/tixjKLaCkhwiDRS1xThCclADpI5GCjvOePtvJTs4cg7BW V53y8za6pJcueTgjLRrw6454Zrj/WoZsVpWq2DCPuiWzGqC2pU/rjsab++I5xA1BGHpk nsQg== 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:mime-version:content-transfer-encoding; bh=RHV3vStI8hqe3CeMRucY7WZ1UFpWZPYBbhdsWvPNW30=; b=HnWnX+C4hufhAzLMCdwizB5iqD6FmPiwdLfjzLCW2GYWh17l2pDpu2R2a6HmeWlIn9 Z7NcBLgFGTP+KHvnQDoBOwzVHF2nHfFHCKpY8s+LvJUhz505GjVcjfso8eIqvIFoQVFT GCxmL9CYqGOCok7A94zNMRiGHei7dV5pCnjwjopJSAJgf2K1bEsaBZePZQIC3hXixyGt CEFaMaXuvdiOhqfw5R1RSKm2V0y3q5oBebYvEE+Hml2I/9eL0Pqg/7ZabZgx+Nlsz9e3 6gNAHXX2Gm9XZaS7atRdyKDw99q4xgvlSHvq/LPSK6jaKNwoYwiJC0oCFqEYGOI2WcrN 1eIA== X-Gm-Message-State: APjAAAUgi6KihFlahzjIm9eL3Y2CqOZ7VqfwL73JTs1bGzdF4ErGo24d VmowHQ5eb94SVGpYHyJ4l7zy2/zOpq4= X-Received: by 2002:a63:9e54:: with SMTP id r20mr96504867pgo.64.1564858099599; Sat, 03 Aug 2019 11:48:19 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:40 -0700 Message-Id: <20190803184800.8221-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v3 14/34] target/arm: Simplify tlb_force_broadcast alternatives X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than call to a separate function and re-compute any parameters for the flush, simply use the correct flush function directly. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 52 +++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 7ecaacb276..185f5e4aea 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -626,56 +626,54 @@ static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate all (TLBIALL) */ - ARMCPU *cpu = env_archcpu(env); + CPUState *cs = env_cpu(env); if (tlb_force_broadcast(env)) { - tlbiall_is_write(env, NULL, value); - return; + tlb_flush_all_cpus_synced(cs); + } else { + tlb_flush(cs); } - - tlb_flush(CPU(cpu)); } static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */ - ARMCPU *cpu = env_archcpu(env); + CPUState *cs = env_cpu(env); + value &= TARGET_PAGE_MASK; if (tlb_force_broadcast(env)) { - tlbimva_is_write(env, NULL, value); - return; + tlb_flush_page_all_cpus_synced(cs, value); + } else { + tlb_flush_page(cs, value); } - - tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); } static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate by ASID (TLBIASID) */ - ARMCPU *cpu = env_archcpu(env); + CPUState *cs = env_cpu(env); if (tlb_force_broadcast(env)) { - tlbiasid_is_write(env, NULL, value); - return; + tlb_flush_all_cpus_synced(cs); + } else { + tlb_flush(cs); } - - tlb_flush(CPU(cpu)); } static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate single entry by MVA, all ASIDs (TLBIMVAA) */ - ARMCPU *cpu = env_archcpu(env); + CPUState *cs = env_cpu(env); + value &= TARGET_PAGE_MASK; if (tlb_force_broadcast(env)) { - tlbimvaa_is_write(env, NULL, value); - return; + tlb_flush_page_all_cpus_synced(cs, value); + } else { + tlb_flush_page(cs, value); } - - tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); } static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3923,11 +3921,10 @@ static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, int mask = vae1_tlbmask(env); if (tlb_force_broadcast(env)) { - tlbi_aa64_vmalle1is_write(env, NULL, value); - return; + tlb_flush_by_mmuidx_all_cpus_synced(cs, mask); + } else { + tlb_flush_by_mmuidx(cs, mask); } - - tlb_flush_by_mmuidx(cs, mask); } static int vmalle1_tlbmask(CPUARMState *env) @@ -4049,11 +4046,10 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t pageaddr = sextract64(value << 12, 0, 56); if (tlb_force_broadcast(env)) { - tlbi_aa64_vae1is_write(env, NULL, value); - return; + tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, mask); + } else { + tlb_flush_page_by_mmuidx(cs, pageaddr, mask); } - - tlb_flush_page_by_mmuidx(cs, pageaddr, mask); } static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, From patchwork Sat Aug 3 18:47:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170487 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2343993ile; Sat, 3 Aug 2019 11:53:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvoPtrha06F3xHUhHq63HHAYEBadJfWB34Wim9P9IU5vMamZShDZzZuxv+eioQzQfxh7ad X-Received: by 2002:ac8:30d2:: with SMTP id w18mr100003730qta.296.1564858434924; Sat, 03 Aug 2019 11:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858434; cv=none; d=google.com; s=arc-20160816; b=LyrwL/TjwzJRjEUT6V4JwAW5GzqSd4gve0ZpVgJNhflTZnxHrJshUex/kBzVQrv8lv bZ5BocoanO+RXm79w/EIno1MsjT6Yp9uvfaL+EbbU5TT9v+FXACq1wMM0SRyCZ+hK8Y6 mzUcQM/GCw5OGpnLGnrCbFBV+T7CwS7F0Bg4ZOqxxK2r8DPdbd5RoEZvVv4ugsUfMs/W WG0BH7sI7ueBm0wCk/CSbBHIaUjmruJgByRbQgtpE9QnpgnPPaE2wwZ6jKPv/iiBT3SY AhDkdbHctZAyg2zhX2Lv45lTQOV3B/vkKVGK28edNL22+mqRNcvnYVMnjKYgcJhppgke n+HA== 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=L2jEAM4PPhyK6Ibom5dDULaexJ8i3bjGCqHj/DqEM+k=; b=O93snPTdC5oONNwKCcLhQ0V2puNOsO+08nQHEgJs+FqIpgLLNwkC0CZi2Qh4YSlAru iy0k2/ha7dtcENndPDWqGFDjJC+XOJa033gtU9mOJQhs9qB1wa1WrPyffZpCMabOJx6L bd7qK5Oxw1Cv81Huz1SlkWZFOtl+d5D8qKM1cj+e3qdoek86cnyVr3rDEyPkUK74WdcE ZmRBdNW4Dml2VoqMPheTk4fzscgGWup9BUN1PpKhihQzhdqMoE3quILhM12xck4bY8tX W9eZh2VKs9i08O2TOevCjJVLYuTlB3G59agvFLlSE/bXkxMNKJ3s4p54Wp0psiP/ySK7 LaWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DrWV5HYm; 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 k3si814982qtf.393.2019.08.03.11.53.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:53:54 -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=DrWV5HYm; 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 ([::1]:41432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzA8-0000s7-T0 for patch@linaro.org; Sat, 03 Aug 2019 14:53:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60838) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4s-0006KG-2u for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4q-0007G5-4N for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:25 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4o-0007E5-0l for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:23 -0400 Received: by mail-pl1-x642.google.com with SMTP id t14so34862567plr.11 for ; Sat, 03 Aug 2019 11:48:21 -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=L2jEAM4PPhyK6Ibom5dDULaexJ8i3bjGCqHj/DqEM+k=; b=DrWV5HYmYrILTnszRc7SWWXnMDSCK9TjQWMUqtZcIS3qnAy1MVBqu56h0FMD9ua6ip w064mHBVtFFeUl47kLOzXm2YlF9HMrPgv0kCGvYrh9phW/wkDtcIasoeYQrrbSShFsp6 tAaVAfqgwdTAobxCLKfRXbK2i79u8JbvfX7I/2io3OOaH0lAbneJawgy9J3OAQhp81oN 3pqSCpwKanee3JKDI48RDv4d4sTyBMnBSnyNVY73qlTh2u5PjTs6bnF6RTReIFFS6Npe 3ZkUK3aqendnGS0MhL+rif1+lhUmfQxg3yFCu3YQC/rmIgTkIzNF9iMVSZxK+dWyBpZs kzww== 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=L2jEAM4PPhyK6Ibom5dDULaexJ8i3bjGCqHj/DqEM+k=; b=kQrkuEyKSRfbgK8EJhGsdRrkuFLIZBXGzb+gMmuxYZXK8mClfa+w17JFA8O0wy+HC/ xF+Ed5ntOh3+E07KtMIgM25zC2TEfWmbi77DG6vgFOC7J3aRk82tfP7GB+noecbzNEfN M4K7NTzgM9tZLAeUNGfk5U7x+wW12aMeAo9ZoVDKG0RuyHu2G3JYQA12GTRCnvic30l4 /5xoOoXAOqE36HcfNgYeEq3vKSidlEJwM2adYJKCNnbvwkI60Iun8oOypd86uPpwhZI5 VwRk6OCW4oAl7N6lDGhp55HilfXD1LbHBXqDp6Xh/fSBd5PP36BpxNUIhIsNe+6yOFoj lYvg== X-Gm-Message-State: APjAAAVLW3jtn3u1ltEvilyXIQQ8w+TT1FVEsTK3WO1XG3jqDBNnNyMZ l0zf9P2AVhjS/frtTtiEzd28URV8Uu0= X-Received: by 2002:a17:902:9b81:: with SMTP id y1mr142720478plp.194.1564858100819; Sat, 03 Aug 2019 11:48:20 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:41 -0700 Message-Id: <20190803184800.8221-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::642 Subject: [Qemu-devel] [PATCH v3 15/34] target/arm: Rename ARMMMUIdx*_S12NSE* to ARMMMUIdx*_E10_* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a reorganization to the set of mmu_idx. This emphasizes that they apply to the EL1&0 regime. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 8 +++---- target/arm/internals.h | 4 ++-- target/arm/helper.c | 44 +++++++++++++++++++------------------- target/arm/translate-a64.c | 4 ++-- target/arm/translate.c | 6 +++--- 5 files changed, 33 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a0f10b60eb..8a3f61bc2c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2850,8 +2850,8 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, #define ARM_MMU_IDX_COREIDX_MASK 0x7 typedef enum ARMMMUIdx { - ARMMMUIdx_S12NSE0 = 0 | ARM_MMU_IDX_A, - ARMMMUIdx_S12NSE1 = 1 | ARM_MMU_IDX_A, + ARMMMUIdx_EL10_0 = 0 | ARM_MMU_IDX_A, + ARMMMUIdx_EL10_1 = 1 | ARM_MMU_IDX_A, ARMMMUIdx_S1E2 = 2 | ARM_MMU_IDX_A, ARMMMUIdx_S1E3 = 3 | ARM_MMU_IDX_A, ARMMMUIdx_S1SE0 = 4 | ARM_MMU_IDX_A, @@ -2876,8 +2876,8 @@ typedef enum ARMMMUIdx { * for use when calling tlb_flush_by_mmuidx() and friends. */ typedef enum ARMMMUIdxBit { - ARMMMUIdxBit_S12NSE0 = 1 << 0, - ARMMMUIdxBit_S12NSE1 = 1 << 1, + ARMMMUIdxBit_EL10_0 = 1 << 0, + ARMMMUIdxBit_EL10_1 = 1 << 1, ARMMMUIdxBit_S1E2 = 1 << 2, ARMMMUIdxBit_S1E3 = 1 << 3, ARMMMUIdxBit_S1SE0 = 1 << 4, diff --git a/target/arm/internals.h b/target/arm/internals.h index 232d963875..fafefdc59e 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -808,8 +808,8 @@ static inline void arm_call_el_change_hook(ARMCPU *cpu) static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { - case ARMMMUIdx_S12NSE0: - case ARMMMUIdx_S12NSE1: + case ARMMMUIdx_EL10_0: + case ARMMMUIdx_EL10_1: case ARMMMUIdx_S1NSE0: case ARMMMUIdx_S1NSE1: case ARMMMUIdx_S1E2: diff --git a/target/arm/helper.c b/target/arm/helper.c index 185f5e4aea..e391654638 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -569,7 +569,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, idxmask = ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; break; case ARM_CP_SECSTATE_NS: - idxmask = ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + idxmask = ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; break; default: g_assert_not_reached(); @@ -682,8 +682,8 @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, CPUState *cs = env_cpu(env); tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | + ARMMMUIdxBit_EL10_1 | + ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_S2NS); } @@ -693,8 +693,8 @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, CPUState *cs = env_cpu(env); tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | + ARMMMUIdxBit_EL10_1 | + ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_S2NS); } @@ -3047,7 +3047,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, format64 = arm_s1_regime_using_lpae_format(env, mmu_idx); if (arm_feature(env, ARM_FEATURE_EL2)) { - if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { + if (mmu_idx == ARMMMUIdx_EL10_0 || mmu_idx == ARMMMUIdx_EL10_1) { format64 |= env->cp15.hcr_el2 & (HCR_VM | HCR_DC); } else { format64 |= arm_current_el(env) == 2; @@ -3146,11 +3146,11 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) break; case 4: /* stage 1+2 NonSecure PL1: ATS12NSOPR, ATS12NSOPW */ - mmu_idx = ARMMMUIdx_S12NSE1; + mmu_idx = ARMMMUIdx_EL10_1; break; case 6: /* stage 1+2 NonSecure PL0: ATS12NSOUR, ATS12NSOUW */ - mmu_idx = ARMMMUIdx_S12NSE0; + mmu_idx = ARMMMUIdx_EL10_0; break; default: g_assert_not_reached(); @@ -3208,10 +3208,10 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S1NSE0; break; case 4: /* AT S12E1R, AT S12E1W */ - mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_S12NSE1; + mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_EL10_1; break; case 6: /* AT S12E0R, AT S12E0W */ - mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S12NSE0; + mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_EL10_0; break; default: g_assert_not_reached(); @@ -3430,7 +3430,7 @@ static void update_lpae_el1_asid(CPUARMState *env, int secure) ttbr0 = env->cp15.ttbr0_ns; ttbr1 = env->cp15.ttbr1_ns; ttcr = env->cp15.tcr_el[1].raw_tcr; - idxmask = ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + idxmask = ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; break; default: g_assert_not_reached(); @@ -3540,10 +3540,10 @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, /* * A change in VMID to the stage2 page table (S2NS) invalidates - * the combined stage 1&2 tlbs (S12NSE1 and S12NSE0). + * the combined stage 1&2 tlbs (EL10_1 and EL10_0). */ tlb_set_asid_for_mmuidx(cs, vmid, ARMMMUIdxBit_S2NS, - ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0); + ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0); } static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { @@ -3901,7 +3901,7 @@ static int vae1_tlbmask(CPUARMState *env) if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; } else { - return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } } @@ -3937,9 +3937,9 @@ static int vmalle1_tlbmask(CPUARMState *env) if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { - return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0 | ARMMMUIdxBit_S2NS; + return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_S2NS; } else { - return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } } @@ -8801,8 +8801,8 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) */ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) { - if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { - mmu_idx += (ARMMMUIdx_S1NSE0 - ARMMMUIdx_S12NSE0); + if (mmu_idx == ARMMMUIdx_EL10_0 || mmu_idx == ARMMMUIdx_EL10_1) { + mmu_idx += (ARMMMUIdx_S1NSE0 - ARMMMUIdx_EL10_0); } return mmu_idx; } @@ -8845,8 +8845,8 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) return true; default: return false; - case ARMMMUIdx_S12NSE0: - case ARMMMUIdx_S12NSE1: + case ARMMMUIdx_EL10_0: + case ARMMMUIdx_EL10_1: g_assert_not_reached(); } } @@ -10750,7 +10750,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, target_ulong *page_size, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) { - if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { + if (mmu_idx == ARMMMUIdx_EL10_0 || mmu_idx == ARMMMUIdx_EL10_1) { /* Call ourselves recursively to do the stage 1 and then stage 2 * translations. */ @@ -11281,7 +11281,7 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) if (el < 2 && arm_is_secure_below_el3(env)) { return ARMMMUIdx_S1SE0 + el; } else { - return ARMMMUIdx_S12NSE0 + el; + return ARMMMUIdx_EL10_0 + el; } } diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index d3231477a2..ece749fe03 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -113,8 +113,8 @@ static inline int get_a64_user_mem_index(DisasContext *s) ARMMMUIdx useridx; switch (s->mmu_idx) { - case ARMMMUIdx_S12NSE1: - useridx = ARMMMUIdx_S12NSE0; + case ARMMMUIdx_EL10_1: + useridx = ARMMMUIdx_EL10_0; break; case ARMMMUIdx_S1SE1: useridx = ARMMMUIdx_S1SE0; diff --git a/target/arm/translate.c b/target/arm/translate.c index 7853462b21..afff595726 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -153,9 +153,9 @@ static inline int get_a32_user_mem_index(DisasContext *s) */ switch (s->mmu_idx) { case ARMMMUIdx_S1E2: /* this one is UNPREDICTABLE */ - case ARMMMUIdx_S12NSE0: - case ARMMMUIdx_S12NSE1: - return arm_to_core_mmu_idx(ARMMMUIdx_S12NSE0); + case ARMMMUIdx_EL10_0: + case ARMMMUIdx_EL10_1: + return arm_to_core_mmu_idx(ARMMMUIdx_EL10_0); case ARMMMUIdx_S1E3: case ARMMMUIdx_S1SE0: case ARMMMUIdx_S1SE1: From patchwork Sat Aug 3 18:47:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170488 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2344171ile; Sat, 3 Aug 2019 11:54:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdLcSlUW7RPEVXbv1QY8ccHAZYQgpTTl4DQR6+g8iCkJ57r3NHKzpqzg/F2kOmNxyMBXr5 X-Received: by 2002:ac8:5294:: with SMTP id s20mr15460963qtn.279.1564858451913; Sat, 03 Aug 2019 11:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858451; cv=none; d=google.com; s=arc-20160816; b=Ju+9iI9uX32p94FIiORIdYys74M1vBhwfr6t1CTe901YzEHJWvlASBAq1aCI2KOYM9 yUynwqChLuOm1Gho9iG1tDQCklhLKpIJpEaQXIn4OtzukDQeXOp9VJN422TTQYgI8Obs QS3dHXIA/mnT+Gqu8U1YaKGNzPs8et0LsOoqrhTSgmZu0eNAB7+VTvYf5z5lpplk1h1n gHAtib+YdrDea8iThsdzLO8eSB7A3Ge0MxG183vy2NwHK1qhIiltpaCoCEq+Ck4oxSJW c4EgliqIqEwn3uLT+lQV87hhAxvQqzwV6zSYWNKolh+xdLhNXRfUj9X2hwdCaZRuQPGn /aXA== 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=la7qxtvs05jrNqcA9h6vjUFPOQjXr0T0i1pOh4sumx8=; b=z6/aQKtSvc9SL//yWdsxn2zch+3tO3O7DknS1dtW8gZIpOygM0jTSwZnp2676CclJY GojSt4beDLj2VApdDV1O1CY5izYRfZetFqWSWvmdP1c/ZkyzDq1ZmuiXL+HXm3FnHYr4 4RrOTAUhMObZcfa7GYFGlnx42foGDqG3HLheDMYJuklN7WlfCoxxR9uO7LqFGZPREdyJ CKE6P/hBKw15i10y5w6Bk4jsqbc0M2Y+5bB9mh0OahNJ1r3WwPWZCLkRg5aNprzugpv7 gaT/aLWpltIoZdYu1ri5numwUkbOCFR+kBjmMHSrFOXdFIJ/044secc37bhAhB/fHRLF fpaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BPtXKMjQ; 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 j22si47047266qta.375.2019.08.03.11.54.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:54:11 -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=BPtXKMjQ; 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 ([::1]:41444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzAR-00021b-Ev for patch@linaro.org; Sat, 03 Aug 2019 14:54:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60884) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4u-0006Ll-5Z for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4s-0007HE-3u for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:28 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4q-0007FA-0N for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:26 -0400 Received: by mail-pg1-x541.google.com with SMTP id z14so437891pga.5 for ; Sat, 03 Aug 2019 11:48:23 -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=la7qxtvs05jrNqcA9h6vjUFPOQjXr0T0i1pOh4sumx8=; b=BPtXKMjQXEwSqf4ihkATokxXgdqYfxy91qDkVzIxkd8iyWIMNJcnybknDrqwLuSPO0 v+TTl6BOSG4nU+HVMi5sEAifBXSQchp0yeklueMV0O6rn821vBeKviV8RKtAPheLeoaN 4wZ8hwpcZ7AXYMhodmsLtWVbVGU5S+bMhZBtn1zhKcZ9e4sR5kEs1CSG3XPhYb369n2J B8Hp4xd9ZjqVXqXoKH2CHlj3R+mNrbFbbvG/hhjeDssuLwzTjTJrzP+ZIeJfmZIT8cMy FPZJxvYz7PvoLF6DG6sCYS+w9gHkTEEzgYeqMwH1a67K+LJ2gIxts7rsHFdkyunLSV+A b5qg== 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=la7qxtvs05jrNqcA9h6vjUFPOQjXr0T0i1pOh4sumx8=; b=NR658wglXv3f7H5DDqZgtNabFnTy1Dv+/nbDbxAVKtlgovnn4qG5Ec0KPH0kVXQzdY o1QmdFDvVP0Mk+F8ukU9prGEwYmHy/6+rahS5Mzyfz6EjuVNO9lMUU6ANAtVLJXm9o4K 5wbSNiGfVl0U8WL2yjkd6IfzPnJBKLth6m1S/2J8cf6dW9nU7foSKlotSKM1PfrEDCJr Rjbhv74+EjDJM3+rxSfdRDgD71ZA8CGS6MJm77cYwgpL5Kub2STX52q2ZiDGYvyOzWQc MceB+UDgCZ1tdBBitYhwUEWsw29y4HlmCgn//zM7ebOVD2MQy9GCg0ZjGTHwuCKGBWWS N/Zw== X-Gm-Message-State: APjAAAURxCRyUWOo63/BVISTpr9eBUDht9oKiqYrWPqPWQNaZy6I0BCD XNRZVEPWD3ZYId9enqzfLnHuUBjQsFk= X-Received: by 2002:a63:fd57:: with SMTP id m23mr64994336pgj.204.1564858101921; Sat, 03 Aug 2019 11:48:21 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:42 -0700 Message-Id: <20190803184800.8221-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::541 Subject: [Qemu-devel] [PATCH v3 16/34] target/arm: Rename ARMMMUIdx_S2NS to ARMMMUIdx_Stage2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The EL1&0 regime is the only one that uses 2-stage translation. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 4 +-- target/arm/internals.h | 2 +- target/arm/helper.c | 54 +++++++++++++++++++------------------- target/arm/translate-a64.c | 2 +- target/arm/translate.c | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8a3f61bc2c..14730d29c6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2856,7 +2856,7 @@ typedef enum ARMMMUIdx { ARMMMUIdx_S1E3 = 3 | ARM_MMU_IDX_A, ARMMMUIdx_S1SE0 = 4 | ARM_MMU_IDX_A, ARMMMUIdx_S1SE1 = 5 | ARM_MMU_IDX_A, - ARMMMUIdx_S2NS = 6 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_A, ARMMMUIdx_MUser = 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv = 1 | ARM_MMU_IDX_M, ARMMMUIdx_MUserNegPri = 2 | ARM_MMU_IDX_M, @@ -2882,7 +2882,7 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_S1E3 = 1 << 3, ARMMMUIdxBit_S1SE0 = 1 << 4, ARMMMUIdxBit_S1SE1 = 1 << 5, - ARMMMUIdxBit_S2NS = 1 << 6, + ARMMMUIdxBit_Stage2 = 1 << 6, ARMMMUIdxBit_MUser = 1 << 0, ARMMMUIdxBit_MPriv = 1 << 1, ARMMMUIdxBit_MUserNegPri = 1 << 2, diff --git a/target/arm/internals.h b/target/arm/internals.h index fafefdc59e..1caa15e7e0 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -813,7 +813,7 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_S1NSE0: case ARMMMUIdx_S1NSE1: case ARMMMUIdx_S1E2: - case ARMMMUIdx_S2NS: + case ARMMMUIdx_Stage2: case ARMMMUIdx_MPrivNegPri: case ARMMMUIdx_MUserNegPri: case ARMMMUIdx_MPriv: diff --git a/target/arm/helper.c b/target/arm/helper.c index e391654638..6c8eddfdf4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -684,7 +684,7 @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -695,7 +695,7 @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } static void tlbiipas2_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -716,7 +716,7 @@ static void tlbiipas2_write(CPUARMState *env, const ARMCPRegInfo *ri, pageaddr = sextract64(value << 12, 0, 40); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S2NS); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2); } static void tlbiipas2_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -732,7 +732,7 @@ static void tlbiipas2_is_write(CPUARMState *env, const ARMCPRegInfo *ri, pageaddr = sextract64(value << 12, 0, 40); tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } static void tlbiall_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3539,10 +3539,10 @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, vmid = extract64(value, 48, 8); /* - * A change in VMID to the stage2 page table (S2NS) invalidates + * A change in VMID to the stage2 page table (Stage2) invalidates * the combined stage 1&2 tlbs (EL10_1 and EL10_0). */ - tlb_set_asid_for_mmuidx(cs, vmid, ARMMMUIdxBit_S2NS, + tlb_set_asid_for_mmuidx(cs, vmid, ARMMMUIdxBit_Stage2, ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0); } @@ -3937,7 +3937,7 @@ static int vmalle1_tlbmask(CPUARMState *env) if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { - return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_S2NS; + return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_Stage2; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } @@ -4091,7 +4091,7 @@ static void tlbi_aa64_ipas2e1_write(CPUARMState *env, const ARMCPRegInfo *ri, pageaddr = sextract64(value << 12, 0, 48); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S2NS); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2); } static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4107,7 +4107,7 @@ static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo *ri, pageaddr = sextract64(value << 12, 0, 48); tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } static CPAccessResult aa64_zva_access(CPUARMState *env, const ARMCPRegInfo *ri, @@ -8690,7 +8690,7 @@ void arm_cpu_do_interrupt(CPUState *cs) static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { - case ARMMMUIdx_S2NS: + case ARMMMUIdx_Stage2: case ARMMMUIdx_S1E2: return 2; case ARMMMUIdx_S1E3: @@ -8744,7 +8744,7 @@ static inline bool regime_translation_disabled(CPUARMState *env, } } - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { /* HCR.DC means HCR.VM behaves as 1 */ return (env->cp15.hcr_el2 & (HCR_DC | HCR_VM)) == 0; } @@ -8775,7 +8775,7 @@ static inline bool regime_translation_big_endian(CPUARMState *env, static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) { - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { return env->cp15.vttbr_el2; } if (ttbrn == 0) { @@ -8790,7 +8790,7 @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, /* Return the TCR controlling this translation regime */ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) { - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { return &env->cp15.vtcr_el2; } return &env->cp15.tcr_el[regime_el(env, mmu_idx)]; @@ -8977,7 +8977,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, bool have_wxn; int wxn = 0; - assert(mmu_idx != ARMMMUIdx_S2NS); + assert(mmu_idx != ARMMMUIdx_Stage2); user_rw = simple_ap_to_rw_prot_is_user(ap, true); if (is_user) { @@ -9069,7 +9069,7 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { if ((mmu_idx == ARMMMUIdx_S1NSE0 || mmu_idx == ARMMMUIdx_S1NSE1) && - !regime_translation_disabled(env, ARMMMUIdx_S2NS)) { + !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { target_ulong s2size; hwaddr s2pa; int s2prot; @@ -9086,7 +9086,7 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, pcacheattrs = &cacheattrs; } - ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa, + ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_Stage2, &s2pa, &txattrs, &s2prot, &s2size, fi, pcacheattrs); if (ret) { assert(fi->type != ARMFault_None); @@ -9558,7 +9558,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, tsz = extract32(tcr, 0, 6); using64k = extract32(tcr, 14, 1); using16k = extract32(tcr, 15, 1); - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { /* VTCR_EL2 */ tbi = tbid = hpd = false; } else { @@ -9619,7 +9619,7 @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, int select, tsz; bool epd, hpd; - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { /* VTCR */ bool sext = extract32(tcr, 4, 1); bool sign = extract32(tcr, 3, 1); @@ -9721,7 +9721,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, level = 1; /* There is no TTBR1 for EL2 */ ttbr1_valid = (el != 2); - addrsize = (mmu_idx == ARMMMUIdx_S2NS ? 40 : 32); + addrsize = (mmu_idx == ARMMMUIdx_Stage2 ? 40 : 32); inputsize = addrsize - param.tsz; } @@ -9772,7 +9772,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, goto do_fault; } - if (mmu_idx != ARMMMUIdx_S2NS) { + if (mmu_idx != ARMMMUIdx_Stage2) { /* The starting level depends on the virtual address size (which can * be up to 48 bits) and the translation granule size. It indicates * the number of strides (stride bits at a time) needed to @@ -9872,7 +9872,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, attrs = extract64(descriptor, 2, 10) | (extract64(descriptor, 52, 12) << 10); - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { /* Stage 2 table descriptors do not include any attribute fields */ break; } @@ -9903,7 +9903,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, ap = extract32(attrs, 4, 2); xn = extract32(attrs, 12, 1); - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { ns = true; *prot = get_S2prot(env, ap, xn); } else { @@ -9930,7 +9930,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, } if (cacheattrs != NULL) { - if (mmu_idx == ARMMMUIdx_S2NS) { + if (mmu_idx == ARMMMUIdx_Stage2) { cacheattrs->attrs = convert_stage2_attrs(env, extract32(attrs, 0, 4)); } else { @@ -9951,7 +9951,7 @@ do_fault: fi->type = fault_type; fi->level = level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_S2NS); + fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2); return true; } @@ -10765,13 +10765,13 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, prot, page_size, fi, cacheattrs); /* If S1 fails or S2 is disabled, return early. */ - if (ret || regime_translation_disabled(env, ARMMMUIdx_S2NS)) { + if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) { *phys_ptr = ipa; return ret; } /* S1 is done. Now do S2 translation. */ - ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_S2NS, + ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_Stage2, phys_ptr, attrs, &s2_prot, page_size, fi, cacheattrs != NULL ? &cacheattrs2 : NULL); @@ -10813,7 +10813,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, /* Fast Context Switch Extension. This doesn't exist at all in v8. * In v7 and earlier it affects all stage 1 translations. */ - if (address < 0x02000000 && mmu_idx != ARMMMUIdx_S2NS + if (address < 0x02000000 && mmu_idx != ARMMMUIdx_Stage2 && !arm_feature(env, ARM_FEATURE_V8)) { if (regime_el(env, mmu_idx) == 3) { address += env->cp15.fcseidr_s; diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ece749fe03..73801c5df7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -119,7 +119,7 @@ static inline int get_a64_user_mem_index(DisasContext *s) case ARMMMUIdx_S1SE1: useridx = ARMMMUIdx_S1SE0; break; - case ARMMMUIdx_S2NS: + case ARMMMUIdx_Stage2: g_assert_not_reached(); default: useridx = s->mmu_idx; diff --git a/target/arm/translate.c b/target/arm/translate.c index afff595726..995010834f 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -172,7 +172,7 @@ static inline int get_a32_user_mem_index(DisasContext *s) case ARMMMUIdx_MSUserNegPri: case ARMMMUIdx_MSPrivNegPri: return arm_to_core_mmu_idx(ARMMMUIdx_MSUserNegPri); - case ARMMMUIdx_S2NS: + case ARMMMUIdx_Stage2: default: g_assert_not_reached(); } From patchwork Sat Aug 3 18:47:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170491 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2345260ile; Sat, 3 Aug 2019 11:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjak4rCPDw/CDzDogf1mA3iuc3pX5VY2z/CZsBzsxO73orQuQX7Bjem9VsdZ6bobmcKTrO X-Received: by 2002:a05:6402:1355:: with SMTP id y21mr49004439edw.169.1564858558325; Sat, 03 Aug 2019 11:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858558; cv=none; d=google.com; s=arc-20160816; b=PxnBDP4HEbuuOhqTOaNJIh86vk0nYdi9ADKP2U6SfcNbTNnm7h7Z682AkdQbofX6tC Wxy4JqrMCwD4dEO02IrdSLpMksxN4vbb6RhNfAOS+5Hnzb4WXI4zR4ONubf6EdvuAANW C8t2VV26fNaha5oUlAPE0GFE+CUZ5r+37nEXFHcg4bfcvvTS7fuz25AMMcDfYn7lEPhn zSErJZPO6IV4DmkQN2CQaYCf/y7NYAuYBkN1bai7uDjewXELQbLPwPQLnJk0XIAZx0Dw oVVtGB44gi8lC5adRsKc47GZqktdG1lVk7FhIKKRsm+C4R9vQ52dctZ2boB+HArIJ0Hf T45g== 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=VjzDc7lTBTDRBT8iLvPhCchzYrLI8WxMxxlUTCAkZXM=; b=FDxEFZDWpBOUo3/gOeDoXXm5nCw8HXCOGtULYxQlcKJHipBnA6Z5KlTtP+nieZqAlE vbe84MDn9ibx/q0J8H/s5CQvFi+hwAmnGK6G1TD6hy5rxaL0C68C1sw9CuNNoO8LQsJz cGng/Z29jDCnMG1yx3J3sA7aclfi9VOP2AZROC5CWTu/VSe0fsNVqCuOrMh/3QCHU07x oe4jWe1bnPeK7nlgPo18PVVA55N9bfK3flf33QLwKEB8FeK6Uv2eRs/DyRLLpLrRrCjE qOWNmCc77IaXb0o+FR/vJjn3H70UjhSNLq0KOXvG30twJxWx41kz9/eQG2ytoy6G7xjf /u8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=foiUfcT4; 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 c57si27243191edc.169.2019.08.03.11.55.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:55:58 -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=foiUfcT4; 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 ([::1]:41478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzC8-0005UK-E5 for patch@linaro.org; Sat, 03 Aug 2019 14:55:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60933) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4v-0006RF-LA for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4u-0007Hr-3C for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:29 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:38245) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4s-0007FV-0S for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:26 -0400 Received: by mail-pg1-x542.google.com with SMTP id z14so437902pga.5 for ; Sat, 03 Aug 2019 11:48:24 -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=VjzDc7lTBTDRBT8iLvPhCchzYrLI8WxMxxlUTCAkZXM=; b=foiUfcT4TZ5uqUsirjpWFshpuOkx97FJ2aHGsrr2Exo2r1R41xS2WETc3BUtHfu3DO KMmV+Hj+0kZJkHsz5iJ/21oELQtf9X3pjUJ3tDn5bc8qWUWPJgvhbdNcPMaKTYgDc6Uo 7zDHJnElftLUjsgZEwqx1tFDhhsm2nqiX75IDNEkesSlwxLhvWXDCkI3+4+WDZHMExEX ORTyQjTbU0S7KJvx8OFa5ADWSNIA723y6NSkjb+D6hRyDWxfYdPptpB9gC8O4DgYs+MG N7YGVGJcZIgMkUijoYAQr+3DzAyl+bOHBZeZalhb4HliwSwAenmUo1SuHRwEbpxW/+vp CfEQ== 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=VjzDc7lTBTDRBT8iLvPhCchzYrLI8WxMxxlUTCAkZXM=; b=VBA5qzSNG5lJffNnC+gxjalNKJ9eqA4GoWU5EjV8d6x2C+oxZQk5KGPavk/ZqWLm/j TYgzHB6f3Zyah29bugP4pdJ87obe9ytPcEJMCbZeUp6O3aSDTL22kEmo2ZNYhZGac/38 5kl6p7HAXhXdo1GBaMB7LrBY0yt2mHrf+nO6Vrm0g6GcNhNznxP7dnMyJO+S/RbetNO8 qzl6+Yw03HX4TbfdIJiI1FL84XEFfFS8pDyQnHo71UQbRrDLXDwko0Xp8sFK78elAIab vZ+Emysdg8CrEoF+uJ1CQko1WS01hE1fpdm/L2NW+dzIw5PL9kpaIS52p76kOQqmMUG8 c8yw== X-Gm-Message-State: APjAAAUPUYYP7Qq7hewUoKRqaW25oeKOqpT7EqZ6N1U8DZ6oPgm+1GUA jV9hyaQvAISO+6xINMvxI6DXFyG4YvQ= X-Received: by 2002:aa7:9217:: with SMTP id 23mr66753521pfo.239.1564858103240; Sat, 03 Aug 2019 11:48:23 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:43 -0700 Message-Id: <20190803184800.8221-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::542 Subject: [Qemu-devel] [PATCH v3 17/34] target/arm: Rename ARMMMUIdx_S1NSE* to ARMMMUIdx_Stage1_E* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a reorganization to the set of mmu_idx. The EL1&0 regime is the only one that uses 2-stage translation. Spelling out Stage avoids confusion with Secure. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 4 ++-- target/arm/internals.h | 6 +++--- target/arm/helper.c | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 14730d29c6..ade558f63c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2868,8 +2868,8 @@ typedef enum ARMMMUIdx { /* Indexes below here don't have TLBs and are used only for AT system * instructions or for the first stage of an S12 page table walk. */ - ARMMMUIdx_S1NSE0 = 0 | ARM_MMU_IDX_NOTLB, - ARMMMUIdx_S1NSE1 = 1 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB, } ARMMMUIdx; /* Bit macros for the core-mmu-index values for each index, diff --git a/target/arm/internals.h b/target/arm/internals.h index 1caa15e7e0..cd9b1acb20 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -810,8 +810,8 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) switch (mmu_idx) { case ARMMMUIdx_EL10_0: case ARMMMUIdx_EL10_1: - case ARMMMUIdx_S1NSE0: - case ARMMMUIdx_S1NSE1: + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_S1E2: case ARMMMUIdx_Stage2: case ARMMMUIdx_MPrivNegPri: @@ -966,7 +966,7 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env); #ifdef CONFIG_USER_ONLY static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) { - return ARMMMUIdx_S1NSE0; + return ARMMMUIdx_Stage1_E0; } #else ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); diff --git a/target/arm/helper.c b/target/arm/helper.c index 6c8eddfdf4..4c0c314c1a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3119,10 +3119,10 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) mmu_idx = ARMMMUIdx_S1E3; break; case 2: - mmu_idx = ARMMMUIdx_S1NSE1; + mmu_idx = ARMMMUIdx_Stage1_E1; break; case 1: - mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_S1NSE1; + mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; break; default: g_assert_not_reached(); @@ -3135,10 +3135,10 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) mmu_idx = ARMMMUIdx_S1SE0; break; case 2: - mmu_idx = ARMMMUIdx_S1NSE0; + mmu_idx = ARMMMUIdx_Stage1_E0; break; case 1: - mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S1NSE0; + mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; break; default: g_assert_not_reached(); @@ -3192,7 +3192,7 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, case 0: switch (ri->opc1) { case 0: /* AT S1E1R, AT S1E1W */ - mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_S1NSE1; + mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; break; case 4: /* AT S1E2R, AT S1E2W */ mmu_idx = ARMMMUIdx_S1E2; @@ -3205,7 +3205,7 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, } break; case 2: /* AT S1E0R, AT S1E0W */ - mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S1NSE0; + mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; break; case 4: /* AT S12E1R, AT S12E1W */ mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_EL10_1; @@ -8698,8 +8698,8 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_S1SE0: return arm_el_is_aa64(env, 3) ? 1 : 3; case ARMMMUIdx_S1SE1: - case ARMMMUIdx_S1NSE0: - case ARMMMUIdx_S1NSE1: + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_MPrivNegPri: case ARMMMUIdx_MUserNegPri: case ARMMMUIdx_MPriv: @@ -8757,7 +8757,7 @@ static inline bool regime_translation_disabled(CPUARMState *env, } if ((env->cp15.hcr_el2 & HCR_DC) && - (mmu_idx == ARMMMUIdx_S1NSE0 || mmu_idx == ARMMMUIdx_S1NSE1)) { + (mmu_idx == ARMMMUIdx_Stage1_E0 || mmu_idx == ARMMMUIdx_Stage1_E1)) { /* HCR.DC means SCTLR_EL1.M behaves as 0 */ return true; } @@ -8802,7 +8802,7 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) { if (mmu_idx == ARMMMUIdx_EL10_0 || mmu_idx == ARMMMUIdx_EL10_1) { - mmu_idx += (ARMMMUIdx_S1NSE0 - ARMMMUIdx_EL10_0); + mmu_idx += (ARMMMUIdx_Stage1_E0 - ARMMMUIdx_EL10_0); } return mmu_idx; } @@ -8837,7 +8837,7 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_S1SE0: - case ARMMMUIdx_S1NSE0: + case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_MUser: case ARMMMUIdx_MSUser: case ARMMMUIdx_MUserNegPri: @@ -9068,7 +9068,7 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, hwaddr addr, MemTxAttrs txattrs, ARMMMUFaultInfo *fi) { - if ((mmu_idx == ARMMMUIdx_S1NSE0 || mmu_idx == ARMMMUIdx_S1NSE1) && + if ((mmu_idx == ARMMMUIdx_Stage1_E0 || mmu_idx == ARMMMUIdx_Stage1_E1) && !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { target_ulong s2size; hwaddr s2pa; From patchwork Sat Aug 3 18:47:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170494 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2346227ile; Sat, 3 Aug 2019 11:57:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuU6oi1nRCkT9coutWOvh4s9OYPUSugL0xF3kWK339/NCBtQSKV+oJ1PtfMgqhExGfquQb X-Received: by 2002:aa7:d4cf:: with SMTP id t15mr125686952edr.215.1564858649499; Sat, 03 Aug 2019 11:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858649; cv=none; d=google.com; s=arc-20160816; b=B0LFK30BKuczuwwl4KQriHA541aLz7ph9uygnSLbwBEsNK0I6GDp85tUv7xTrEKJNC ZwOxh7+9oMbZ1AEA7MzAFH6DFGfaXXr14bMiP5SMF9zdu0id8A3cLy66Yb14yl5qWVHy HuPLgV2V34nXaq8lKA7s1GMN/ewFWEnI/L/aohVpoaCcrrUHZWKzemtQ1TjrXYq2zCAP biAioxixp3PKX9UdHAXfVL/GnOfpmkQR3s89FzBIM/DBsJqlcCwHDVQFWnfjM/hu5KuI gcsyT/+O68ecc0EbFJlXwd+T0cyMa0nO4QHHm6ngurs0wdUsC0t+PR+gV/ulXgNJ4WYm gc6Q== 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=w216qTj/BYqjTL2Y/6Uaoyzbe1vK0P5jhQZ1rUoxx+c=; b=MM+cxU7rb2J5uUo3WOZji59ZajoSpDrCLUfQ43wZRQNRhDsZXnFfWsBX6cG4+y1BHr eco6J6TO6JvCy164KuAP6QIIaONXi2BBYLL9tfOxt6ruSLhdWaJEfTX/rm9cnsXzUCe1 ImHqQ0Y2/Hgkt4zPZghPPecLPzbJBjDyLJYj6S6G7GUGNSkauwb6JQm07yadGR6ijpGh BLn5rm/UBzeSlYaW0uJPPNiXuL1Q/+OnzXp6DUf/jxlaEYzU2IF6d23qsa9nX3vy3GbU 1wK5JaP6GndoQ4YLMO1T0XxYtcxrztNoY7XRHT/zwIqRf8es0D6d4CQVLJKAMbAppYl4 XxsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="VshZ5FZ/"; 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 k12si24858653ejs.159.2019.08.03.11.57.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:57:29 -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="VshZ5FZ/"; 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 ([::1]:41516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzDc-000065-Hm for patch@linaro.org; Sat, 03 Aug 2019 14:57:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60948) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4v-0006SW-UP for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4u-0007IA-5M for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:29 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:32976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4s-0007GQ-2f for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:28 -0400 Received: by mail-pf1-x441.google.com with SMTP id g2so37628919pfq.0 for ; Sat, 03 Aug 2019 11:48:25 -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=w216qTj/BYqjTL2Y/6Uaoyzbe1vK0P5jhQZ1rUoxx+c=; b=VshZ5FZ/nArFkQFQb7nU4aHDQVOFJUdHPmPlru4x3yPa9mSn0gl9yvoND9TEAFdOZ/ yZDA96+cgmGMBx7Kd/2wPOrIMj8+T9rscFkIG/DFJFaWLDKmpNXRmdAC7BY3QAh5/jvs 5M23Pm9CHPl3z0WDwuzKlj/lXdcKQ+7oExXe3KgIEq/xuF7yfX9x2PEr4qul3sD5Qscz p9krloOMxMIqH4GP5Kt9q53d8YEnBOpWCFb5E8jySL0nmi3ZQC2hKFhl8dl/CHIb3MAb FCzUU/cMHasVZ10ACJvfF8ECDP8ix230+IDYMbU0tE1LH169onpvcRG5XTkEs+KYNHA0 yQ6w== 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=w216qTj/BYqjTL2Y/6Uaoyzbe1vK0P5jhQZ1rUoxx+c=; b=SkMM6B6W+CSQSrMu+lEakFq9h4+pyYs+XMD/9eFf1bI2bZtcqWi7bVhsTrxnOeNGxX tfXli+u++snNIx8bgyvBhrVqxLXrDOoKaMAd5tk/W4pw4/X/ZapdeFcri9yfLSK4Mf5g crHw1/iInbtWHri57cG8CwToVN9OPebMj03ZUC4Cky4swcIVQXpqGQdk3/+TEUVezTmI GcCUXnIYeh0eDjvRpP3uZzpiy7azyYXtrgddq28GTHy+3FF83cdFhleox+bG6KU9HFfi aMc4J1AyDbZb918yYjq3m9e8OxNkfKgdfbFCTVYY2qVBQzqXyY+wgEUUgKhk8lkScGQs tjnA== X-Gm-Message-State: APjAAAXeWCmNVt4y1Oq5pbgZPDEkEXUb59WI+PYIiT7GWEQcuOzIUNvW viNHOyPjKzn4Qa0PtHHu29p4MOGVM08= X-Received: by 2002:a17:90a:5884:: with SMTP id j4mr10856534pji.142.1564858104262; Sat, 03 Aug 2019 11:48:24 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:44 -0700 Message-Id: <20190803184800.8221-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::441 Subject: [Qemu-devel] [PATCH v3 18/34] target/arm: Rename ARMMMUIdx_S1SE* to ARMMMUIdx_SE* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a reorganization to the set of mmu_idx. The Secure regimes all have a single stage translation; there is no point in pointing out that the idx is for stage1. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 8 ++++---- target/arm/internals.h | 4 ++-- target/arm/translate.h | 2 +- target/arm/helper.c | 30 +++++++++++++++--------------- target/arm/translate-a64.c | 4 ++-- target/arm/translate.c | 6 +++--- 6 files changed, 27 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index ade558f63c..c7ce8a4da5 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2854,8 +2854,8 @@ typedef enum ARMMMUIdx { ARMMMUIdx_EL10_1 = 1 | ARM_MMU_IDX_A, ARMMMUIdx_S1E2 = 2 | ARM_MMU_IDX_A, ARMMMUIdx_S1E3 = 3 | ARM_MMU_IDX_A, - ARMMMUIdx_S1SE0 = 4 | ARM_MMU_IDX_A, - ARMMMUIdx_S1SE1 = 5 | ARM_MMU_IDX_A, + ARMMMUIdx_SE0 = 4 | ARM_MMU_IDX_A, + ARMMMUIdx_SE1 = 5 | ARM_MMU_IDX_A, ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_A, ARMMMUIdx_MUser = 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv = 1 | ARM_MMU_IDX_M, @@ -2880,8 +2880,8 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_EL10_1 = 1 << 1, ARMMMUIdxBit_S1E2 = 1 << 2, ARMMMUIdxBit_S1E3 = 1 << 3, - ARMMMUIdxBit_S1SE0 = 1 << 4, - ARMMMUIdxBit_S1SE1 = 1 << 5, + ARMMMUIdxBit_SE0 = 1 << 4, + ARMMMUIdxBit_SE1 = 1 << 5, ARMMMUIdxBit_Stage2 = 1 << 6, ARMMMUIdxBit_MUser = 1 << 0, ARMMMUIdxBit_MPriv = 1 << 1, diff --git a/target/arm/internals.h b/target/arm/internals.h index cd9b1acb20..c505cae30c 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -820,8 +820,8 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_MUser: return false; case ARMMMUIdx_S1E3: - case ARMMMUIdx_S1SE0: - case ARMMMUIdx_S1SE1: + case ARMMMUIdx_SE0: + case ARMMMUIdx_SE1: case ARMMMUIdx_MSPrivNegPri: case ARMMMUIdx_MSUserNegPri: case ARMMMUIdx_MSPriv: diff --git a/target/arm/translate.h b/target/arm/translate.h index a20f6e2056..715fa08e3b 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -122,7 +122,7 @@ static inline int default_exception_el(DisasContext *s) * exceptions can only be routed to ELs above 1, so we target the higher of * 1 or the current EL. */ - return (s->mmu_idx == ARMMMUIdx_S1SE0 && s->secure_routed_to_el3) + return (s->mmu_idx == ARMMMUIdx_SE0 && s->secure_routed_to_el3) ? 3 : MAX(1, s->current_el); } diff --git a/target/arm/helper.c b/target/arm/helper.c index 4c0c314c1a..e0d4f33026 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -566,7 +566,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, switch (ri->secure) { case ARM_CP_SECSTATE_S: - idxmask = ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + idxmask = ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; break; case ARM_CP_SECSTATE_NS: idxmask = ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; @@ -3122,7 +3122,7 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) mmu_idx = ARMMMUIdx_Stage1_E1; break; case 1: - mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; + mmu_idx = secure ? ARMMMUIdx_SE1 : ARMMMUIdx_Stage1_E1; break; default: g_assert_not_reached(); @@ -3132,13 +3132,13 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) /* stage 1 current state PL0: ATS1CUR, ATS1CUW */ switch (el) { case 3: - mmu_idx = ARMMMUIdx_S1SE0; + mmu_idx = ARMMMUIdx_SE0; break; case 2: mmu_idx = ARMMMUIdx_Stage1_E0; break; case 1: - mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; + mmu_idx = secure ? ARMMMUIdx_SE0 : ARMMMUIdx_Stage1_E0; break; default: g_assert_not_reached(); @@ -3192,7 +3192,7 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, case 0: switch (ri->opc1) { case 0: /* AT S1E1R, AT S1E1W */ - mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; + mmu_idx = secure ? ARMMMUIdx_SE1 : ARMMMUIdx_Stage1_E1; break; case 4: /* AT S1E2R, AT S1E2W */ mmu_idx = ARMMMUIdx_S1E2; @@ -3205,13 +3205,13 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, } break; case 2: /* AT S1E0R, AT S1E0W */ - mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; + mmu_idx = secure ? ARMMMUIdx_SE0 : ARMMMUIdx_Stage1_E0; break; case 4: /* AT S12E1R, AT S12E1W */ - mmu_idx = secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_EL10_1; + mmu_idx = secure ? ARMMMUIdx_SE1 : ARMMMUIdx_EL10_1; break; case 6: /* AT S12E0R, AT S12E0W */ - mmu_idx = secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_EL10_0; + mmu_idx = secure ? ARMMMUIdx_SE0 : ARMMMUIdx_EL10_0; break; default: g_assert_not_reached(); @@ -3424,7 +3424,7 @@ static void update_lpae_el1_asid(CPUARMState *env, int secure) ttcr = env->cp15.tcr_el[3].raw_tcr; /* Note that cp15.ttbr0_s == cp15.ttbr0_el[3], so S1E3 is affected. */ /* ??? Secure EL3 really using the ASID field? Doesn't make sense. */ - idxmask = ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0 | ARMMMUIdxBit_S1E3; + idxmask = ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0 | ARMMMUIdxBit_S1E3; break; case ARM_CP_SECSTATE_NS: ttbr0 = env->cp15.ttbr0_ns; @@ -3899,7 +3899,7 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, static int vae1_tlbmask(CPUARMState *env) { if (arm_is_secure_below_el3(env)) { - return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } @@ -3935,7 +3935,7 @@ static int vmalle1_tlbmask(CPUARMState *env) * stage 1 translations. */ if (arm_is_secure_below_el3(env)) { - return ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_Stage2; } else { @@ -8695,9 +8695,9 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) return 2; case ARMMMUIdx_S1E3: return 3; - case ARMMMUIdx_S1SE0: + case ARMMMUIdx_SE0: return arm_el_is_aa64(env, 3) ? 1 : 3; - case ARMMMUIdx_S1SE1: + case ARMMMUIdx_SE1: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_MPrivNegPri: @@ -8836,7 +8836,7 @@ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { - case ARMMMUIdx_S1SE0: + case ARMMMUIdx_SE0: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_MUser: case ARMMMUIdx_MSUser: @@ -11279,7 +11279,7 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) el = arm_current_el(env); if (el < 2 && arm_is_secure_below_el3(env)) { - return ARMMMUIdx_S1SE0 + el; + return ARMMMUIdx_SE0 + el; } else { return ARMMMUIdx_EL10_0 + el; } diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 73801c5df7..dbe2189e51 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -116,8 +116,8 @@ static inline int get_a64_user_mem_index(DisasContext *s) case ARMMMUIdx_EL10_1: useridx = ARMMMUIdx_EL10_0; break; - case ARMMMUIdx_S1SE1: - useridx = ARMMMUIdx_S1SE0; + case ARMMMUIdx_SE1: + useridx = ARMMMUIdx_SE0; break; case ARMMMUIdx_Stage2: g_assert_not_reached(); diff --git a/target/arm/translate.c b/target/arm/translate.c index 995010834f..1fc2bf8a52 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -157,9 +157,9 @@ static inline int get_a32_user_mem_index(DisasContext *s) case ARMMMUIdx_EL10_1: return arm_to_core_mmu_idx(ARMMMUIdx_EL10_0); case ARMMMUIdx_S1E3: - case ARMMMUIdx_S1SE0: - case ARMMMUIdx_S1SE1: - return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0); + case ARMMMUIdx_SE0: + case ARMMMUIdx_SE1: + return arm_to_core_mmu_idx(ARMMMUIdx_SE0); case ARMMMUIdx_MUser: case ARMMMUIdx_MPriv: return arm_to_core_mmu_idx(ARMMMUIdx_MUser); From patchwork Sat Aug 3 18:47:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170496 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2346416ile; Sat, 3 Aug 2019 11:57:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSUEhFivAJRVB7GTUYEUmmI52Ll2c/6QoiU2IJhPEyYRvzFooXK/Oh1ffGCEukT8hLQc8M X-Received: by 2002:a50:982a:: with SMTP id g39mr124694504edb.88.1564858669240; Sat, 03 Aug 2019 11:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858669; cv=none; d=google.com; s=arc-20160816; b=gqsRwcXmXB5PrlEMlFbOyV16PmiUxIvoFsecOjeiWnMMxCPMT7918XYzpf4XdGJBlp H+wOVbbuBSQhBHUf09lUB6/lCKdLFK9QK5zJq3qO7+5P/PBptKxZhhXNPsB7j7G78onj eI3sF85IwnlplHj2Pdla6sDtqIz92lWBkrY1Dm9sTGBiGHq1yxEJaOlgNvEyIoP5mvjD ZZBz6NLS99GVtwXOtmHpigwjSKvWIwDV5mr9tftdeNqNJOkoFUMb7ARVZTJH6rfqqAc4 D0e2ZqHqZ91w/8wcIVDmdOF5zX+KG+5yanvhKlwHvyEn1JxyIKKLTyjFdjqgNqYSvYBW gPrg== 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=uNn5q4INDqZzSSWnDmMk9zDSnWJbLDXBWQcIuUU2uJI=; b=U4El/wuOXR0BN+S0WFyZ7VYtg3deXhq/rV2fsKS4lAGH25cKB7DhzC4eAc3kec18il 9wnbAyOdodTGwoZIKHz/Wn4YZxBVScXQIVEUMVx30ocaED/MelkVYpFepZ0yaNxbZ1ef XHv1Xr0Dwxd342NZLoxmijd802Nwo4cO2GxyUBcJVHsMSiPOXc24L1+eTWys4RWdjwlf FPcaG2+7ZvOD9po9AKqD73SUydOzxDNy2yYcDK4AC0VKHVXJiYS1jT6ZI5ZD0eI1+ohH DSJs1+x+lZpGkJxPs9BircKcNjVi7ZvO7COpJLvLNolVpH0fI2DpA1KTyuTyZ3kVPT4x ckbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jr7Kr4c7; 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 gs7si23886413ejb.68.2019.08.03.11.57.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:57:49 -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=Jr7Kr4c7; 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 ([::1]:41527 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzDw-00011D-6e for patch@linaro.org; Sat, 03 Aug 2019 14:57:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60938) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4v-0006Rr-Q4 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4u-0007Ib-CU for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:29 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:46089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4u-0007HJ-4s for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:28 -0400 Received: by mail-pf1-x443.google.com with SMTP id c3so14484240pfa.13 for ; Sat, 03 Aug 2019 11:48:26 -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=uNn5q4INDqZzSSWnDmMk9zDSnWJbLDXBWQcIuUU2uJI=; b=Jr7Kr4c7WspWidhsMVEBqY65eKtoOdpD1vCf6jz53B3T1k0v4zi0g49FgBx3q1I7Dl BTWK7XyI/dIIKkJfmI3AbpmfrMn9f/Zzb+m+zzgjRAeUKHoRjtzmfBr43KMhTVdGoG6e R1jshS01nZ63gENO4CsOUEOID4yKeDERfXiWhVs4ZmspOYpH1022C7gHcmepqL/GlgqK xg47MUOEO+7FCLiL6o3DI+Msqbvtpd44FOF4sZFCLthzejM9lygGkgjwPtLY8k0DjeyO zm0EToUtJ4y5e6tNnTApDJ2mJgMTrHiVFPqPYTi509+wTyGFH6chjSpQwLW+tBdffG9J KlmQ== 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=uNn5q4INDqZzSSWnDmMk9zDSnWJbLDXBWQcIuUU2uJI=; b=Yn/LZNYQufWF9oXJ2CyH2/Z4WPZh0DrMpeG48zXY1kWOhYRMeX87EvOpGARpqLmyLR i0qeL9YTL6lcwtkbjZpo8hm05ifBk6sT+b+sIl40j8re3zCAdevOvOs9Sz5y4/Xml+1p yLuoz7dawYYga1S+dXp7TfOhpr8zquplNQe6/eU3hEUfdMgTCVDdBwrJGo/7SW4ehwOI MS3r/MvvtA+LoIX1ggUu6hmCZo4LF67yr2HrAz9PJ1eRLZy4o8QVQjQIHUZKr7otY4pJ mVdRylKcTbaQIWmBfs52zCRgR7nPphv7TR7Ww8riiBOIjHTKWS9rCZeMyAIkP9y8/W+O j/4g== X-Gm-Message-State: APjAAAWe5M1yMlD8LjviR3Tib6h3vwtdUPOzyqsJkfxvTB0q51sZtg/k xZ3UMTZFUskvWgoe8CMADf0axjB/L4k= X-Received: by 2002:a62:187:: with SMTP id 129mr66266219pfb.128.1564858105384; Sat, 03 Aug 2019 11:48:25 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:45 -0700 Message-Id: <20190803184800.8221-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::443 Subject: [Qemu-devel] [PATCH v3 19/34] target/arm: Rename ARMMMUIdx*_S1E3 to ARMMMUIdx*_SE3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a reorganization to the set of mmu_idx. The EL3 regime only has a single stage translation, and is always secure. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 4 ++-- target/arm/internals.h | 2 +- target/arm/helper.c | 18 +++++++++--------- target/arm/translate.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c7ce8a4da5..94337b2fb0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2853,7 +2853,7 @@ typedef enum ARMMMUIdx { ARMMMUIdx_EL10_0 = 0 | ARM_MMU_IDX_A, ARMMMUIdx_EL10_1 = 1 | ARM_MMU_IDX_A, ARMMMUIdx_S1E2 = 2 | ARM_MMU_IDX_A, - ARMMMUIdx_S1E3 = 3 | ARM_MMU_IDX_A, + ARMMMUIdx_SE3 = 3 | ARM_MMU_IDX_A, ARMMMUIdx_SE0 = 4 | ARM_MMU_IDX_A, ARMMMUIdx_SE1 = 5 | ARM_MMU_IDX_A, ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_A, @@ -2879,7 +2879,7 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_EL10_0 = 1 << 0, ARMMMUIdxBit_EL10_1 = 1 << 1, ARMMMUIdxBit_S1E2 = 1 << 2, - ARMMMUIdxBit_S1E3 = 1 << 3, + ARMMMUIdxBit_SE3 = 1 << 3, ARMMMUIdxBit_SE0 = 1 << 4, ARMMMUIdxBit_SE1 = 1 << 5, ARMMMUIdxBit_Stage2 = 1 << 6, diff --git a/target/arm/internals.h b/target/arm/internals.h index c505cae30c..dbb46da549 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -819,7 +819,7 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_MPriv: case ARMMMUIdx_MUser: return false; - case ARMMMUIdx_S1E3: + case ARMMMUIdx_SE3: case ARMMMUIdx_SE0: case ARMMMUIdx_SE1: case ARMMMUIdx_MSPrivNegPri: diff --git a/target/arm/helper.c b/target/arm/helper.c index e0d4f33026..e5b07b4770 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3116,7 +3116,7 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) /* stage 1 current state PL1: ATS1CPR, ATS1CPW */ switch (el) { case 3: - mmu_idx = ARMMMUIdx_S1E3; + mmu_idx = ARMMMUIdx_SE3; break; case 2: mmu_idx = ARMMMUIdx_Stage1_E1; @@ -3198,7 +3198,7 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, mmu_idx = ARMMMUIdx_S1E2; break; case 6: /* AT S1E3R, AT S1E3W */ - mmu_idx = ARMMMUIdx_S1E3; + mmu_idx = ARMMMUIdx_SE3; break; default: g_assert_not_reached(); @@ -3422,9 +3422,9 @@ static void update_lpae_el1_asid(CPUARMState *env, int secure) ttbr0 = env->cp15.ttbr0_s; ttbr1 = env->cp15.ttbr1_s; ttcr = env->cp15.tcr_el[3].raw_tcr; - /* Note that cp15.ttbr0_s == cp15.ttbr0_el[3], so S1E3 is affected. */ + /* Note that cp15.ttbr0_s == cp15.ttbr0_el[3], so SE3 is affected. */ /* ??? Secure EL3 really using the ASID field? Doesn't make sense. */ - idxmask = ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0 | ARMMMUIdxBit_S1E3; + idxmask = ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0 | ARMMMUIdxBit_SE3; break; case ARM_CP_SECSTATE_NS: ttbr0 = env->cp15.ttbr0_ns; @@ -3967,7 +3967,7 @@ static void tlbi_aa64_alle3_write(CPUARMState *env, const ARMCPRegInfo *ri, ARMCPU *cpu = env_archcpu(env); CPUState *cs = CPU(cpu); - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_S1E3); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_SE3); } static void tlbi_aa64_alle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3992,7 +3992,7 @@ static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, { CPUState *cs = env_cpu(env); - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E3); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_SE3); } static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4020,7 +4020,7 @@ static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri, CPUState *cs = CPU(cpu); uint64_t pageaddr = sextract64(value << 12, 0, 56); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S1E3); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_SE3); } static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4069,7 +4069,7 @@ static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t pageaddr = sextract64(value << 12, 0, 56); tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1E3); + ARMMMUIdxBit_SE3); } static void tlbi_aa64_ipas2e1_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -8693,7 +8693,7 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_Stage2: case ARMMMUIdx_S1E2: return 2; - case ARMMMUIdx_S1E3: + case ARMMMUIdx_SE3: return 3; case ARMMMUIdx_SE0: return arm_el_is_aa64(env, 3) ? 1 : 3; diff --git a/target/arm/translate.c b/target/arm/translate.c index 1fc2bf8a52..5372947e47 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -156,7 +156,7 @@ static inline int get_a32_user_mem_index(DisasContext *s) case ARMMMUIdx_EL10_0: case ARMMMUIdx_EL10_1: return arm_to_core_mmu_idx(ARMMMUIdx_EL10_0); - case ARMMMUIdx_S1E3: + case ARMMMUIdx_SE3: case ARMMMUIdx_SE0: case ARMMMUIdx_SE1: return arm_to_core_mmu_idx(ARMMMUIdx_SE0); From patchwork Sat Aug 3 18:47:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170492 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2345835ile; Sat, 3 Aug 2019 11:56:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsUwknHZW63ERyerTTuYfOS7gKPXKBOckYzZg+xDyeVst7gUofpZNxhlQ5Af3OXkrh+5xb X-Received: by 2002:aa7:c754:: with SMTP id c20mr124116371eds.265.1564858613294; Sat, 03 Aug 2019 11:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858613; cv=none; d=google.com; s=arc-20160816; b=zNPyv4XI1A2b0JOvBnjNTop9raM7XxKU/oFEGXoN6Gdw+QryaFzT/oAKcUzWGAaV8I 6dspzwJprZz0MCJQ3gC7/BxPhfAB+r8OaDkx1zSy7+nxtLDL1CwGDERzoRsjGiUVW9zJ tQMb3Lc34steD/aVPjaq/J3mprQtmf9ZXWw6+5pLBnUHILzh2b78mde3VVXZuIskiqQE NZfrrj3JycBpF5PgHuQpS/5AL+tL8QyqGnTHgRD+jcYptCyWiHTu+1aj7LLkXImHCKzQ zZ0fEfbJL9R6D1pAmMZw/SclI6vtpcvovwxfrItt6QXHe42WWe8hECHyCwO7D68F0Rv1 X/gA== 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=trlNGPogxXBK9OHHkWCBGsx/W/Lwzy6lbLUgzLGbb4A=; b=EUYXwDdfrzRBVWGtlZSx9f2wrgrUznvaG4r/F9sO/PxDwZMuo1vZMbBsHfnwnUGyn2 dM0LcYguuuFsZQgvUVy4Yp95nyqnP9d64qURMr5uRnz0fBTCkLDucvRCPsr7+uvgt87F 5MsxhijKF1VRo905+qVH3EAv+8J2lB2t03GaJAEFlF/nJbjEhCFvst3YokXFEa78F2DX U70OEryW0PuNJeJNdbDLZvG1cUAG3UMtlzbFz14F7kwFYIaMACj1p0fCT12xAreWID03 5x1qOMUdNPDbYJcNRK0OI21D5jxZIkCpA8MJhYmcjBNWZNljc95Sx/T4aGh4QiCTXjNu wQAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=odxwR9Yi; 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 d39si28008370eda.8.2019.08.03.11.56.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:56:53 -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=odxwR9Yi; 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 ([::1]:41508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzD2-0007XW-B5 for patch@linaro.org; Sat, 03 Aug 2019 14:56:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60945) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4v-0006SL-Ti for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4u-0007Ii-DE for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:29 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:34464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4u-0007Hh-3m for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:28 -0400 Received: by mail-pf1-x444.google.com with SMTP id b13so37624306pfo.1 for ; Sat, 03 Aug 2019 11:48:27 -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=trlNGPogxXBK9OHHkWCBGsx/W/Lwzy6lbLUgzLGbb4A=; b=odxwR9YiZlmrGzO7nK5x0AhHcuzhht7jcq0WhlNQQ435GlTLBD9THl+3O3xN+t3S8l Mjjl/Bpa3Y4ktoiHXlSVFsy3PY0tO931k7fbIopPIMSHjy37h3SnI/17cNUE7gy/eEWO BlLJR4LbROSaNtbY5CsUzRCofyePk6lM2zUIL9XeFQn/AiKmOOiO2O4UMnBgs09iUfJ2 74P6x64vngm09vFVL+36Y9sY9LtwuQIcqpG1MEzzJ2XQb9J+Q7utHiXIT/1VVam0WTxE bzKp9eTr0Kw8211EBtHNGuaNfxPHQYJvyL6LVsDJYSTXsscLU+8sM6gKGkpL2flczyrT 1LsA== 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=trlNGPogxXBK9OHHkWCBGsx/W/Lwzy6lbLUgzLGbb4A=; b=FyZCBkJmiObRF6DnFtT8wX5b9r11/HJcyKeYJsdbyjpgva9Tu8Yvq+Jlq5YoAQ3CKT v1r1R7E/Q9mVLVry6gZvRd7h2BtzQMJYaOjSrlBQzp7bx3HrYG3OQ1peUousZUEGHdBC 4+XtZvLoHuvrKjkXZju8b/xOS/k4XV3GD9etarLTeHRq5Je8jqnELSID63IQC4yJMmvp 55yV1iE3U0Lznyk8SHTVYiRVfagd1Bks8baeu3RTvKK+wfAee19f09ja4PC+N194STGe SkvpQecYN8ZLhlvsXWwCXHVaUtvYgrT+qRSqhPE50taTnjt8xrlyLeG/UrpLLUpt9B6+ Z8JQ== X-Gm-Message-State: APjAAAXBy0hn2eFU9Uee6i4VYjjZGTsxIxf/VEoza3Bc4qxL+UKxvEpp OM2iU7sooq2Q+nNtEqHQzpcJPz5IROY= X-Received: by 2002:a17:90a:9a95:: with SMTP id e21mr10190086pjp.98.1564858106593; Sat, 03 Aug 2019 11:48:26 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:46 -0700 Message-Id: <20190803184800.8221-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::444 Subject: [Qemu-devel] [PATCH v3 20/34] target/arm: Rename ARMMMUIdx_S1E2 to ARMMMUIdx_E2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a reorganization to the set of mmu_idx. The non-secure EL2 regime only has a single stage translation; there is no point in pointing out that the idx is for stage1. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 4 ++-- target/arm/internals.h | 2 +- target/arm/helper.c | 24 ++++++++++++------------ target/arm/translate.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 94337b2fb0..552269daad 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2852,7 +2852,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, typedef enum ARMMMUIdx { ARMMMUIdx_EL10_0 = 0 | ARM_MMU_IDX_A, ARMMMUIdx_EL10_1 = 1 | ARM_MMU_IDX_A, - ARMMMUIdx_S1E2 = 2 | ARM_MMU_IDX_A, + ARMMMUIdx_E2 = 2 | ARM_MMU_IDX_A, ARMMMUIdx_SE3 = 3 | ARM_MMU_IDX_A, ARMMMUIdx_SE0 = 4 | ARM_MMU_IDX_A, ARMMMUIdx_SE1 = 5 | ARM_MMU_IDX_A, @@ -2878,7 +2878,7 @@ typedef enum ARMMMUIdx { typedef enum ARMMMUIdxBit { ARMMMUIdxBit_EL10_0 = 1 << 0, ARMMMUIdxBit_EL10_1 = 1 << 1, - ARMMMUIdxBit_S1E2 = 1 << 2, + ARMMMUIdxBit_E2 = 1 << 2, ARMMMUIdxBit_SE3 = 1 << 3, ARMMMUIdxBit_SE0 = 1 << 4, ARMMMUIdxBit_SE1 = 1 << 5, diff --git a/target/arm/internals.h b/target/arm/internals.h index dbb46da549..027878516f 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -812,7 +812,7 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_EL10_1: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: - case ARMMMUIdx_S1E2: + case ARMMMUIdx_E2: case ARMMMUIdx_Stage2: case ARMMMUIdx_MPrivNegPri: case ARMMMUIdx_MUserNegPri: diff --git a/target/arm/helper.c b/target/arm/helper.c index e5b07b4770..69c913d824 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -740,7 +740,7 @@ static void tlbiall_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, { CPUState *cs = env_cpu(env); - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); } static void tlbiall_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -748,7 +748,7 @@ static void tlbiall_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, { CPUState *cs = env_cpu(env); - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); } static void tlbimva_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -757,7 +757,7 @@ static void tlbimva_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, CPUState *cs = env_cpu(env); uint64_t pageaddr = value & ~MAKE_64BIT_MASK(0, 12); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S1E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); } static void tlbimva_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -767,7 +767,7 @@ static void tlbimva_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t pageaddr = value & ~MAKE_64BIT_MASK(0, 12); tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1E2); + ARMMMUIdxBit_E2); } static const ARMCPRegInfo cp_reginfo[] = { @@ -3167,7 +3167,7 @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; uint64_t par64; - par64 = do_ats_write(env, value, access_type, ARMMMUIdx_S1E2); + par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2); A32_BANKED_CURRENT_REG_SET(env, par, par64); } @@ -3195,7 +3195,7 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, mmu_idx = secure ? ARMMMUIdx_SE1 : ARMMMUIdx_Stage1_E1; break; case 4: /* AT S1E2R, AT S1E2W */ - mmu_idx = ARMMMUIdx_S1E2; + mmu_idx = ARMMMUIdx_E2; break; case 6: /* AT S1E3R, AT S1E3W */ mmu_idx = ARMMMUIdx_SE3; @@ -3958,7 +3958,7 @@ static void tlbi_aa64_alle2_write(CPUARMState *env, const ARMCPRegInfo *ri, ARMCPU *cpu = env_archcpu(env); CPUState *cs = CPU(cpu); - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); } static void tlbi_aa64_alle3_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3984,7 +3984,7 @@ static void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri, { CPUState *cs = env_cpu(env); - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); } static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4006,7 +4006,7 @@ static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, CPUState *cs = CPU(cpu); uint64_t pageaddr = sextract64(value << 12, 0, 56); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S1E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); } static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4059,7 +4059,7 @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t pageaddr = sextract64(value << 12, 0, 56); tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1E2); + ARMMMUIdxBit_E2); } static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4375,7 +4375,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "AT_S12E0W", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 7, .access = PL2_W, .type = ARM_CP_NO_RAW, .writefn = ats_write64 }, - /* AT S1E2* are elsewhere as they UNDEF from EL3 if EL2 is not present */ + /* AT E2* are elsewhere as they UNDEF from EL3 if EL2 is not present */ { .name = "AT_S1E3R", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 8, .opc2 = 0, .access = PL3_W, .type = ARM_CP_NO_RAW, .writefn = ats_write64 }, @@ -8691,7 +8691,7 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_Stage2: - case ARMMMUIdx_S1E2: + case ARMMMUIdx_E2: return 2; case ARMMMUIdx_SE3: return 3; diff --git a/target/arm/translate.c b/target/arm/translate.c index 5372947e47..4e79dbbdfc 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -152,7 +152,7 @@ static inline int get_a32_user_mem_index(DisasContext *s) * otherwise, access as if at PL0. */ switch (s->mmu_idx) { - case ARMMMUIdx_S1E2: /* this one is UNPREDICTABLE */ + case ARMMMUIdx_E2: /* this one is UNPREDICTABLE */ case ARMMMUIdx_EL10_0: case ARMMMUIdx_EL10_1: return arm_to_core_mmu_idx(ARMMMUIdx_EL10_0); From patchwork Sat Aug 3 18:47:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170497 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2346584ile; Sat, 3 Aug 2019 11:58:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSh5ikk0El3Y0Z3ekFveLVFHFvnXhfq1Pt4/FMG8jXwjnTK3U4CHy1bEqBw0rbNmWO+gjJ X-Received: by 2002:a50:b6ce:: with SMTP id f14mr120338899ede.236.1564858686441; Sat, 03 Aug 2019 11:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858686; cv=none; d=google.com; s=arc-20160816; b=Rm3K+rq/UP4UQD1veUhobcNIXS9N5JsOIebKUG4hpo1yaWmB6ihoshagW2ivjdvbz5 clPMJvMdilXfZ4Gn1EZTBL4BCzDJ7kGHSNO+OsYne5PtO4UyIf8YUmWStBCeknaFPJXJ vP616sbXdBhhTsYYWgGkj+NZpNpr03B2HxV2Qtf3Dg/XgOaJ7B/40PLdvMDtnsnyIlUm 3Gh0JiwEqSb1RrnHHWGzzctrWpR7ch0uJp4FIogNtA3n86Ckzruz9mOzXl8R5pGnkZQm 81LqEvPi8izHb65ozHwWEV6QbTOcAjM/YRhSH2CyT1Hle3K1iiyaal073pPKsm9D8Zf/ dnPw== 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=C4yPNU5MzTttlOEZGJqyKcDVIL6n5tI4jir190lVFFk=; b=tBRLcJOKycdTvqxOM8b3rgTd2oFW+nkjcbM/C4S2b1kXOZK2gOsOLA4Z9V7CVjncRM m07F0SpyAiHhYRwsK59DJ9114TecsRqf5Wd3DEP0sFwyUkLencgYgmBkzhivWExDBhnI C+muV12HdbSQ5fnGeNOiNcSsrOlSO/n7H/cMruvBsTnk2rnENdPJkitPMQLvSNJy6yLV eJrBjbIGXWfVjQukYq4oP/UCwM31HwZjqgBctOBOZlleTUiVWSaucsFOLkIPtAiVSFZc ISyK3F1SmsD/frD5mveZIkrKx9Gi1BZBLbUOQ6/tr6a7Ds1Ph9Td10+Hr2LYxoFhCJ9S /HWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JQIYGZ53; 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 h10si27472203edh.141.2019.08.03.11.58.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:58:06 -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=JQIYGZ53; 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 ([::1]:41540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzED-0002sC-At for patch@linaro.org; Sat, 03 Aug 2019 14:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32784) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4y-0006c3-3d for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4v-0007JB-Ci for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35703) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4v-0007Iu-4U for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:29 -0400 Received: by mail-pf1-x441.google.com with SMTP id u14so37642214pfn.2 for ; Sat, 03 Aug 2019 11:48:29 -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=C4yPNU5MzTttlOEZGJqyKcDVIL6n5tI4jir190lVFFk=; b=JQIYGZ53MtqAowkP2w6l/7Wd/j/veiwZC49CUbVDamurSfVRPozCNx6usezA+jz41x FcmDYL3K1AiLcawd29RXtu04yyoFF5MBF0VnvK2j7RA9AgFlbiY7muB6HcIZTPfCIN8D VquiPPs5H1om2PMOzAMn4ANu22yrskwBy/GIAZFPmBgUAP4LnUdPteuNPc/lpai3BJTE UtSubYeZHkeaVLT5gxt4jLGss2bT8lr9gIK7X6nXptXNWQmzX5XJH2Bc+uftMbZztPIv TmhOSdgvkx+AySe/qCfggGSQCB067RNpdLxUHbas2ZcapbVt+aOwHrDLXDik/+UfakAU yFDg== 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=C4yPNU5MzTttlOEZGJqyKcDVIL6n5tI4jir190lVFFk=; b=KAyoFcHrDDyTOCHlbAyPju2IDsB9/9Ud5DyYBKO0m8hz8CNXo/V3FotpAqDmGC7/SY 93RCOzOehf0cWK29Yjgmu8fOntjpwsfrG2RQQUxyfGbEvmlmW7R4oMXDEH87zc9SxQUR t0qcNLMGL3SiZLKorNkvObeUgRPNlSXTBK7psLzkXlAe8C/8uvivDJ5dd5+Xji5EN3uO K24QWKMs4kWjTIs8uFjKnxxuUIenDcZd0SK0DNq+Y1rIFBaVl/N0GYJ0Hzz4ZO9oKEWB EWyGwt6aRjih9yS/WtW1aZ1HWfMf+63po8rv0oIenZxobcik6kwxaIqRzUSkI61nHOl4 7vTg== X-Gm-Message-State: APjAAAWMZm6Fv9++pJwhWWrOvJiE911O+2/RUqzDLmRj03XWPPMB4CMn n1NQPS+4kHeB9OKqcKL8Ib2NNiy5RAk= X-Received: by 2002:a65:6108:: with SMTP id z8mr98286967pgu.289.1564858107784; Sat, 03 Aug 2019 11:48:27 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:47 -0700 Message-Id: <20190803184800.8221-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::441 Subject: [Qemu-devel] [PATCH v3 21/34] target/arm: Reorganize ARMMMUIdx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Prepare for, but do not yet implement, the EL2&0 regime and the Secure EL2 regime. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 173 ++++++++++++++++++++--------------------- target/arm/internals.h | 44 +++++------ target/arm/helper.c | 60 ++++++++++++-- target/arm/m_helper.c | 6 +- target/arm/translate.c | 1 - 5 files changed, 165 insertions(+), 119 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 552269daad..b5300f9014 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2764,7 +2764,10 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, * + NonSecure EL1 & 0 stage 1 * + NonSecure EL1 & 0 stage 2 * + NonSecure EL2 - * + Secure EL1 & EL0 + * + NonSecure EL2 & 0 (ARMv8.1-VHE) + * + Secure EL0 + * + Secure EL1 + * + Secure EL2 (ARMv8.4-SecEL2) * + Secure EL3 * If EL3 is 32-bit: * + NonSecure PL1 & 0 stage 1 @@ -2774,8 +2777,9 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, * (reminder: for 32 bit EL3, Secure PL1 is *EL3*, not EL1.) * * For QEMU, an mmu_idx is not quite the same as a translation regime because: - * 1. we need to split the "EL1 & 0" regimes into two mmu_idxes, because they - * may differ in access permissions even if the VA->PA map is the same + * 1. we need to split the "EL1 & 0" and "EL2 & 0" regimes into two mmu_idxes, + * because they may differ in access permissions even if the VA->PA map is + * the same * 2. we want to cache in our TLB the full VA->IPA->PA lookup for a stage 1+2 * translation, which means that we have one mmu_idx that deals with two * concatenated translation regimes [this sort of combined s1+2 TLB is @@ -2787,19 +2791,26 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, * 4. we can also safely fold together the "32 bit EL3" and "64 bit EL3" * translation regimes, because they map reasonably well to each other * and they can't both be active at the same time. - * This gives us the following list of mmu_idx values: + * 5. we want to be able to use the TLB for accesses done as part of a + * stage1 page table walk, rather than having to walk the stage2 page + * table over and over. * - * NS EL0 (aka NS PL0) stage 1+2 - * NS EL1 (aka NS PL1) stage 1+2 + * This gives us the following list of cases: + * + * NS EL0 (aka NS PL0) EL1&0 stage 1+2 + * NS EL1 (aka NS PL1) EL1&0 stage 1+2 + * NS EL0 (aka NS PL0) EL2&0 + * NS EL2 (aka NS PL2) EL2&0 * NS EL2 (aka NS PL2) - * S EL3 (aka S PL1) * S EL0 (aka S PL0) * S EL1 (not used if EL3 is 32 bit) - * NS EL0+1 stage 2 + * S EL2 (not used if EL3 is 32 bit) + * S EL3 (aka S PL1) + * NS EL0&1 stage 2 * - * (The last of these is an mmu_idx because we want to be able to use the TLB - * for the accesses done as part of a stage 1 page table walk, rather than - * having to walk the stage 2 page table over and over.) + * We then merge the two NS EL0 cases, and two NS EL2 cases to produce + * 8 different mmu_idx. We retain separate symbols for these four cases + * in order to simplify distinguishing them in the code. * * R profile CPUs have an MPU, but can use the same set of MMU indexes * as A profile. They only need to distinguish NS EL0 and NS EL1 (and @@ -2837,62 +2848,88 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, * For M profile we arrange them to have a bit for priv, a bit for negpri * and a bit for secure. */ -#define ARM_MMU_IDX_A 0x10 /* A profile */ -#define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */ -#define ARM_MMU_IDX_M 0x40 /* M profile */ +#define ARM_MMU_IDX_S 0x04 /* Secure */ +#define ARM_MMU_IDX_A 0x10 /* A profile */ +#define ARM_MMU_IDX_M 0x20 /* M profile */ +#define ARM_MMU_IDX_NOTLB 0x100 /* does not have a TLB */ -/* meanings of the bits for M profile mmu idx values */ -#define ARM_MMU_IDX_M_PRIV 0x1 +/* Meanings of the bits for A profile mmu idx values */ +#define ARM_MMU_IDX_A_PRIV 0x3 +#define ARM_MMU_IDX_A_EL10 0x40 +#define ARM_MMU_IDX_A_EL20 0x80 + +/* Meanings of the bits for M profile mmu idx values */ +#define ARM_MMU_IDX_M_PRIV 0x1 #define ARM_MMU_IDX_M_NEGPRI 0x2 -#define ARM_MMU_IDX_M_S 0x4 -#define ARM_MMU_IDX_TYPE_MASK (~0x7) +#define ARM_MMU_IDX_TYPE_MASK (ARM_MMU_IDX_A | ARM_MMU_IDX_M) #define ARM_MMU_IDX_COREIDX_MASK 0x7 typedef enum ARMMMUIdx { - ARMMMUIdx_EL10_0 = 0 | ARM_MMU_IDX_A, - ARMMMUIdx_EL10_1 = 1 | ARM_MMU_IDX_A, + ARMMMUIdx_EL10_0 = 0 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL10, + ARMMMUIdx_EL10_1 = 1 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL10, + ARMMMUIdx_EL20_0 = 0 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL20, + ARMMMUIdx_EL20_2 = 2 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL20, + ARMMMUIdx_E2 = 2 | ARM_MMU_IDX_A, - ARMMMUIdx_SE3 = 3 | ARM_MMU_IDX_A, - ARMMMUIdx_SE0 = 4 | ARM_MMU_IDX_A, - ARMMMUIdx_SE1 = 5 | ARM_MMU_IDX_A, - ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_A, + + /* + * While Stage2 is used by A profile, and uses a TLB, it is only + * used for page table walks and is not a valid as an arm_mmu_idx(). + * Overlap it on the non-existant non-secure el3 slot. + */ + ARMMMUIdx_Stage2 = 3, + + ARMMMUIdx_SE0 = 0 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_SE1 = 1 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_SE2 = 2 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_SE3 = 3 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_MUser = 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv = 1 | ARM_MMU_IDX_M, ARMMMUIdx_MUserNegPri = 2 | ARM_MMU_IDX_M, ARMMMUIdx_MPrivNegPri = 3 | ARM_MMU_IDX_M, - ARMMMUIdx_MSUser = 4 | ARM_MMU_IDX_M, - ARMMMUIdx_MSPriv = 5 | ARM_MMU_IDX_M, - ARMMMUIdx_MSUserNegPri = 6 | ARM_MMU_IDX_M, - ARMMMUIdx_MSPrivNegPri = 7 | ARM_MMU_IDX_M, - /* Indexes below here don't have TLBs and are used only for AT system - * instructions or for the first stage of an S12 page table walk. - */ - ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB, - ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_MSUser = 0 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + ARMMMUIdx_MSPriv = 1 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + ARMMMUIdx_MSUserNegPri = 2 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + ARMMMUIdx_MSPrivNegPri = 3 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + + /* Indicies that are only used only for AT system or Stage1 walk. */ + ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_A | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_A | ARM_MMU_IDX_NOTLB, } ARMMMUIdx; -/* Bit macros for the core-mmu-index values for each index, +/* + * Bit macros for the core-mmu-index values for each index, * for use when calling tlb_flush_by_mmuidx() and friends. */ +#define TO_CORE_BIT(NAME) \ + ARMMMUIdxBit_##NAME = 1 << (ARMMMUIdx_##NAME & ARM_MMU_IDX_COREIDX_MASK) + typedef enum ARMMMUIdxBit { - ARMMMUIdxBit_EL10_0 = 1 << 0, - ARMMMUIdxBit_EL10_1 = 1 << 1, - ARMMMUIdxBit_E2 = 1 << 2, - ARMMMUIdxBit_SE3 = 1 << 3, - ARMMMUIdxBit_SE0 = 1 << 4, - ARMMMUIdxBit_SE1 = 1 << 5, - ARMMMUIdxBit_Stage2 = 1 << 6, - ARMMMUIdxBit_MUser = 1 << 0, - ARMMMUIdxBit_MPriv = 1 << 1, - ARMMMUIdxBit_MUserNegPri = 1 << 2, - ARMMMUIdxBit_MPrivNegPri = 1 << 3, - ARMMMUIdxBit_MSUser = 1 << 4, - ARMMMUIdxBit_MSPriv = 1 << 5, - ARMMMUIdxBit_MSUserNegPri = 1 << 6, - ARMMMUIdxBit_MSPrivNegPri = 1 << 7, + TO_CORE_BIT(EL10_0), + TO_CORE_BIT(EL10_1), + TO_CORE_BIT(EL20_0), + TO_CORE_BIT(EL20_2), + TO_CORE_BIT(E2), + TO_CORE_BIT(Stage2), + TO_CORE_BIT(SE0), + TO_CORE_BIT(SE1), + TO_CORE_BIT(SE2), + TO_CORE_BIT(SE3), + + TO_CORE_BIT(MUser), + TO_CORE_BIT(MPriv), + TO_CORE_BIT(MUserNegPri), + TO_CORE_BIT(MPrivNegPri), + TO_CORE_BIT(MSUser), + TO_CORE_BIT(MSPriv), + TO_CORE_BIT(MSUserNegPri), + TO_CORE_BIT(MSPrivNegPri), } ARMMMUIdxBit; +#undef TO_CORE_BIT + #define MMU_USER_IDX 0 static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx) @@ -2900,44 +2937,6 @@ static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx) return mmu_idx & ARM_MMU_IDX_COREIDX_MASK; } -static inline ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx) -{ - if (arm_feature(env, ARM_FEATURE_M)) { - return mmu_idx | ARM_MMU_IDX_M; - } else { - return mmu_idx | ARM_MMU_IDX_A; - } -} - -/* Return the exception level we're running at if this is our mmu_idx */ -static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx & ARM_MMU_IDX_TYPE_MASK) { - case ARM_MMU_IDX_A: - return mmu_idx & 3; - case ARM_MMU_IDX_M: - return mmu_idx & ARM_MMU_IDX_M_PRIV; - default: - g_assert_not_reached(); - } -} - -/* - * Return the MMU index for a v7M CPU with all relevant information - * manually specified. - */ -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, - bool secstate, bool priv, bool negpri); - -/* Return the MMU index for a v7M CPU in the specified security and - * privilege state. - */ -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, - bool secstate, bool priv); - -/* Return the MMU index for a v7M CPU in the specified security state */ -ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); - /** * cpu_mmu_index: * @env: The cpu environment diff --git a/target/arm/internals.h b/target/arm/internals.h index 027878516f..dd0bc4377f 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -769,6 +769,26 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx); +int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); + +/* + * Return the MMU index for a v7M CPU with all relevant information + * manually specified. + */ +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, + bool secstate, bool priv, bool negpri); + +/* + * Return the MMU index for a v7M CPU in the specified security and + * privilege state. + */ +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, + bool secstate, bool priv); + +/* Return the MMU index for a v7M CPU in the specified security state */ +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); + /* Return true if the stage 1 translation regime is using LPAE format page * tables */ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); @@ -807,29 +827,7 @@ static inline void arm_call_el_change_hook(ARMCPU *cpu) /* Return true if this address translation regime is secure */ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) { - switch (mmu_idx) { - case ARMMMUIdx_EL10_0: - case ARMMMUIdx_EL10_1: - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_Stage1_E1: - case ARMMMUIdx_E2: - case ARMMMUIdx_Stage2: - case ARMMMUIdx_MPrivNegPri: - case ARMMMUIdx_MUserNegPri: - case ARMMMUIdx_MPriv: - case ARMMMUIdx_MUser: - return false; - case ARMMMUIdx_SE3: - case ARMMMUIdx_SE0: - case ARMMMUIdx_SE1: - case ARMMMUIdx_MSPrivNegPri: - case ARMMMUIdx_MSUserNegPri: - case ARMMMUIdx_MSPriv: - case ARMMMUIdx_MSUser: - return true; - default: - g_assert_not_reached(); - } + return (mmu_idx & ARM_MMU_IDX_S) != 0; } /* Return the FSR value for a debug exception (watchpoint, hardware diff --git a/target/arm/helper.c b/target/arm/helper.c index 69c913d824..9c2c81c434 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8687,9 +8687,11 @@ void arm_cpu_do_interrupt(CPUState *cs) #endif /* !CONFIG_USER_ONLY */ /* Return the exception level which controls this address translation regime */ -static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) +static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { + case ARMMMUIdx_EL20_0: + case ARMMMUIdx_EL20_2: case ARMMMUIdx_Stage2: case ARMMMUIdx_E2: return 2; @@ -8700,6 +8702,8 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_SE1: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_EL10_0: + case ARMMMUIdx_EL10_1: case ARMMMUIdx_MPrivNegPri: case ARMMMUIdx_MUserNegPri: case ARMMMUIdx_MPriv: @@ -11262,6 +11266,41 @@ int fp_exception_el(CPUARMState *env, int cur_el) return 0; } +ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx) +{ + if (arm_feature(env, ARM_FEATURE_M)) { + return mmu_idx | ARM_MMU_IDX_M; + } + + mmu_idx |= ARM_MMU_IDX_A; + switch (mmu_idx) { + case 0 | ARM_MMU_IDX_A: + return ARMMMUIdx_EL10_0; + case 1 | ARM_MMU_IDX_A: + return ARMMMUIdx_EL10_1; + case ARMMMUIdx_E2: + case ARMMMUIdx_SE0: + case ARMMMUIdx_SE1: + case ARMMMUIdx_SE3: + return mmu_idx; + default: + g_assert_not_reached(); + } +} + +/* Return the exception level we're running at if this is our mmu_idx */ +int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) +{ + switch (mmu_idx & ARM_MMU_IDX_TYPE_MASK) { + case ARM_MMU_IDX_A: + return mmu_idx & ARM_MMU_IDX_A_PRIV; + case ARM_MMU_IDX_M: + return mmu_idx & ARM_MMU_IDX_M_PRIV; + default: + g_assert_not_reached(); + } +} + #ifndef CONFIG_TCG ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) { @@ -11278,10 +11317,21 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) } el = arm_current_el(env); - if (el < 2 && arm_is_secure_below_el3(env)) { - return ARMMMUIdx_SE0 + el; - } else { - return ARMMMUIdx_EL10_0 + el; + switch (el) { + case 0: + /* TODO: ARMv8.1-VHE */ + case 1: + return (arm_is_secure_below_el3(env) + ? ARMMMUIdx_SE0 + el + : ARMMMUIdx_EL10_0 + el); + case 2: + /* TODO: ARMv8.1-VHE */ + /* TODO: ARMv8.4-SecEL2 */ + return ARMMMUIdx_E2; + case 3: + return ARMMMUIdx_SE3; + default: + g_assert_not_reached(); } } diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 84609f446e..f745c0d067 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -126,7 +126,7 @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, hwaddr physaddr; int prot; ARMMMUFaultInfo fi = {}; - bool secure = mmu_idx & ARM_MMU_IDX_M_S; + bool secure = mmu_idx & ARM_MMU_IDX_S; int exc; bool exc_secure; @@ -218,7 +218,7 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr, hwaddr physaddr; int prot; ARMMMUFaultInfo fi = {}; - bool secure = mmu_idx & ARM_MMU_IDX_M_S; + bool secure = mmu_idx & ARM_MMU_IDX_S; int exc; bool exc_secure; uint32_t value; @@ -2669,7 +2669,7 @@ ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, } if (secstate) { - mmu_idx |= ARM_MMU_IDX_M_S; + mmu_idx |= ARM_MMU_IDX_S; } return mmu_idx; diff --git a/target/arm/translate.c b/target/arm/translate.c index 4e79dbbdfc..f25d5f18c6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -172,7 +172,6 @@ static inline int get_a32_user_mem_index(DisasContext *s) case ARMMMUIdx_MSUserNegPri: case ARMMMUIdx_MSPrivNegPri: return arm_to_core_mmu_idx(ARMMMUIdx_MSUserNegPri); - case ARMMMUIdx_Stage2: default: g_assert_not_reached(); } From patchwork Sat Aug 3 18:47:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170500 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2347065ile; Sat, 3 Aug 2019 11:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqye8B137bt9XwgPS/4eFxlXv9icMulIuX3yqbBuU6omUXAeDpWzy58qWzuxsXzaAkCgtE4c X-Received: by 2002:a17:906:19c6:: with SMTP id h6mr22998813ejd.262.1564858733595; Sat, 03 Aug 2019 11:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858733; cv=none; d=google.com; s=arc-20160816; b=GV4MEbGtp9uadliuAYDJ4HP6CTph9GmyamL4s5TWEiy4LfqYAXrlR0ApydEbsX+nQt Vsfn/1tqn214fiYGHebQYCyYCnU90BGMX7u76bl13wzS1Rvr03M7jfz8z+hiK0+c/Mia 4vqO0xUSRRSewlqDaQ3cDXIhICE61RQrGPWgpaYqPqIA40omjTMZWp6p09Wx9PbzkVlF DEJs9w5iPekdtHP6zIWUw8s51dzWugNMfrc1+mQIQia+YfNNXldwUJJQKzhxf2NkVxXG ghIKsNxzgvqLlZ6xeYIgvTtMJjrs1TK4epLnrskFp3yjrg1ic91Hwgji2WlXasxddt1z eBtA== 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=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=a3u+v1D2Fqgw0oUei7zRyOtxznNePu5hN/xH21qFxBzkS3k/oB+0RYKosmha+D25qP pNY0okl33o0dgIaOJTNIcSTjuoB3gtE04oa0G+5hOW+fzjDm5lVTS4wGyrcrDUBHlUTv sGMNnYKUJWPEV4XwU7p9mg2/81LErsspdf8wlWokhEFAGfVss3PQ4ZIU93T3Q4MDKDNN YafXl4RH1EwVqau+qbzDkwigs1JFcEWMQ7RXBY7PWlcZw0E9vXdH2/lfQoHB5whyfRuY QmlKdDeMNkY5UwncdKcegY7fLFoTV9QVLRz0cHgBBz7DqV92BCDEfLj0J9+RoppR9fe7 Q4pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nyYDZlSW; 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 r21si22644984ejz.133.2019.08.03.11.58.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:58:53 -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=nyYDZlSW; 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 ([::1]:41556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzEx-0004RW-HL for patch@linaro.org; Sat, 03 Aug 2019 14:58:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32780) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4y-0006b2-0G for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4w-0007KS-H7 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:37893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4w-0007Jh-Az for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:30 -0400 Received: by mail-pf1-x430.google.com with SMTP id y15so37633372pfn.5 for ; Sat, 03 Aug 2019 11:48:30 -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=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=nyYDZlSWyWGgw+mPVtlmhwfzB+jmeYrS0DerBgWFeqgL+G4q5VWZOZ8SvW5yOrpQZt OHDluovFZg0lfnnBNbYnupFrR153G38gNkqA67gqexIqco+RYNjPDDClWR8fgOPjk5BQ qnpqCzjqxWSrxhSjZ5eOopQU/pnZtFYggk0+wyZSClNmfhdb17isKnb+g1TbzwJMVhtk Gl+rsPp3ix+4j/Aw5+T6ATffS5ACO04ZxhbIp5pfMjzVEN1p4GImzqxntaCIfY/+qj4T mffVDkVALM4tRvVLgN2k3kDSiu2BT7swflBjyPLmIt0k8m82/9y5KlfaqFVLSQOHQ1zm TfTg== 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=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=o0yJNPvJSSoIYfzAAeSjesfH89itSZYHqFOerrKD4Op5WLrIwjT3fSjdiRUk1ezPX3 XaUZ/nntgySvENdhrtRv8/ELC7Br819YWsGgQFAMRAXgx2muX6JxoUbm2QIs8Bxs8gn1 dzBFDwkvzUFHd336o6/dQQ5uraYgMrr7XFzKDe8gNt+9p9i9DE/pdv+aYZ0tRROmvWSx tVd0KDiKLxwiXHurFuv/tCIJ37RACbVMhPXKO0Bhfwzufh6Lq9DNgJkCZnWegAuk+os6 5nkRuOl5QNa5wBjYs2QroRPPkcS7M5xoyajyfipmj1DFXGXl1enSPrvnN6C9I3hwCNdd z/Ow== X-Gm-Message-State: APjAAAWJ4YZnOLcxhuHBGJTAssgmB2b9LzxoF2Rxfxiz/gEkDU5wzK5Q nWYR2pxC7Vbnt3+wLuK4YhhvBzabwKw= X-Received: by 2002:a63:f926:: with SMTP id h38mr40174630pgi.80.1564858108975; Sat, 03 Aug 2019 11:48:28 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:48 -0700 Message-Id: <20190803184800.8221-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::430 Subject: [Qemu-devel] [PATCH v3 22/34] target/arm: Add regime_has_2_ranges X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/internals.h | 16 ++++++++++++++++ target/arm/helper.c | 22 +++++----------------- target/arm/translate-a64.c | 3 +-- 3 files changed, 22 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index dd0bc4377f..1b64ceeda6 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -824,6 +824,22 @@ static inline void arm_call_el_change_hook(ARMCPU *cpu) } } +/* Return true if this address translation regime has two ranges. */ +static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_EL10_0: + case ARMMMUIdx_EL10_1: + case ARMMMUIdx_EL20_0: + case ARMMMUIdx_EL20_2: + return true; + default: + return false; + } +} + /* Return true if this address translation regime is secure */ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/helper.c b/target/arm/helper.c index 9c2c81c434..5472424179 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9006,15 +9006,8 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, } if (is_aa64) { - switch (regime_el(env, mmu_idx)) { - case 1: - if (!is_user) { - xn = pxn || (user_rw & PAGE_WRITE); - } - break; - case 2: - case 3: - break; + if (regime_has_2_ranges(mmu_idx) && !is_user) { + xn = pxn || (user_rw & PAGE_WRITE); } } else if (arm_feature(env, ARM_FEATURE_V7)) { switch (regime_el(env, mmu_idx)) { @@ -9548,7 +9541,6 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, ARMMMUIdx mmu_idx) { uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; - uint32_t el = regime_el(env, mmu_idx); bool tbi, tbid, epd, hpd, using16k, using64k; int select, tsz; @@ -9558,7 +9550,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, */ select = extract64(va, 55, 1); - if (el > 1) { + if (!regime_has_2_ranges(mmu_idx)) { tsz = extract32(tcr, 0, 6); using64k = extract32(tcr, 14, 1); using16k = extract32(tcr, 15, 1); @@ -9714,10 +9706,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, param = aa64_va_parameters(env, address, mmu_idx, access_type != MMU_INST_FETCH); level = 0; - /* If we are in 64-bit EL2 or EL3 then there is no TTBR1, so mark it - * invalid. - */ - ttbr1_valid = (el < 2); + ttbr1_valid = regime_has_2_ranges(mmu_idx); addrsize = 64 - 8 * param.tbi; inputsize = 64 - param.tsz; } else { @@ -11368,8 +11357,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); int tbii, tbid; - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - if (regime_el(env, stage1) < 2) { + if (regime_has_2_ranges(mmu_idx)) { ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); tbid = (p1.tbi << 1) | p0.tbi; tbii = tbid & ~((p1.tbid << 1) | p0.tbid); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index dbe2189e51..06ff3a7f2e 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -175,8 +175,7 @@ static void gen_top_byte_ignore(DisasContext *s, TCGv_i64 dst, if (tbi == 0) { /* Load unmodified address */ tcg_gen_mov_i64(dst, src); - } else if (s->current_el >= 2) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ + } else if (!regime_has_2_ranges(s->mmu_idx)) { /* Force tag byte to all zero */ tcg_gen_extract_i64(dst, src, 0, 56); } else { From patchwork Sat Aug 3 18:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170498 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2346727ile; Sat, 3 Aug 2019 11:58:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzr82DT/gtTyLxd8vJ37md5DzQnaSw7VSHaH/W93qr/5tuZJZmSTANzUKCLLM6aAFtpvaQy X-Received: by 2002:a50:91ae:: with SMTP id g43mr125922363eda.279.1564858697737; Sat, 03 Aug 2019 11:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858697; cv=none; d=google.com; s=arc-20160816; b=xr717AGTJ/3G4UytX4EKCSpSiYvPv2o4mlDeTRZy113fCnD9hneDeCxlhUHV1WvsUD jkxDd4q+Pj0r8uufyHahPsUZNpTCurjSEO7KHyuqP9po450K+Yh6AMQLSfSyNV32KcgC rwEZ8eUtvmZ0SAfIc36dRn316Sp2nFHbCzocSvdqdP2iDT4eRqkk5xKmrlc0iTBCKUhw aT/gIsjSwbdphccJ1rwfy5HTM4wB0+EsLagTEaNF+SjjOqd8UqCYyBD0qrLcHgwtXJ0j WxLZDV/849IMUTCzA/yzQ9AuOaYs+cB+W3/XYpqdCPcmxlxiWwtJgJsRgL2a9WvToGDa 4wkA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=990oq3Jk2iwM+tnufP71c3BjXCbJEu9Ritd8u64nkfc=; b=nFi3pHkRevFUAqEilIEjo42LoM0vbiGOwH51S5jahi6YjAmF/cWaOvfnVf71iJoU9P ihsaqeR3aBw+p1ktF/4KtNoi6wR9lkWENx8u2/3h3UxxgqxCNE9pgNFZyIyhKpZNDhpu XrmuqA8JYl35ZBCMo6Wz/pWc+3bySLhSZ4TAhbce5Uyg9Tltq5Ztl3UYEsD6ZRdyQgwu 759vzHrb2WS4HY4EhGiuiEeL7a8z2t1YZ8YcJObjEODsGITQIcWYBZQ72sErWnIz2RZ2 idLqIG0drmY9ClbuL+Jlt6AS4aNPUXbEETWSyETtdz2Op2gqfav7XNhIN470G/HJnnp1 BWWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QAYOiJWr; 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 h4si20586810ejj.127.2019.08.03.11.58.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:58:17 -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=QAYOiJWr; 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 ([::1]:41546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzEO-0003Ur-OW for patch@linaro.org; Sat, 03 Aug 2019 14:58:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32810) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4z-0006f5-0D for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4x-0007LB-QF for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:32 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:45953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4x-0007Kd-Ko for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:31 -0400 Received: by mail-pg1-x543.google.com with SMTP id o13so37653202pgp.12 for ; Sat, 03 Aug 2019 11:48:31 -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=990oq3Jk2iwM+tnufP71c3BjXCbJEu9Ritd8u64nkfc=; b=QAYOiJWrEQohdb0ezaHo0wG2XvNgh80GWi42I6kfRjO7WMPazyDP9i06wrRYddoSmU uyWtoHoeIPKeWz96c/rCKqO39n5zTWue5SNHTTkA1XC6iG+6ZOMSqHc+Jnt2jYSObR7g 4LCzxJW17ZhlCD8D5oiuCWB++EnKAFLT0MCCHTQ+3lXrIzhAwhnQWkynvvh7ui4Hmnde slOiqtQA0ZYhfC0IX1XsB3XRFp5NRnCg3KJ/ArwUzKqCT7DWx7qNFsZULQdA0t2qb0o3 EwS5cLkpEZI6NqR2ovZNEd7H5962ZgpoL+IfwuIZp3XjH5BIC+RWyRx9hNIhqiqG5jbB njkQ== 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:mime-version:content-transfer-encoding; bh=990oq3Jk2iwM+tnufP71c3BjXCbJEu9Ritd8u64nkfc=; b=VGySwlEc4wi9KEzw61M/+cQywbEx75V8t/0C0EITqPEwSJKu1loUXtsXh8W0k4UC4U Erb3wbtld31694AUu3NfhkPjWL1yiQ0PsOQJHMvgx9dDvSYvKf469kvIK+eAlU+5kwVJ XEln+4P+Mq7xKVWmVVik0eXT7FNhETAPTNApby+txaraJErmAvNzPiMQQIEqs2w9X0bz Ts7QtQ7FfON8INmoOY/j+lgiAkCDKb2lL8Hk30uFzHWC3L4Cfq8rQY00NmRVoaC1e4Wu 4AUPwoGCqTkZprpZDt8dHreYTmuy2OErHAeFtpUWKgVEdsmi9TDOV8hM7b4WfUkauR/D 51lA== X-Gm-Message-State: APjAAAVU9CqPYgJEGYA3gZYS6A6GzSC80EBKj6PlbpyL6oYuDOyUMUmV 6RCp3AOpgHL1okvGhyQAaXMV4yE+6Zs= X-Received: by 2002:a17:90a:9bc5:: with SMTP id b5mr10473944pjw.109.1564858110427; Sat, 03 Aug 2019 11:48:30 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:49 -0700 Message-Id: <20190803184800.8221-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v3 23/34] target/arm: Update arm_mmu_idx for VHE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Return the indexes for the EL2&0 regime when the appropriate bits are set within HCR_EL2. This happens for initial generation in arm_mmu_idx, and reconstruction in core_to_arm_mmu_idx. In order to make this reliable, we also need a bit in TBFLAGS. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- v5: Consistently check E2H & TGE & ELUsingAArch32(EL2). --- target/arm/cpu.h | 2 ++ target/arm/helper.c | 51 ++++++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b5300f9014..8d90a4fc4d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3153,6 +3153,8 @@ FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) /* Target EL if we take a floating-point-disabled exception */ FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) FIELD(TBFLAG_ANY, BE_DATA, 23, 1) +/* For A profile only, if EL2 is AA64 and HCR_EL2. == 11 */ +FIELD(TBFLAG_ANY, E2H_TGE, 22, 1) /* Bit usage when in AArch32 state: */ FIELD(TBFLAG_A32, THUMB, 0, 1) diff --git a/target/arm/helper.c b/target/arm/helper.c index 5472424179..a570d43232 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11257,21 +11257,31 @@ int fp_exception_el(CPUARMState *env, int cur_el) ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx) { + bool e2h; + if (arm_feature(env, ARM_FEATURE_M)) { return mmu_idx | ARM_MMU_IDX_M; } mmu_idx |= ARM_MMU_IDX_A; + if (mmu_idx & ARM_MMU_IDX_S) { + return mmu_idx; + } + + /* + * All remaining states are non-secure, so we can directly + * access hcr_el2 for these two bits. + */ + e2h = (env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE) + && arm_el_is_aa64(env, 2); + switch (mmu_idx) { case 0 | ARM_MMU_IDX_A: - return ARMMMUIdx_EL10_0; + return e2h ? ARMMMUIdx_EL20_0 : ARMMMUIdx_EL10_0; case 1 | ARM_MMU_IDX_A: return ARMMMUIdx_EL10_1; case ARMMMUIdx_E2: - case ARMMMUIdx_SE0: - case ARMMMUIdx_SE1: - case ARMMMUIdx_SE3: - return mmu_idx; + return e2h ? ARMMMUIdx_EL20_2 : ARMMMUIdx_E2; default: g_assert_not_reached(); } @@ -11300,25 +11310,27 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) ARMMMUIdx arm_mmu_idx(CPUARMState *env) { int el; + bool e2h; if (arm_feature(env, ARM_FEATURE_M)) { return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); } el = arm_current_el(env); + if (el == 3 || arm_is_secure_below_el3(env)) { + return ARMMMUIdx_SE0 + el; + } + + e2h = (env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE) + && arm_el_is_aa64(env, 2); + switch (el) { case 0: - /* TODO: ARMv8.1-VHE */ + return e2h ? ARMMMUIdx_EL20_0 : ARMMMUIdx_EL10_0; case 1: - return (arm_is_secure_below_el3(env) - ? ARMMMUIdx_SE0 + el - : ARMMMUIdx_EL10_0 + el); + return ARMMMUIdx_EL10_1; case 2: - /* TODO: ARMv8.1-VHE */ - /* TODO: ARMv8.4-SecEL2 */ - return ARMMMUIdx_E2; - case 3: - return ARMMMUIdx_SE3; + return e2h ? ARMMMUIdx_EL20_2 : ARMMMUIdx_E2; default: g_assert_not_reached(); } @@ -11428,6 +11440,17 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); + /* + * Include E2H in TBFLAGS so that core_to_arm_mmu_idx can + * reliably determine EL1&0 vs EL2&0 regimes. + */ + if (arm_el_is_aa64(env, 2)) { + uint64_t hcr = arm_hcr_el2_eff(env); + if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, E2H_TGE, 1); + } + } + /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep: * SS_ACTIVE PSTATE.SS State From patchwork Sat Aug 3 18:47:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170502 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2347694ile; Sat, 3 Aug 2019 11:59:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9lRxdqJMcpq7H8zQjWA8QGHmEgQ13vB/F0j6/ON7vSe+tRp5dSV51i012abiDQK0s489x X-Received: by 2002:a37:2e07:: with SMTP id u7mr93968782qkh.383.1564858794702; Sat, 03 Aug 2019 11:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858794; cv=none; d=google.com; s=arc-20160816; b=nWtSQ4n8w+fFVAsPyLpjbOHl1PFiEOCTG5THcHA+0rPkxx68w81y2w9iukN8Y/omtE pAJ9RyZMQf7PptzGk6mKZ2pbbmVnXcLIbOc+2hwkTQ+U1psuziZU4X/w8IRelU4Tx2/0 NfFoBH9C6ef007MOqCYAlpp3AJSFffgw0N8iMgZTZUsG93lxomrgUAX+moiENzFZSSdp dnHK71hSq+vI7oLdhqD1CZRr0UqMcUDFZmxplxzpSPf/lNQCr1lvRk4bdVoLTwXULNES ixuCsnyp44Rc1GoWw/zHSFoOh74OsHyzsusO0sPYtzi/AB/TuJBeeUhmX6k4WAta8p5F yyjA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nHfPCz5YwCEUlzjuGzWzTb7gnkajF/XBRvaJmIbxmI0=; b=TzYO9fQAgN/jOmdYGYxaBjZfDoNuSBa4GnmXJptEZEL5UWiAQO55qro4D4h5D/6AV5 O9ejm6fcYcQc/3XVazY8fI4TkyuaA9kujkEILP2eb4DSfWVMW9K2n+cZg7Ii6o4VSo2J mB3oFYx1BFQncZlLeFvLAX/0u/ong3gaS3OUZbknvJfvmJlzpthAGHn7ZGXkyC7XvXVt MrK7k2TisBJv98Uxb1BgMGF/dd12rC0cVRrkKhq6kuz7LaBCCBQLMBRbv6H++hVRIZ/w u3TYMAEDnIuY87dAJOgXwWmKawbqaIwTuDbPn+TTcO9B/dL79L+2C2sdirmlEmLRK4rm epCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hXxC9JbV; 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 n9si44513025qtf.386.2019.08.03.11.59.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:59:54 -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=hXxC9JbV; 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 ([::1]:41580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzFy-0006rm-9N for patch@linaro.org; Sat, 03 Aug 2019 14:59:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32841) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz50-0006hn-85 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4y-0007M5-Uo for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:34 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33666) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4y-0007La-OM for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:32 -0400 Received: by mail-pg1-x544.google.com with SMTP id n190so2542683pgn.0 for ; Sat, 03 Aug 2019 11:48:32 -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=nHfPCz5YwCEUlzjuGzWzTb7gnkajF/XBRvaJmIbxmI0=; b=hXxC9JbVWxcs5YnVTE4WAwREG86bgECaTH2NORht9mgPe6k9Dg2bTQSpTsz7SBlWuU QC+fxv5+FUgKq2V1gu/3cKNHYyfw/g8B7au/L2bg2YpkYwHH0Cv98WMv47VCA3swB2a1 nTLBl0vHndkP0WIYA1EK8tqZXz8oKt4SHpEMwgxLVZGJ0Wl7nsMKnWUoGQaXHBJVjJz2 eZvX91NtuWi3fa+Z83IlYexblAHHXEXauFI8A8ALj6zPdCcx6NvXUJXKitcGjf3NGEAf R6UnC+nKLtkwBr+DPP2UJ9+M7AgVayW+j8ct7QrGAryEIdARj+IJdKku/MSFucfVcw9M lyyA== 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:mime-version:content-transfer-encoding; bh=nHfPCz5YwCEUlzjuGzWzTb7gnkajF/XBRvaJmIbxmI0=; b=VHbrfTvdyQlq//98G1+hYaOdjV//XD7DHVfN3U6lbSlEceGHz32pB1ad5reQelX/1D gdw3l9RuFOezZTa0Dt8S4+FImveZ+pWiV6/ZLvGNO3QAO2wwckW4HtrvCwgBqwJHZZcG vBJ95dbCaW4NhR7jgoLnQwXrNZeLpDUjy1dpVQ3Fk41vPb5wap85ylaL4OjTZOytqcFW MuzWGYyZgy5VPYgL2grQ4Rw3ns+ZH+xzyA8Z9Q6hf7KZeGyH3NSEw1QkwYxXOxaBXo9b e32foA87GFxY7qjPGBqGYYySCy4vPkRZzyAVkNo4z9Qg+7Dn4lCIrMJoXTwFbTbMslV4 iZDg== X-Gm-Message-State: APjAAAUzNiEq48ANcM6mZ6zwTN1uQt3Uvmt9LuAT37FgQ5C6CQwyMepZ yjGTk1BtLbONPl2LlFR9FZmkfhJFk5E= X-Received: by 2002:a63:184b:: with SMTP id 11mr70008432pgy.112.1564858111468; Sat, 03 Aug 2019 11:48:31 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:50 -0700 Message-Id: <20190803184800.8221-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v3 24/34] target/arm: Update arm_sctlr for VHE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the correct sctlr for EL2&0 regime. Due to header ordering, and where arm_mmu_idx is declared, we need to move the function out of line. Use the function in many more places in order to select the correct control. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- v5: Use arm_mmu_idx() to avoid incorrectly replicating the el2&0 condition therein. Drop the change to cpu_get_dump_info, as that needs a more significant rethink of hard-coded oddness. --- target/arm/cpu.h | 11 +---------- target/arm/helper-a64.c | 2 +- target/arm/helper.c | 14 ++++++++++++-- target/arm/pauth_helper.c | 9 +-------- 4 files changed, 15 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8d90a4fc4d..d7c5a123a3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3096,16 +3096,7 @@ static inline bool arm_sctlr_b(CPUARMState *env) (env->cp15.sctlr_el[1] & SCTLR_B) != 0; } -static inline uint64_t arm_sctlr(CPUARMState *env, int el) -{ - if (el == 0) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - return env->cp15.sctlr_el[1]; - } else { - return env->cp15.sctlr_el[el]; - } -} - +uint64_t arm_sctlr(CPUARMState *env, int el); /* Return true if the processor is in big-endian mode. */ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 060699b901..3bf1b731e7 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -70,7 +70,7 @@ static void daif_check(CPUARMState *env, uint32_t op, uint32_t imm, uintptr_t ra) { /* DAIF update to PSTATE. This is OK from EL0 only if UMA is set. */ - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UMA)) { + if (arm_current_el(env) == 0 && !(arm_sctlr(env, 0) & SCTLR_UMA)) { raise_exception_ra(env, EXCP_UDEF, syn_aa64_sysregtrap(0, extract32(op, 0, 3), extract32(op, 3, 3), 4, diff --git a/target/arm/helper.c b/target/arm/helper.c index a570d43232..9e9d2ce99b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3867,7 +3867,7 @@ static void aa64_fpsr_write(CPUARMState *env, const ARMCPRegInfo *ri, static CPAccessResult aa64_daif_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) { - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UMA)) { + if (arm_current_el(env) == 0 && !(arm_sctlr(env, 0) & SCTLR_UMA)) { return CP_ACCESS_TRAP; } return CP_ACCESS_OK; @@ -3886,7 +3886,7 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, /* Cache invalidate/clean: NOP, but EL0 must UNDEF unless * SCTLR_EL1.UCI is set. */ - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UCI)) { + if (arm_current_el(env) == 0 && !(arm_sctlr(env, 0) & SCTLR_UCI)) { return CP_ACCESS_TRAP; } return CP_ACCESS_OK; @@ -8718,6 +8718,16 @@ static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) } } +uint64_t arm_sctlr(CPUARMState *env, int el) +{ + /* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */ + if (el == 0) { + ARMMMUIdx mmu_idx = arm_mmu_idx(env); + el = (mmu_idx == ARMMMUIdx_EL20_0 ? 2 : 1); + } + return env->cp15.sctlr_el[el]; +} + #ifndef CONFIG_USER_ONLY /* Return the SCTLR value which controls this address translation regime */ diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index d3194f2043..42c9141bb7 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -386,14 +386,7 @@ static void pauth_check_trap(CPUARMState *env, int el, uintptr_t ra) static bool pauth_key_enabled(CPUARMState *env, int el, uint32_t bit) { - uint32_t sctlr; - if (el == 0) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - sctlr = env->cp15.sctlr_el[1]; - } else { - sctlr = env->cp15.sctlr_el[el]; - } - return (sctlr & bit) != 0; + return (arm_sctlr(env, el) & bit) != 0; } uint64_t HELPER(pacia)(CPUARMState *env, uint64_t x, uint64_t y) From patchwork Sat Aug 3 18:47:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170505 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2349466ile; Sat, 3 Aug 2019 12:01:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu3STXvmUNar7nKpoZyjYJXLE0mQ+ZOOakjgJgV+4iyTQUnyPt4v/atMMRPxICEIcj2iQ4 X-Received: by 2002:ae9:eb4e:: with SMTP id b75mr93947411qkg.478.1564858907638; Sat, 03 Aug 2019 12:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858907; cv=none; d=google.com; s=arc-20160816; b=FHd857JR5Ue7ZKNPv0H8XlBm+q3w2V6FHPksablY3sjkFU5AnGeehgdca3mnhrHCSN 6WQOaPAjKF7p1wuz0ybkEj37T/OvinmeK0prxf34Oodne9kWN6SXEbnw3GckhnkpkIQO uAzvM5I6ySqJfAfQpgXOvDXPtRtuLZO/0CJJvO0qAmkDvX2c7VSTsK3neI53cRo4CyNi /S0xlOnOqP8WfPJPrmprhnQqz8HreK3ouraMrlfkzp0dUmJ+z0kY+ij6QrdN0U67QKy3 Fzz8muhNPGZkRc2XZrBcKWRySmp5b4/YkMCBpQKTx7yfiX+M8ZBtsIwnN/kV2Vt6Qjbt qQFQ== 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=XOwe1x9jkMeobEp2gGQ1QVWfLomppnXBcfQfzlWOS/E=; b=Jwv3xxoQI6do5uTDK8MP24aL/Z91adns9SUZEGmihvC8khhZvU+XKG/PLv/JcovIF8 Be68V9HjcOzrJkx+Yfpn1u3wYjIt1yeEazxZUjwjlY50Kvr5ClS4LLaRtcDFy75WU1Ba beKrVdQd8GBlOGfnLkH7hTqAUQjoFwHwQk0r5Ay29SxOFv56FViOXwKpJolusdD255Ub 8SOQoaKr+zHSwZjCoVaTaXXPgX7FibYgch9gKKE8keLUMB7edRbu7pJXHFRylitMAX9z AImLGKRseUx601ULeaLLfpmBYhU6WOy3ArlquhuBSgzAgPo7OJk37qPUgjYPkl/2BnR0 7lpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dMqUYYmR; 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 q68si7668562qkb.286.2019.08.03.12.01.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:01:47 -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=dMqUYYmR; 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 ([::1]:41620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzHn-0002cD-8Q for patch@linaro.org; Sat, 03 Aug 2019 15:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32862) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz51-0006ka-Bu for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz50-0007Mm-3x for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:35 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:43813) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4z-0007MK-V4 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:34 -0400 Received: by mail-pl1-x641.google.com with SMTP id 4so27885291pld.10 for ; Sat, 03 Aug 2019 11:48:33 -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=XOwe1x9jkMeobEp2gGQ1QVWfLomppnXBcfQfzlWOS/E=; b=dMqUYYmRfdayPFfbUWwMEx9J2DbZBKw2F4NAJoNPOwLBmqrOuFzJaZYBpEpuXKphx1 k73GH4LZNLW8ZcfyO87kGFQQTTfXTFLE/f6gvk1z2RiesiH1K0PjhQnXIzaW3SHb/cID /w/DfIbV/75N84T2THH4vOYiInYakfJu9A7ElnolFK36pD1HyeS43c3PgOew1zddvEWX HzAcn4s9+sTMspPIHAkYjlByi0Y0pfsgypM/POeJxGLNs40YlCnb1AVJsc+MKMs4UAxx Aveu6pq6lBGaSaBO+2y82E3xXr7kW26UT0Un0Qe3PPlUksqIRPxlEERvvNnIzzlHH8ww ERrA== 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=XOwe1x9jkMeobEp2gGQ1QVWfLomppnXBcfQfzlWOS/E=; b=saSaKNMlZ9AdMs67TabjHunn5zoJUfGTuSKsXgnPU7Z88YNR3Lqo5vsKOl8D9cVyaG c/zwbnG8KJ3ert7fTIicxolPgW0HhJFgCU+CiZ4/2DfprpqqWDs23qjamwpDhPVajTLc sOxFF/TTLsHyUjP32dYw0YYJng4Ahr5TdS2BMwtp4v4dJQ+oanG9IGKU8V6oB3v95veB T6elbTDRrZ8cJheLzRpgzRLITGf3CRXgKRKcjLrCZHdDHU+ACqh5I8i6jdntQrFb951L ELjTnRP3JTZAEHCF5ZnqxnqRF1zs+DUsKu9Y8HVCbVXws6ubcbDnkQFA6925a0MExkDs uuDg== X-Gm-Message-State: APjAAAWLAvLUJT3DbXvxVVqWLFoKrsoQRrZCowmDLXqUqBUlCcqS7HZv gdYW0k1U36YTUFp8xUpk3IWpP/+r82U= X-Received: by 2002:a17:902:b48f:: with SMTP id y15mr139996271plr.268.1564858112630; Sat, 03 Aug 2019 11:48:32 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:51 -0700 Message-Id: <20190803184800.8221-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::641 Subject: [Qemu-devel] [PATCH v3 25/34] target/arm: Update aa64_zva_access for EL2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The comment that we don't support EL2 is somewhat out of date. Update to include checks against HCR_EL2.TDZ. Signed-off-by: Richard Henderson --- target/arm/helper.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 9e9d2ce99b..37c881baab 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4113,11 +4113,27 @@ static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo *ri, static CPAccessResult aa64_zva_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) { - /* We don't implement EL2, so the only control on DC ZVA is the - * bit in the SCTLR which can prohibit access for EL0. - */ - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_DZE)) { - return CP_ACCESS_TRAP; + int cur_el = arm_current_el(env); + + if (cur_el < 2) { + uint64_t hcr = arm_hcr_el2_eff(env); + + if (cur_el == 0) { + if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + if (!(env->cp15.sctlr_el[2] & SCTLR_DZE)) { + return CP_ACCESS_TRAP_EL2; + } + } else { + if (!(env->cp15.sctlr_el[1] & SCTLR_DZE)) { + return CP_ACCESS_TRAP; + } + if (hcr & HCR_TDZ) { + return CP_ACCESS_TRAP_EL2; + } + } + } else if (hcr & HCR_TDZ) { + return CP_ACCESS_TRAP_EL2; + } } return CP_ACCESS_OK; } From patchwork Sat Aug 3 18:47:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170501 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2347455ile; Sat, 3 Aug 2019 11:59:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPq+U7N0KczGD+RxEBjOdEGmVmm9ysGeUa2bXPcWjuymcgmDEJMHcC8hGwzqv7RrDCsA90 X-Received: by 2002:a37:3c4:: with SMTP id 187mr88521776qkd.406.1564858772168; Sat, 03 Aug 2019 11:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858772; cv=none; d=google.com; s=arc-20160816; b=LSU0tT+zmCDSTrXIEud5LWYk4qSrggp7SccmWmFeaPHzBqHfDa1cvaNzu6vGE1EKUb zxWN3yffjZGnmyHoZW9EE9PCppOsiLKrTYUNQoFem2l21jNBD/LtgNKjkpoAEe2in9cT RTV88UiyARJz4qP1uC8xIZ/au0De/7XpqIXYOEm7ywLC5ns1iLTzP3vwIBJa0ScjsM0Q UTu+Bwc1SVc1N/5SYah7eMyD18mrSNu2ncYsaS81ZI5HJzajyCqJZiukloBWj7SG413Y PJ21DPsiFhHPyv288Z26N315o8FiZOW2wFa/vk9gFxHDJs0D+qFWG5zkyYx0nMTZBy4m +kRg== 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=+czGE1389+p9Ry0JcTeQCKYKOo7/YkTFZC4yltahS2c=; b=bjjLs7OCJYgiP/v099AlJiBgff1PrE+VF61clJqlwYEaVQ2zcrJX+fHwHtD+VjtGk3 2YgTNVWFnCo03+XPXae5r7UOc8byTGfANs7UUsoilKhtx9imTrC5SXyNz1qFFppspzc/ 1XJdPEF/uaPs5CzEqJO+wSxsFqYQXH5gK2fr3I+IKiPIE2EqdGu5bSYfcWkkhnzLluJL Nn2HGC2d3AGHsdoxmP6mRhe8NNhLs/Wuf5qtO3yCVlw+6YR31tWb1EfU0yNNfwor3t/X 5XgDr9dZPuqxwJYEnUwA80HFhFv2JZBCPXR9hOkofaYrzOE4xMws3gz2qVJjGmx1rSAW 7RgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xyjg5s19; 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 t3si48680676qtc.276.2019.08.03.11.59.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:59:32 -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=Xyjg5s19; 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 ([::1]:41574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzFb-0006d8-MK for patch@linaro.org; Sat, 03 Aug 2019 14:59:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32884) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz52-0006ng-De for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz51-0007NR-BK for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:36 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33665) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz51-0007My-2X for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:35 -0400 Received: by mail-pg1-x542.google.com with SMTP id n190so2542703pgn.0 for ; Sat, 03 Aug 2019 11:48:34 -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=+czGE1389+p9Ry0JcTeQCKYKOo7/YkTFZC4yltahS2c=; b=Xyjg5s19r/WRWUfR6xaWgAyr8CsYpH1Dr1oYlq23QP+aj6s+bmdUNjI9ShzPR/5bnD 8MtEvO474wOlswxFWfcG976klTMfYNrp2yo7J5Mj5ul/UI5FsIpB1iNE2+6AVR9CjG/q AayUcEl14Gm7TZL84nQm+/2sVXDCVtdUoLRPJoLyuxCe78jcvMfCya7ikbRPUnpg29y+ MGss9X0u+c9rabYdQZX7JAGTwIb3FNrEn2HiYEqMRIDE798KSq2aJMY/ykeQlm5vxoib Tm7V6QmSqeXMlMBhQFeo04Qrdfr9jYnyjyR1JSGmWLeD/g9KQGISk4DjevZtQOx1+gGz KUxQ== 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=+czGE1389+p9Ry0JcTeQCKYKOo7/YkTFZC4yltahS2c=; b=pHu5ks8KiF+G/ZU080eNpWvGQS1DvPgaVNHJ9Bpmqz4kp4oTUBhsxM+7KWRm0ZgqlV XISJbK3JrMQvkQ/4zTAHl38aSFZLi3dXLM0I/gq/1rkAgniHshZX5uTjlc6WEzg1g8w2 6PMvmm632dvu9va4+0NQQKprITkg/sri9+4skFF9VgE5EDUWLfM0khFVNJRkFPWZ0GR6 tecrNNzMcgvWOcSeNo4IrhTGsXtAbjtTVod/6Sr4rU0Er2jiTMIJFcRhF4EqyI2TaDOt xj0YggKKveTQ0p3ZPkdOhfnPIKfkmp9pNW7c9kNYalJWQb8Y/xeVY2OWDS/HAf2G+B1z mJtQ== X-Gm-Message-State: APjAAAVu8Rcn0nLwvM6FB5WyJF/aiwjHoQOp2YK1TRYaD1fems3fgds4 uexalbECHmqM6/atLK98WuJbh3puwrc= X-Received: by 2002:a63:784c:: with SMTP id t73mr133510686pgc.268.1564858113670; Sat, 03 Aug 2019 11:48:33 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:52 -0700 Message-Id: <20190803184800.8221-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::542 Subject: [Qemu-devel] [PATCH v3 26/34] target/arm: Update ctr_el0_access for EL2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Update to include checks against HCR_EL2.TID2. Signed-off-by: Richard Henderson --- target/arm/helper.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 37c881baab..b8c45eb484 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5361,11 +5361,27 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) { - /* Only accessible in EL0 if SCTLR.UCT is set (and only in AArch64, - * but the AArch32 CTR has its own reginfo struct) - */ - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UCT)) { - return CP_ACCESS_TRAP; + int cur_el = arm_current_el(env); + + if (cur_el < 2) { + uint64_t hcr = arm_hcr_el2_eff(env); + + if (cur_el == 0) { + if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + if (!(env->cp15.sctlr_el[2] & SCTLR_UCT)) { + return CP_ACCESS_TRAP_EL2; + } + } else { + if (!(env->cp15.sctlr_el[1] & SCTLR_UCT)) { + return CP_ACCESS_TRAP; + } + if (hcr & HCR_TID2) { + return CP_ACCESS_TRAP_EL2; + } + } + } else if (hcr & HCR_TID2) { + return CP_ACCESS_TRAP_EL2; + } } return CP_ACCESS_OK; } From patchwork Sat Aug 3 18:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170503 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2348445ile; Sat, 3 Aug 2019 12:00:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMET9ONtHAXvI1JN+qLextrTk7GvNpq4h3ok+VQMrX427OcbGBxIiy7INgq3dlV8W3qOdm X-Received: by 2002:ad4:4985:: with SMTP id t5mr45002467qvx.193.1564858840342; Sat, 03 Aug 2019 12:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858840; cv=none; d=google.com; s=arc-20160816; b=xXemTJaLqRfRw8owaiP7boCrVixoJxoeVh3NnTQ3zz2b8FHpB/lA95CT7jjuGnZsoR JJKI1CztAlJhkQEZCzL1U2CaLMJXl8L+DotJtZRkC3U5Moe/x4jLYUd1c8KIahpRM+5k vnUYowXCqYadIuyXezl9ZLzbEeLTihgWb6WUT9qs2JM+cGEBhJKcQHPtceexV0IUE5nI AH+EF6XYxVf6iAcVJsREhn+Z7sHuUblvNeOomrpGM/1gR0Djw+ccnqLc62FEz4v1gsGT nsZ+7QUKSNfkWNO+E5jFN2cyNU+ctkMrZf7FakYvuHrze8pdgCFD4Wt/iGcj5jwejJMv okNA== 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=MpItA1dQTcuKZiJtCdjWs8WMTH2c/gBkJl0/pbYk+Ag=; b=LkDv1zKZWKivr7K+E+wzQu3vM5g9PfQXhGDpfRcgIZXwgy7ZIT54gJZsJfQfq9UhUs AUal74hPgJtH5jmVUVZUyqaJWpBcLtbL+M/OD8Go8OQ+17JKVs01mbOq16CEh/m5QS/y VberHfVtjSsFPQDY9anzdx4zvBIom04zVAes+oHCgJW/GYgeSh/lmiRQaxneUM8ejLO0 GW/xVUnOemrywKui20G6XWPMbkY2zdyqm81zlp+KQoYjZ50Os1BUDXhMjd+902AP/7Xr TtTmIlvfy9AZ7uL98jaHHE+0adETQPovcFmc7f2glGtRshcPtrC4K68jfYkHwrfrm0Dt pjMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dyd6gD5w; 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 d26si49560488qvd.200.2019.08.03.12.00.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:00: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=fail header.i=@linaro.org header.s=google header.b=dyd6gD5w; 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 ([::1]:41586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzGh-00087N-QB for patch@linaro.org; Sat, 03 Aug 2019 15:00:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32898) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz53-0006p4-5e for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz52-0007Nx-2h for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:37 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:37970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz51-0007Nc-U0 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:36 -0400 Received: by mail-pl1-x644.google.com with SMTP id az7so34857836plb.5 for ; Sat, 03 Aug 2019 11:48:35 -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=MpItA1dQTcuKZiJtCdjWs8WMTH2c/gBkJl0/pbYk+Ag=; b=dyd6gD5w/4Z2lzudxNV49llWNQPEJUnKWUVoGSgnqRWeB254Fu61z1VLQlr3V41LAf PUcSyUdJt4beh8L3lxmOq/VU6wJutjNQ9Bm2BEiE+OKjKmv/ef84XRZmNDgk4IEmUbEh X1jSvQReMowgAPMPo40P7JTnmTGiW7nVwAU1FRYBAfV8jHXjWfRNZI6rNiRqGBzlm825 lfBfdP2/EIZlhzW8egdiiEFA8GDjYJIUQwt7pdjWMTU//wYGNPmxPqGhfCtUhtpwWScx +ifF/NZ80NPq3l2CwdHxEuuWSsCV5JhdPP/aBf25qxm66O/OUmdNyRN6y/7A5QW277e2 ozbQ== 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=MpItA1dQTcuKZiJtCdjWs8WMTH2c/gBkJl0/pbYk+Ag=; b=RZHOBlOZQtUq877ifM8BfVWfZg185HsvaQVhzKW96kvGHkoXVZ9fFW5DoO4zChaClk wBrJA5jpvKTuQ1xPA3xJSj+DcrC+66rRQM3JYHdFtsP6o5EARWkJ/6+X5JPYNh8awiHt flBl/taPBb8FIQP8SoxImxGPa8jA8ywy8y+sOX6HHWIx0hCWnEJWBuc3FVT3X44IJUqm VHhBPlocyujMv3+pDyeyxVfJ9axcVBUMBYMq0dZjEUSzVXJxCDlK6RNarIjf40z9ehM3 RhKJPBU6WNuAb0R98w6ctvE6ofHm5aEU8i0TdDuZFRQNsInVwIv3pVJhHkJH/Bwx5yix dy8g== X-Gm-Message-State: APjAAAUM1dpHo3oE7eew92EP0zey11OChAeEzonN9ERw9Nw/9GKKH3/a 7yKrUkYmymGRLhkXX4Cu/3thKRX/fdY= X-Received: by 2002:a17:902:112c:: with SMTP id d41mr126176670pla.33.1564858114794; Sat, 03 Aug 2019 11:48:34 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:53 -0700 Message-Id: <20190803184800.8221-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::644 Subject: [Qemu-devel] [PATCH v3 27/34] target/arm: Install asids for E2&0 translation regime X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When clearing HCR_E2H, this involves re-installing the EL1&0 asid. Signed-off-by: Richard Henderson --- target/arm/helper.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index b8c45eb484..9d74162bbd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3518,10 +3518,29 @@ static void vmsa_ttbr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, } } +static void update_el2_asid(CPUARMState *env) +{ + CPUState *cs = env_cpu(env); + uint64_t ttbr0, ttbr1, ttcr; + int asid, idxmask; + + ttbr0 = env->cp15.ttbr0_el[2]; + ttbr1 = env->cp15.ttbr1_el[2]; + ttcr = env->cp15.tcr_el[2].raw_tcr; + idxmask = ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; + asid = extract64(ttcr & TTBCR_A1 ? ttbr1 : ttbr0, 48, 16); + + tlb_set_asid_for_mmuidx(cs, asid, idxmask, 0); +} + static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + if (arm_hcr_el2_eff(env) & HCR_E2H) { + /* We are running with EL2&0 regime and the ASID is active. */ + update_el2_asid(env); + } } static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4670,6 +4689,7 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) ARMCPU *cpu = env_archcpu(env); /* Begin with bits defined in base ARMv8.0. */ uint64_t valid_mask = MAKE_64BIT_MASK(0, 34); + uint64_t old_value; if (arm_feature(env, ARM_FEATURE_EL3)) { valid_mask &= ~HCR_HCD; @@ -4696,15 +4716,25 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) /* Clear RES0 bits. */ value &= valid_mask; - /* These bits change the MMU setup: + old_value = env->cp15.hcr_el2; + env->cp15.hcr_el2 = value; + + /* + * These bits change the MMU setup: * HCR_VM enables stage 2 translation * HCR_PTW forbids certain page-table setups - * HCR_DC Disables stage1 and enables stage2 translation + * HCR_DC disables stage1 and enables stage2 translation + * HCR_E2H enables E2&0 translation regime. */ - if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) { + if ((old_value ^ value) & (HCR_VM | HCR_PTW | HCR_DC | HCR_E2H)) { tlb_flush(CPU(cpu)); + /* Also install the correct ASID for the regime. */ + if (value & HCR_E2H) { + update_el2_asid(env); + } else { + update_lpae_el1_asid(env, false); + } } - env->cp15.hcr_el2 = value; /* * Updates to VI and VF require us to update the status of From patchwork Sat Aug 3 18:47:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170493 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2345912ile; Sat, 3 Aug 2019 11:57:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqXb3ub1RPVHwARzOh1IS8GxWg8mrfc64V6S70vQIPr6eedMj5220wqP5NgtiGkbzEq91M X-Received: by 2002:a17:906:b283:: with SMTP id q3mr56131697ejz.153.1564858621899; Sat, 03 Aug 2019 11:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858621; cv=none; d=google.com; s=arc-20160816; b=eEYMR8AIzT1iFBF9JvnB8IXEjIy2xJvTvwdtFWPGtMGBA6iRqgHZlzEvbqmTTWPUjV Skc6CANcwFFoHbuWKo3aRvMpJsZVMpylv51xJHFC16eIQdWHTp5cWXw5a0A19g0Xbyc1 H0h8cw5V7+r24BXXZIowcdBbkWm/o9yxX52OZFmjXUDBPPcLRN8Dc7l4qgE34UKpXKK9 8yWsqHpauAAOGyaJdU4CfSMVSg4pxrnpp9iGPquZU7/Nl8D1xkGuZQrIbY2QDL/P/s18 4vUeVMEUgL5BrOcGNFse97cR3g7xzwZjoJnoZ/RotewqYBtVKuzQ05I2KUXK1t1iHbHv yQGA== 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=AKU1gGfJD0fHB3QeRt9QRaO7IOfL7ZvP1zaRZud/BsE=; b=IYPuIlkhXAXQcR+FnbPQNxeSQJjkNKuhQNiYNjAqdmmeniOEvY9OH63shPBNGG2ZKr 45HoT/9RTJs1I8IHORExMbwxcYsUDgrA/MPyjo0fjQ5MwCVH9AvIUeeAZcdONQiGxcGI LG4gKMyx0E+ZcXazfCabppjfCEOekJ17h+GmJsgmOW7NbXIAzYzJKto0W7N6cYAi0GnR 4jFYe8oohFzQ4ZnsqrhWe93XK8/P/n6zR7/EJp4Conb+kGiKvFpItFL22NPafU3SKQld d64wa1/xkhg5tZaTC6B8xhnmFI3EOjnTAOI8RCQ6/BlcPVkWuOoLE0gA4rusL3xPOSG/ I2gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RzRDhP10; 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 um7si24288199ejb.72.2019.08.03.11.57.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:57:01 -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=RzRDhP10; 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 ([::1]:41498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzDA-0006wb-Rh for patch@linaro.org; Sat, 03 Aug 2019 14:57:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32921) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz58-0006rl-Aq for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz53-0007Oe-KB for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:41 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:46549) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz53-0007OJ-DQ for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:37 -0400 Received: by mail-pg1-x542.google.com with SMTP id w3so463131pgt.13 for ; Sat, 03 Aug 2019 11:48:37 -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=AKU1gGfJD0fHB3QeRt9QRaO7IOfL7ZvP1zaRZud/BsE=; b=RzRDhP10pg0B8kssRnKpGMDyeZ0CTYSkr/iXpyetK+I8OqDcpyaHvTOEzBw9q1+vnS yRXRNdfbYkO7LoK95UnEZ+G6QuxWCyTwjDy/eBXf4WpoKjVDPqMUSIS5pHc7BzDaztVT 8f5XPqSlCC5FCy6ick5E2j062jJ91k70CN8IBZxr5CsWTIB29MKBccHdbLbERCCpFMur vS8dfJo8ddRCKHLQzpXt1t+/3sjVieV8Qz0Z01+0EuNNoAJL4eGO3RVvsKoIaltd1syB eBQh2rtbnAiKOx1WHALl/cLcW2DlglBKn8iLF0Bdx8cm3qv2uCP7WuYf68vS057Sy+1Z KX3Q== 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=AKU1gGfJD0fHB3QeRt9QRaO7IOfL7ZvP1zaRZud/BsE=; b=CWo3nh0Okf/xfFRttII0SALON4RbDIJ/wUSIW5f8C2pLd5Zp76lWjhroySFnEDoecE myk3hYVC+88/FOChNm5Idv1pczLNHOXKIC6xPjLjavahP62sYi1kGK8/l/tQ1E2AkR5q 3qvPrWpDcatRjlGvNGu9Wc34lpgloAuO/9jUNlJ3f3wjRtm0Qz5LDbX13nvELfyuUUOu uEvWwt4sxh2tZBBbzkTFybD+EhDSaJtC1mixPUMvfQNV9SU67bSsueXCyqje8tYKzrFr xEV2tA9jra2CHFjAoe1brXZTuD4pkLEcVh8DkyfVt5sPvgmI7XL8ZFdPgplf9DuQxOTj UOHg== X-Gm-Message-State: APjAAAXymRkdADGaHRp77HMvyMaXw5BbGAbC0EawFYoT0qe3rDFhTzq+ oNpd+2HQSJXelb3kGxlXjlpkLUyhCOM= X-Received: by 2002:a65:57ca:: with SMTP id q10mr133449832pgr.52.1564858116151; Sat, 03 Aug 2019 11:48:36 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:54 -0700 Message-Id: <20190803184800.8221-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::542 Subject: [Qemu-devel] [PATCH v3 28/34] target/arm: Flush tlbs for E2&0 translation regime X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 9d74162bbd..984a441cc4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3917,8 +3917,11 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, static int vae1_tlbmask(CPUARMState *env) { + /* Since we exclude secure first, we may read HCR_EL2 directly. */ if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; + } else if (env->cp15.hcr_el2 & HCR_E2H) { + return ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL10_0; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } @@ -3956,6 +3959,10 @@ static int vmalle1_tlbmask(CPUARMState *env) if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { + /* Since we exclude secure first, we may read HCR_EL2 directly. */ + if (env->cp15.hcr_el2 & HCR_E2H) { + return ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; + } return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_Stage2; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; @@ -3971,13 +3978,22 @@ static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, tlb_flush_by_mmuidx(cs, mask); } +static int vae2_tlbmask(CPUARMState *env) +{ + if (arm_hcr_el2_eff(env) & HCR_E2H) { + return ARMMMUIdxBit_EL20_0 | ARMMMUIdxBit_EL20_2; + } else { + return ARMMMUIdxBit_E2; + } +} + static void tlbi_aa64_alle2_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int mask = vae2_tlbmask(env); - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx(cs, mask); } static void tlbi_aa64_alle3_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4002,8 +4018,9 @@ static void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { CPUState *cs = env_cpu(env); + int mask = vae2_tlbmask(env); - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, mask); } static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4021,11 +4038,11 @@ static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, * Currently handles both VAE2 and VALE2, since we don't support * flush-last-level-only. */ - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int mask = vae2_tlbmask(env); uint64_t pageaddr = sextract64(value << 12, 0, 56); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, mask); } static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri, From patchwork Sat Aug 3 18:47:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170504 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2348990ile; Sat, 3 Aug 2019 12:01:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqI48YhYnd6j+XJ0hMn7CNZOWS9O9IpQRM2/iTKn/5xPW/gW9XUN+0g83Xy/XAFaICh5sG X-Received: by 2002:a37:be85:: with SMTP id o127mr96805176qkf.194.1564858873962; Sat, 03 Aug 2019 12:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858873; cv=none; d=google.com; s=arc-20160816; b=oWSjdjBq2bG0H3QTzKzs/F7/KG9uZ2/DMTVYcTGGufHos38prJ4UDnzUvPOXWc2174 6z1JWaqwuaGKea4qSzyckOJGNj1h2ovH8qUVsZ6aM0JpZqKHYCT6fMhSYmiBnlkbfe52 j3qrv8VVh/uSb0+49Oy/E3KbTxCR74O4jBPcTw1KBQUBHdbVjhg2jJA44Kd2uZmxyza8 9ZRI0W1V5ePPJRvHNXIJptOdQaiUe2orH2tbcjWdbuSd8hv6NaYRx+iBxkcYXUf5eZwJ 0sw1hY5A4vqimViaFho8Z0fsdrYby9Td/+YVaNfD+CnXCd7AUYJ0XZXRVXnfNrs8/DN9 JELQ== 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=4Ze85vH/aQjxlcuWsjYuHifd5A5xyc14ioC1rkP0Yto=; b=u2Wtq6Qh50luH7LAGj+CjE6iMS40hKWyVx6nDSWBCK/I/rXsYfeIm1CNLWrSYH9ULQ CeOc5Y9UPg+t/o4r/zMvHdpl856PaEOsBlYG5nmENzmfmtuFpvycCM1FVtn6X7cISRs5 /7r+dTKcJYb9Xoku8tgiPAl7LmxvucHfCdlvghfv2osTI5mnvClvGy2hc8UP1dkR+1mP taBr1HtbM01iygLqfs8yAaaLRB4ZqlfBHQtfnJca2T57BUctDkuznodNTpok2ekuKEQ/ HTX7ibUKMXquE38eox8TF1JR044AcvPik6EednPmU+ImjCYQjQwcOulal0qazuuej6eq SPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="B/K5WUnn"; 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 o11si18058766qvf.31.2019.08.03.12.01.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:01:13 -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="B/K5WUnn"; 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 ([::1]:41602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzHF-0000fT-Jf for patch@linaro.org; Sat, 03 Aug 2019 15:01:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33003) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5D-0006vn-Hg for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5B-0007SF-KW for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:47 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:39906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz59-0007Oy-L3 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:44 -0400 Received: by mail-pl1-x643.google.com with SMTP id b7so34933483pls.6 for ; Sat, 03 Aug 2019 11:48:38 -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=4Ze85vH/aQjxlcuWsjYuHifd5A5xyc14ioC1rkP0Yto=; b=B/K5WUnnGiy111NPTwOaiQW0NtyN9hpfo4MH+vcSVcsOM/2oss8u0hV3oRVIh0AYHT Q9X/yodCD/1/kDno63G/LcVovJJW9iHlyBX9ihwk5aeRS+mLvzxOt6LWUnYKffOMdALc 8kQ9ZcY0bj3js5usQnd1daxvaGay8B7k6IRXr0W24a8TIsrx9bnj3IwL5yBIa2aCyuKT J1HSY9fImd3SmYU/7JQN3uWubz7I6BH++g0KihvBQT7bQEx2AAeNwOLZzSRTVLUjF3w0 L+JnCj9eer4GkI2V/tXWBV8W+bIl6bil4kr89MYOhpuVVxpEKi+uHWL4KIYumKvxoUev 468Q== 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=4Ze85vH/aQjxlcuWsjYuHifd5A5xyc14ioC1rkP0Yto=; b=g6Zf4BnZZTBWgxvrFkT1L7+5p2agrZpz+PBFnzYsN7fx/nlSbhmLjxrvv5zod47NsD GeWABKE/IAGPXgGi6KaATv3VJnnwzxFsq6fegrUc5LPqc+tC6banbWtAhXSQWZNYVXmk kwd8/f3G0FuvIRRx4S7q2WHJZqDNqT8h6zWfQm9/OxbDU0vKCMw6tk4Bs9rrOtwpqtD3 rEcsgRdd9lZX5o1gPs8HJsXyEf1GpkN58NR5+ZWxX4uoFJDBUFD44lLEb2O0h/MHCn+1 hVDVHffC4chKvxDpNn2f4QXCdajaK/NiucYl/exPk2dRe6t/Z/PLAp3evVURBiKf4PbM FwvA== X-Gm-Message-State: APjAAAUziHgcxg8h0nmbDwy+bS5pXoHeZBauvWiFksE0dipChpa0iUoE 18SuS8LpiJgtVVP5E8ZKtD3ioUJZIS8= X-Received: by 2002:a17:902:9041:: with SMTP id w1mr23791104plz.132.1564858117384; Sat, 03 Aug 2019 11:48:37 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:55 -0700 Message-Id: <20190803184800.8221-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::643 Subject: [Qemu-devel] [PATCH v3 29/34] target/arm: Update arm_phys_excp_target_el for TGE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The TGE bit routes all asynchronous exceptions to EL2. Signed-off-by: Richard Henderson --- target/arm/helper.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 984a441cc4..a0969b78bf 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7968,6 +7968,12 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, break; }; + /* + * For these purposes, TGE and AMO/IMO/FMO both force the + * interrupt to EL2. Fold TGE into the bit extracted above. + */ + hcr |= (hcr_el2 & HCR_TGE) != 0; + /* Perform a table-lookup for the target EL given the current state */ target_el = target_el_table[is64][scr][rw][hcr][secure][cur_el]; From patchwork Sat Aug 3 18:47:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170495 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2346412ile; Sat, 3 Aug 2019 11:57:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmTtfWtvaLHId88au3FGJh2MxF/4dl9d1S/KZN54Diw+W5tqSAuk9dPceDbews+nNFbflJ X-Received: by 2002:aa7:ca45:: with SMTP id j5mr124680429edt.217.1564858668176; Sat, 03 Aug 2019 11:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858668; cv=none; d=google.com; s=arc-20160816; b=vSrIRZnaLaJHN1W6QfCIeFRXDF/P91wXW8YzthDwPnJsOh539cM5B6DaeahGSo9mfE kGXFk6RvVkMI7F2X3brQXTfgzTUahPVGs3yVQygQoLBd8fYjdzaScIITPPmwiCIopqDL Oj+xyCXs369K0yoZv0z92zMS0AqSZDVCWr0iGLtC6m27x/bkHEdutGSjI/xyqOitHjRx gkgnkb/4koW8OLcVa/NiwcJL5VC5born+pYQRUKhy9p9p9RqeXrXsn7viUDYCrJOmZfp K3YI8UoY8EToju96IOpfAiC9cpqgBN+z5kG4C5bscUI/SWrbZ/9kQywH3PF993cnw/8P S2hQ== 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=x75zfy++4h7G7+9uJPGHwt0vV9wve8SgXFTPLCjlkks=; b=lHCg86QDErxf1mOUuX9/yi8pUEcd6VVp2NkeMyHnDOvPqvQwkjMtfnmwZoR3pnD4s+ rN1vLgsvaOsNCPxp0KGJHiAUBqlCKFNT6ethBu3FyetPcHoMiX706OU/XNtRsPG8D4Ka YWpGQzkDg40RSFDaqdmGtt5i8h7J5iICtwiTZdjZKQX4rbsFFfpIf2LJLkmwNa90HGBA iHrHLUKGWEMqEdlELNtXeT1mDHqgeJ1uZDb4/2nE6G7VqkPerI5/GX3meOkqc/mx86u6 xp1UPT1QvGlkOzieEb+kP1NUW+zgUXJ/39zIwALyCiFWD4GfV5L0X9q6dGJQUkOmGGRF 7BYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vSbLBug1; 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 a14si23444886ejr.135.2019.08.03.11.57.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:57:48 -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=vSbLBug1; 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 ([::1]:41532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzDv-0001xZ-5u for patch@linaro.org; Sat, 03 Aug 2019 14:57:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32999) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5D-0006vd-HJ for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5B-0007Rd-F7 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:46 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:45759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz59-0007PK-J8 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:43 -0400 Received: by mail-pg1-x52d.google.com with SMTP id o13so37653279pgp.12 for ; Sat, 03 Aug 2019 11:48:39 -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=x75zfy++4h7G7+9uJPGHwt0vV9wve8SgXFTPLCjlkks=; b=vSbLBug1LuIdmY3e05odA6DONIHNQKBNmeojBFBcQFRAAln5HmcZSfiO3bZML0gPB5 o8uOagH6fGlOmk8pB3PnoKl7zwdN7KJ1daKWWnv7qLvZ2hpKzvFkKkhywpFiGYe4Pgc4 H+7HCtNZ41yARIYpZ3zOhQ040U7hPn1sQ7zwAplnf+MjdUdL6jt5VYhNGQuY9GE4yg+0 3EQg3ZZYJOKjWUJrtrzD2X3w9kldGktifhfDyKwll+jqOD8QSgGsBIkTATiSDCtG9URd S4Hg6G47XIilxW10LxvEJvPMtcjlVL8kqZebme30vgQxacppg4ev4lKoDVYHeGPAXsSt hrAA== 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=x75zfy++4h7G7+9uJPGHwt0vV9wve8SgXFTPLCjlkks=; b=TCnPg9Zx1tmu1qb11hIXkDCGjDc2PEjE2VrJf6cxhijJ3X3hZIBUEkiKZQrdWeSftI eP1vW8x7mEsn+iSQzbH9A3OG+p/X8Lna+4u6U0wGgw0eUR8yfYAzzeiGbVsZL2DbDfsn x7oXizLsyAU1AdBYsvxQSbZ376GBJHLAaUwcpaa5/ILiqRLYVTH7t86IR/GAg+mjIBGV x/YwxuG2vGrkoG7Wsr6DJygVEPL9q/2eGgPkKwoCycDdmmjcdQBGc6BO3uJ5/tcWCuoI OyKqTWh0S68emQosiAKvX+oGiiZE8OQvOWtmubIk2p2/TPpH7qebWuZc0kq0JhxqenRb Xoxg== X-Gm-Message-State: APjAAAXvivdFjVSaaubgfrmRSGSEuS9o5JlAdndu94mfcTYa18kmAqS/ 2P1MgONNOYAaOcIPHJGnGz9mPqQ+xRc= X-Received: by 2002:a17:90a:24ac:: with SMTP id i41mr10331984pje.124.1564858118408; Sat, 03 Aug 2019 11:48:38 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:56 -0700 Message-Id: <20190803184800.8221-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::52d Subject: [Qemu-devel] [PATCH v3 30/34] target/arm: Update regime_is_user for EL2&0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index a0969b78bf..d481716b97 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8936,6 +8936,7 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_SE0: + case ARMMMUIdx_EL20_0: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_MUser: case ARMMMUIdx_MSUser: From patchwork Sat Aug 3 18:47: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: 170499 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2347029ile; Sat, 3 Aug 2019 11:58:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdu9kHSMjKPThyFSI42UKgWhCoIT0zzXCCh/7W+wmIWggUn9Aiquuk+uvZvne64mZ/poLb X-Received: by 2002:a17:906:d8ab:: with SMTP id qc11mr48827813ejb.219.1564858730578; Sat, 03 Aug 2019 11:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858730; cv=none; d=google.com; s=arc-20160816; b=iUEFYAOmmrN6hCDpk/m8kaQP7Mgx58y4AZqa/R1llrMwLp2mxvqg4fBop/cnaHOWQt N3Jn4fQVVvBZOdq9VVJbJEAsRYvcSFS3bg1nGb6mBVsQ0hbJ+LmQT14LdsayKYrssF+4 b7hqZIFolgLZGMWd1X4NRVz0xLn5Bcp4HEzUwPO/YBJ7t04tRfM47BdGH/wY1LqPgPGo Yf9xWyUPI7RFeA+BCyY8ZzllXeEXQktyEZRjlESpYCf2fpD/XxM7AV48IaMBQiLwE8oI HlFSbwjS27sgBecWwpa+32hM2s54BQoEAS4xQHC0TTHYLF1Z9pV8jZJ0CeRU9Cv/lUS9 /vug== 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=fQb2baX8+br9XDTjkUGb5FILfpDmjfnieLRvexjfCRg=; b=fWHjzOOrfA7kx6RhkVYBFuhMh1xsP6q2fco1QW98ua4S01IqK1UdWQ2EffAaey4Ncj t3dlvizOm0Cpmf++AWBb4hAf4fT9ckZ8ZEw6vghHu5DzA266nIenAUrf0TNc0iXWUHWc rej30VuRaC4jlfhKSxNq4Sv/uXXymOft6pDefZxqgQ3Edufe52IeIQ0wzUujhbLvUz3O 4hyaFi8GWeMeWw9ocA9Ev3X2PJXu4vNqVg9TrCrO/4+Klb1EW0NNzX5kDi4dwP6TegmQ SH8smpgQ80cAvsCNlzyjfh6CA0yx95S2vzjc4diOoL+Elg1nergCG7RW3LXlQSxUrv6C 2kqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZHFbLtM2; 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 h13si24007376ejx.231.2019.08.03.11.58.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:58:50 -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=ZHFbLtM2; 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 ([::1]:41564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzEv-0005H1-K3 for patch@linaro.org; Sat, 03 Aug 2019 14:58:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33000) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5D-0006vh-H6 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5B-0007Ri-F9 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:47 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:43344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz59-0007Pd-IZ for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:43 -0400 Received: by mail-pf1-x443.google.com with SMTP id i189so37625822pfg.10 for ; Sat, 03 Aug 2019 11:48:40 -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=fQb2baX8+br9XDTjkUGb5FILfpDmjfnieLRvexjfCRg=; b=ZHFbLtM2E06kgJw7hT0Egbeg9owC+1p6dPnG4drYYDaV1gn4UGEFq6dm4GnDGTxgJ6 yPYbHxLvHHTQ3bYaIFZwUNkS/1xDppWkvjVkOmRUqHXoI+Tf4z1UGdu1DjksEdf8uGXl +SuFpIsNLFprQtP1if5EjQGhtH8IcVn+wwwCn7GLUllKJRV88oqO8J/DCg0D5HJfDnT6 +o5weLX8BQujymbxv3/CzWAb7CFIMmM4VCf+WhyDSWqlwF8rYhiXKUZaPemUAn9/qU3C TBMaSgrAct7EUoGw408h+YJRJYNrc2S3hF6DF8YeT/KQP1YpAbN8O6n1vfsTauCdmhs1 Q2vA== 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=fQb2baX8+br9XDTjkUGb5FILfpDmjfnieLRvexjfCRg=; b=Ji/0e/9NCqsV79Pua8kJGIHSkQ3sEpueoao3DPf+DFIqbr8jwCs2MEiFgQPLP7mWbw qzgAVLWsul8rY/VZnw9MZftoPRYo8SNp08cKFuyZVCTWCqMuB6DZHhDhmWXkLpgT2UY6 EmkmTHY0RoYGA+4HirYhLfNHqsVY1Iw69MUDGX50pJv8gFnT9v5KkdwDYHh6alP4NAFR feaF31fYpYgpgwcfet0zkh4K+/hBPP0xp0tZRv7zn6lDVotlos1L3/GhpeukZ2EFR80j yMCw9/lzAdV9+WWhjz94rSv4fmFil9QmVXOm51O+p/PcuKt4raFr775tnHUvG1r5j+n+ b0hw== X-Gm-Message-State: APjAAAWvN7Qc1ZlDV6mQnvhELEaLs+1lGofN07789rODXcKc58u6upze eMHfl3E7sPqnYT2iDiqkKB5dRsKaKhA= X-Received: by 2002:aa7:8b10:: with SMTP id f16mr66690094pfd.44.1564858119468; Sat, 03 Aug 2019 11:48:39 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:57 -0700 Message-Id: <20190803184800.8221-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::443 Subject: [Qemu-devel] [PATCH v3 31/34] target/arm: Update {fp, sve}_exception_el for VHE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When TGE+E2H are both set, CPACR_EL1 is ignored. Signed-off-by: Richard Henderson --- target/arm/helper.c | 53 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index d481716b97..2939454c8a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5539,7 +5539,9 @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { int sve_exception_el(CPUARMState *env, int el) { #ifndef CONFIG_USER_ONLY - if (el <= 1) { + uint64_t hcr_el2 = arm_hcr_el2_eff(env); + + if (el <= 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { bool disabled = false; /* The CPACR.ZEN controls traps to EL1: @@ -5554,8 +5556,7 @@ int sve_exception_el(CPUARMState *env, int el) } if (disabled) { /* route_to_el2 */ - return (arm_feature(env, ARM_FEATURE_EL2) - && (arm_hcr_el2_eff(env) & HCR_TGE) ? 2 : 1); + return hcr_el2 & HCR_TGE ? 2 : 1; } /* Check CPACR.FPEN. */ @@ -11263,8 +11264,6 @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes) int fp_exception_el(CPUARMState *env, int cur_el) { #ifndef CONFIG_USER_ONLY - int fpen; - /* CPACR and the CPTR registers don't exist before v6, so FP is * always accessible */ @@ -11292,30 +11291,34 @@ int fp_exception_el(CPUARMState *env, int cur_el) * 0, 2 : trap EL0 and EL1/PL1 accesses * 1 : trap only EL0 accesses * 3 : trap no accesses + * This register is ignored if E2H+TGE are both set. */ - fpen = extract32(env->cp15.cpacr_el1, 20, 2); - switch (fpen) { - case 0: - case 2: - if (cur_el == 0 || cur_el == 1) { - /* Trap to PL1, which might be EL1 or EL3 */ - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { + if ((arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { + int fpen = extract32(env->cp15.cpacr_el1, 20, 2); + + switch (fpen) { + case 0: + case 2: + if (cur_el == 0 || cur_el == 1) { + /* Trap to PL1, which might be EL1 or EL3 */ + if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { + return 3; + } + return 1; + } + if (cur_el == 3 && !is_a64(env)) { + /* Secure PL1 running at EL3 */ return 3; } - return 1; + break; + case 1: + if (cur_el == 0) { + return 1; + } + break; + case 3: + break; } - if (cur_el == 3 && !is_a64(env)) { - /* Secure PL1 running at EL3 */ - return 3; - } - break; - case 1: - if (cur_el == 0) { - return 1; - } - break; - case 3: - break; } /* From patchwork Sat Aug 3 18:47:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170506 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2350468ile; Sat, 3 Aug 2019 12:02:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBdT5lWZaKykA/7ubW9zwbCT0EOYHUCgPnp1kxmW7HIkp3fdekAJNzgXGob4KdUCqT/SMf X-Received: by 2002:a17:907:110b:: with SMTP id qu11mr112307405ejb.18.1564858973589; Sat, 03 Aug 2019 12:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858973; cv=none; d=google.com; s=arc-20160816; b=hRB7dPzODLQUCms0vHdAjphvtKFGk4Msd7XhVcmx46LtVKl/a5iWu0STFk2aq6WkNY hxCrsZFxu+1DFPVxZSw7JPLS8eqIrVgnpVmbl7z1ylL1LaBNWiuJ/U2Jxi18YrycDlI/ 5bLsUY3kn2kJfJhYwv9ob8oLKAYa043W7f8TsAE+thc1YwuJqvRGurHlH/fFAzEz3TKS GzS8V4XSSaqknamcn0gtlr5vvrheLO0iII6+/mdJ+w0k1w1uT28JdMlEr/vdfOKchsR6 +FJOVr8FmzvwgccmvKwM4NwTUSnViHqVheBkXqazU8Kxy/CtUv+WAFVM0RG6+PdosSx5 4tDw== 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=JBDZxP60+vIjwwzQbC3L2o1kpMj6601b/tqCyxFOHVI=; b=zXoB0XQ8vAc42n9PZDVnmg6qFLV9anl0ogEGnDHciAI0yNPwaB9SubJmYoRpJmeT3C XYLvwoRwEI9KepyrnbqAGfOou07/18YOcLZYmbGcdi2YEd5t4EUfUvR5TdIHc7C1jra2 9BZpZChO/y7dInKawc/7CpSvZj9tydig6Nfdu1gzGCEljcvpZyZvETFo13sMjrom38c3 /zrvujwyk/9es4H73kvZR2OA6pY+Pz1J0fp9UgN94uMtviQgBRQmdzpP6mJcTmHbz7fX o+HwYN4Tdy1vK4y7NHRZLYPHeFISMOEuVIqwrVlzhi09Z1S1CHTYIgWq4fpyMHm5b/dP A+qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QWKl0+P7; 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 y5si24288736ejq.146.2019.08.03.12.02.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:02:53 -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=QWKl0+P7; 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 ([::1]:41660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzIq-00052f-Km for patch@linaro.org; Sat, 03 Aug 2019 15:02:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33011) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5D-0006vt-Hs for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5B-0007SL-Ju for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:47 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:34530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz59-0007Pz-KF for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:44 -0400 Received: by mail-pg1-x542.google.com with SMTP id n9so31447493pgc.1 for ; Sat, 03 Aug 2019 11:48:41 -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=JBDZxP60+vIjwwzQbC3L2o1kpMj6601b/tqCyxFOHVI=; b=QWKl0+P7ZCOzrJrGAAa335JojcAeKlcVoNs1cAydwjDyaxukqGtQnw6FMo6klTTsSr V8JrdKdrddDhr1/jqvOmEUZOrm/NCNmkWtc8YEsvczoU0dOKyATP6Pzc1B01JyNL34dN J3mwHRjHZGob/MtP/AJsmyZpX9MFb2OXxjLYg7rPRwIJkEK2p9CpM/ojJYbxjJNjJvej YEwlX7vtKw5QXwXU+l7G6J7yC5ppYyeCTRz+COZRCf9UjW6lf2K0c3AeYlyNvlA6a16X /lHkMqyLXBtduo9etkcuJU4JK7ICQiik7TISJxmCSAZlFZDX6l65LIBrGBUCRbwafi81 337g== 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=JBDZxP60+vIjwwzQbC3L2o1kpMj6601b/tqCyxFOHVI=; b=EzJd4sweE6Zktx8FacOAjlZ1Gcz8/V8RLkVpXlulbnr9iCgD8mdRL7zg9swsPmhGr7 DT7J8TeqzwobmTBZ3YcrXJLNquWmXHn1UO7Mt3LDgl4wnjxQbOi1Hyut+GF0UH+13FrS 1ZhIjPNnHiVytDZzS2prs8vxwWZQwj0UecuKq3ow1JmU+W663idPJIKe4qQGdT7Ywxd0 SBlSdhsBv/Sr493MRHzRlubceHKJn2IU5hChf/HYRXh5+uhtTcr3FSFU4l4m318L8Y0x 3iihL9QjPvQG0lBT+mQ6R9zbZ0u/rAuYaI8WZpAh8pDsBEtpk9cDE4da2yZFoqxsSbnL 18WQ== X-Gm-Message-State: APjAAAWdZAx6qW26EtoMen4K5y1YnNFGR50OeZSn/HtDwJPwbQbxCjMY be79vQMVVOwqTNHAp5G5BWWAPPPNeik= X-Received: by 2002:a17:90a:2525:: with SMTP id j34mr10667580pje.11.1564858120445; Sat, 03 Aug 2019 11:48:40 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:58 -0700 Message-Id: <20190803184800.8221-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::542 Subject: [Qemu-devel] [PATCH v3 32/34] target/arm: Enable ARMv8.1-VHE in -cpu max X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1901997a06..b1bb394c6d 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -337,6 +337,7 @@ static void aarch64_max_initfn(Object *obj) t = cpu->isar.id_aa64mmfr1; t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); + t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); cpu->isar.id_aa64mmfr1 = t; /* Replicate the same data to the 32-bit id registers. */ From patchwork Sat Aug 3 18:47:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170508 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2351728ile; Sat, 3 Aug 2019 12:04:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcaeP041ywKUUZDGhuYpeXSDtn2uL5sm722jr2RRmhWpg3UAINVvpePDdQnBLhQMwxjbF6 X-Received: by 2002:a0c:bd1f:: with SMTP id m31mr103199952qvg.54.1564859066404; Sat, 03 Aug 2019 12:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564859066; cv=none; d=google.com; s=arc-20160816; b=VLlSrVegmxmxb7CnprJDi2rApSYQ8y/Glnt6yZOnb9xbyV6CM/ygZZ7Q/gkS61nvRb ucbHHSZcx5wopXodO5tNQI87Mkc+uHF3Yl+3iPsT2YfgH9yPA9Jz9dqNk1RBnPZHX+D+ PlPK61ht8qWhdJDgZNcikGjRlAwLskAoIet2wwUM8h8a8JGMfvuBbM3SWlgvCz/oya9B ZCpuuGi0RqHfwvQEBxb3/dO+EwqN5lWBOIcnaJ1attyvmjTPOL8blaUs1Y96gpvpK6LY kexozgc8nbnqBT7kccTPa2MJrj54yPWBpeq6xisAVWCXiGyXD3Qo3g8uRzrNb330nUBt HONw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=1OFhZYB7REGpAAmdzyA7otQ/hGEth32oUJ6nOIibRSY=; b=m+GwZxDAKlDa+D/daLOvNP27v6FxTTUe6JNNGY3hSuxPO3DYYpiyq6fmrKLH7KITF2 dH1U1tlsMTZsJZpJDSsjw4g1lnLQbGgrngz8Pl8Ji6FOVFIStCJNfchQchcMeccygPj1 /WsD84ylzhl1L29FCTrVYTWHXFwtFePAZKiDWTRjsmEi6m//6OKe5WsaeqQN+g0PrbwM PjUGQPCpKcXpC1A3DvtHNZVR4W0Eml9kuK2kwVV9PWzZA527WtQMYZUWQROnmUUqSDAc dhsrXwcW75VsIucFCZGIkRP7zu6ckuwXVNs/XEKCYFiv65sdVyJ7hxSSxMcfBGvz1MDD rnjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q2KjR7sz; 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 u40si48969360qvg.25.2019.08.03.12.04.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:04:26 -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=Q2KjR7sz; 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 ([::1]:41690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzKM-0008C0-1R for patch@linaro.org; Sat, 03 Aug 2019 15:04:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33108) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5K-0007GI-LZ for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5J-0007WE-OA for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:54 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:42856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz5J-0007QN-JI for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:53 -0400 Received: by mail-pf1-x441.google.com with SMTP id q10so37607491pff.9 for ; Sat, 03 Aug 2019 11:48:42 -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=1OFhZYB7REGpAAmdzyA7otQ/hGEth32oUJ6nOIibRSY=; b=Q2KjR7szqQzFJBEH2NX0Shzd0whUpZj611QA5mIAYhzgpKlRBh5ODsGM5FpzlG4XYN E60p6k7knFLoG/3l6e6jb7NjxMSe0Uv8+wqgGre6LtOAO8f9GbaDAC+QVVD/ZN5iyITN lGdwQcy388XZhoO0jJnjvMrs8PgL8MKY8f2zAiABXU4jRRFArYBaW2DC9HbECCXS3boA MVFaJlKA0Jjiem7h2Fc2fVhhL4udB+lpnGcgR8fnzJZy8uhg7VgTozjHaTNGGsA68nb+ pNMQWGe5juX6arF/6MAQUZs+Ue9hikLMS6b4/+dUo5QLrj218JfX5gH9w7La9BbmqPbo yNEg== 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:mime-version:content-transfer-encoding; bh=1OFhZYB7REGpAAmdzyA7otQ/hGEth32oUJ6nOIibRSY=; b=PiA56Qe461Ikjgo524YDH1tBp04+AV3VRRgNXiGQvkN7Yi5N6SeyQ2fUje4QgvDXRt uOMj9niWmdtcyy9v0T489aBsjEo5HQPX2dR449GR97yt0MF05PbqyrUik0KVGxVGzKfw EYUAWR2YkTCMOCehSHN6Xu3+4G8pYyXIcuF9lY44tC7occMjSfKZiMLEgIHWvxlwVvCp d3WC4AYge3u5p99XoIGTsY0+BnOWnYlXALLD4aekRpkDBgKsIBNBXa5uJ4DjiAV57CKP 7vEOu+rl5I7gc/vEJqvr6XzjdsHmruap9M8bzXSkLLd4o1gVAGB8QjUwf4R9uAu/Yh6T eQBQ== X-Gm-Message-State: APjAAAVEJHwRwsdPHVwFIIpIEUcLirj1kS1kpm2LIXQQ+R0hIeeL88aM a8i7F+w43qWGAi77C507n73S396lM+4= X-Received: by 2002:a62:ac11:: with SMTP id v17mr65823645pfe.236.1564858121535; Sat, 03 Aug 2019 11:48:41 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:59 -0700 Message-Id: <20190803184800.8221-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v3 33/34] target/arm: check TGE and E2H flags for EL0 pauth traps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée According to ARM ARM we should only trap from EL0 when TCG or E2H are 0. Signed-off-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/pauth_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index 42c9141bb7..9fa002068e 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -371,7 +371,9 @@ static void pauth_check_trap(CPUARMState *env, int el, uintptr_t ra) if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { uint64_t hcr = arm_hcr_el2_eff(env); bool trap = !(hcr & HCR_API); - /* FIXME: ARMv8.1-VHE: trap only applies to EL1&0 regime. */ + if (el < 1) { + trap &= !(hcr & HCR_TGE) | !(hcr & HCR_E2H); + } /* FIXME: ARMv8.3-NV: HCR_NV trap takes precedence for ERETA[AB]. */ if (trap) { pauth_trap(env, 2, ra); From patchwork Sat Aug 3 18:48:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170507 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2350814ile; Sat, 3 Aug 2019 12:03:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmvOCCq4ckAwrj6uV1dgTYbMrnSf4E+cmZgnmhiyZMPmwTLC1JtlXe2EJz2I/ifLFTOF6h X-Received: by 2002:a50:f982:: with SMTP id q2mr125564491edn.270.1564859000717; Sat, 03 Aug 2019 12:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564859000; cv=none; d=google.com; s=arc-20160816; b=LsZDqfFBu/p/1hD4D5y8UclpHk36L23ZSLZdRBlN9OBnKVzi/13gJIk/OvFV0pWc2u q5vUjv34vKHOeTb2yNSePbuQGp0qTi+NHdLidMwzydlPQiMNUYRAV1VguaTHfL3tWkWl vqasA9p9HiG+Tk5D9V4h8YTd+Fg3L449I55u+sz0ZiOjuSKYcqKM+feHsM95VwRJkBxJ 9iKV4r9Pn0gv9NAdXcKxHGDE44lms4KcgVgoduUWovaywtdFax/3aR2LBUhMPXcqOm5u d/SrlV9z4Pv2/tvon3JwqcBJmWDUosqAwSmZDx4EMQBx2BAVS1b1gzTyaAXMYsg3rjNv eZpA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=VZbb1rzI4zahnAL11h/DzkD7ar6WwiCPlhOLpT3N7ho=; b=nQ34I4LSEyIwWpPtctrp88WYX5sBZjv6BVDvgjQkPrvNH/Rfx2L1sCWbRrFIODeGys Wb0+G37fnBwxoCfiVAxVaQH8EBfI5bH5lIrngCPWwGMInFPXx+7tH/S/F8pFQG3kDJLb w4Wnk/KCn57T8LYd+5BlQ103tNswS+QTHOPwX0CgI/akTY7RNshCfNW5DmJteULsmYze +eJ4PyXneDtXbvg9TwWhskfrmNEFN7wuCELGdJU9DXdTQW8VbllJ4mgxl5gDNKCFxeTV /6Rcbf6pV8d08IjQ4pnCPtRach/39LxtF3efiUoljQLzREKGbtoduVnpLTPVoyzQ2av3 Hw0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XUMdfYty; 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 c45si27425908eda.303.2019.08.03.12.03.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:03:20 -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=XUMdfYty; 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 ([::1]:41672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzJH-00062T-Nq for patch@linaro.org; Sat, 03 Aug 2019 15:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33007) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5D-0006vq-Hg for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5B-0007SW-L1 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:47 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz5B-0007Qu-EX for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:45 -0400 Received: by mail-pg1-x543.google.com with SMTP id n9so31447517pgc.1 for ; Sat, 03 Aug 2019 11:48:43 -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=VZbb1rzI4zahnAL11h/DzkD7ar6WwiCPlhOLpT3N7ho=; b=XUMdfYtyP/dN0NvjiEKzLhQ81PX1aEG6yfDSVTntnAkC0mjiaPutVEuE/iwMSdBaoI W2BAVieKDVGUWnETHBzDpm1ZmGfk/R32ANvpX6bxCan8Oz3rTCsduFiqbjm7V8wqU8/b bMpmDhcVV6F2wWxm9nc7j2Bn/Ofi/Zs7IjN9iW/QZAMI2nSs5Wx6sAVyRWuS0BaY5UXm WQA5op6gMyyi/s9Nb5FAhiwqXDqXfizNoVCq7fWlZCVe/TUh3wfRLSGOd2CkAbw8Rm8S rFZi2TjdomMmBQLXmyScAFfk/5j0NKU2Smfhj+o1qrw/6SRBWfVSw12ecq7VZLD5gkW6 wutQ== 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:mime-version:content-transfer-encoding; bh=VZbb1rzI4zahnAL11h/DzkD7ar6WwiCPlhOLpT3N7ho=; b=bjbgNkLsAO9wuVUJHNrTXFf9vcsPcpIH0ArWblUGeH6I7RiO0Zp8GldTAufQOBDxyC XzlsmNF71GK5iruNxtdldeMq7W3EQk6Alxoo2kScjqL9jyffcLgcISJwtCecsZtZBI4Q J447CHAoltnNwfIaijU7zbpqPHLKL+Wfwoy74mME2QXGbl8MxO2j+lOMKJjjuv5I/UtW 95c+0MQHcoPdyQCl0lfnIZ6Acw/e2NuWWO3wkFVEw4+0ZMySaIxj3NeVE1o7nJAoQ7Za ayh8Hl3PTCBIqnfQHrCHq5jj7r5iDbOgT6zYN0iZiLuNWgKTyp78aoIK0ccrfvj99/hz MqhQ== X-Gm-Message-State: APjAAAWnBVr3vUvmn3nZ4bv5lnPbVxu142TKs2yprn/miMKxYZNKGz0u DJi5mrAOlFSjYy3ormgLVpH2/Alek9o= X-Received: by 2002:a17:90a:8a0b:: with SMTP id w11mr10351911pjn.125.1564858122529; Sat, 03 Aug 2019 11:48:42 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:48:00 -0700 Message-Id: <20190803184800.8221-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v3 34/34] target/arm: generate a custom MIDR for -cpu max X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée While most features are now detected by probing the ID_* registers kernels can (and do) use MIDR_EL1 for working out of they have to apply errata. This can trip up warnings in the kernel as it tries to work out if it should apply workarounds to features that don't actually exist in the reported CPU type. Avoid this problem by synthesising our own MIDR value. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20190726113950.7499-1-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- target/arm/cpu.h | 6 ++++++ target/arm/cpu64.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d7c5a123a3..6e4c97d398 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1605,6 +1605,12 @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) /* * System register ID fields. */ +FIELD(MIDR_EL1, REVISION, 0, 4) +FIELD(MIDR_EL1, PARTNUM, 4, 12) +FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) +FIELD(MIDR_EL1, VARIANT, 20, 4) +FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) + FIELD(ID_ISAR0, SWAP, 0, 4) FIELD(ID_ISAR0, BITCOUNT, 4, 4) FIELD(ID_ISAR0, BITFIELD, 8, 4) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index b1bb394c6d..3a1e98a18e 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -296,6 +296,25 @@ static void aarch64_max_initfn(Object *obj) uint32_t u; aarch64_a57_initfn(obj); + /* + * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real + * one and try to apply errata workarounds or use impdef features we + * don't provide. + * An IMPLEMENTER field of 0 means "reserved for software use"; + * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers + * to see which features are present"; + * the VARIANT, PARTNUM and REVISION fields are all implementation + * defined and we choose to define PARTNUM just in case guest + * code needs to distinguish this QEMU CPU from other software + * implementations, though this shouldn't be needed. + */ + t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); + t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); + t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0); + t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); + cpu->midr = t; + t = cpu->isar.id_aa64isar0; t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);