From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605585; cv=none; d=zoho.com; s=zohoarc; b=URU21ydORxkjMxC2gIk6AT7GBWsf7eCgchtscDWbsvvNtlIM7c3YZS3MbfbLlkI0pkUZHcZELpvjmwP3nqtxHR8kbEHsXWnMJgEqiHgwPvKQhWaDHSxAubBPfry4CIjXxnPSvCdlfM1JqcEGuyI668yciIa70Mb3YMggtoHgD2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3Vv1PJfuLW2Q3y6jhZwS+VA5WdsiwenJEhdiHqcPU8E=; b=b2X1Cp82Zo4FcYV5VazIrem182o/Zgu4992tpde8xeHQFISi6OKGVyBfTR21TI7//tH1lY+k/zyal2/07MNWMKs3C67WoaEv/i7oR0tT/J6F+Bd4rK5jLVfav+3yJtkMgi6PLMP2u/LVth+CReSxlvhtHtKVJGzrIbwSR6zTn6k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605585070923.5263230047796; Wed, 31 Jul 2019 13:39:45 -0700 (PDT) Received: from localhost ([::1]:44224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvNq-0005uS-JS for importer@patchew.org; Wed, 31 Jul 2019 16:39:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60599) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMZ-0003vr-Kg for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMY-0003H0-6V for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:19 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:46529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMY-0003Gh-03 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:18 -0400 Received: by mail-pf1-x444.google.com with SMTP id c3so9373387pfa.13 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=3Vv1PJfuLW2Q3y6jhZwS+VA5WdsiwenJEhdiHqcPU8E=; b=UHN9Ri7INF29P80/b9NdjhxTy8SPM+M2VMwY0AJl5Igm1w4JA4pRaa4rdxWtUTls8r BwBAmwaWQPRpHk1JrvnweqW3TC0WT0YHKSW7omxdpNQh/LwLT74ok9c1Km9b2mVMcGFi aWmjsqG3OHPDlcbNnhfoN8JrogF0ucwsmaGTOAW63L3ZnrEXsOnKkQrJ56frq2ZdALFb VXQUldBYkUlfdJOpwj03UWgXB502/M6IRQ7eSzEFgbhjopCyE27+kaQm5vfACBaP7AnK wxMZbi0gmdttuWpCUmZx7r+5W5awZxidi4a/V9KCDsoQLbsOOwXuHGnV6M37q9xf0JjU szig== 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=FbjiMBZvVqTrhanxeOew8wubWqiF59Lgwovf3VRJqubKsh0B9RuxkatnWCgB1LWWOj NPINz1Z7jqzBLcSv/xR2DdTaNk7rUCX3lkpSTAnhYdyszkQjUW5/8ZEunHS07JjJaXQd EZZsMPgJiJBKu17UrzSkH4EqEK3AIitKkwsidmvlsrKTbICDXBPCxOf0Jq1mSF9cb7M0 UlSPb/++D/dq0A1ZGfPIDMKvmRBB8zj/2Bs+/FWT2xkkuONibxa3nS1AHhayt80hOd/T jdwim9aDMis8W8WZvjGiv6mkbJ3uvgK2g8fjtdtyyHMh5DhmpYbyYSRGTTlSDxsQ0uW0 yP2A== X-Gm-Message-State: APjAAAXm+Ej8vaJICjBaBm1IqEK880Bc+kJtZXqVmsyE5XLaNZtV5S3P eLAQdjlKC5cFmekyLPwjqluvai0muRI= X-Google-Smtp-Source: APXvYqwDPcKf+ZZvl6tAtuy9oiYCe6HiatU4e0VHY/ab6pwUF4w0YU3MEqjLGb59jIR95iuJ8fFEjw== X-Received: by 2002:a62:764d:: with SMTP id r74mr51255602pfc.110.1564605496727; Wed, 31 Jul 2019 13:38:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:42 -0700 Message-Id: <20190731203813.30765-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 01/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e 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(+) 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; } =20 +/** + * 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, uint1= 6_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 depma= p) +{ +} #endif =20 #define CODE_GEN_ALIGN 16 /* must be >=3D of the size of a icach= e 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, tar= get_ulong addr) tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS); } =20 +void tlb_set_asid_for_mmuidx(CPUState *cpu, uint32_t asid, uint16_t idxmap, + uint16_t depmap) +{ + CPUTLB *tlb =3D cpu_tlb(cpu); + uint16_t work, to_flush =3D 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 =3D idxmap; work !=3D 0; work &=3D work - 1) { + int mmu_idx =3D ctz32(work); + if (tlb->d[mmu_idx].asid !=3D asid) { + tlb->d[mmu_idx].asid =3D asid; + to_flush |=3D 1 << mmu_idx; + } + } + if (to_flush) { + to_flush |=3D 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) --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605585; cv=none; d=zoho.com; s=zohoarc; b=BpkOqx9ArNFbSDXbAgJtrcam9XJk8F8R6O6nMEffrUomOWVKhq9v9bI6bwYXcjRovyfZ+VlGvevxxJf7fBmGQ56D/hcx4uHTbcfQJCfzQufaeDTi69tbCRMRMrxwbhg0/mYY7E3SSb0sPc7PSbvfR5JdllBFp+eTTB+11vjFsF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OzH9oAANiLbbz3MZqOd0740wSKDkRIpOzsZLTONmMZs=; b=iRWTUVoOQ3t2I+zShSVCUQ3JJ5ElgzyAjITTlrfsL4V0689ob+J91zwG3lJl91Y4pIaipNNvpSQfjEBsqlxebjMbOMyr8hZpxBm/aoUlfna0k2ldeOMnfZguJ0j0clUtTVVapQG36BwGHyPz/ChxPB9VN278Ek+v1MmRScbRZ+M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605585651324.74249948617364; Wed, 31 Jul 2019 13:39:45 -0700 (PDT) Received: from localhost ([::1]:44226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvNw-00069V-M9 for importer@patchew.org; Wed, 31 Jul 2019 16:39:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60623) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMa-0003wA-O5 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMZ-0003Hf-Jf for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:20 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:42596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMZ-0003HH-B2 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:19 -0400 Received: by mail-pg1-x543.google.com with SMTP id t132so32632236pgb.9 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=OzH9oAANiLbbz3MZqOd0740wSKDkRIpOzsZLTONmMZs=; b=mkHD3+iYsbWab5cdVZchcSsYztaDNDugjO/BYtRQhaR9lWwuMtKJO1MOfTOMi+41tK vt6UkLW3JTiyThN3STPBnqE59TUW11RxDLiQ/biaUh2aO84jV77b/5fX8jYTq7pxU97z Ozu8J/5z66NiObuOQTlQzV6OEwh+egQSop9TErhKiE6aCHisL/bVRc4pTuIcb3++LkLT QlYOucEUVqXBkN7zQQoQMB62P06LSBvG8N2aZ8KN1Ipc6icCZMvXpNGcjCOT1DYMm8Xo hltZZ27joq3NsBo6CUCTa2HdLvkgt5I96hCt3h50ndDp11BSX9caNWf0FVB1+EsgxVd5 Pb8A== 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=QlF/6Udy5HWs+7HJMRar5Ha1IWUZgECeJYE7eQsAkvkca1KBhbfFoo9QlAsH3Uy4Kk bOcSRUPhCdWAblNZWT0CQXBvm0zzUVvaWmPAj168oz60bNCGHsQH3Wflw59kmO3WLPNA QFFgTCmA1xQwmfHRJ00klzIZVszPGoDy9hSEDKZPucwvLEaAOYt/GXMSq4UcHlXZJoc6 XchzVx5QeOIh2Fi+/BFJmiiGafZ+HTuuwsmyvC9NrZGKLXyFVkCFF6VdY82yGAjahukq YmXACYk3LkNux59y9eHR8eOq6kN8EVHstFYlk6oam4r54vFLF7PCQV/GDqAzhgmFqHHL v4dw== X-Gm-Message-State: APjAAAUtGvJTL+mfL+IkR1Iy9jKT+EmfzMhoXJFbjAtYOdOGOBljRvDa dmBQE6kVfhtD4/pnSVnnqPup5bezxxg= X-Google-Smtp-Source: APXvYqyCh4czqu5MPOguqi5mN0IkCbCArQrhKl2imbG1TB/cUQHFz0tm3E1i7kVM2Hu07hZ8yC7ShQ== X-Received: by 2002:aa7:9407:: with SMTP id x7mr51015581pfo.163.1564605497999; Wed, 31 Jul 2019 13:38:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:43 -0700 Message-Id: <20190731203813.30765-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 02/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Since we have remembered ASIDs, we can further minimize flushing by comparing against the one we want to flush. Reviewed-by: Alex Benn=C3=A9e 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(+) 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 idxma= p); +/* 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; =20 #define RUN_ON_CPU_HOST_PTR(p) ((run_on_cpu_data){.host_ptr =3D (p)}) #define RUN_ON_CPU_HOST_INT(i) ((run_on_cpu_data){.host_int =3D (i)}) #define RUN_ON_CPU_HOST_ULONG(ul) ((run_on_cpu_data){.host_ulong =3D (ul)}) #define RUN_ON_CPU_TARGET_PTR(v) ((run_on_cpu_data){.target_ptr =3D (v)}) +#define RUN_ON_CPU_UINT64(i) ((run_on_cpu_data){.uint64 =3D (i)}) #define RUN_ON_CPU_NULL RUN_ON_CPU_HOST_PTR(NULL) =20 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, tar= get_ulong addr) tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS); } =20 +static void tlb_flush_asid_by_mmuidx_async_work(CPUState *cpu, + run_on_cpu_data data) +{ + CPUTLB *tlb =3D cpu_tlb(cpu); + uint32_t asid =3D data.uint64; + uint16_t idxmap =3D data.uint64 >> 32; + uint16_t to_flush =3D 0, work; + + assert_cpu_is_self(cpu); + + for (work =3D idxmap; work !=3D 0; work &=3D work - 1) { + int mmu_idx =3D ctz32(work); + if (tlb->d[mmu_idx].asid =3D=3D asid) { + to_flush |=3D 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 idxma= p) +{ + uint64_t asid_idx =3D 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_id= x)); + } +} + +void tlb_flush_asid_by_mmuidx_all_cpus(CPUState *src_cpu, + uint32_t asid, uint16_t idxmap) +{ + uint64_t asid_idx =3D 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_id= x)); +} + +void tlb_flush_asid_by_mmuidx_all_cpus_synced(CPUState *src_cpu, + uint32_t asid, uint16_t idxm= ap) +{ + uint64_t asid_idx =3D 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) { --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605588; cv=none; d=zoho.com; s=zohoarc; b=SYd/eZJ0GTHcKLECsAP94i+0R+5Z2P41A1BPNJzAGKGLVlvsjEcNd2ycM5ItzgVOSjMzT4pvnwNRbFHIi9qjyOBnXFQcDC2jqXG0fx2K8z7ZcIxenwDdOQBSF6yvFvn9hf5gkwiR8onU/pJc52RudXP6jbHRCHiwkuy8QzS5czk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605588; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZRDl/Ha+kclTizhs/nHDa+7096PsBT003cOS/ic3LTY=; b=I+PbKUb009vIVagdXEmT5s5fv1EKSiPqR2h0eOmISIq6sv0b4pfqxYviS0iTEE/algjDMUAw644LkM0wqPOXbjee6bqayhdG0kGJasuc39BsKgyRy60Fv6TKRRkOxoDdDPG2EYhhtjkjIFJzHX/AeykjPJgWv5U/NzecdDT75N8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605588858144.0689374369847; Wed, 31 Jul 2019 13:39:48 -0700 (PDT) Received: from localhost ([::1]:44228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvNz-0006Ly-TT for importer@patchew.org; Wed, 31 Jul 2019 16:39:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60653) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMc-0003zv-8Q for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMa-0003Ig-KP for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:22 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMa-0003Hq-Dt for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:20 -0400 Received: by mail-pl1-x641.google.com with SMTP id t14so30968102plr.11 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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 :mime-version:content-transfer-encoding; bh=ZRDl/Ha+kclTizhs/nHDa+7096PsBT003cOS/ic3LTY=; b=BrNtztSKwNJY0w/qMsV8+5wn4WcG6r4UAkotM3F1Fr5GTPMAXcVgrqHjx1FIW66bFr voGvXlo+sk+LOwKuxpVJmzUqP6ryvIWJ+RccWHsdrYBIA5zpjgEzLk0S2s7M08DnGhae RoxZK0x9byYFKU8QZ7+41B6YLY9eg1o2PafxegkAmZ2hPwr7IjgDGhd6ygh1wkZD58CV yjLmRLyQm37yaiDumd+HxvlJqBvPJbKDRDQw6BWfghL1BFsBuDB/vJjWmiHZ8Xot0pjP QA2Yg8OIKXIwsasWN/QJkbLmtVffUpmMmVrARxz3QX5wmngBTyscEuAK3HrcevjdsHmS 5GIA== 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=TIXf0/LRpyB8m470ryWotrn3Qqe5E/MBcvaGdUKlaIkQ/Gw0jLiDh5z6hrplD0mVJl 7swGNFMXC3JY3OepOopUYBomxz/LPJljzDPWmxIoIAY5R0C04HIM7Cv11tsY14/oi/Cb U52W6TqHMq8maNDZ1Jkrzu/Ubl8+rITmkq9utSGn9lHFZQlyup1DBSykuSCOZzTdvR4j YfBdBRb6VXfMBkYK9hH8WgsT1G++BDtPpj41MBjlCJ1zMSm91R+fLUqiEOf3xOFwnag7 KlvhJpqhITg3iZRbm9CGdh5N+RVDwv1xXKXTWjY7HX+WNyAraEmcPXej8OIFP5SNyhGW OQRw== X-Gm-Message-State: APjAAAUP4r+nAVnNDRXX7SIE1Z7SPIWc38v5ARgJxjZNromQr5QaX8Ys L3owuizc908AQpfSH+OBdB+PuYoXGNg= X-Google-Smtp-Source: APXvYqyWEV274dQZVgWi2Wu86iEvI+0HHvGMf3nXZJrLkcxk/IZ06QEj1btzVpyIJhovftlZLcbaGA== X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr68507527plm.306.1564605499140; Wed, 31 Jul 2019 13:38:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:44 -0700 Message-Id: <20190731203813.30765-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 03/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 73 +++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 25 deletions(-) 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[] =3D { REGINFO_SENTINEL }; =20 +/* Called after a change to any of TTBR*_EL1 or TTBCR_EL1. */ +static void update_lpae_el1_asid(CPUARMState *env, int secure) +{ + CPUState *cs =3D env_cpu(env); + uint64_t ttbr0, ttbr1, ttcr; + int asid, idxmask; + + switch (secure) { + case ARM_CP_SECSTATE_S: + ttbr0 =3D env->cp15.ttbr0_s; + ttbr1 =3D env->cp15.ttbr1_s; + ttcr =3D env->cp15.tcr_el[3].raw_tcr; + /* Note that cp15.ttbr0_s =3D=3D cp15.ttbr0_el[3], so S1E3 is affe= cted. */ + /* ??? Secure EL3 really using the ASID field? Doesn't make sense= . */ + idxmask =3D ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0 | ARMMMUIdxBit= _S1E3; + break; + case ARM_CP_SECSTATE_NS: + ttbr0 =3D env->cp15.ttbr0_ns; + ttbr1 =3D env->cp15.ttbr1_ns; + ttcr =3D env->cp15.tcr_el[1].raw_tcr; + idxmask =3D ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + break; + default: + g_assert_not_reached(); + } + asid =3D 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 =3D env_archcpu(env); TCR *tcr =3D raw_ptr(env, ri); =20 - 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 =3D 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); + } } =20 static void vmsa_ttbcr_reset(CPUARMState *env, const ARMCPRegInfo *ri) @@ -3392,24 +3420,19 @@ static void vmsa_ttbcr_reset(CPUARMState *env, cons= t ARMCPRegInfo *ri) static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu =3D env_archcpu(env); - TCR *tcr =3D raw_ptr(env, ri); - - /* For AArch64 the A1 bit could result in a change of ASID, so TLB flu= sh. */ - tlb_flush(CPU(cpu)); - tcr->raw_tcr =3D value; + raw_write(env, ri, value); + /* The A1 bit controls which ASID is active. */ + update_lpae_el1_asid(env, ri->secure); } =20 -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) !=3D 0) { - ARMCPU *cpu =3D 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); + } } =20 static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3455,12 +3478,12 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, cp15.esr_el[1]), .resetvalue = =3D 0, }, { .name =3D "TTBR0_EL1", .state =3D ARM_CP_STATE_BOTH, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 0, .opc2 =3D 0, - .access =3D PL1_RW, .writefn =3D vmsa_ttbr_write, .resetvalue =3D 0, + .access =3D PL1_RW, .writefn =3D vmsa_ttbr_el1_write, .resetvalue = =3D 0, .bank_fieldoffsets =3D { offsetof(CPUARMState, cp15.ttbr0_s), offsetof(CPUARMState, cp15.ttbr0_ns) } }, { .name =3D "TTBR1_EL1", .state =3D ARM_CP_STATE_BOTH, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 0, .opc2 =3D 1, - .access =3D PL1_RW, .writefn =3D vmsa_ttbr_write, .resetvalue =3D 0, + .access =3D PL1_RW, .writefn =3D vmsa_ttbr_el1_write, .resetvalue = =3D 0, .bank_fieldoffsets =3D { offsetof(CPUARMState, cp15.ttbr1_s), offsetof(CPUARMState, cp15.ttbr1_ns) } }, { .name =3D "TCR_EL1", .state =3D ARM_CP_STATE_AA64, @@ -3715,12 +3738,12 @@ static const ARMCPRegInfo lpae_cp_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_64BIT | ARM_CP_ALIAS, .bank_fieldoffsets =3D { offsetof(CPUARMState, cp15.ttbr0_s), offsetof(CPUARMState, cp15.ttbr0_ns) }, - .writefn =3D vmsa_ttbr_write, }, + .writefn =3D vmsa_ttbr_el1_write, }, { .name =3D "TTBR1", .cp =3D 15, .crm =3D 2, .opc1 =3D 1, .access =3D PL1_RW, .type =3D ARM_CP_64BIT | ARM_CP_ALIAS, .bank_fieldoffsets =3D { offsetof(CPUARMState, cp15.ttbr1_s), offsetof(CPUARMState, cp15.ttbr1_ns) }, - .writefn =3D vmsa_ttbr_write, }, + .writefn =3D vmsa_ttbr_el1_write, }, REGINFO_SENTINEL }; =20 --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605698; cv=none; d=zoho.com; s=zohoarc; b=j8YeZv/X/fbNMrMzroJJBqfGMYGcaqIK+siXBRtEn0flCtKZp5EJ7sU/6V4YXDoTn6L8coQzSlr9ESIfHmVtyKBuFsYMmoRre4PadiE/LVsSCR8Oex/Qk4I8sJtKPrZgAyf9GCs032xzE0i4TNrWJg8SLiyKftkmRW072+tyffw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605698; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7Rs0ix/SYQKzQx2FXXQO106tmFBYyCQIrr3vAmMEheQ=; b=BGvuEruwWdUHknzfIyMuVJV8GJ9Q1KDH6fySnNZ0W7VoN2lqN9ujzGtWLT1UbP+Tf1VFPBf62XvigQmrsHLerp6PT8ZDUimOhu1Sx+gqgvrrTtq0uqEBpTwTyuXEzLhZ8UC1PEJY6grP/ZANNW3uk6kA3SZlz4/2hFosR15o/Y0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605698560592.5296579642298; Wed, 31 Jul 2019 13:41:38 -0700 (PDT) Received: from localhost ([::1]:44258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvPl-0001A5-L8 for importer@patchew.org; Wed, 31 Jul 2019 16:41:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60670) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMc-00041q-Qu for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMb-0003K2-PR for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:22 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42363) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMb-0003JA-IV for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:21 -0400 Received: by mail-pf1-x444.google.com with SMTP id q10so32498887pff.9 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=7Rs0ix/SYQKzQx2FXXQO106tmFBYyCQIrr3vAmMEheQ=; b=V5ayK2HbCrq8lkE6uzbtB+Gh4x+wbDqsfwQvU/DsGlCULld2xwWZQ6oEk4ZWoALJuA 6uwN/OKw9WpLikQjbhJO76mCnWqYyH+VzGSaCkwioqSitwZd4H1qc4foFdlx+vHbbfff d/sE8XnpavzktAWghiBaSNvvM+6wKi1HghKumI9drfM/FleAcJzrT1epZ6/E/avkwR6/ 1Cf18+Eq2YCoRDZZhhv1G/bPeQqx+do3NMXjJfgpEyfvcCHfYkEL5PHiScvFEgYKKD2C NbF6UzncMkRIF1uZ2FQUk3h1NF730sZSZt22C3+kCZIq/DpOVj84p5cZxWi6fu7Qjka0 BxTQ== 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=qD45x25uE5eb/RZ12+X8Cy/EkWFsWVZE2of+V9UBmnW8uUdhUGl3p6rFK1Sq6MrEYL RxR0RhyrCRtdNR7Hu7Ail0Bo2EUFtgxzc+346Nw1urStGfbSWxVW68UL9ervxyJwXcGe xEA+Skf/WUFmuq7ObNAPcbVasDYHPU/Cs3XPu363MzojqSir61TTUELgIdUQHwW/SbuJ jA5EoLs5IdiU0lKC6xnfR2w1bwPOh0j7+3/0EJzrspiWYaMqyAT4hY/e/NH6QYpy4bBU 1PyifXYtpmOdEcmPMpfjpgGcXO4yTZQuJ61ypBFQG7LqqfDATKovNbjBpk9rhnMeZKbO 0PsA== X-Gm-Message-State: APjAAAVe8CVfdrCuIXoKpDt+zvlr9TKUyXC6lKNPaMYRlQaZCIfpR9ND d1p3kQJMHuU2+dWphhAt6Yn2xHQuOHc= X-Google-Smtp-Source: APXvYqzyMRv4i60Cc+tZSoFWbWciYfFyeBgjDAnRVHQlUyW0sDi1GnHafxRO8/5mQC3TXzR5lIEHHg== X-Received: by 2002:a62:3103:: with SMTP id x3mr48307894pfx.107.1564605500394; Wed, 31 Jul 2019 13:38:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:45 -0700 Message-Id: <20190731203813.30765-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 04/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) 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 ARMCPR= egInfo *ri, uint64_t value) static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu =3D env_archcpu(env); - - if (raw_read(env, ri) !=3D 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 =3D env_cpu(env); + int asid =3D extract32(value, 0, 8); + int idxmask; + + switch (ri->secure) { + case ARM_CP_SECSTATE_S: + idxmask =3D ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + break; + case ARM_CP_SECSTATE_NS: + idxmask =3D ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + break; + default: + g_assert_not_reached(); + } + tlb_set_asid_for_mmuidx(cs, asid, idxmask, 0); + } } =20 /* IS variants of TLB operations must affect all cores */ --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605710; cv=none; d=zoho.com; s=zohoarc; b=B20Ux0eujClICLpL47ZndJTknx8RmmR55/MqevPIOBpujOSP92oO6xQqOelRakUAQld6L4paN6PB+qDjZOoE2aX3Bo8ElW6bQWwQJAvcvftUbp60hNlT3At9k3LIi8bZDKO5FyILZL98N6XDKq38z5fTzx3JvMR9qYWpgn0S9bI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605710; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hV2eslCkM9+11E22XGBDo1tPxuDz+vxwGvc3iXR5Q+U=; b=SZtRTtOkyAcMOA4ysXSLAUih45itg/wj994JtMjUx7hR587TYyebfXjcYAZKbVXvj/FOgGBkhLRACh/Hycvibt3CqDrAbZuj/CF/nCOW6HIXDURgRmDkjJOb8B1pbnpBpqPFZqUJZgNzbB/uO5BWuBX6CuyH9Ao2iRlAWzw8xpw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605710339146.00402648554677; Wed, 31 Jul 2019 13:41:50 -0700 (PDT) Received: from localhost ([::1]:44262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvPx-0001j5-D5 for importer@patchew.org; Wed, 31 Jul 2019 16:41:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60703) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMe-00046H-11 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMc-0003LV-Tb for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:23 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:43333) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMc-0003Km-OO for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:22 -0400 Received: by mail-pl1-x642.google.com with SMTP id 4so23999414pld.10 for ; Wed, 31 Jul 2019 13:38:22 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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 :mime-version:content-transfer-encoding; bh=hV2eslCkM9+11E22XGBDo1tPxuDz+vxwGvc3iXR5Q+U=; b=QNmCPw3GCuujd8LoT8j4bsCJSixD7op8PTLgNifr81NcecAEkA9d/fNMyHEA/3bPl1 EiN7CzYJbcBQAHqYrBVOkNpnJWkTqJSNeZ+rlLVnDTfVsYVqMi6Yoj/q7Dvy59N7Vgtz mJka6IEPmGDCnUAb0ogeiP7XOzvbfjiupgMvRLVzS9MFGibnBjtyq+RPH6PzaiZzP+VN KDXE/qyFcvcXMHouwvNzY+Y6OKs/Dgp3aL0sDLLFm9HyDLG9FbXMbXOeCD2ysmSluVLi DXlO9v5a31ollQGNny6RsqgeupPNNtM234csP23pUHdMX+760AQ4e/E23fAmqvMfbJjl DLAg== 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=MJdBmb/U3TTpd+7BBR9gNOD0oObjyulNZytlQ2SeGEZ2oDQRV3bF1QCeymvYMWi0Qr xxjs6PvuNxbsCkEJjKe0crx+t81tlF+/fZy2QkpxVNIvyjUQ+KPdUA08cw3fpR3W/H61 sy60gb85T+lM7dMvWb8jCjXAV7bGyDBnbqi9Z+u/+RfDHG6edjBCu9v/3Z+vMMdXyYdq kHO5VdYNeBKSMyzYBMO5hHkiIlTEIG3dXop4wgbBoGuI3kh047jzpCpnvFISIb9CzCvT +KYvgm0RXw3MHYgOtZFVX64RScERNhy6rzncDKBBAvBbCi5fE9aec/qHCnN4Is7tqfzh Cp6w== X-Gm-Message-State: APjAAAWdvNMb/sy1yjpCaYSlQYMAHr/Q9EOz1OsL4NOF3q95lmanFoGY QzMiNK6AIW5ZTN55IxxUrQH9vvuK0go= X-Google-Smtp-Source: APXvYqxOiDSAeJ+RBMLE5SPQtY//yIxMGzLsjoYBWLyI3JToLrJ4Or80Gl67YMLSVzHF3NPv+CWSVA== X-Received: by 2002:a17:902:aa8a:: with SMTP id d10mr124813523plr.154.1564605501580; Wed, 31 Jul 2019 13:38:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:46 -0700 Message-Id: <20190731203813.30765-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 05/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The VMID is the ASID for the 2nd stage page lookup. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) 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, c= onst ARMCPRegInfo *ri, static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D env_cpu(env); + int vmid; =20 - /* Accesses to VTTBR may change the VMID so we must flush the TLB. */ - if (raw_read(env, ri) !=3D 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 =3D 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); } =20 static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] =3D { --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605701; cv=none; d=zoho.com; s=zohoarc; b=ZEceuFce3OF6uV+75zt0h58tig+l1QA27c9qrm6D5uqs46CtSY/N996Qb206n8QcX8eKVjX6LEr48Jo3/AFoWGXpfreYifIWd/GSYvCPaccqjp1/y/zZozNuWEBLIzarbUceuVQ+ic3gulELUJ3aLyJnyX2YYxcov0/AckbV9Xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605701; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6IeFtwkeZbBPVLT5Rmllb3ExAsBhlKcdIq9EZhAeEOQ=; b=UN+HWozFW/16bwPBhuL0yxvsmXX2yPxD/QIGcDJbVdpbg9soPkWJE86WvYYF+Zn208+vJBjqQNayfTIfh3QZbtB3TsgkJMkqUr6mAU+nEhm50f1mxfvYSaRnify/lik8sT5BMgOkKyx7z6V6RTLSxl6S81d4VhnOzkmqRiA+2Es= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605701727507.5854015931616; Wed, 31 Jul 2019 13:41:41 -0700 (PDT) Received: from localhost ([::1]:44260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvPo-0001IE-Pv for importer@patchew.org; Wed, 31 Jul 2019 16:41:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60731) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMf-00049A-1E for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMe-0003Md-5y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:24 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:41503) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMe-0003Lv-0w for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:24 -0400 Received: by mail-pg1-x544.google.com with SMTP id x15so22297019pgg.8 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:22 -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=O/GWG1vm0GYyFApT/JUxE06dQDg+BEu9I0fKzi/ASPf07ZtfGyq9opJRL4dUai0mux eU7ruZSdfVcqEFARLpd/rSUmTwckk6nwb8nEx09lZUMw99HBKO7ZeodlseN5m6Rsr3uH NrJCjDhHmDoLZ0APwwhUsUPv0BXorZcsVjzb4X8rp0Vub3WO2fZmfMpt/MeMbSi39hYo zPFdo3VDUCJGRtpohDA9p0gKBcFPkEJE5pFVj5dQBsuncOG22hO78T6DZi9w8HYcIYLh 11FEbIo2DltQXa5cvKMr0mba9j8LftBQuF1tPblPELqpKDxUdJa+QXO4ifV0+230SU8d fR6Q== 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=eZQwUPSSvEfpXborS0NKu4xQ32gao7VmtrUXeK5i60z8iUc7l9S0MjK3iCW59JVnoI PQadLKPmDRRX2zVQVqRgeE0aYaAx8IT6IwQUTlerPx7+wznCXRoITKq5tkUOWz8Mgauy aExMzo5Qbz6Lh4Lwm0jkr7EyFwHO1DOMVpuEoegL62OsmXqktay/6mspx/9GbZQ3XX96 U2itGC4hUtgtyf4TqugoQuwG/iDQF7KTMC4+lV+dO6xmz8lC4207Fx5nq3oV1chdY2sV yCLxrNm/piWiom6ckKU9OKkzZVX70ziteWLdQ3wucoV9bYEVgd7RhxX/q+SvqTqFk2yu Z8Lg== X-Gm-Message-State: APjAAAUcGYrwSH4wvZL0exBOdPcD5hNUBCVgj+uGgoTiUVz4xuzUNGsu Ev+Q71+tyEsT7/T8lLrs7JF5hwoLGUo= X-Google-Smtp-Source: APXvYqxPcmvh5VYQWOzxJCBS0y9i2ckmXm+3TIue93ewDGEjwJkruVEQcz4UUPsK8Wr2AXnSKzDx1g== X-Received: by 2002:a62:2582:: with SMTP id l124mr48886230pfl.43.1564605502801; Wed, 31 Jul 2019 13:38:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:47 -0700 Message-Id: <20190731203813.30765-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 06/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) 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 ARMIS= ARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) !=3D 0; } =20 +static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) !=3D 0; +} + static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) !=3D 0; --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605769; cv=none; d=zoho.com; s=zohoarc; b=Pk89FSili7HufPmNbabLecpxsUWpMumqMUyAeqYg2uOIxP39XW3ae5pbd8L+xIY60SO8DEPfPOBSVTDm+yX31qqbKhOHsbxk8Ir4znvlVXlsJ6tRZayci0XWyOfnjbVLlmbIc8Rriz4kB1YhQWPSWBi0/w6q5SnTZLermMVuJPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605769; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VC440BcwSuqOKz+Fo7ui0w+dupEF68UzkVylEVc+WDs=; b=IBQcKm4nB2kKbn2MvGmxuf2jY5annB9Fd2HTe6LF8obCW6PFIEkuwVO762ephynCUZJaEjjPeMdXeFHsXp5oX1bhBTY3S+sdeX929B5bzj6xL7aotqhah2pPsgAz2fr0z2fH64skHTwF8L9EyrHg931Z6hfk5wvzrybrGi3AREE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605769691992.7109657533383; Wed, 31 Jul 2019 13:42:49 -0700 (PDT) Received: from localhost ([::1]:44290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvQu-0004gz-Oc for importer@patchew.org; Wed, 31 Jul 2019 16:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60763) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMg-0004ES-FT for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMf-0003NM-Ep for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:26 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:42595) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMf-0003Mt-9Y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:25 -0400 Received: by mail-pg1-x541.google.com with SMTP id t132so32632353pgb.9 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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 :mime-version:content-transfer-encoding; bh=VC440BcwSuqOKz+Fo7ui0w+dupEF68UzkVylEVc+WDs=; b=I9uyMOU3oEdwC4uca/HtLL2zKp2V2rvHGUrb1UsT+oOlm1DEvz2TAK+0wpTiyUukX+ BBfUCM+XSFoCKDZwKc0WTIlFyX4mk7eziMk3HgGDslZ3yQTRDf0zrVxE7hldTwZ4q6Zl Nwb8wjypqFtUFir+gZ2lbYle8UY09BKUXUxuJbSImbMnzznNPUjkGdOODCOkHwPVv17L ZKz5VWjIortAYA6H3X6Vrw73ZG9kbrScFVshp7eSCsM6mc5GSWG3PMhg0+mttZLRmP/9 OeozOhiGC1hOjujJZz7LAg1mqcjBRxUIe6W5k10hgcsFdxEquKzjsL6ooDvAEqphzXVq aUDQ== 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=QMPRt0qFk6Sm9uXlnSVh9mvmHyjN8TE/ElqqZbenZVYPrJtDv7Fc3788BAG0V6r+Db dHQxIuiFT0Pq3150sPYPWldL5YLmMhCbXkrfAOmubPNKGFmjwicZe2xg0aDSfkIdRN/A JDQUN95U/qp8dMlH4aKQqynEcUnwD7BnYKaztJ7W0zbNV8vDs0RX/6IRWKyBzHOC/BpZ CX3ZWpcgHM7ktmYK26n7rgy8hAZmDLNQHo3hwYaQOMizPTu+FeQ6YYWDYZvtAAfwM3Gh Ig40Mv+dyzGagWKEhvrHa3kew8wiKKPrZZ/uD+MYAKsq0LagQ9nkfTi4FNctfh7ax4Fx U10Q== X-Gm-Message-State: APjAAAWDnfST4Xrc0HiYXP7uSlZS8CYIPJGOXfxTrIjHTAEyngS3ucYT YCRsnFcoEWcXLcGCG2CTTp20eDceGO0= X-Google-Smtp-Source: APXvYqxrwIjjz+PLHlGQZcyrMabdgwhqnqTo3z5N8wLK59zia+OByOKST1v4zmMxJUlLtpWwLacpzg== X-Received: by 2002:aa7:91cc:: with SMTP id z12mr49207441pfa.76.1564605504020; Wed, 31 Jul 2019 13:38:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:48 -0700 Message-Id: <20190731203813.30765-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 07/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/cpu.h | 7 ------- target/arm/helper.c | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) 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, uint= 32_t val, uint32_t mask) #define HCR_ATA (1ULL << 56) #define HCR_DCT (1ULL << 57) =20 -/* - * 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[] = =3D { static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t v= alue) { ARMCPU *cpu =3D env_archcpu(env); - uint64_t valid_mask =3D HCR_MASK; + /* Begin with bits defined in base ARMv8.0. */ + uint64_t valid_mask =3D MAKE_64BIT_MASK(0, 34); =20 if (arm_feature(env, ARM_FEATURE_EL3)) { valid_mask &=3D ~HCR_HCD; @@ -4637,6 +4638,9 @@ static void hcr_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) */ valid_mask &=3D ~HCR_TSC; } + if (cpu_isar_feature(aa64_vh, cpu)) { + valid_mask |=3D HCR_E2H; + } if (cpu_isar_feature(aa64_lor, cpu)) { valid_mask |=3D HCR_TLOR; } --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605770; cv=none; d=zoho.com; s=zohoarc; b=Ei114iShCAXD831jCWK5bmePHGmDJCTz4jrXTpQjpvKVfDpe58shxGHixOx2MwK50drK8ePG1GHd8oPb+Fz7G6zEf/S+lbpmENuTZGxeKeNZSEhwKe5YUuKmHRSJPgdinQ5aw/4eftUVJij2zDmEk1FBKHfFmnD+hp8VHsWiK0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605770; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=Hlav0XX3NPr1FT4pYDFfMvbVioz8jeon9JswRqEQx8sAB0nydQ1LCpXIdgO/azlZ2uJO6+nI1ohE7rA+9BKsxNiJP3ZpqhHEhHtsUv2mIFhslbn3Ii8t4Jo8Xl9O+4AUD2B1jXdEIYL+SsQdjxBDyWrpBnsL4kv7UgErCRUgBq4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156460577094057.40146915573632; Wed, 31 Jul 2019 13:42:50 -0700 (PDT) Received: from localhost ([::1]:44292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvQv-0004lM-Vz for importer@patchew.org; Wed, 31 Jul 2019 16:42:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60791) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMh-0004IW-Oq for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMg-0003OU-J2 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:27 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:46530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMg-0003NW-DL for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:26 -0400 Received: by mail-pf1-x444.google.com with SMTP id c3so9373544pfa.13 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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 :mime-version:content-transfer-encoding; bh=BmJBoz3ocCwfjPIQpLnVRF2wr3dk36b5G/HujhxQoNg=; b=Dq6i1Hs91zq16uGduehbgnzKRhAalaBIaKorKOpFS3H0qN/HcGntn1JbQwgg+s7Ew1 GqApdJQUGjWAxY/aMF00+P9eOlfn99eKYnNQ0sCAQ0KpVVUDXlWA5m/3TwR6jsxqt0Xj IQM7HjUKo8dWTW3mgc0mkxqQmTYr+yZ4jfBsGljgZ8K5KPvfyXP6ZhUc6k6uWgCKT3l0 /d6q2IGejlSyIrwYMz3R13QENJgCD3q2nwCdiFPhusW/aFArl8lIjzL/OHZv3PmlXN4N 7VRzrHfFj9fKlr/q3Y5cdzxzuJFL1Bnfu1bLTgWtjP6F/GhXJEJ32mGhFYUPXAPidLVz O+3Q== 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=H+V5UoRJhd5BX7ZrJPG5PhKL/fewUe+ENqtos0vVltNWUS6NTt6i5gwndr+qPuLQHL jJfqDAS35IzhJ74M6iWWnV0ieGANo1/Zls+lxRlpIzXBO3l7V+bzSyxV3GRaejwv1HOE jjPV5ggapY383TvnvVWOMJVJKCQ9fnhHJW+uZ+q3Fbgs2MnjpstLPEK9Adbhy9g1S/hY k5BPajgh81EIrjxgAlFEMD/oNuefiPHgpgB2Qaq8FzhoVpSoNJvqSfuQK2ygTxC8j2wQ /xh3zkwMszyiSK67jQrDUSdH0Yl5tlHzKORQxutL4TlB6dtxSLCoi51vf4JL+dzG4qUp 0WjA== X-Gm-Message-State: APjAAAUI/GTfbZB4SdBoojiRuvIY25LdskqOMRolVlr/N1LUvhnuoAmR XA29GUjLpgafJ9WvFwHmqE/7PPiWV2A= X-Google-Smtp-Source: APXvYqyCL2CMqPxgwL8CQNGuInvavMSrrVdR9gHFBtMu2xxN/27T3RG46re5lp2XLkfCb17S0cH4zA== X-Received: by 2002:a62:3895:: with SMTP id f143mr48675062pfa.116.1564605505099; Wed, 31 Jul 2019 13:38:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:49 -0700 Message-Id: <20190731203813.30765-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 08/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Richard Henderson --- target/arm/debug_helper.c | 50 +++++++++++++++++++++++++++++---------- target/arm/helper.c | 11 +++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) 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 =3D extract32(cpu->dbgdidr, 20, 4); int bt; uint32_t contextidr; + uint64_t hcr_el2; =20 /* * Links to unimplemented or non-context aware breakpoints are @@ -40,24 +41,44 @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) } =20 bt =3D 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 ASI= D), - * since we don't implement the optional v7 context ID masking. - */ - contextidr =3D extract64(env->cp15.contextidr_el[1], 0, 32); + hcr_el2 =3D arm_hcr_el2_eff(env); =20 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 =3D env->cp15.contextidr_el[2]; + break; + case 1: + contextidr =3D env->cp15.contextidr_el[1]; + break; + case 0: + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) =3D=3D (HCR_E2H | HCR_TGE)= ) { + contextidr =3D env->cp15.contextidr_el[2]; + } else { + contextidr =3D env->cp15.contextidr_el[1]; + } + break; } - return (contextidr =3D=3D extract64(env->cp15.dbgbvr[lbn], 0, 32)); - case 5: /* linked address mismatch (reserved in AArch64) */ + break; + + case 7: /* linked contextidr_el1 match */ + contextidr =3D env->cp15.contextidr_el[1]; + break; + case 13: /* linked contextidr_el2 match */ + contextidr =3D 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; } =20 - 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 ASI= D), + * since we don't implement the optional v7 context ID masking. + */ + return contextidr =3D=3D (uint32_t)env->cp15.dbgbvr[lbn]; } =20 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); } =20 + if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu= )) { + static const ARMCPRegInfo vhe_reginfo[] =3D { + { .name =3D "CONTEXTIDR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 13, .crm =3D 0, .opc2 =3D= 1, + .access =3D PL2_RW, + .fieldoffset =3D 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)) { --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605750; cv=none; d=zoho.com; s=zohoarc; b=haUKIHytHtUAcsY9xosmnS2C9wn6882yov3hw50aNjSzF3aa8WWoXLGmoRoN6MkGLSYIkykVvsHMKYzICJabmgH6wPa8wg/N/+K+8+Dhu7rhwZ5IsqmCxfEEqNdrnAzXaEL0Xa3BhopDi4eKzaD6q8KBpCbm+g1/CWHIe9rownk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605750; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=eXztB5+CPZYWvtJqCXCkkbobp/U8zAPLQueishTnE64=; b=QOFQPBAPj1/f5QK8aOF46rsRsuxIIjdyzif9fIR/CmVBibD1a1F7qKkeBgx6pkYmBNSsW/taZCLpTD6iuYfoa1/71fEmr4h++m524njnM3XNvjH+dTZ4GazZjUxkkQXkbCs3eTzZfNOAvsOzERw50T/8HRbZ+fF6VDF1TY63HWE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605750449566.8379848478224; Wed, 31 Jul 2019 13:42:30 -0700 (PDT) Received: from localhost ([::1]:44282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvQb-0003je-Gp for importer@patchew.org; Wed, 31 Jul 2019 16:42:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60816) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMi-0004Kn-Rh for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMh-0003Py-Pe for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:28 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:35180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMh-0003Of-KQ for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:27 -0400 Received: by mail-pf1-x442.google.com with SMTP id u14so32533404pfn.2 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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 :mime-version:content-transfer-encoding; bh=eXztB5+CPZYWvtJqCXCkkbobp/U8zAPLQueishTnE64=; b=YZBRaFRDeE/C9WJ9U7ACwGnFPRCpOoJFuqnM2lVJHxJ0dLtO/g5G9LOwwLdcIbIcVq V0rn35vxniVdiuN2orhSR+g/A51rIlfJQxrH2C+F0ec487jADOIrW8coX6bWTtSwK5A9 JJzFNRq1UfvEegm/Dsv/AB5WGHpwQb/anWBWBftgcNJqUOYjg5kZgCwxiXNG5aHQEqfq Pnd1W3VvS8+EwAkWdnsou3RCh9ARY3I/9XC92W8nltPmIvsz40pIu9Vr6cWtbRVdQDiu NzPpstQyYFlYi/xNxdXVpKyvlHir50JZGov4d7SJDjjmCb3giNYSQ79sxQBinKPqQ+H2 brqw== 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=XtOwnYS5ixCWQFiQzUt6ki+BsVog1lu0TtG4CT1WUsoPX1ysrf/ENKKK2X+YdrnqhG GWU9F/fGh370B9FgyNLPrkoL0RQWgfupPaf275irMYYuBVjSZb4bGrIRr08SZXPItQ89 oTTRKAjDW5YKD1yHvlEnBO01Gow9Ryfa4PWa5wOQ7IHfVNflQ9DjsR6wiPuKFmQSRINd cr0SpoDiJaI9TG3Xkf6v1OEKb8FJLij+g9o487ZiMLr8HgXsCC6qkITL0lWS6R+RIWxM toCsPvTjGskva+bJYwnuAXKohaYk+4ZGF5rNkmFnypaKJKw0tVSvv2k4F2bLdtTSs65N Crpg== X-Gm-Message-State: APjAAAU3LofUTmTZqxa3KSxquXvC+bugqkwtDD9FYFYut7ZFkgh1F304 VxPGbxHxpF36oDbqbksltBizcc+/L5c= X-Google-Smtp-Source: APXvYqydtT5ieHPuIhGsR9m+t2LPyIs+SxOF/gV8J0m2blMmbEMchISfMm4lgQHzmpzAPb0gxwebcQ== X-Received: by 2002:a17:90a:3086:: with SMTP id h6mr4877113pjb.14.1564605506348; Wed, 31 Jul 2019 13:38:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:50 -0700 Message-Id: <20190731203813.30765-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 09/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) At the same time, add writefn to TTBR0_EL2 and TCR_EL2. A later patch will update any ASID therein. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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, co= nst ARMCPRegInfo *ri, } } =20 +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[] =3D { .resetvalue =3D 0 }, { .name =3D "TCR_EL2", .state =3D ARM_CP_STATE_BOTH, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 0, .opc2 =3D 2, - .access =3D 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 =3D PL2_RW, .writefn =3D vmsa_tcr_ttbr_el2_write, + /* no .raw_writefn or .resetfn needed as we never use mask/base_mask= */ .fieldoffset =3D offsetof(CPUARMState, cp15.tcr_el[2]) }, { .name =3D "VTCR", .state =3D ARM_CP_STATE_AA32, .cp =3D 15, .opc1 =3D 4, .crn =3D 2, .crm =3D 1, .opc2 =3D 2, @@ -4881,7 +4885,7 @@ static const ARMCPRegInfo el2_cp_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, cp15.tpidr_el[2]) }, { .name =3D "TTBR0_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 0, .opc2 =3D 0, - .access =3D PL2_RW, .resetvalue =3D 0, + .access =3D PL2_RW, .resetvalue =3D 0, .writefn =3D vmsa_tcr_ttbr_el= 2_write, .fieldoffset =3D offsetof(CPUARMState, cp15.ttbr0_el[2]) }, { .name =3D "HTTBR", .cp =3D 15, .opc1 =3D 4, .crm =3D 2, .access =3D PL2_RW, .type =3D ARM_CP_64BIT | ARM_CP_ALIAS, @@ -6807,6 +6811,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 =3D 3, .opc1 =3D 4, .crn =3D 13, .crm =3D 0, .opc2 =3D= 1, .access =3D PL2_RW, .fieldoffset =3D offsetof(CPUARMState, cp15.contextidr_el[2]= ) }, + { .name =3D "TTBR1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 0, .opc2 =3D = 1, + .access =3D PL2_RW, .writefn =3D vmsa_tcr_ttbr_el2_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.ttbr1_el[2]) }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vhe_reginfo); --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605792; cv=none; d=zoho.com; s=zohoarc; b=D5y4mM/w9mXmulwJ3JSS6xwIdNxCTLFKb7Yfqv6YcIicFBYDmtdypVQ4s2VAiSCDQMJl0k0Qq2C+cRIn5neSjeyU/phYkrW9l6p+xmnWKT+qqGktW07AmctsUK6mOu6tT7KV50uRe7/LbdXEiv5naEM82StWUa4Udkhw+rtJ0lQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ebweW1bxG4mlr4zUkxD0Pv+fcpZzn603jNjjqkso5Rc=; b=QFbW+xdpLJiw/c8hnSzEPgnt19jI73XdKuXqlzAQd5u0AK60HEop9V7+vFgpY+WQpa9XIfsIbdC/bHv1hmBHwK/LLpLNgoOJsY9sEowrYP/HHvj2/KY0JzM9hSdF7SFjII62cXaT4neAcVKTKcFNLjC11hqMexrsrnG9agyZc5I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156460579246380.64397038353752; Wed, 31 Jul 2019 13:43:12 -0700 (PDT) Received: from localhost ([::1]:44300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvRH-0005tW-H8 for importer@patchew.org; Wed, 31 Jul 2019 16:43:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60842) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMk-0004PZ-4l for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMj-0003R5-5d for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:30 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:42596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMj-0003Qc-0J for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:29 -0400 Received: by mail-pg1-x542.google.com with SMTP id t132so32632425pgb.9 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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 :mime-version:content-transfer-encoding; bh=ebweW1bxG4mlr4zUkxD0Pv+fcpZzn603jNjjqkso5Rc=; b=Pd4FHlXVvd1NDlai2uvi/QThJmS6tM9qc8YQZhRRXPHzO/xGKv4PyTfytTx+FuzJGw 8vMOLE4mLSYhTlI9N+sVoOdsrBLamtj+EXgP+UI0WYyZ/+5LgzMwUgnziTwp2kGegI8V ZenC+sp7oFcVh713Ov6tWgN6zxk8h3UB24DfggXhtQTUP57LWiMsbBVhrnCknyVK1qh5 7ZeAIvsKW+e4BqdQQheZohhIRLftBqR0a8i4JKYeaU83Px/TdNaK/yOI4g1rGGjiDm6V hEeuvwi1VxTfJ5lcBVI+4bu/Wj0bry6xnF2Um0HQxOJdON+QyWgeMiZolQaUWwZax2Hp TUwg== 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=ESdtlkJ+2zMJpFp6ELuQQ5ArCHZK2uoElb+rgaFb/WJs7U6wTkK97vU7uvp+F3EJO+ dn/gUB9yxE3w7WowltgVNsn7Pd/15G61vIoC5wtVcqTSNkVsHqYqgQ1thORkYsaphmNp gPlqVSwFA0wnlAl9MRQA3yoAQo1/NW8FIlnQNi7YQinyg57jU/NSV2G5dLrgGSzlZ+ok tdSo32YU5didPBmuoyzjiCz09liC6eUCybHG1Hfl/PVr2li10/Hys95ly6eI5+ONCJEo p6dhGAp/xcaovG/k3lpK34W2gS/DgBfaP6TrGBizm0MsNGVvoQMNYw0eFdpEQw+JCilk o+WQ== X-Gm-Message-State: APjAAAUJHf9oaL9Nmd4SwHudebTgSrhkbT0lRNROGLH+MqZM+Im8MX4X 6hSItZ6xLuqtOBGNueXU9ND0dhzbu/I= X-Google-Smtp-Source: APXvYqzIpj1PYk8SZZchf81xB6FYstaT2805Ekm/aKloX7Cr22N30pDGchCcQmW19UGq4I0YnJ+QXQ== X-Received: by 2002:a63:f452:: with SMTP id p18mr89844584pgk.373.1564605507738; Wed, 31 Jul 2019 13:38:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:51 -0700 Message-Id: <20190731203813.30765-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 10/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The virtual offset may be 0 depending on EL, E2H and TGE. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) 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); } =20 +static uint64_t gt_virt_cnt_offset(CPUARMState *env) +{ + uint64_t hcr; + + switch (arm_current_el(env)) { + case 2: + hcr =3D arm_hcr_el2_eff(env); + if (hcr & HCR_E2H) { + return 0; + } + break; + case 0: + hcr =3D arm_hcr_el2_eff(env); + if ((hcr & (HCR_E2H | HCR_TGE)) =3D=3D (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); } =20 static void gt_cval_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -2501,7 +2523,13 @@ static void gt_cval_write(CPUARMState *env, const AR= MCPRegInfo *ri, static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, int timeridx) { - uint64_t offset =3D timeridx =3D=3D GTIMER_VIRT ? env->cp15.cntvoff_el= 2 : 0; + uint64_t offset =3D 0; + + switch (timeridx) { + case GTIMER_VIRT: + offset =3D gt_virt_cnt_offset(env); + break; + } =20 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 AR= MCPRegInfo *ri, int timeridx, uint64_t value) { - uint64_t offset =3D timeridx =3D=3D GTIMER_VIRT ? env->cp15.cntvoff_el= 2 : 0; + uint64_t offset =3D 0; + + switch (timeridx) { + case GTIMER_VIRT: + offset =3D gt_virt_cnt_offset(env); + break; + } =20 trace_arm_gt_tval_write(timeridx, value); env->cp15.c14_timer[timeridx].cval =3D gt_get_countervalue(env) - offs= et + --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605841; cv=none; d=zoho.com; s=zohoarc; b=AIGMhO4wDT4l5CflQzvgqZk/eCs19oSYWdLcGnDeRgy/xY+UDGAJc7CcJrbwhAJy5Xu/lMbSvaaBkZ29tt7PHV59c+mU765iycNz0QvCQHU/LkOfzqHh7Wo7yV+gdjvotdNBIcJ9g2cY8L72Q9i/fvW070K9CxeBsD+a+pu8cx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605841; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CFTl19ZF5edhUenxmEwmpn5Y/VYa/1WL6bwC0O5YAUU=; b=U7mVc5U6xmqvBxHmaOhMX7aEx1Hua0i/PsOBvySy554tHNJaAdJzP1H1/OH+RHM5aGbI3hvPr3pEYeK9WtBI+c/ahYrvdEpBbHrKzGmUJAT+YOiRyxEkZx6Hzs5ea6ej3HEnOXmMHl2LeE7nnbaG5Rg75UZV7JGO+vfGHwggiLA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605841096391.2429216982267; Wed, 31 Jul 2019 13:44:01 -0700 (PDT) Received: from localhost ([::1]:44320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvS4-0007DJ-6R for importer@patchew.org; Wed, 31 Jul 2019 16:44:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60867) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMl-0004WE-LW for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMk-0003SQ-DR for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:31 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:36177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMk-0003Rf-6C for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:30 -0400 Received: by mail-pf1-x442.google.com with SMTP id r7so32515298pfl.3 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:28 -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=CFTl19ZF5edhUenxmEwmpn5Y/VYa/1WL6bwC0O5YAUU=; b=amuUyuNwDci6gXi5XG1g/VwjnH2iPNi7yLWFwNScGq65RDwAoi1nJAx+bRS0q49EN5 oK8W2K/TN2nqy7CVzonuNVUM+JIITKfOG98/TCzvh0qNE/5HUHTEcKWDHY+FQxVCvYf3 B12VxhY/wLtFJj7v1fkdvPULody89gFCTh2UOaJ0cpDRbdLVrMb01o6/FeA2a+OgjPPA o+QTwKVmcBEfzSi6tcyetU2ubXGsd7xC7M1Km/POBvW4rvsa9hJYImXfTFTPIJWeSl4M RLDvQ3r5WBeYo1ZY8wZJbqKQ8Gy2XL8dk/5bYFMAXb9kW6zqdiUfSKPIBz5QYYKJ1cBY WHyA== 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=CFTl19ZF5edhUenxmEwmpn5Y/VYa/1WL6bwC0O5YAUU=; b=IH9dm9xvqnY7eVUBNfIOdkVhJI4nbhlI2sg+LCvm9BR+nmyS4d7gVDWfFDzI0IlD/a tuLbdBNbuhqHZ9A3yjitJyjgTl8Y+Gkee3jsx6rqQBGRPz7sSjeUzELPKyz57GXSxolj LKapKrMS7oWj/YqJt42RkM2JGpjuq2Y0uypmJjzYZF5M+6RkQnV2Od8ewqkeQbbrxi5a FojBTndSjxThByguzHhUKv5PO0ECd6tOywoUtnnWEZGf73Zkzuy8kAAyBjHYIFze9MTa U2AQjTlfBqQ+NwLCK/gZ6hSrcunaf7RyfQK+d1t3xKTCFsSvCQXWz/Nr1MbXDC6i4cKy MJVw== X-Gm-Message-State: APjAAAWEQqT/gln7hd91yS3U3vmQKSUQ2kYqrJIBo8PtC+8+/atM/YdJ Lxh8lpinfcLlpRjAkws2MYFe0ow5QBA= X-Google-Smtp-Source: APXvYqyGLOOxqQiryuyFxgUVwuW7mgaPqKiJOD2c2zGANGfK5om39sexJYEq4WObtiteKWKW8qlNng== X-Received: by 2002:a17:90a:2ec1:: with SMTP id h1mr4754846pjs.101.1564605508954; Wed, 31 Jul 2019 13:38:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:52 -0700 Message-Id: <20190731203813.30765-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 11/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Alex Benn=C3=A9e 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(-) 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); =20 #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; =20 -#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 =20 typedef struct { uint64_t raw_tcr; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 9eb40ff755..e10b510c0b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1218,6 +1218,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) arm_gt_htimer_cb, cpu); cpu->gt_timer[GTIMER_SEC] =3D timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCA= LE, arm_gt_stimer_cb, cpu); + cpu->gt_timer[GTIMER_HYPVIRT] =3D timer_new(QEMU_CLOCK_VIRTUAL, GTIMER= _SCALE, + arm_gt_hvtimer_cb, cpu); #endif =20 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, =20 switch (timeridx) { case GTIMER_VIRT: + case GTIMER_HYPVIRT: offset =3D gt_virt_cnt_offset(env); break; } @@ -2543,6 +2544,7 @@ static void gt_tval_write(CPUARMState *env, const ARM= CPRegInfo *ri, =20 switch (timeridx) { case GTIMER_VIRT: + case GTIMER_HYPVIRT: offset =3D 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); } =20 +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 =3D opaque; @@ -2726,6 +2756,13 @@ void arm_gt_stimer_cb(void *opaque) gt_recalc_timer(cpu, GTIMER_SEC); } =20 +void arm_gt_hvtimer_cb(void *opaque) +{ + ARMCPU *cpu =3D opaque; + + gt_recalc_timer(cpu, GTIMER_HYPVIRT); +} + static const ARMCPRegInfo generic_timer_cp_reginfo[] =3D { /* 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 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 0, .opc2 =3D = 1, .access =3D PL2_RW, .writefn =3D vmsa_tcr_ttbr_el2_write, .fieldoffset =3D offsetof(CPUARMState, cp15.ttbr1_el[2]) }, +#ifndef CONFIG_USER_ONLY + { .name =3D "CNTHV_CVAL_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 14, .crm =3D 3, .opc2 =3D= 2, + .fieldoffset =3D + offsetof(CPUARMState, cp15.c14_timer[GTIMER_HYPVIRT].cval), + .type =3D ARM_CP_IO, .access =3D PL2_RW, + .writefn =3D gt_hv_cval_write, .raw_writefn =3D raw_write }, + { .name =3D "CNTHV_TVAL_EL2", .state =3D ARM_CP_STATE_BOTH, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 14, .crm =3D 3, .opc2 =3D= 0, + .type =3D ARM_CP_NO_RAW | ARM_CP_IO, .access =3D PL2_RW, + .resetfn =3D gt_hv_timer_reset, + .readfn =3D gt_hv_tval_read, .writefn =3D gt_hv_tval_write }, + { .name =3D "CNTHV_CTL_EL2", .state =3D ARM_CP_STATE_BOTH, + .type =3D ARM_CP_IO, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 14, .crm =3D 3, .opc2 =3D= 1, + .access =3D PL2_RW, + .fieldoffset =3D + offsetof(CPUARMState, cp15.c14_timer[GTIMER_HYPVIRT].ctl), + .writefn =3D gt_hv_ctl_write, .raw_writefn =3D raw_write }, +#endif REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vhe_reginfo); --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605935; cv=none; d=zoho.com; s=zohoarc; b=f6lHoHYmxDmJf6vpNU40iL0K5TPDA3ICSY1jLKm6/8r+ZrURjUVNvBFVF1Cn8XjFuSgJtEqzNwgNNkDmLcnJrnr/uvYp0IDGlrvpuowiDcoeUvEX+ytTEQKxStsE2CXIX5yuZ1OINFCKzkNKo+14w657YVdS47HWaYhk5Djj8/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605935; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mRFuXKk2Gwl0/7zE7hzogtQkhwOwZ57w0oxCxJ+Y7Jc=; b=GnpG8HDUTNKPCZs0ioKdmmBsbLjStDZiIjL3lGX/7BblqHd9QgWwXcocbkr0n8+3nI+/8p5KKURFWVKtwdDktvfARDQaNOlc1BoWTW1qI3WKIDfUxqAwOBZqP3/0Tgw7x9LoyKNKCj4z4u/q3IIun7v70u0uxllsmZumc5rWGBE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605935436249.29544659858595; Wed, 31 Jul 2019 13:45:35 -0700 (PDT) Received: from localhost ([::1]:44360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvTa-0002Iv-Cv for importer@patchew.org; Wed, 31 Jul 2019 16:45:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60897) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMn-0004d9-MO for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMl-0003UA-SS for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:33 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:33855) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMl-0003TB-LH for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:31 -0400 Received: by mail-pf1-x443.google.com with SMTP id b13so32516048pfo.1 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=mRFuXKk2Gwl0/7zE7hzogtQkhwOwZ57w0oxCxJ+Y7Jc=; b=fGPtrJi5lMT5db66q3lUVogvy1stjLkaPyGvAtBruficEjFf1GvyrkRNhgkQl2/+Uy PytEwlEo6zjLNTsti/sxJCtyURJN1c/GHPruTRIM1qdfdeGgutEryRyGQzlFZf3pHqLg Ivkq3Qq+R8rFUk1KnhllUNqnojOcSoCOVLX7du2gD/3wM79ZmeOsXB2Wf0y3GtSDQALc GhobsRrQjPV5M+S6svitEK/ZjYtfMlEMiPYsUmhs+baG/X8wrbFaR6i3R+WEYrcHhMCs Wn9bbbjAM4C7USvW50fi5Q3F/jskctSNB5bIl4bqsgo4trJQTP8k6b3sLRTJoHx8CD9i 7Gqw== 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=eWWXuaPj9iwz5aT2Kfs7+b5BYHmE6LLAlOHJEq8wgfVv/gFW9aV0T8WJKdf4kAaP0s xz+NP09D4QaciTFwwJyneRu5gYxk2Stph44oQQeaUnyCE+rMmBL/DIhp9Xp/7uSzwGoi Zv6gpcoEsP5+WwHu/D/v+Q/17HTg7jTCtfLfvAlkk1IP2GVZnddQtd51k6WmKhGopxny b7kMIb9lqNq05IIj79lL5Em+8aiRorY1MJQ2OatzulDuj8tvAl9ZD/owEWcvLl1sJ7s1 g1WannuvAbiaXD1Q/lBQXHarYK8w41B/crPO2VRsRJSMCUCRrYCIKUcCgjKoekxW5Gyz Nx5A== X-Gm-Message-State: APjAAAU8TIe+xjWzivo8FPfzU66XYYSn0TxGMhOlrGuawhQM3uXy2YFx yqSvf12wid6fuhKKKHlZYxQAKMnW5eM= X-Google-Smtp-Source: APXvYqyhjZ5R+/B2YsiAszESP1POQNreO4Dns6HtEA1jSw4p0zZceg6blvW5kby/+CZe7bN6Hj4pxg== X-Received: by 2002:a65:610a:: with SMTP id z10mr115874511pgu.178.1564605510226; Wed, 31 Jul 2019 13:38:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:53 -0700 Message-Id: <20190731203813.30765-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 12/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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) */ =20 - /* Offsets of the secure and non-secure fields in CPUARMState for the - * register if it is banked. These fields are only used during the st= atic - * 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 expec= ted - * that both bank offsets are set when defining a banked register. Th= is - * 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; + }; + }; }; =20 /* 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[] =3D { REGINFO_SENTINEL }; =20 +#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) =3D=3D 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 =3D ri->opaque; + readfn =3D ri->readfn; + } else { + readfn =3D ri->orig_readfn; + } + if (readfn =3D=3D NULL) { + readfn =3D 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 =3D ri->opaque; + writefn =3D ri->writefn; + } else { + writefn =3D ri->orig_writefn; + } + if (writefn =3D=3D NULL) { + writefn =3D 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[] =3D { + { 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 =3D 0; i < ARRAY_SIZE(aliases); i++) { + const struct E2HAlias *a =3D &aliases[i]; + ARMCPRegInfo *src_reg, *dst_reg; + + if (a->feature && !a->feature(&cpu->isar)) { + continue; + } + + src_reg =3D g_hash_table_lookup(cpu->cp_regs, &a->src_key); + dst_reg =3D g_hash_table_lookup(cpu->cp_regs, &a->dst_key); + g_assert(src_reg !=3D NULL); + g_assert(dst_reg !=3D NULL); + + /* Cross-compare names to detect typos in the keys. */ + g_assert(strcmp(src_reg->name, a->src_name) =3D=3D 0); + g_assert(strcmp(dst_reg->name, a->dst_name) =3D=3D 0); + + /* None of the core system registers use opaque; we will. */ + g_assert(src_reg->opaque =3D=3D NULL); + + /* Create alias before redirection so we dup the right data. */ + if (a->new_key) { + ARMCPRegInfo *new_reg =3D g_memdup(src_reg, sizeof(ARMCPRegInf= o)); + uint32_t *new_key =3D g_memdup(&a->new_key, sizeof(uint32_t)); + bool ok; + + new_reg->name =3D a->new_name; + new_reg->type |=3D ARM_CP_ALIAS; + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ + new_reg->access &=3D 0xf0; + + ok =3D g_hash_table_insert(cpu->cp_regs, new_key, new_reg); + g_assert(ok); + } + + src_reg->opaque =3D dst_reg; + src_reg->orig_readfn =3D src_reg->readfn; + src_reg->orig_writefn =3D src_reg->writefn; + src_reg->readfn =3D el2_e2h_read; + src_reg->writefn =3D 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 } =20 void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606001; cv=none; d=zoho.com; s=zohoarc; b=STSK1mm4gRR0DNKoOjX0/cRJlyVTfyjOj1C7RmbfbkYqKwS8RmS6CUzoK0BE+cSB958UccQHXNZJqJ2Z9CnhqbCxTDeCtHCYIOtu8Pnh4ji4znR5YXeK77r1KGEPYDcTgHxJc4rPiskiKwZH7wrJQNEBucOqvDbiCiK7+nF4ZZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=h3dhwpfe86udFJHT5d1QRrLfJzUV39xxz0iIkIlTtJQ=; b=ZGhWGXiR5sB07sGxHvcImqOEAnNN4aqtWANP4ij5A8Nxl+W45q23JGIgjuK2IjSm7XpKIlzmUSKLuNENpBj6AQNNceNEFTOVLdiY5v5KPEbBG0EHxbMaXMKbkZjUiSUkYBJEfnLbM/+p7HFP4ahbN0Y1A8yMV2NWgM73pSBSN8k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606001617658.2557831450562; Wed, 31 Jul 2019 13:46:41 -0700 (PDT) Received: from localhost ([::1]:44388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvUe-0005no-N7 for importer@patchew.org; Wed, 31 Jul 2019 16:46:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60916) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMo-0004gb-Fx for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMn-0003Um-68 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:34 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:45315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMm-0003UL-VV for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:33 -0400 Received: by mail-pf1-x443.google.com with SMTP id r1so32508286pfq.12 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=h3dhwpfe86udFJHT5d1QRrLfJzUV39xxz0iIkIlTtJQ=; b=fEfOWxba8dUcw1YB9PkYIF7f0IZt3Jot9DSidbxSvrttwik89jhDybvAmE8VjvntkR mDhvbPtx9iN+Z9x0RjobWti4c2cp2cY8mDuDtAqKQ4WtW3WwgeUXoJYyL95HToYcRHrM Xsq6CJqvcgL+jwB0/QbDoMWfP85NCylb65BUO2s8jFH0TwOMeL0uv0ehHKDdjmjmkL9p ze0FDx8VuCQYQR0/twXL9eSoBsBgOWaRBgek75lmMDXYGekadt8wj0iKMPHEkJOnq5uq ecKpamJKT5bbCXFt1APD3TF4suID1yEE2tlK8d/YvA2ZNBLEFaYkifOJviGN09SzEvV6 IA3g== 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=IQqTGImmvvSsf360KnRltbdOiGWtGIXWqUdMALYWmI6bHc8R/dzxzT9rVWqqOKn2jR kpTt7sFWSTVv+HxT31xbbMBuKHCsAEBzS0e9vZrlqcaLlcklMHr3HJqLcJfXo5YnpxJn btUgWczDTy0yledKUWRmoQ2XoZKKkZfgdkZFQTY+VlhpRvaClaO3Yz35lXiSsbEQhPQR IrL/7ItVnTeG12APj9NkS0oLADYYxAI2VFFJCwJB5/jhBrFSyNLuwsb0Oyh1W91zM59k 7DkB+R4+jC4CvStejHjQXqXa2mKlJgvyELtcpqxVXbiUPhSWfi5ffl5PACy1p6CblwDX UUtg== X-Gm-Message-State: APjAAAWVY7OdSJtxye7fFbbKanW3n+w5iqpWyVYxfqxHTrtUhSRTBsQj feV6gXWahK3ibNuqly+eaeBdHgTwic4= X-Google-Smtp-Source: APXvYqzxWA7PoiKIGMQfA5MX/czSvkN8aHlzxQZ51Aq22HOdgfpUq2gXlCELt+djs6Adnmv1yOCUJw== X-Received: by 2002:a63:550d:: with SMTP id j13mr52857180pgb.173.1564605511637; Wed, 31 Jul 2019 13:38:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:54 -0700 Message-Id: <20190731203813.30765-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 13/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) No functional change, but unify code sequences. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 118 ++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 81 deletions(-) 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(CPUARMSta= te *env, * Page D4-1736 (DDI0487A.b) */ =20 +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 =3D env_cpu(env); - bool sec =3D arm_is_secure_below_el3(env); + int mask =3D vae1_tlbmask(env); =20 - 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); } =20 static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *= ri, uint64_t value) { CPUState *cs =3D env_cpu(env); + int mask =3D vae1_tlbmask(env); =20 if (tlb_force_broadcast(env)) { tlbi_aa64_vmalle1is_write(env, NULL, value); return; } =20 + 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; } } =20 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 =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D env_cpu(env); + int mask =3D vmalle1_tlbmask(env); =20 - 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); } =20 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 =3D env_cpu(env); - bool sec =3D arm_is_secure_below_el3(env); - bool has_el2 =3D arm_feature(env, ARM_FEATURE_EL2); + int mask =3D vmalle1_tlbmask(env); =20 - 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); } =20 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 *r= i, uint64_t value) { - ARMCPU *cpu =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); - bool sec =3D arm_is_secure_below_el3(env); + CPUState *cs =3D env_cpu(env); + int mask =3D vae1_tlbmask(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 - 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); } =20 static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4080,8 +4044,8 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, * since we don't support flush-for-specific-ASID-only or * flush-last-level-only. */ - ARMCPU *cpu =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D env_cpu(env); + int mask =3D vae1_tlbmask(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 if (tlb_force_broadcast(env)) { @@ -4089,15 +4053,7 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, return; } =20 - 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); } =20 static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *r= i, --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606070; cv=none; d=zoho.com; s=zohoarc; b=bdp1Vv9+fkDs1iRDxDRcL0u1HTjOSQl1J0sNf/9Ucp2U1UBTaAkx+VbZJjIKbDzut2b+toqJ5DrkVU7fMVF1LzJfH4iDK+R1Vt+D1+T1o/eJ6KpIgdDrbUiEach4kYvqaQkx+lRkvO6uCRrahBD3BE3/6shTPdsf8qeyLA/9Ris= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606070; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RHV3vStI8hqe3CeMRucY7WZ1UFpWZPYBbhdsWvPNW30=; b=af6BW+dBE2dVfoimOrk7eLSrWz/ZnCkntGX0l3Vmk/3U3CqE6umVwiBpXBWEFuMjeJG5tiphWrATixHB7HG0Ptq/nyRSpUSLdXuzIImGZE+yYnMsFQboj+VSiIxXDe1+bw5e29UW1euNRrF4ABcZVjrGqmJ2ItWy7EgRiL2Mz1w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606070624861.5954302101028; Wed, 31 Jul 2019 13:47:50 -0700 (PDT) Received: from localhost ([::1]:44412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvVl-00013L-LK for importer@patchew.org; Wed, 31 Jul 2019 16:47:49 -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 1hsvMp-0004iy-8b for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMo-0003VK-7R for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:35 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40497) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMo-0003Uv-2E for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:34 -0400 Received: by mail-pf1-x443.google.com with SMTP id p184so32509288pfp.7 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=RHV3vStI8hqe3CeMRucY7WZ1UFpWZPYBbhdsWvPNW30=; b=QWm4D6tIVVlCHNDWidhXBv3U+A7GuWyovfDIlJWkpWxjEGZJBP5am0SjFaoXk2ATrD e95MlhjOojiBHxxlx6AO7etV/0yRuB1DQesRzt0eDwuKlueXLG0n45AogMfs6im7YH9G pyZBdxPoArEG5YT0c0hH5q8swpTWofLTUdk01WHc+2SCW5/iAawesl/QOOhY7nOz/6b1 do4D1rkW5Y+EGNQBLANbDPWVBfibMol1BwM3ku5MZLiAagRTIR9Y1PxYL++Lsm4jkA// 0xkGFAPdTq8gnajI61cWS5WOdmIOu7PDBwfkPx2srm1Fvn5alrvnV4dPmVlJ4c1Kndrc exjA== 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=RM7ZK9rnpuzID7qv/3Y6XfWg1u1JCWme3YPItJpdoFAfZSUILcwue5OXeJS7DKJ21p fuFsJIN3yYYyQLoVT5UEoFrZ25Ml3iazpRUBcIi8pin+o+TL6jnOqTvJv6UaHWRa+tZy BGTORaUrJVpauhNc3OUr+gnPj8DcrLnRcnFszuK9AJcZtfCrnAoDU5KmNLkbZ7J3Wg2C YqGvjnGd1t3hERZUw/Nrhp6xpCYl1IfwaCVmabtqUW95m5He/Q7vLkJjsHfKNMsutN4b b1I+HlPzjnKToRiyxq/Mnw6YmGt922bqtkzWz46ojF+TkewDspnhbXUvKSsQ2momtf6w DZNA== X-Gm-Message-State: APjAAAU/mccsIIoOl8uv0DOVbEP1WpjWjUYbCE6BlLy3tl3SsCqpPuzZ taJPakZLvAuOt8xJGlDF+emoH9VFd1g= X-Google-Smtp-Source: APXvYqw1Pnr6Xw4hruHzabYkUdZFOSUsMarpt/euRbJpfwC1kyTDI5CmNtdCTxXN/pw7fQm3/2cNPw== X-Received: by 2002:a63:9c5:: with SMTP id 188mr80039525pgj.2.1564605512775; Wed, 31 Jul 2019 13:38:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:55 -0700 Message-Id: <20190731203813.30765-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 14/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 52 +++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 28 deletions(-) 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 ARM= CPRegInfo *ri, uint64_t value) { /* Invalidate all (TLBIALL) */ - ARMCPU *cpu =3D env_archcpu(env); + CPUState *cs =3D env_cpu(env); =20 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)); } =20 static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */ - ARMCPU *cpu =3D env_archcpu(env); + CPUState *cs =3D env_cpu(env); =20 + value &=3D 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); } =20 static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate by ASID (TLBIASID) */ - ARMCPU *cpu =3D env_archcpu(env); + CPUState *cs =3D env_cpu(env); =20 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)); } =20 static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Invalidate single entry by MVA, all ASIDs (TLBIMVAA) */ - ARMCPU *cpu =3D env_archcpu(env); + CPUState *cs =3D env_cpu(env); =20 + value &=3D 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); } =20 static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3923,11 +3921,10 @@ static void tlbi_aa64_vmalle1_write(CPUARMState *en= v, const ARMCPRegInfo *ri, int mask =3D vae1_tlbmask(env); =20 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); } =20 static int vmalle1_tlbmask(CPUARMState *env) @@ -4049,11 +4046,10 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, = const ARMCPRegInfo *ri, uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 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); } =20 static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *r= i, --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605925; cv=none; d=zoho.com; s=zohoarc; b=apj7BUj6K/sHh1HZVDDkDxYIqD9TSpBnz62qDFk4gMZHCfxQ5VAREjP1ym+Xqs0K0v5dKja8eJY6nAN7kANv7qOMepSXjc/yukAsdguhNOWo05y0xZcZgObD2nfPgNh1bYhluds66FWKdOLjEgz28dKllYc0TW5bxPdDjfzS1Xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605925; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=L2jEAM4PPhyK6Ibom5dDULaexJ8i3bjGCqHj/DqEM+k=; b=HzOE5bHF3C1W6mXlPhh2mBiYD8b/0P58NennYHJGSGhHapuc3O2YTi+/ZQ6QmU87joBxNa6G/h1wmNwxGgpbw3ShhoRK3z4pn9o3jIBDUiyOp0SKf6kikz8avIL56Al1BECAJ3ufEk2KKMef09Q5qlzFcn9mS833D/movcfTeu8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605925028299.67423397268976; Wed, 31 Jul 2019 13:45:25 -0700 (PDT) Received: from localhost ([::1]:44346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvTP-0001kI-T4 for importer@patchew.org; Wed, 31 Jul 2019 16:45:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60970) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMr-0004ny-4y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMp-0003Wa-Im for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:37 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:43908) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMp-0003Vs-B8 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:35 -0400 Received: by mail-pf1-x441.google.com with SMTP id i189so32518339pfg.10 for ; Wed, 31 Jul 2019 13:38:35 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=L2jEAM4PPhyK6Ibom5dDULaexJ8i3bjGCqHj/DqEM+k=; b=pFPGzUv+XpANzatykHte2BoXPFvKqdZkkCtKFkJHInAgFxspNEeoqlnC1WTfaISoaI r15bsxeyPvZhxRaK8XXvgCljrPe/hXx9cnkKMjEF5Xah5pjbXudPNfnTxNR/u2AumuhG 3Ws81xMxJdKSlwnVh6JS3X8f3pwWe6+seUFuJlVGon8tO7w0gix8LDAYcBexbgUs39sU ctGILn0k3uXH6RqqHAHPDeg45LSEUREe9zRcPnAMVvzujxulRQ5DuEzWGuQrvICyB8RO sC5ZhvSHZxGwkSPoZlYpgUTMxTFHJNmLJBNI9l40DLbwO48uijlwPU0XO1v6yy0xoA/P dz0A== 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=lCc6dj0yUm6cw90oHHD9i12f/M8+RbqtM5tiYQiYdz2aRPiMffv7U3LsQ5sKQNeaUO g5nkj4lVZQJhtDFM5L7N/VTGZpyPegkIDObJqz3dtJuIhe7tnjBNErQq5heequJNKgPm 0LGUFZVghxaGvwBV2/WBxw++AdgEASrTr9Bf2w6aF6SMWGZq734N8Ld8WEc+ue3SDdg0 ub3VRJeC413sVGRfUxWFsPkNmhIng/XIU8FLK1dqwveKENlKkgNGcVsjXAg2WXV8ivEy izsJ0s3YqXkttSp0OekycPLHz5kqGxZw8tryvK4eBtjwul/KkSiWJbu/r4KEEOzklDFK MKVg== X-Gm-Message-State: APjAAAWnnxqWa1U0xjCJWvixUPd2y08EHPJW4yM/mcZoWYqdbdIm2p+u Rfq5pVlwBY/51tjkuvewQQ4bp9XR7gk= X-Google-Smtp-Source: APXvYqwy3qjG7qVc+THMwNXFSkYPloTym7x+ameh4Re0ehIKFdw1/EZ4X43ITo+LMoHPseSBnScxgA== X-Received: by 2002:a63:fd57:: with SMTP id m23mr50313122pgj.204.1564605514021; Wed, 31 Jul 2019 13:38:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:56 -0700 Message-Id: <20190731203813.30765-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 15/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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, un= signed int excp_idx, #define ARM_MMU_IDX_COREIDX_MASK 0x7 =20 typedef enum ARMMMUIdx { - ARMMMUIdx_S12NSE0 =3D 0 | ARM_MMU_IDX_A, - ARMMMUIdx_S12NSE1 =3D 1 | ARM_MMU_IDX_A, + ARMMMUIdx_EL10_0 =3D 0 | ARM_MMU_IDX_A, + ARMMMUIdx_EL10_1 =3D 1 | ARM_MMU_IDX_A, ARMMMUIdx_S1E2 =3D 2 | ARM_MMU_IDX_A, ARMMMUIdx_S1E3 =3D 3 | ARM_MMU_IDX_A, ARMMMUIdx_S1SE0 =3D 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 =3D 1 << 0, - ARMMMUIdxBit_S12NSE1 =3D 1 << 1, + ARMMMUIdxBit_EL10_0 =3D 1 << 0, + ARMMMUIdxBit_EL10_1 =3D 1 << 1, ARMMMUIdxBit_S1E2 =3D 1 << 2, ARMMMUIdxBit_S1E3 =3D 1 << 3, ARMMMUIdxBit_S1SE0 =3D 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 AR= MCPRegInfo *ri, idxmask =3D ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; break; case ARM_CP_SECSTATE_NS: - idxmask =3D ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + idxmask =3D 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 =3D env_cpu(env); =20 tlb_flush_by_mmuidx(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | + ARMMMUIdxBit_EL10_1 | + ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_S2NS); } =20 @@ -693,8 +693,8 @@ static void tlbiall_nsnh_is_write(CPUARMState *env, con= st ARMCPRegInfo *ri, CPUState *cs =3D env_cpu(env); =20 tlb_flush_by_mmuidx_all_cpus_synced(cs, - ARMMMUIdxBit_S12NSE1 | - ARMMMUIdxBit_S12NSE0 | + ARMMMUIdxBit_EL10_1 | + ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_S2NS); } =20 @@ -3047,7 +3047,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64= _t value, format64 =3D arm_s1_regime_using_lpae_format(env, mmu_idx); =20 if (arm_feature(env, ARM_FEATURE_EL2)) { - if (mmu_idx =3D=3D ARMMMUIdx_S12NSE0 || mmu_idx =3D=3D ARMMMUI= dx_S12NSE1) { + if (mmu_idx =3D=3D ARMMMUIdx_EL10_0 || mmu_idx =3D=3D ARMMMUId= x_EL10_1) { format64 |=3D env->cp15.hcr_el2 & (HCR_VM | HCR_DC); } else { format64 |=3D arm_current_el(env) =3D=3D 2; @@ -3146,11 +3146,11 @@ static void ats_write(CPUARMState *env, const ARMCP= RegInfo *ri, uint64_t value) break; case 4: /* stage 1+2 NonSecure PL1: ATS12NSOPR, ATS12NSOPW */ - mmu_idx =3D ARMMMUIdx_S12NSE1; + mmu_idx =3D ARMMMUIdx_EL10_1; break; case 6: /* stage 1+2 NonSecure PL0: ATS12NSOUR, ATS12NSOUW */ - mmu_idx =3D ARMMMUIdx_S12NSE0; + mmu_idx =3D ARMMMUIdx_EL10_0; break; default: g_assert_not_reached(); @@ -3208,10 +3208,10 @@ static void ats_write64(CPUARMState *env, const ARM= CPRegInfo *ri, mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S1NSE0; break; case 4: /* AT S12E1R, AT S12E1W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_S12NSE1; + mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_EL10_1; break; case 6: /* AT S12E0R, AT S12E0W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S12NSE0; + mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_EL10_0; break; default: g_assert_not_reached(); @@ -3430,7 +3430,7 @@ static void update_lpae_el1_asid(CPUARMState *env, in= t secure) ttbr0 =3D env->cp15.ttbr0_ns; ttbr1 =3D env->cp15.ttbr1_ns; ttcr =3D env->cp15.tcr_el[1].raw_tcr; - idxmask =3D ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + idxmask =3D ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; break; default: g_assert_not_reached(); @@ -3540,10 +3540,10 @@ static void vttbr_write(CPUARMState *env, const ARM= CPRegInfo *ri, =20 /* * 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); } =20 static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] =3D { @@ -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; } } =20 @@ -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_S2= NS; } else { - return ARMMMUIdxBit_S12NSE1 | ARMMMUIdxBit_S12NSE0; + return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } } =20 @@ -8801,8 +8801,8 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMM= UIdx mmu_idx) */ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) { - if (mmu_idx =3D=3D ARMMMUIdx_S12NSE0 || mmu_idx =3D=3D ARMMMUIdx_S12NS= E1) { - mmu_idx +=3D (ARMMMUIdx_S1NSE0 - ARMMMUIdx_S12NSE0); + if (mmu_idx =3D=3D ARMMMUIdx_EL10_0 || mmu_idx =3D=3D ARMMMUIdx_EL10_1= ) { + mmu_idx +=3D (ARMMMUIdx_S1NSE0 - ARMMMUIdx_EL10_0); } return mmu_idx; } @@ -8845,8 +8845,8 @@ static inline bool regime_is_user(CPUARMState *env, A= RMMMUIdx 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 a= ddress, target_ulong *page_size, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) { - if (mmu_idx =3D=3D ARMMMUIdx_S12NSE0 || mmu_idx =3D=3D ARMMMUIdx_S12NS= E1) { + if (mmu_idx =3D=3D ARMMMUIdx_EL10_0 || mmu_idx =3D=3D 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; } } =20 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; =20 switch (s->mmu_idx) { - case ARMMMUIdx_S12NSE1: - useridx =3D ARMMMUIdx_S12NSE0; + case ARMMMUIdx_EL10_1: + useridx =3D ARMMMUIdx_EL10_0; break; case ARMMMUIdx_S1SE1: useridx =3D 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: --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605992; cv=none; d=zoho.com; s=zohoarc; b=NQv/GeDAuYroAzYJGRdVeUxemszc+/M3YTd7mT6WkBL4tiCRg5d2Ww1zePuMFMZwdSiWe42sXtzuuPgdnlks95T6RQXXkBBrym+5ereIea1TsbMFSuYXiNgcdoFxzQIAR5Cbnoz29GPenREEoErUtQBVFj6BjbH0q+rAtbA0Jps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605992; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=la7qxtvs05jrNqcA9h6vjUFPOQjXr0T0i1pOh4sumx8=; b=fTrPCCAQCdS/mU6ybO7wjifdl0e2/euHHBbjwX3W+5QzjnsKA70f55Blon6pAqlPUk/78f2GW9UhOWpRqk/rCp3rfDf4GimOEr80bHw/jDfkCO309j2fFEFm0qJWJhXtrhqcCgDY5mV9KMYTdLLZY3aJNzW7o9iax9dbFOiIe7c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605992177673.1929203042181; Wed, 31 Jul 2019 13:46:32 -0700 (PDT) Received: from localhost ([::1]:44382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvUV-0005Go-5p for importer@patchew.org; Wed, 31 Jul 2019 16:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32768) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMs-0004st-OY for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMq-0003Xf-So for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:38 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:46802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMq-0003X1-LL for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:36 -0400 Received: by mail-pg1-x544.google.com with SMTP id k189so13598196pgk.13 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=la7qxtvs05jrNqcA9h6vjUFPOQjXr0T0i1pOh4sumx8=; b=LrErQ68BK+vduNZLkGSyaZby8VDGk8wOmjljuOaqhRubX1ZNKIaz5KOUkKB/O7z++/ VlHCvrqM4k5dOuTg94iqEnVu5ct4fTG2eqjhpgXbISJ4kZCpvMfHWxVJpFMPFPs4gnt2 8ECs/B7RDPBCyM5Dpx1jUcDPwAgj8EYs0b2qbnm2ihp03yK95Jjbo6f7ct005b2/qqqK 4EcRXZQ5mvh/paKFJ5NqqM4LZQIbUYadGlGRBdpHjfb5J4V7nQarpzPRDxC7KxAZbN45 FCZ7YsZcouTpNNPX67FTKwdNhV5BjRF7jjfwCLefz1F2uLBrOsxTRsju8IHi4takodT/ hGVw== 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=rsIiVWJKiyv3OkjJB2wRWD59HdXDo1UHeowb65J0tUzQjYH1xj/7o81oOgumRbOzFh hvpZh84zjtz0uK12uwILlUIaYNn5Qt6415iKAdLatp1i3fw2Ps/U2PCtWDd7FRHC9sMt kD2nBqkTMOSjhsfq0PPD8mfZn/0a+bRSXKtGgTXPlp134twKt/F5/RZTJjSaogsXAeqI ioUAkdSbqAj71iVQBSfSCkx/OKDZsfhXu+NYYGHIp3/LClhBjwrlyk6TISepQ29Wy44Y uluPS4kBGaguTmIIHTh6pafYNk+NgCyCGjgMfLo5lP/vwqypSchoIuJvF6wLwo3UaXME rNag== X-Gm-Message-State: APjAAAXz4pXwi9nz0PU4Sfnxpu3ZsZKSKR38opWzhRx5BkyX9r3qlHvU g1PtgSFknZg5dRGUEqdINIhWBVCX8KE= X-Google-Smtp-Source: APXvYqxvmbGqNWP/1YrWKb74xuGco4kv/54CFOlJbvYzGw36TGmfE6OvjqNYlFU0x6Lt9qTzUS0O0w== X-Received: by 2002:a63:e54f:: with SMTP id z15mr115016323pgj.4.1564605515275; Wed, 31 Jul 2019 13:38:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:57 -0700 Message-Id: <20190731203813.30765-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::544 Subject: [Qemu-devel] [PATCH v2 16/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 3 | ARM_MMU_IDX_A, ARMMMUIdx_S1SE0 =3D 4 | ARM_MMU_IDX_A, ARMMMUIdx_S1SE1 =3D 5 | ARM_MMU_IDX_A, - ARMMMUIdx_S2NS =3D 6 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2 =3D 6 | ARM_MMU_IDX_A, ARMMMUIdx_MUser =3D 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv =3D 1 | ARM_MMU_IDX_M, ARMMMUIdx_MUserNegPri =3D 2 | ARM_MMU_IDX_M, @@ -2882,7 +2882,7 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_S1E3 =3D 1 << 3, ARMMMUIdxBit_S1SE0 =3D 1 << 4, ARMMMUIdxBit_S1SE1 =3D 1 << 5, - ARMMMUIdxBit_S2NS =3D 1 << 6, + ARMMMUIdxBit_Stage2 =3D 1 << 6, ARMMMUIdxBit_MUser =3D 1 << 0, ARMMMUIdxBit_MPriv =3D 1 << 1, ARMMMUIdxBit_MUserNegPri =3D 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, A= RMMMUIdx 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); } =20 static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -695,7 +695,7 @@ static void tlbiall_nsnh_is_write(CPUARMState *env, con= st ARMCPRegInfo *ri, tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } =20 static void tlbiipas2_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -716,7 +716,7 @@ static void tlbiipas2_write(CPUARMState *env, const ARM= CPRegInfo *ri, =20 pageaddr =3D sextract64(value << 12, 0, 40); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S2NS); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2); } =20 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 =3D sextract64(value << 12, 0, 40); =20 tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } =20 static void tlbiall_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -3539,10 +3539,10 @@ static void vttbr_write(CPUARMState *env, const ARM= CPRegInfo *ri, vmid =3D extract64(value, 48, 8); =20 /* - * 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); } =20 @@ -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_S2= NS; + return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_St= age2; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } @@ -4091,7 +4091,7 @@ static void tlbi_aa64_ipas2e1_write(CPUARMState *env,= const ARMCPRegInfo *ri, =20 pageaddr =3D sextract64(value << 12, 0, 48); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S2NS); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2); } =20 static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo= *ri, @@ -4107,7 +4107,7 @@ static void tlbi_aa64_ipas2e1is_write(CPUARMState *en= v, const ARMCPRegInfo *ri, pageaddr =3D sextract64(value << 12, 0, 48); =20 tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S2NS); + ARMMMUIdxBit_Stage2); } =20 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(CPUARM= State *env, } } =20 - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { /* HCR.DC means HCR.VM behaves as 1 */ return (env->cp15.hcr_el2 & (HCR_DC | HCR_VM)) =3D=3D 0; } @@ -8775,7 +8775,7 @@ static inline bool regime_translation_big_endian(CPUA= RMState *env, static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) { - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { return env->cp15.vttbr_el2; } if (ttbrn =3D=3D 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 =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D 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 =3D 0; =20 - assert(mmu_idx !=3D ARMMMUIdx_S2NS); + assert(mmu_idx !=3D ARMMMUIdx_Stage2); =20 user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); if (is_user) { @@ -9069,7 +9069,7 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMM= MUIdx mmu_idx, ARMMMUFaultInfo *fi) { if ((mmu_idx =3D=3D ARMMMUIdx_S1NSE0 || mmu_idx =3D=3D ARMMMUIdx_S1NSE= 1) && - !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, ARMM= MUIdx mmu_idx, pcacheattrs =3D &cacheattrs; } =20 - ret =3D get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa, + ret =3D get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_Stage2, &s2pa, &txattrs, &s2prot, &s2size, fi, pcacheatt= rs); if (ret) { assert(fi->type !=3D ARMFault_None); @@ -9558,7 +9558,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *= env, uint64_t va, tsz =3D extract32(tcr, 0, 6); using64k =3D extract32(tcr, 14, 1); using16k =3D extract32(tcr, 15, 1); - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { /* VTCR_EL2 */ tbi =3D tbid =3D hpd =3D false; } else { @@ -9619,7 +9619,7 @@ static ARMVAParameters aa32_va_parameters(CPUARMState= *env, uint32_t va, int select, tsz; bool epd, hpd; =20 - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { /* VTCR */ bool sext =3D extract32(tcr, 4, 1); bool sign =3D extract32(tcr, 3, 1); @@ -9721,7 +9721,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, targ= et_ulong address, level =3D 1; /* There is no TTBR1 for EL2 */ ttbr1_valid =3D (el !=3D 2); - addrsize =3D (mmu_idx =3D=3D ARMMMUIdx_S2NS ? 40 : 32); + addrsize =3D (mmu_idx =3D=3D ARMMMUIdx_Stage2 ? 40 : 32); inputsize =3D addrsize - param.tsz; } =20 @@ -9772,7 +9772,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, targ= et_ulong address, goto do_fault; } =20 - if (mmu_idx !=3D ARMMMUIdx_S2NS) { + if (mmu_idx !=3D ARMMMUIdx_Stage2) { /* The starting level depends on the virtual address size (which c= an * 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, targ= et_ulong address, attrs =3D extract64(descriptor, 2, 10) | (extract64(descriptor, 52, 12) << 10); =20 - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { /* Stage 2 table descriptors do not include any attribute fiel= ds */ break; } @@ -9903,7 +9903,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, targ= et_ulong address, ap =3D extract32(attrs, 4, 2); xn =3D extract32(attrs, 12, 1); =20 - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { ns =3D true; *prot =3D get_S2prot(env, ap, xn); } else { @@ -9930,7 +9930,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, targ= et_ulong address, } =20 if (cacheattrs !=3D NULL) { - if (mmu_idx =3D=3D ARMMMUIdx_S2NS) { + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { cacheattrs->attrs =3D convert_stage2_attrs(env, extract32(attrs, 0, 4= )); } else { @@ -9951,7 +9951,7 @@ do_fault: fi->type =3D fault_type; fi->level =3D level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 =3D fi->s1ptw || (mmu_idx =3D=3D ARMMMUIdx_S2NS); + fi->stage2 =3D fi->s1ptw || (mmu_idx =3D=3D ARMMMUIdx_Stage2); return true; } =20 @@ -10765,13 +10765,13 @@ bool get_phys_addr(CPUARMState *env, target_ulong= address, prot, page_size, fi, cacheattrs); =20 /* 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 =3D ipa; return ret; } =20 /* S1 is done. Now do S2 translation. */ - ret =3D get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_S2= NS, + ret =3D get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_St= age2, phys_ptr, attrs, &s2_prot, page_size, fi, cacheattrs !=3D NULL ? &cacheattrs2 := NULL); @@ -10813,7 +10813,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong a= ddress, /* 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 !=3D ARMMMUIdx_S2NS + if (address < 0x02000000 && mmu_idx !=3D ARMMMUIdx_Stage2 && !arm_feature(env, ARM_FEATURE_V8)) { if (regime_el(env, mmu_idx) =3D=3D 3) { address +=3D 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 =3D ARMMMUIdx_S1SE0; break; - case ARMMMUIdx_S2NS: + case ARMMMUIdx_Stage2: g_assert_not_reached(); default: useridx =3D 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(); } --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605904; cv=none; d=zoho.com; s=zohoarc; b=MrUVRvI0TJ2XE13OvBO7nKH6NZQ+ZwlWLRobGNlomX1Oc6BTv0KaTeMrbvGLOvBnbd+202PmElSd+1/CNJ3qmyi4N8O1pebMVdvDXo4jpWvtgvdhbWmwyd3VQs1luinf9XGKtAoCl3jKyDZHmnSJpivi7OnA/OI6yImtnhddrzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605904; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VjzDc7lTBTDRBT8iLvPhCchzYrLI8WxMxxlUTCAkZXM=; b=X/KqmKtuSyk24N73LfqOyx7f9/V+CmPyohrUsmfz3FQDEjL8Pxw6DJuDVehHdIjS5o7bpYlmtTZv7NxO/4dIt8pR2K3JptV/VyzheFsfl3dWiw44dnhKWNLHUwgROvodTWbnceVbFq3LpmIBIpf2Swtcu24rVDSYOgDPgMytT4I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605904344176.8177126624854; Wed, 31 Jul 2019 13:45:04 -0700 (PDT) Received: from localhost ([::1]:44344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvT2-0001Eh-1r for importer@patchew.org; Wed, 31 Jul 2019 16:45:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32786) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMt-0004uz-EJ for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMs-0003YS-5C for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:39 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:46530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMr-0003YC-Ve for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:38 -0400 Received: by mail-pf1-x442.google.com with SMTP id c3so9373793pfa.13 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:36 -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=yPTd0O7fRJX3oN/NIk1KJXpMXKNUSUieojMA6sirH87WzI0hLAImW/7xL6AAADqdGj rpCbee1zgVQHL0x4O6SWurc2E7M8vyiXRrD/XH+fKl7EY19JDbMCPP+HjsMa3UqjpevD ceDIHyrTIvQ728fqiyNHc4NAlNtS1Mr4z43dIU9wHC5xgCithjZ9DCXeeidAAuqfFlwg Ztm4xIfvWWnH9wMN09ws2TrENC3djDwlhFmPcULTIm2APPYy4w7Nnsg34oPLnA5uvpE9 xhOPFM1j2+6xZ7/zKa2lkTXcawHqmptADbus7fN3ItMJgnSqt+v3WXkVYXYK82d3YAc2 oH+g== 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=rysktvuW9EfG0ybGhX4+uxSxygm1mfhMQPtX7TA98Mic6/dHPleOhNqe7qwjHOMgt2 JluB3rvyLuMPyN+mnL1tF/PgSYUiyk5Xu7WtAfJIyHdn1hBa1LT1uGCx3zgzVe1N2T9o NvOd9sT3YiRBd/Xzvlahm5jkqOsffKPF1+mxDveuVyvC8zKK2AhlyjeXDGVDd+LBWJF1 zHje/EbK1SwnMq/+OT4VcjQXD4KV4E4vFsHuWcmEYM3MyCLs68WSXyxiTLPww+EWpfds mL/stutgBmgAXFIEPwQLC3HPeDfZ0sxz3i5mQXMw7UFRk380lpWPukcby7qapJPgcpV7 /L2Q== X-Gm-Message-State: APjAAAWt6Yk72V396Qu2a5TB9+Pgmpjg3kg9ZWaRsjwN6B+5AJeMsMQn thG1aSMw+16bUTfx3GGdmnss+vIOEVg= X-Google-Smtp-Source: APXvYqwtt/1l8XbKy48xMPFLe7idgZ+sYP8DqXL3C0cpLNiyTW2ESxSsNJwMtK8WcXNgBtcaMpacUQ== X-Received: by 2002:a17:90a:2343:: with SMTP id f61mr4805864pje.130.1564605516716; Wed, 31 Jul 2019 13:38:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:58 -0700 Message-Id: <20190731203813.30765-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::442 Subject: [Qemu-devel] [PATCH v2 17/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 0 | ARM_MMU_IDX_NOTLB, - ARMMMUIdx_S1NSE1 =3D 1 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E0 =3D 0 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1 =3D 1 | ARM_MMU_IDX_NOTLB, } ARMMMUIdx; =20 /* 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, A= RMMMUIdx 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 ARMCP= RegInfo *ri, uint64_t value) mmu_idx =3D ARMMMUIdx_S1E3; break; case 2: - mmu_idx =3D ARMMMUIdx_S1NSE1; + mmu_idx =3D ARMMMUIdx_Stage1_E1; break; case 1: - mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_S1NSE1; + mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; break; default: g_assert_not_reached(); @@ -3135,10 +3135,10 @@ static void ats_write(CPUARMState *env, const ARMCP= RegInfo *ri, uint64_t value) mmu_idx =3D ARMMMUIdx_S1SE0; break; case 2: - mmu_idx =3D ARMMMUIdx_S1NSE0; + mmu_idx =3D ARMMMUIdx_Stage1_E0; break; case 1: - mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S1NSE0; + mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; break; default: g_assert_not_reached(); @@ -3192,7 +3192,7 @@ static void ats_write64(CPUARMState *env, const ARMCP= RegInfo *ri, case 0: switch (ri->opc1) { case 0: /* AT S1E1R, AT S1E1W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_S1NSE1; + mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; break; case 4: /* AT S1E2R, AT S1E2W */ mmu_idx =3D ARMMMUIdx_S1E2; @@ -3205,7 +3205,7 @@ static void ats_write64(CPUARMState *env, const ARMCP= RegInfo *ri, } break; case 2: /* AT S1E0R, AT S1E0W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_S1NSE0; + mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; break; case 4: /* AT S12E1R, AT S12E1W */ mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_EL10_1; @@ -8698,8 +8698,8 @@ static inline uint32_t regime_el(CPUARMState *env, AR= MMMUIdx 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(CPUARM= State *env, } =20 if ((env->cp15.hcr_el2 & HCR_DC) && - (mmu_idx =3D=3D ARMMMUIdx_S1NSE0 || mmu_idx =3D=3D ARMMMUIdx_S1NSE= 1)) { + (mmu_idx =3D=3D ARMMMUIdx_Stage1_E0 || mmu_idx =3D=3D ARMMMUIdx_St= age1_E1)) { /* HCR.DC means SCTLR_EL1.M behaves as 0 */ return true; } @@ -8802,7 +8802,7 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMM= UIdx mmu_idx) static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) { if (mmu_idx =3D=3D ARMMMUIdx_EL10_0 || mmu_idx =3D=3D ARMMMUIdx_EL10_1= ) { - mmu_idx +=3D (ARMMMUIdx_S1NSE0 - ARMMMUIdx_EL10_0); + mmu_idx +=3D (ARMMMUIdx_Stage1_E0 - ARMMMUIdx_EL10_0); } return mmu_idx; } @@ -8837,7 +8837,7 @@ static inline bool regime_is_user(CPUARMState *env, A= RMMMUIdx 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, ARMM= MUIdx mmu_idx, hwaddr addr, MemTxAttrs txattrs, ARMMMUFaultInfo *fi) { - if ((mmu_idx =3D=3D ARMMMUIdx_S1NSE0 || mmu_idx =3D=3D ARMMMUIdx_S1NSE= 1) && + if ((mmu_idx =3D=3D ARMMMUIdx_Stage1_E0 || mmu_idx =3D=3D ARMMMUIdx_St= age1_E1) && !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { target_ulong s2size; hwaddr s2pa; --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606057; cv=none; d=zoho.com; s=zohoarc; b=Ba9fboh3onLvXaK9SRaiXw7AV7L3aRUDOA1fI8s5UXnR787kHgM4MDJHnJBOc3WjDZSobn4sTIq8Y5OYMeXbZKj3mWgnDAafSLIKUjRIpSYlOoZVbdYXKbTl9qbQf3VN2GcFfwxKCUR4PMDaUega6bUaEqLAh7edtPqBta8iyEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606057; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=w216qTj/BYqjTL2Y/6Uaoyzbe1vK0P5jhQZ1rUoxx+c=; b=StG/GuBWssYJJBba2BNPS04XpeF0DbIAuvDtQkUpCaPhgDHiqBO/QXthvgLdy1KWefsMgP5LJkAfdwlbUobVjL/xfkxzan2gYnFXUndLTfwvnfG4jQZTC31SyZ+wZvlApUWqps8SJ7iJcmrnKuTr6JhIKqp3GaBcRv+s0n+9QzA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606057467460.49117368026214; Wed, 31 Jul 2019 13:47:37 -0700 (PDT) Received: from localhost ([::1]:44410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvVY-0000Wl-Gw for importer@patchew.org; Wed, 31 Jul 2019 16:47:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32824) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMu-0004y6-PQ for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMt-0003Zm-AS for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:40 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMt-0003Z2-3L for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:39 -0400 Received: by mail-pf1-x443.google.com with SMTP id y15so32523189pfn.5 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=w216qTj/BYqjTL2Y/6Uaoyzbe1vK0P5jhQZ1rUoxx+c=; b=bFowufDLex3H542SkfQ/bQfosy6tn/Ojv7bEXbY1EhtXRJAI0Yag/bDa1cTuPTKsUq LD7aOQuSu/jBfGclXdekQzO7eqIfz1wPJ91ienNMn66WTSe4irTJct2M5WXU797+Qo6Y i1Y8hhktqRE56EVYsqVrkmLd+BnsSWbHGqilQRWkOL9+egErfjUpPo+kOPtZM9eTGj5J heqdcvAU48DMFyWeHjeFHCXRd+OOBfICYus7b2ZpSoIvq8UZ20CTqxXYHZpwxY9uNEVG QwDzM3ZbPJxF7iL4oA6wXOtyzf7j4Fjb4qUNd+nf0dXD8onxc0rP9hLXzbQnEUSLp+/m +ZgQ== 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=E+3wKyfh17oFW8DNREcf5M94pLri1XwU3fMp5lZ/fmHdN638cwnRZGKmZZUULNZ9Z2 PqQcSZXX7vpdiNLYT8PQCwM7URoxmPdQKgBUZ/uMEVgkAwsRz0IgoR5y4PTlAyzSt21K E5lbSNx1Gkq223O4hxa3o0LWTa3k/g425fw5kfVBxsl1BSwP0i2cAjdvFNHLpLhGSxnA 3gpzzKzm7LVYHc/7b8CNAAjWzBSA6u912y2Lfu0xRw2MFYo2sL0rSxzwUArQQnav4JGg xxRqqjp8JQeB6qrUQGf/v0xtPe1gmgWsyTiyb30ek56hpTVo0C1iF90HbvoREsLhNNAq X6Yg== X-Gm-Message-State: APjAAAXjRVbXOS1XLb7Mba72efWhmHgIs7thzAWOU+L78odsezaxTRaE NSundOC9wSijkQv+CaLpGuA6xETWUf4= X-Google-Smtp-Source: APXvYqxOKj1em8qaxP4nENdgwpqNQLtSy2kyj09wLKnKozdmiiBMFB86q6HXPLNEXDoLR1HWjB0siw== X-Received: by 2002:a17:90a:d343:: with SMTP id i3mr4902091pjx.15.1564605517824; Wed, 31 Jul 2019 13:38:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:37:59 -0700 Message-Id: <20190731203813.30765-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 18/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 1 | ARM_MMU_IDX_A, ARMMMUIdx_S1E2 =3D 2 | ARM_MMU_IDX_A, ARMMMUIdx_S1E3 =3D 3 | ARM_MMU_IDX_A, - ARMMMUIdx_S1SE0 =3D 4 | ARM_MMU_IDX_A, - ARMMMUIdx_S1SE1 =3D 5 | ARM_MMU_IDX_A, + ARMMMUIdx_SE0 =3D 4 | ARM_MMU_IDX_A, + ARMMMUIdx_SE1 =3D 5 | ARM_MMU_IDX_A, ARMMMUIdx_Stage2 =3D 6 | ARM_MMU_IDX_A, ARMMMUIdx_MUser =3D 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv =3D 1 | ARM_MMU_IDX_M, @@ -2880,8 +2880,8 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_EL10_1 =3D 1 << 1, ARMMMUIdxBit_S1E2 =3D 1 << 2, ARMMMUIdxBit_S1E3 =3D 1 << 3, - ARMMMUIdxBit_S1SE0 =3D 1 << 4, - ARMMMUIdxBit_S1SE1 =3D 1 << 5, + ARMMMUIdxBit_SE0 =3D 1 << 4, + ARMMMUIdxBit_SE1 =3D 1 << 5, ARMMMUIdxBit_Stage2 =3D 1 << 6, ARMMMUIdxBit_MUser =3D 1 << 0, ARMMMUIdxBit_MPriv =3D 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, A= RMMMUIdx 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 high= er of * 1 or the current EL. */ - return (s->mmu_idx =3D=3D ARMMMUIdx_S1SE0 && s->secure_routed_to_el3) + return (s->mmu_idx =3D=3D ARMMMUIdx_SE0 && s->secure_routed_to_el3) ? 3 : MAX(1, s->current_el); } =20 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 AR= MCPRegInfo *ri, =20 switch (ri->secure) { case ARM_CP_SECSTATE_S: - idxmask =3D ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0; + idxmask =3D ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; break; case ARM_CP_SECSTATE_NS: idxmask =3D ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; @@ -3122,7 +3122,7 @@ static void ats_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) mmu_idx =3D ARMMMUIdx_Stage1_E1; break; case 1: - mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; + mmu_idx =3D secure ? ARMMMUIdx_SE1 : ARMMMUIdx_Stage1_E1; break; default: g_assert_not_reached(); @@ -3132,13 +3132,13 @@ static void ats_write(CPUARMState *env, const ARMCP= RegInfo *ri, uint64_t value) /* stage 1 current state PL0: ATS1CUR, ATS1CUW */ switch (el) { case 3: - mmu_idx =3D ARMMMUIdx_S1SE0; + mmu_idx =3D ARMMMUIdx_SE0; break; case 2: mmu_idx =3D ARMMMUIdx_Stage1_E0; break; case 1: - mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; + mmu_idx =3D secure ? ARMMMUIdx_SE0 : ARMMMUIdx_Stage1_E0; break; default: g_assert_not_reached(); @@ -3192,7 +3192,7 @@ static void ats_write64(CPUARMState *env, const ARMCP= RegInfo *ri, case 0: switch (ri->opc1) { case 0: /* AT S1E1R, AT S1E1W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_Stage1_E1; + mmu_idx =3D secure ? ARMMMUIdx_SE1 : ARMMMUIdx_Stage1_E1; break; case 4: /* AT S1E2R, AT S1E2W */ mmu_idx =3D ARMMMUIdx_S1E2; @@ -3205,13 +3205,13 @@ static void ats_write64(CPUARMState *env, const ARM= CPRegInfo *ri, } break; case 2: /* AT S1E0R, AT S1E0W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_Stage1_E0; + mmu_idx =3D secure ? ARMMMUIdx_SE0 : ARMMMUIdx_Stage1_E0; break; case 4: /* AT S12E1R, AT S12E1W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE1 : ARMMMUIdx_EL10_1; + mmu_idx =3D secure ? ARMMMUIdx_SE1 : ARMMMUIdx_EL10_1; break; case 6: /* AT S12E0R, AT S12E0W */ - mmu_idx =3D secure ? ARMMMUIdx_S1SE0 : ARMMMUIdx_EL10_0; + mmu_idx =3D secure ? ARMMMUIdx_SE0 : ARMMMUIdx_EL10_0; break; default: g_assert_not_reached(); @@ -3424,7 +3424,7 @@ static void update_lpae_el1_asid(CPUARMState *env, in= t secure) ttcr =3D env->cp15.tcr_el[3].raw_tcr; /* Note that cp15.ttbr0_s =3D=3D cp15.ttbr0_el[3], so S1E3 is affe= cted. */ /* ??? Secure EL3 really using the ASID field? Doesn't make sense= . */ - idxmask =3D ARMMMUIdxBit_S1SE1 | ARMMMUIdxBit_S1SE0 | ARMMMUIdxBit= _S1E3; + idxmask =3D ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0 | ARMMMUIdxBit_S1E= 3; break; case ARM_CP_SECSTATE_NS: ttbr0 =3D 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_St= age2; } else { @@ -8695,9 +8695,9 @@ static inline uint32_t regime_el(CPUARMState *env, AR= MMMUIdx 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) =20 el =3D 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 =3D ARMMMUIdx_EL10_0; break; - case ARMMMUIdx_S1SE1: - useridx =3D ARMMMUIdx_S1SE0; + case ARMMMUIdx_SE1: + useridx =3D 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); --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605990; cv=none; d=zoho.com; s=zohoarc; b=Bg8wFpgALt4drhP3Ge66oFVWSfwb/IAOuQPiuWUY/4KLL47OtdyySBF8M+kJpYx/aPlS2hPjgzH5KsDMwI0tKVGhqLVp/2cDAj9O1ggtqad/eJ8DkON0iNoxLDR/3Y26v63TB8D4h/sYwJnIeZuzS8kDixwX20SaTEBKIeFwxSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605990; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uNn5q4INDqZzSSWnDmMk9zDSnWJbLDXBWQcIuUU2uJI=; b=BEL1bg5slEu9xqEgI69g6g85qEgwoxrNTP3DLMxG+n+ktMoaS15FR1CXaiBENCM6cY1639BEgC8aeqRxTC5ugFHvUMCJTK2XfAeAnMid9+QLRu9un8ZmICnN9D7/xD7NawDXnCXUaK9MG+xuC2H0Y1HQ90Bhaq4mPz2lCRrdwJk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605990018176.05964140354843; Wed, 31 Jul 2019 13:46:30 -0700 (PDT) Received: from localhost ([::1]:44380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvUT-0005C5-2Z for importer@patchew.org; Wed, 31 Jul 2019 16:46:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32849) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMw-00052Z-2m for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMu-0003ad-HN for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:41 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:32941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMu-0003a4-A3 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:40 -0400 Received: by mail-pg1-x542.google.com with SMTP id n190so1202372pgn.0 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=uNn5q4INDqZzSSWnDmMk9zDSnWJbLDXBWQcIuUU2uJI=; b=Z7CoxzCy7QzgKSn7JoSt1DYfrp/h+j3DRImGw5eTnQYNT05aU5yG6PH19lI08Oc2Mc OYFD/NRagj8NbGPMqM0YojWoortqXmBm3imFic2o+VZQqHspWlm/NKYfHItMCwaHdxEs z8LZY7XseWXFpasA+AD5VRVJoNb2+aZmdy+NOjFPhKR93qoUwpmI/a4YFm1mKco+6fOh KQIy4NX1pbso1YyxH9Am4evsc7J6BvN75BY1AoWlkfOqq3qlOyV1VvV0TVglIZcONbxK 0jpkdMJQHTnIenX0l3orH4NaCF2S5gVX9VqiBv9HsqD3RaS78FVWtsD1XSQZ7+VDcSdn 4AtQ== 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=R//Q8WijVX13K4kdDHDK4pVDTBSTEFoE8VJ4swrvIqxCIuBWqcJjUduINVvhpvKaXM wGxXQ1UDzVQkiKQLLDyBjyF+qn2U7kO77dAnX1fDETpVsuATsOq9a7DfJ4vkP2DLJ7hJ 59T75oWO/SjxgU/wc+M7D18EZeZvEGJsahpaUKVjiSVGAgx8cBvM+eKKP9M9GhfUEter mvmjtX6Gp1byYvKK2Crq2WV9ADGd8d9mBIzIRvLAvFjXDTZyBO4k+bf+HQJKxi8wm8UJ LETgQor5vWlN/hoQPzfSTDctmnfZwuzVe/HqCnnsDqhp+rd11yoC1tNXzMONx6lLLMYS TmFA== X-Gm-Message-State: APjAAAUif1TR2O3tRMSgQBFHdwtAZLI00RyKCknUeKzDyQHTScVNNMqZ 02KsANqwsgmlq7YInkNiMjijrtMb8PU= X-Google-Smtp-Source: APXvYqyni8wVYxHX5Ha1dlrOrOSB5gBHIrtpkhP1sfv3fZC0UUncAYqaJak7iKtV5DE4//YOX3M4Pg== X-Received: by 2002:a63:ff65:: with SMTP id s37mr73372006pgk.102.1564605519022; Wed, 31 Jul 2019 13:38:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:00 -0700 Message-Id: <20190731203813.30765-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 19/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 0 | ARM_MMU_IDX_A, ARMMMUIdx_EL10_1 =3D 1 | ARM_MMU_IDX_A, ARMMMUIdx_S1E2 =3D 2 | ARM_MMU_IDX_A, - ARMMMUIdx_S1E3 =3D 3 | ARM_MMU_IDX_A, + ARMMMUIdx_SE3 =3D 3 | ARM_MMU_IDX_A, ARMMMUIdx_SE0 =3D 4 | ARM_MMU_IDX_A, ARMMMUIdx_SE1 =3D 5 | ARM_MMU_IDX_A, ARMMMUIdx_Stage2 =3D 6 | ARM_MMU_IDX_A, @@ -2879,7 +2879,7 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_EL10_0 =3D 1 << 0, ARMMMUIdxBit_EL10_1 =3D 1 << 1, ARMMMUIdxBit_S1E2 =3D 1 << 2, - ARMMMUIdxBit_S1E3 =3D 1 << 3, + ARMMMUIdxBit_SE3 =3D 1 << 3, ARMMMUIdxBit_SE0 =3D 1 << 4, ARMMMUIdxBit_SE1 =3D 1 << 5, ARMMMUIdxBit_Stage2 =3D 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, A= RMMMUIdx 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 ARMCPRe= gInfo *ri, uint64_t value) /* stage 1 current state PL1: ATS1CPR, ATS1CPW */ switch (el) { case 3: - mmu_idx =3D ARMMMUIdx_S1E3; + mmu_idx =3D ARMMMUIdx_SE3; break; case 2: mmu_idx =3D ARMMMUIdx_Stage1_E1; @@ -3198,7 +3198,7 @@ static void ats_write64(CPUARMState *env, const ARMCP= RegInfo *ri, mmu_idx =3D ARMMMUIdx_S1E2; break; case 6: /* AT S1E3R, AT S1E3W */ - mmu_idx =3D ARMMMUIdx_S1E3; + mmu_idx =3D ARMMMUIdx_SE3; break; default: g_assert_not_reached(); @@ -3422,9 +3422,9 @@ static void update_lpae_el1_asid(CPUARMState *env, in= t secure) ttbr0 =3D env->cp15.ttbr0_s; ttbr1 =3D env->cp15.ttbr1_s; ttcr =3D env->cp15.tcr_el[3].raw_tcr; - /* Note that cp15.ttbr0_s =3D=3D cp15.ttbr0_el[3], so S1E3 is affe= cted. */ + /* Note that cp15.ttbr0_s =3D=3D cp15.ttbr0_el[3], so SE3 is affec= ted. */ /* ??? Secure EL3 really using the ASID field? Doesn't make sense= . */ - idxmask =3D ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0 | ARMMMUIdxBit_S1E= 3; + idxmask =3D ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0 | ARMMMUIdxBit_SE3; break; case ARM_CP_SECSTATE_NS: ttbr0 =3D env->cp15.ttbr0_ns; @@ -3967,7 +3967,7 @@ static void tlbi_aa64_alle3_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D CPU(cpu); =20 - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_S1E3); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_SE3); } =20 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 =3D env_cpu(env); =20 - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E3); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_SE3); } =20 static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4020,7 +4020,7 @@ static void tlbi_aa64_vae3_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, CPUState *cs =3D CPU(cpu); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S1E3); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_SE3); } =20 static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *r= i, @@ -4069,7 +4069,7 @@ static void tlbi_aa64_vae3is_write(CPUARMState *env, = const ARMCPRegInfo *ri, uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1E3); + ARMMMUIdxBit_SE3); } =20 static void tlbi_aa64_ipas2e1_write(CPUARMState *env, const ARMCPRegInfo *= ri, @@ -8693,7 +8693,7 @@ static inline uint32_t regime_el(CPUARMState *env, AR= MMMUIdx 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); --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606054; cv=none; d=zoho.com; s=zohoarc; b=enq4rPVRnErMEAHYm4P0Y3tIKsKJk9DGKLysPEeyENserMnIAWA2lFhDMG1aJG+8Gw2IQtpou9yNi5r9C6+yxfZ50j+PZZmsjVz9ButHk0zdkMiZhXfQc/z/GBt7/i7F8VrWXnRLzrdEJLxmNPNOhgdN+8vvMqM/DxX/dn7M8pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606054; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=trlNGPogxXBK9OHHkWCBGsx/W/Lwzy6lbLUgzLGbb4A=; b=lPIuSmoEw6MUwcqlDZNfKi4Sm8n2q8FKwuEUbDAI3Qgf4FVRNjYGgddeRjcc3R4uwTxvYoBb6qtLhbPKpIqJBI3EHC2+1aW9jEKI/mtfNmjCThd+Ml2FEza8/Jlqf9CwHBerwTrBF4wkRKl3jeM6SWICgdBkW7wFeyTWUzX6GxU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606054568593.8091564684066; Wed, 31 Jul 2019 13:47:34 -0700 (PDT) Received: from localhost ([::1]:44408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvVV-0000OX-Jk for importer@patchew.org; Wed, 31 Jul 2019 16:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32872) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMw-000564-WF for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMv-0003bd-Jx for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:42 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:44650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMv-0003au-EL for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:41 -0400 Received: by mail-pf1-x441.google.com with SMTP id t16so32483842pfe.11 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=trlNGPogxXBK9OHHkWCBGsx/W/Lwzy6lbLUgzLGbb4A=; b=FnckERwDmDIWWSq+DLNZGvLiUHOrNRx2cZ9VfPjMtiB92cIz1roDmLiFD7HvVwmpkW 6qGkDMkHKnGBjfzEa206YBOv4NGezzn1SePqNbJkbPIU9d8rG/iiVO5GFHVbmA2/bLFG 0MHopL3QvcgO73DQaOTvXlIBrareISyUWIBuzMOnoqJzKgLC8YYCWgHvH+QnSuMNZmv1 pzH/ujw2eO/6r/ECClBwZdPCSXk36wpchu3lKwwHPuKtSMfA2tp+UNYinFK+xdoAH6re JWS17iGGpWNTUr9JrE4bam+5vDoqSp6I6gMqRe2/5HbYitTCuRlgwW+bgR1Q03M84F0O 7Yow== 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=S2EIHWYqhU+Wo8v8/DglYh+K58mHiv2cosLF3ylFDG/vTtf/R9ocQrd7zlvtxFpDsR el3yEOdtgvkMYN3oZFJlwR62/0+GRNijPlUe9sfmoQKOim+ZYjgGLKLvgMg0wVF7zw3s eItRpzB4Uci3xdGtt6J3NYXow6Bs9GvEHiC7BLsooUtkMwPSPoUB7SQtJFM6Me4jxfHh UeH8S9KItWAktADbNi0C+NYetNQrQCVACjvHG3otIfB4A8ss6gMfL42wJjK76fw95S+x q1DpUWXgpUxzGAUHyAt7qNaEm2VZL4DkC+mIQFtykmVtIJzJZ+so6ngnVFEVe9F7EFmA kZIQ== X-Gm-Message-State: APjAAAUik39XS0TNhXeUbj3mf96D0VBS9k5nYHeTJSuhaSDcL2SG21ZV xadYcPaEqjBOMNwp/sQt87BsJvxDrpY= X-Google-Smtp-Source: APXvYqxWjZ7IxLToKxY6I3CKj5IZHVw8vuKJNV16ChWEFEdhM+8u4ipR5eI3r7dsp0t7YQiaQyYb+A== X-Received: by 2002:a65:5202:: with SMTP id o2mr90826501pgp.29.1564605520120; Wed, 31 Jul 2019 13:38:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:01 -0700 Message-Id: <20190731203813.30765-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 20/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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, un= signed int excp_idx, typedef enum ARMMMUIdx { ARMMMUIdx_EL10_0 =3D 0 | ARM_MMU_IDX_A, ARMMMUIdx_EL10_1 =3D 1 | ARM_MMU_IDX_A, - ARMMMUIdx_S1E2 =3D 2 | ARM_MMU_IDX_A, + ARMMMUIdx_E2 =3D 2 | ARM_MMU_IDX_A, ARMMMUIdx_SE3 =3D 3 | ARM_MMU_IDX_A, ARMMMUIdx_SE0 =3D 4 | ARM_MMU_IDX_A, ARMMMUIdx_SE1 =3D 5 | ARM_MMU_IDX_A, @@ -2878,7 +2878,7 @@ typedef enum ARMMMUIdx { typedef enum ARMMMUIdxBit { ARMMMUIdxBit_EL10_0 =3D 1 << 0, ARMMMUIdxBit_EL10_1 =3D 1 << 1, - ARMMMUIdxBit_S1E2 =3D 1 << 2, + ARMMMUIdxBit_E2 =3D 1 << 2, ARMMMUIdxBit_SE3 =3D 1 << 3, ARMMMUIdxBit_SE0 =3D 1 << 4, ARMMMUIdxBit_SE1 =3D 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, A= RMMMUIdx 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 A= RMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); =20 - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); } =20 static void tlbiall_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -748,7 +748,7 @@ static void tlbiall_hyp_is_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); =20 - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); } =20 static void tlbimva_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -757,7 +757,7 @@ static void tlbimva_hyp_write(CPUARMState *env, const A= RMCPRegInfo *ri, CPUState *cs =3D env_cpu(env); uint64_t pageaddr =3D value & ~MAKE_64BIT_MASK(0, 12); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S1E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); } =20 static void tlbimva_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -767,7 +767,7 @@ static void tlbimva_hyp_is_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, uint64_t pageaddr =3D value & ~MAKE_64BIT_MASK(0, 12); =20 tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1E2); + ARMMMUIdxBit_E2); } =20 static const ARMCPRegInfo cp_reginfo[] =3D { @@ -3167,7 +3167,7 @@ static void ats1h_write(CPUARMState *env, const ARMCP= RegInfo *ri, MMUAccessType access_type =3D ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA= _LOAD; uint64_t par64; =20 - par64 =3D do_ats_write(env, value, access_type, ARMMMUIdx_S1E2); + par64 =3D do_ats_write(env, value, access_type, ARMMMUIdx_E2); =20 A32_BANKED_CURRENT_REG_SET(env, par, par64); } @@ -3195,7 +3195,7 @@ static void ats_write64(CPUARMState *env, const ARMCP= RegInfo *ri, mmu_idx =3D secure ? ARMMMUIdx_SE1 : ARMMMUIdx_Stage1_E1; break; case 4: /* AT S1E2R, AT S1E2W */ - mmu_idx =3D ARMMMUIdx_S1E2; + mmu_idx =3D ARMMMUIdx_E2; break; case 6: /* AT S1E3R, AT S1E3W */ mmu_idx =3D ARMMMUIdx_SE3; @@ -3958,7 +3958,7 @@ static void tlbi_aa64_alle2_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D CPU(cpu); =20 - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); } =20 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 =3D env_cpu(env); =20 - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); } =20 static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *= ri, @@ -4006,7 +4006,7 @@ static void tlbi_aa64_vae2_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, CPUState *cs =3D CPU(cpu); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_S1E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); } =20 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 =3D sextract64(value << 12, 0, 56); =20 tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_S1E2); + ARMMMUIdxBit_E2); } =20 static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *r= i, @@ -4375,7 +4375,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] =3D { { .name =3D "AT_S12E0W", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 4, .crn =3D 7, .crm =3D 8, .opc2 =3D 7, .access =3D PL2_W, .type =3D ARM_CP_NO_RAW, .writefn =3D 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 =3D "AT_S1E3R", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 6, .crn =3D 7, .crm =3D 8, .opc2 =3D 0, .access =3D PL3_W, .type =3D ARM_CP_NO_RAW, .writefn =3D ats_write64= }, @@ -8691,7 +8691,7 @@ static inline uint32_t regime_el(CPUARMState *env, AR= MMMUIdx 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); --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606225; cv=none; d=zoho.com; s=zohoarc; b=YcbEw5taZ8x1/1BsFUonuwJPZZtthG5XqZdMJGiG1sXpufVaECm2CjyLwPYnBtH1yS+4eo2hugD2U5eH5Z3u1U4qzmgIzCLfFRaSmd5WCY/tbuw9jd4guO1Fd/P4sHfohlcn7ShuW1zUv/CxsYeP0fyYhldelrocm+zm/YkgE2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606225; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=C4yPNU5MzTttlOEZGJqyKcDVIL6n5tI4jir190lVFFk=; b=GroDdFbMIEHfUUSxQFf4/HDJlLzYZQ7VVgBWU+sxSzJbk+Y7qUFMt6XCbv6J0KEEOB71VbTdSY8sW/MY0sDptEgkwU40c/d5YnS3SF+Ee/DiS1QWN5MTCY8cC2vtTd0kYQKGchEYecGUotfAaPEA1dL7+0CwwSS2/H4L7NxYaYQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606225928942.2029850540843; Wed, 31 Jul 2019 13:50:25 -0700 (PDT) Received: from localhost ([::1]:44468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvYG-0005kr-Qb for importer@patchew.org; Wed, 31 Jul 2019 16:50:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32930) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMz-0005F0-F6 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMx-0003cv-5W for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:45 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34022) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMw-0003c0-UG for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:43 -0400 Received: by mail-pg1-x543.google.com with SMTP id n9so26419811pgc.1 for ; Wed, 31 Jul 2019 13:38: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 g4sm84054164pfo.93.2019.07.31.13.38.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=C4yPNU5MzTttlOEZGJqyKcDVIL6n5tI4jir190lVFFk=; b=qwXqk/n2w2shA6GSwLU0+zQFVvdzsuk7GgABORJx8pqUt2mH8nfoUlKqlokuPPLomG pUVgIqNaTa/84/54evPJ3BEBqAyf0lgNryY3XWPOx69iIo3EhXRkh35uZv3AoGsQwxD7 ru4lfhz/LlFqlBw7OD3pSIEbjSsB/xhMWEWu74+jwTkJaPvInl/5ezNF0ButVex2T5JY U7Aje3RBCadNwJ8tKq6DXRYxxzyICmT+02NWK2DZoHa0IdPr78Z72RhqED15nv14PyrP ESj4MxsUyzJX75VG4WGcl2FmrSL/1WjkV/Lvrtwd0XQz0KplPSHe0oNxSfL+wUdzOR0W qgNw== 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=tYqK+fS9kKQ3WsOZwPMQCRe+3+dd4laputPx0ta4sE+UBlQIg2yj7hdKOQn9ofg4At UOoQFr7obV8mZ7fB3WiyomsbD8aNDmDMlGW7b57OiE0ed5Qsoett1M1ZkqDeWEDQYIqg gkqoUPJD1hdsdQOx04NzXlGEpzOcnZZYppVnJAAsM4KEUy4AuA3S/655VI6v7epGtUxr gqpvx8RSrGCmN5Lwg3kwqs76DhIlEy7+8SLXMuKb/xKUZeXmvLga1EHwtRe2U6mUXZBZ dGJEI4QZpVyZDcnHJ9D4bJ6ePWQMXn00ImbXkwFTqn62TqdhaiBL2cKZyFXaN6iBRy2J FvgA== X-Gm-Message-State: APjAAAVWi4tZoqUJkYXt5mmiAoECeCedAd7IDrEJ4cynHfgRiBlszb/O g+0msw6ux4GDDVoUkJqHjl/Bx20y1dA= X-Google-Smtp-Source: APXvYqyl3hFL+TnJffEsVCfkYIjgjlDgZtIGJ9v3QPRVPqyOpdN8DZwaOyefrHzmHisJNuLGzYrlEg== X-Received: by 2002:a62:26c1:: with SMTP id m184mr47261363pfm.200.1564605521415; Wed, 31 Jul 2019 13:38:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:02 -0700 Message-Id: <20190731203813.30765-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 21/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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, u= nsigned 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, un= signed 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 beca= use: - * 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_i= dxes, + * because they may differ in access permissions even if the VA->PA ma= p 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 t= wo * 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 */ =20 -/* 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 =20 -#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 =20 typedef enum ARMMMUIdx { - ARMMMUIdx_EL10_0 =3D 0 | ARM_MMU_IDX_A, - ARMMMUIdx_EL10_1 =3D 1 | ARM_MMU_IDX_A, + ARMMMUIdx_EL10_0 =3D 0 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL10, + ARMMMUIdx_EL10_1 =3D 1 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL10, + ARMMMUIdx_EL20_0 =3D 0 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL20, + ARMMMUIdx_EL20_2 =3D 2 | ARM_MMU_IDX_A | ARM_MMU_IDX_A_EL20, + ARMMMUIdx_E2 =3D 2 | ARM_MMU_IDX_A, - ARMMMUIdx_SE3 =3D 3 | ARM_MMU_IDX_A, - ARMMMUIdx_SE0 =3D 4 | ARM_MMU_IDX_A, - ARMMMUIdx_SE1 =3D 5 | ARM_MMU_IDX_A, - ARMMMUIdx_Stage2 =3D 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 =3D 3, + + ARMMMUIdx_SE0 =3D 0 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_SE1 =3D 1 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_SE2 =3D 2 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_SE3 =3D 3 | ARM_MMU_IDX_S | ARM_MMU_IDX_A, + ARMMMUIdx_MUser =3D 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv =3D 1 | ARM_MMU_IDX_M, ARMMMUIdx_MUserNegPri =3D 2 | ARM_MMU_IDX_M, ARMMMUIdx_MPrivNegPri =3D 3 | ARM_MMU_IDX_M, - ARMMMUIdx_MSUser =3D 4 | ARM_MMU_IDX_M, - ARMMMUIdx_MSPriv =3D 5 | ARM_MMU_IDX_M, - ARMMMUIdx_MSUserNegPri =3D 6 | ARM_MMU_IDX_M, - ARMMMUIdx_MSPrivNegPri =3D 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 =3D 0 | ARM_MMU_IDX_NOTLB, - ARMMMUIdx_Stage1_E1 =3D 1 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_MSUser =3D 0 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + ARMMMUIdx_MSPriv =3D 1 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + ARMMMUIdx_MSUserNegPri =3D 2 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + ARMMMUIdx_MSPrivNegPri =3D 3 | ARM_MMU_IDX_S | ARM_MMU_IDX_M, + + /* Indicies that are only used only for AT system or Stage1 walk. */ + ARMMMUIdx_Stage1_E0 =3D 0 | ARM_MMU_IDX_A | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1 =3D 1 | ARM_MMU_IDX_A | ARM_MMU_IDX_NOTLB, } ARMMMUIdx; =20 -/* 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 =3D 1 << (ARMMMUIdx_##NAME & ARM_MMU_IDX_COREIDX_M= ASK) + typedef enum ARMMMUIdxBit { - ARMMMUIdxBit_EL10_0 =3D 1 << 0, - ARMMMUIdxBit_EL10_1 =3D 1 << 1, - ARMMMUIdxBit_E2 =3D 1 << 2, - ARMMMUIdxBit_SE3 =3D 1 << 3, - ARMMMUIdxBit_SE0 =3D 1 << 4, - ARMMMUIdxBit_SE1 =3D 1 << 5, - ARMMMUIdxBit_Stage2 =3D 1 << 6, - ARMMMUIdxBit_MUser =3D 1 << 0, - ARMMMUIdxBit_MPriv =3D 1 << 1, - ARMMMUIdxBit_MUserNegPri =3D 1 << 2, - ARMMMUIdxBit_MPrivNegPri =3D 1 << 3, - ARMMMUIdxBit_MSUser =3D 1 << 4, - ARMMMUIdxBit_MSPriv =3D 1 << 5, - ARMMMUIdxBit_MSUserNegPri =3D 1 << 6, - ARMMMUIdxBit_MSPrivNegPri =3D 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; =20 +#undef TO_CORE_BIT + #define MMU_USER_IDX 0 =20 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; } =20 -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); =20 +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) !=3D 0; } =20 /* 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 */ =20 /* Return the exception level which controls this address translation regi= me */ -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, AR= MMMUIdx 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; } =20 +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 |=3D 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) } =20 el =3D 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(); } } =20 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 =3D {}; - bool secure =3D mmu_idx & ARM_MMU_IDX_M_S; + bool secure =3D mmu_idx & ARM_MMU_IDX_S; int exc; bool exc_secure; =20 @@ -218,7 +218,7 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest,= uint32_t addr, hwaddr physaddr; int prot; ARMMMUFaultInfo fi =3D {}; - bool secure =3D mmu_idx & ARM_MMU_IDX_M_S; + bool secure =3D 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, } =20 if (secstate) { - mmu_idx |=3D ARM_MMU_IDX_M_S; + mmu_idx |=3D ARM_MMU_IDX_S; } =20 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(); } --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605895; cv=none; d=zoho.com; s=zohoarc; b=Krb2mln8roDMbZB2F0/8Rjke9nkXjo//3DxnPzB/LPhoJiupQkXZYghi9YqdD/ORsBgaVfzRE8aXquhOoSDkBKFmK0yvdbJgp5Pbng4xvvVlojqi00AYmL7VWvkgZ0Z6Sb5X9UnnY5Jefccu1tmWVT3tf5IiScIABNoR1XQHVCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605895; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=WwuqB9iHGzaanXcvxb8eFVamOkF9w6n6TtphPBoS1qtZ9b46Vp69em+eqKxQ0Sq14zag2ZDs8xV5EaGUytNO+shvWxS/SA9HDb8sdvgARbRrXDB/8qa44jOlX9xswTUSZV4Gn3beVKveF5ms0BRIbkk6Cl46CaCd2pPcB4Cd2C4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605895064730.4326649963767; Wed, 31 Jul 2019 13:44:55 -0700 (PDT) Received: from localhost ([::1]:44340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvSo-0000TS-E6 for importer@patchew.org; Wed, 31 Jul 2019 16:44:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32919) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMz-0005Dl-3O for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMx-0003dJ-QN for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:45 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:34882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMx-0003cs-Ks for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:43 -0400 Received: by mail-pf1-x429.google.com with SMTP id u14so32533762pfn.2 for ; Wed, 31 Jul 2019 13:38:43 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=Kdwl74B6/jWmsEEKylVhNh+FnEqvpfAEzIn2lRU1DV+O/n0aqloQ5a9vX12Kj+4j+a AhFLTo/SkoMoEZu0dPjijScKjTXgFHIreIjwOGrdEpw/a8TLIsXUs8BT66ED9TnXbzYe VuK58p3XkTOTfylmbJXdoHnsQkMk0JfAw3i8+dCotxAOcyZ3+WxrhPH5Y08pZ1xUdH6d VcGvyaF2775EPpVE1zlsbEJjPZwCAOwagUCd9m9Q1DmZ+W7jA25BCPeyS9hzI+wDedeq IsqL8bubc932Lws41JBLO2MTvydw/Bz8l12PPTb7Hxfkw9MctKDI6qdeZ+ZTcRXvAoae clgg== 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=NtK6/tlsq29oH/i2+aAHn+UnnFoy0R890Fgju6eFfFVzJoX5aBQ89P7SNr+NtoCgSP I6tywbPPrMKVQlvA8+Rj10Nv3N2nLuJFduh7cn7rhk5ZHypTw2CZCk4xW0Ztska6cu5r bY4TBTrIWrmG65Y8f6wB0mc/yy3eY73W1lAVVLXHWUz01zQZciE+bKuiTrDC/d2B0xjH wkMp81EVmtY95WSFGaqLItKq0ZaAXHgTkjZP6CZNVuoI+B56Qn0sTL71H04wEIGNpI54 NKilLDRnlUzm3S0vLwmWrlR8g5aHjXfs3LYBOz5It6X777hCaEUIQevFkL4juKbkNQHh DHrg== X-Gm-Message-State: APjAAAVuDTWkcEAx8vqab69gXIKBoRPbpVL84rKPTw9XqCa+Iw63N3BN PLKA3+EIX3SeZfBO895NnwdkNwafA90= X-Google-Smtp-Source: APXvYqzMfdfh+XWUeoxyr1jeHDBR6hkx2nkKxbcKB8o5LdXGl98IHaupUed4PR2GNMK8i22Pfx8bLg== X-Received: by 2002:a63:7c0d:: with SMTP id x13mr75531824pgc.360.1564605522335; Wed, 31 Jul 2019 13:38:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:03 -0700 Message-Id: <20190731203813.30765-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::429 Subject: [Qemu-devel] [PATCH v2 22/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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) } } =20 +/* 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 mm= u_idx, bool is_aa64, } =20 if (is_aa64) { - switch (regime_el(env, mmu_idx)) { - case 1: - if (!is_user) { - xn =3D pxn || (user_rw & PAGE_WRITE); - } - break; - case 2: - case 3: - break; + if (regime_has_2_ranges(mmu_idx) && !is_user) { + xn =3D 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 =3D regime_tcr(env, mmu_idx)->raw_tcr; - uint32_t el =3D regime_el(env, mmu_idx); bool tbi, tbid, epd, hpd, using16k, using64k; int select, tsz; =20 @@ -9558,7 +9550,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *= env, uint64_t va, */ select =3D extract64(va, 55, 1); =20 - if (el > 1) { + if (!regime_has_2_ranges(mmu_idx)) { tsz =3D extract32(tcr, 0, 6); using64k =3D extract32(tcr, 14, 1); using16k =3D extract32(tcr, 15, 1); @@ -9714,10 +9706,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, tar= get_ulong address, param =3D aa64_va_parameters(env, address, mmu_idx, access_type !=3D MMU_INST_FETCH); level =3D 0; - /* If we are in 64-bit EL2 or EL3 then there is no TTBR1, so mark = it - * invalid. - */ - ttbr1_valid =3D (el < 2); + ttbr1_valid =3D regime_has_2_ranges(mmu_idx); addrsize =3D 64 - 8 * param.tbi; inputsize =3D 64 - param.tsz; } else { @@ -11368,8 +11357,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_= ulong *pc, ARMVAParameters p0 =3D aa64_va_parameters_both(env, 0, stage1); int tbii, tbid; =20 - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - if (regime_el(env, stage1) < 2) { + if (regime_has_2_ranges(mmu_idx)) { ARMVAParameters p1 =3D aa64_va_parameters_both(env, -1, st= age1); tbid =3D (p1.tbi << 1) | p0.tbi; tbii =3D 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_i= 64 dst, if (tbi =3D=3D 0) { /* Load unmodified address */ tcg_gen_mov_i64(dst, src); - } else if (s->current_el >=3D 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 { --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606237; cv=none; d=zoho.com; s=zohoarc; b=hKahOkMX1N/QkkxCIH0/NmiVXGA7m91XuYWH4YfKlBYfoUFp9V++WjBxe+tVWB2nOh2eK8m18VfPrGDqTiqdai1eMyIvvvJsJl1wlEh5gh/62jLCLiE0dF6HgHW9fS8U63qVQO5ebjahq1fU0zifeLVHGmx1IlrLeWqc9zau1Nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606237; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gkdd1xo9dAf4K2ZLEThkLYxs4H8KbbboSDJfUHi98zc=; b=EVV+l1ZBCyhzQzG69Si2VJBI7Ii57yld/4pY7o6osQBHwGR5YYokCdVj6WGJ+CliQSHI/PpmCbuEZTTjopqg62v3knaekSF7XPOoAcAq3ppzwjb/nYVOHHKToHIxGs3gkt6M9Uhyb8uQHFBZwGr7XEHd1emmbmmmyh81DP8IiNM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606237132569.3144993460973; Wed, 31 Jul 2019 13:50:37 -0700 (PDT) Received: from localhost ([::1]:44474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvYS-0006O4-5u for importer@patchew.org; Wed, 31 Jul 2019 16:50:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32955) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN0-0005IS-8y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMz-0003ew-2s for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:46 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:35141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMy-0003dv-Sv for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:45 -0400 Received: by mail-pg1-x543.google.com with SMTP id s1so26341816pgr.2 for ; Wed, 31 Jul 2019 13:38:44 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38: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=gkdd1xo9dAf4K2ZLEThkLYxs4H8KbbboSDJfUHi98zc=; b=ZDbaISIZ3zgNqxZlEnpBUY3V2zdR9HW9CR1WHtGeWAaHAYFzmG1zEiUvprFlqdWgBF OoDezKag3b/3idd6mx+ISvn38e2INhCTTjhgRgA+fb6OzEVxk99vZjc/n6f2Fkrtt4MP NdvOAY9UqpPnTLAdnqnZmP01d4tCo5Nr8TW04LgZrHetRTTiu8Xjt6e2i9kNZVlrDjRp QaxgMB3oG/u5BZp4G516V1v9Mh3ICvJJQTvv3F4m1EQn/ME1w9Cxsl83+cUjn0UQJEIu U0hyfSgyExKgrah2yP6hc33PXurZbRsvoO3umB0UXjfv16/TJZde8QSaqIVi5NEce9Wb HZEg== 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=gkdd1xo9dAf4K2ZLEThkLYxs4H8KbbboSDJfUHi98zc=; b=fFFiS1cA+ay5rCVVuyivg9qF+oPFukDNGwcpvy3GfC5TzRXSvWPtROEOv2vGVJAF7K 0a8KVq0A5jcfVN5cTN8LPXKSU6HIUR6sReuYYWggcLH7OWT3KjM/OBd2BQWHq7Jy3tTQ bBY4I4lgikry5ZSNH056J1Pvj+o0gvRYRBKYwlFtxVUeaejA5fId49eEMB4WDVyTDYz3 TJW2hfvOh493kdUv6ncfDR1v+mC3jlH0LuaAHN9Hjn6twjQGSBaRFVym2Ym4gvx2UW2I lfaGe21swmVHzyPIU9GbDbE4ik4IfpK5w3EC892KybVytEQmHdsomm14V2exz5rs+8tk KQUA== X-Gm-Message-State: APjAAAXVPUve9OB2JLk0oxR62ki/wpbilpBONTXcxTIqTp8aMH4q1rfk WJxXLslL/x783Kj5Aj/SDn35pw29BIw= X-Google-Smtp-Source: APXvYqxI9PkBPDFz1O+ZDnSIrP/QU7NtnsaAm7mvEC2zO8tOn+kFG6lKJgv2UTEXdcZ5Uzot5HIbqw== X-Received: by 2002:a62:198d:: with SMTP id 135mr48906850pfz.169.1564605523502; Wed, 31 Jul 2019 13:38:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:04 -0700 Message-Id: <20190731203813.30765-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 23/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This covers initial generation in arm_mmu_idx, and reconstruction in core_to_arm_mmu_idx. As a conseqeuence, we also need a bit in TBFLAGS in order to make the latter reliable. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/cpu.h | 2 ++ target/arm/helper.c | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b5300f9014..64cda8dbea 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.E2H is set. */ +FIELD(TBFLAG_ANY, E2H, 22, 1) =20 /* 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..578dcfefbf 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11257,21 +11257,29 @@ int fp_exception_el(CPUARMState *env, int cur_el) =20 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; } =20 mmu_idx |=3D ARM_MMU_IDX_A; + if (mmu_idx & ARM_MMU_IDX_S) { + return mmu_idx; + } + + e2h =3D (env->cp15.hcr_el2 & HCR_E2H) !=3D 0; + if (!arm_el_is_aa64(env, 2)) { + e2h =3D false; + } + 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(); } @@ -11299,24 +11307,28 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMStat= e *env, bool secstate) =20 ARMMMUIdx arm_mmu_idx(CPUARMState *env) { + bool e2h, sec; int el; =20 if (arm_feature(env, ARM_FEATURE_M)) { return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); } =20 + sec =3D arm_is_secure_below_el3(env); + e2h =3D (env->cp15.hcr_el2 & HCR_E2H) !=3D 0; + if (!arm_el_is_aa64(env, 2)) { + e2h =3D false; + } + el =3D arm_current_el(env); switch (el) { case 0: - /* TODO: ARMv8.1-VHE */ + return sec ? ARMMMUIdx_SE0 : e2h ? ARMMMUIdx_EL20_0 : ARMMMUIdx_EL= 10_0; case 1: - return (arm_is_secure_below_el3(env) - ? ARMMMUIdx_SE0 + el - : ARMMMUIdx_EL10_0 + el); + return sec ? ARMMMUIdx_SE1 : ARMMMUIdx_EL10_1; case 2: - /* TODO: ARMv8.1-VHE */ /* TODO: ARMv8.4-SecEL2 */ - return ARMMMUIdx_E2; + return e2h ? ARMMMUIdx_EL20_2 : ARMMMUIdx_E2; case 3: return ARMMMUIdx_SE3; default: @@ -11428,6 +11440,14 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target= _ulong *pc, =20 flags =3D FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mm= u_idx)); =20 + /* + * Include E2H in TBFLAGS so that core_to_arm_mmu_idx can + * reliably determine E1&0 vs E2&0 regimes. + */ + if (arm_el_is_aa64(env, 2) && (env->cp15.hcr_el2 & HCR_E2H)) { + flags =3D FIELD_DP32(flags, TBFLAG_ANY, E2H, 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 --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606331; cv=none; d=zoho.com; s=zohoarc; b=lcOAOJcnL3JXW4h3YmXcnG1G2ZOwiVrPEOC+ZKbaltl2mmlKeTAKzb2mBObTT+/IVtL4VsGc1W0UdEyp6iKugTHXHuh94LKDlz/uUcGwM1iV2ztOTcgbtXxnSE85amfJq4Rm20lgWTkcTr4moDU0hoyZDouc6nT2JRfX+uqGB/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606331; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ANNHdO/zBUkLNhCgl4wRP8H0y0X0qC4dG7xLb+E0zx4=; b=cp8zDVzhc//3WVHzCLV50sgEpmLUWw1zy5Djtu+lUuXCLQfJBf5g1JfrVlFOu0bCOf5gn0UaZb7W/aGiKrYbxphLJf7+mzm6c3Du1UvJcqksVGHCCi7j9bMScidJTpOfsA8inwAMBbRie7iVcwVgYwTisoM6Cw9YPjc3bFO+Tmo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606331938202.12773076374083; Wed, 31 Jul 2019 13:52:11 -0700 (PDT) Received: from localhost ([::1]:44502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvZy-0001QJ-Un for importer@patchew.org; Wed, 31 Jul 2019 16:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33010) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN1-0005Nl-Mr for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN0-0003gH-52 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:47 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37535) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMz-0003fQ-VV for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:46 -0400 Received: by mail-pf1-x441.google.com with SMTP id 19so32507817pfa.4 for ; Wed, 31 Jul 2019 13:38:45 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:44 -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=ANNHdO/zBUkLNhCgl4wRP8H0y0X0qC4dG7xLb+E0zx4=; b=hJwlrZJCHdgQWubKECzMUn3b7kQ09I+dYs05SKGnRm1d+8AyIatq3u9UgKJKRVGIOn wcwcfFXPbzsMtW6QRzVTurSySAQ8Z7hdusyNfiF/1oG/rBcpgMxH3QuxG+mYCgVqSVHz 0YLHJ8SQx3Xlsj4/EMfwawe5W2JVii56TYkvH2B8W6jZu4RwdtYlSzRIdspTBHCCEt0k DSz0tnkOmky4F6YAUHjM2hjmfsvxZu6q6fz6sqF/7BlNVXfVt1WOZOM7zKbIQwDj9RcP w7CzBWbZ8mOuBZSzPHuzSoEvVr0QHrMEysqAKZ3I2ibTHlRZmX3NtW25DZin2PVO1mLL wYkQ== 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=ANNHdO/zBUkLNhCgl4wRP8H0y0X0qC4dG7xLb+E0zx4=; b=hMClBDwRx+fCXt5edXScGApQQzw5DR7xC2Ik8OwEgmfGAnoFMxr5aWYIrirVja3EWE n5Bm75ehrz1pwqr6Ggj0MfC3y8VM0BgP/mHhOoPQjB0BLXj9npK+uOXaViBP7byA1Tav wHEihyYJi19cewU36DPdpIWVwo1wV2atxInzDtIgtYF47O41asQVkq5tcpG9c/dA3z49 CBIIhRbnQBIwkkrDo0r2wleV63vLl2fR9X2qVk4DjWiL8735AI1QjSbn9pBLnZ5Du4m6 RPnDvvbc//rNrHG94cvBaYNg9KH4QR1mz3Zu0gwjIr7OMY/S1pMQqqAwvetARiHMvM9J /53Q== X-Gm-Message-State: APjAAAX7iL22dpe4MV06AGF8iu4Z4t61+rJrD+4Y2TlwZxcm6cJIiw6q la8av4m8gF0IL/Z06EZlbhqhLPc0kVw= X-Google-Smtp-Source: APXvYqzFjCmUxBGewxqBNn5FET3fk96MPNLs1F9/D0IYgxShOvD0XX7Ci68goWzC9PABhjaut3QjYg== X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr4659919pji.136.1564605524679; Wed, 31 Jul 2019 13:38:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:05 -0700 Message-Id: <20190731203813.30765-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 24/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Use this function in many more places in order to select the correct control. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/cpu.h | 10 ++++++---- target/arm/arch_dump.c | 2 +- target/arm/helper-a64.c | 2 +- target/arm/helper.c | 10 +++++----- target/arm/pauth_helper.c | 9 +-------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 64cda8dbea..c41da1d791 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3099,11 +3099,13 @@ static inline bool arm_sctlr_b(CPUARMState *env) static inline uint64_t arm_sctlr(CPUARMState *env, int el) { if (el =3D=3D 0) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - return env->cp15.sctlr_el[1]; - } else { - return env->cp15.sctlr_el[el]; + if (arm_el_is_aa64(env, 2) && (arm_hcr_el2_eff(env) & HCR_E2H)) { + el =3D 2; + } else { + el =3D 1; + } } + return env->cp15.sctlr_el[el]; } =20 =20 diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c index 26a2c09868..5fbd008d8c 100644 --- a/target/arm/arch_dump.c +++ b/target/arm/arch_dump.c @@ -320,7 +320,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, * dump a hypervisor that happens to be running an opposite-endian * kernel. */ - info->d_endian =3D (env->cp15.sctlr_el[1] & SCTLR_EE) !=3D 0 + info->d_endian =3D (arm_sctlr(env, 1) & SCTLR_EE) !=3D 0 ? ELFDATA2MSB : ELFDATA2LSB; =20 return 0; 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) =3D=3D 0 && !(env->cp15.sctlr_el[1] & SCTLR_UM= A)) { + if (arm_current_el(env) =3D=3D 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 578dcfefbf..2883d6e568 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3867,7 +3867,7 @@ static void aa64_fpsr_write(CPUARMState *env, const A= RMCPRegInfo *ri, static CPAccessResult aa64_daif_access(CPUARMState *env, const ARMCPRegInf= o *ri, bool isread) { - if (arm_current_el(env) =3D=3D 0 && !(env->cp15.sctlr_el[1] & SCTLR_UM= A)) { + if (arm_current_el(env) =3D=3D 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) =3D=3D 0 && !(env->cp15.sctlr_el[1] & SCTLR_UC= I)) { + if (arm_current_el(env) =3D=3D 0 && !(arm_sctlr(env, 0) & SCTLR_UCI)) { return CP_ACCESS_TRAP; } return CP_ACCESS_OK; @@ -4116,7 +4116,7 @@ static CPAccessResult aa64_zva_access(CPUARMState *en= v, const ARMCPRegInfo *ri, /* 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) =3D=3D 0 && !(env->cp15.sctlr_el[1] & SCTLR_DZ= E)) { + if (arm_current_el(env) =3D=3D 0 && !(arm_sctlr(env, 0) & SCTLR_DZE)) { return CP_ACCESS_TRAP; } return CP_ACCESS_OK; @@ -5348,7 +5348,7 @@ static CPAccessResult ctr_el0_access(CPUARMState *env= , const ARMCPRegInfo *ri, /* 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) =3D=3D 0 && !(env->cp15.sctlr_el[1] & SCTLR_UC= T)) { + if (arm_current_el(env) =3D=3D 0 && !(arm_sctlr(env, 0) & SCTLR_UCT)) { return CP_ACCESS_TRAP; } return CP_ACCESS_OK; @@ -8167,7 +8167,7 @@ static void take_aarch32_exception(CPUARMState *env, = int new_mode, env->uncached_cpsr =3D (env->uncached_cpsr & ~CPSR_M) | new_mode; /* Set new mode endianness */ env->uncached_cpsr &=3D ~CPSR_E; - if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) { + if (arm_sctlr(env, arm_current_el(env)) & SCTLR_EE) { env->uncached_cpsr |=3D CPSR_E; } /* J and IL must always be cleared for exception entry */ 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) =20 static bool pauth_key_enabled(CPUARMState *env, int el, uint32_t bit) { - uint32_t sctlr; - if (el =3D=3D 0) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - sctlr =3D env->cp15.sctlr_el[1]; - } else { - sctlr =3D env->cp15.sctlr_el[el]; - } - return (sctlr & bit) !=3D 0; + return (arm_sctlr(env, el) & bit) !=3D 0; } =20 uint64_t HELPER(pacia)(CPUARMState *env, uint64_t x, uint64_t y) --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564605968; cv=none; d=zoho.com; s=zohoarc; b=BogEn31e5JtvFp0oX2lzdFcx+lSVs6exvqcA0HbHxSLL3QUvUsQk2vrKfHlaeRYqptbVlrbFtVs90/Cj6m1w+chTR+wfxSfwKiS1WEt8Tu5QhQOLVLetSOTGKDecnxFKLoZU5W562lhCBp33JGwMio5e5mnebSIKThBE0JuTxgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564605968; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LCePFTUgV8mXAATt2U3SG8TFwN2aa4K3amCrfCCSR5k=; b=W0b8MbGXoOjxmoYhQBO4QydyWBSA7twJvl5jgoFmSaqISJUk8Jb7bdXGoteEZn5Nex9oFF2VReygNG5ZwcG5sxW7adp+RQB+ag0w7bciSzs9pviGz8HR1TItWgUfevUQCXe8W8KAFknCIgQgRLQerIKTEykf3b2cjjb25Ks04oQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564605968024776.2861363044896; Wed, 31 Jul 2019 13:46:08 -0700 (PDT) Received: from localhost ([::1]:44374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvU7-0003x6-1C for importer@patchew.org; Wed, 31 Jul 2019 16:46:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33027) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN2-0005PO-8U for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN1-0003hI-3w for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:48 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN0-0003gn-U7 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:47 -0400 Received: by mail-pf1-x441.google.com with SMTP id u14so32533841pfn.2 for ; Wed, 31 Jul 2019 13:38:46 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:45 -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=LCePFTUgV8mXAATt2U3SG8TFwN2aa4K3amCrfCCSR5k=; b=ylcLI33wAu8jB+aF2RW3yIA7CY7z4OkSO67AZXkNhw0oJWzLdIplqnhrrRQRhUGiX+ MRrS1dCFaWrcsZ0CO/dMpxAui4+ZBtg6dRA+TlZauo6VV7NXtil+5dpCzWVBuUm8dJko /9CVVD5eQh14fJaRha5bs2zg5EnLxDyMGgTBKJduh6Tact3fBZf1Zyl7r+KrKheGa0L2 582ykZER8T+zrtCCauIOt96pruwGsEkhYX2Ydq4ZcFPUvZrO2H7Yb1eItzoLkCLK9pV/ li33q3IkeJPZf4kTyGLEMWO2Ad7kUp+8GQITwwrzPkOgBn9Y6TwLlsRNmyHGrAuvKeoE xQ7g== 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=LCePFTUgV8mXAATt2U3SG8TFwN2aa4K3amCrfCCSR5k=; b=hszQfhAzO1gbLiewpBPR6wEyNs/XNj71Op47fGPYD5ZDRDyBtI+qh7pbsThaYg+qhH cw5eCD/mpTqjWOz507Y4xvNaF2qvDuQcaBFpYuZULoBjntvOxVVrNSyRs7JgOSZ6IgMd dsOGCtfIeqA6WESAJ+NoNNHC6RFnQ1GdxV60HEIzOsjtIw/wEcRPkKgV/n+uIJ4RRBKw WudHjcR/PiS8DjGPGKWlUElq1KVfeiqwtZ9VzUvXoAytoHOyqPPIBmOySbc6Qz65I4YQ NYdPYBfTHAo1GNJULUEeWqZDBJIDZj4qN5k2Nl1GtpnXUh9dzB0x0UGFRtdX2qEG7Tjh KGfQ== X-Gm-Message-State: APjAAAVToFgKEw2AqdKOKNq1ZcPdAIihsmpMpqfavTc7Kset6U/B/YbF N+KjHz4VF77ttfOPXv2pLeyhkFbEIeU= X-Google-Smtp-Source: APXvYqxnYjLEeHlM08/x5xP620ezHYZoGXIJPtdB14e+wl1qym3Dj9OqqPwR/DEsiQD8o7781IX0JA== X-Received: by 2002:aa7:93a8:: with SMTP id x8mr50841612pff.49.1564605525791; Wed, 31 Jul 2019 13:38:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:06 -0700 Message-Id: <20190731203813.30765-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 25/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 2883d6e568..30f93f4792 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3518,10 +3518,29 @@ static void vmsa_ttbr_el1_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, } } =20 +static void update_el2_asid(CPUARMState *env) +{ + CPUState *cs =3D env_cpu(env); + uint64_t ttbr0, ttbr1, ttcr; + int asid, idxmask; + + ttbr0 =3D env->cp15.ttbr0_el[2]; + ttbr1 =3D env->cp15.ttbr1_el[2]; + ttcr =3D env->cp15.tcr_el[2].raw_tcr; + idxmask =3D ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; + asid =3D 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); + } } =20 static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4654,6 +4673,7 @@ static void hcr_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) ARMCPU *cpu =3D env_archcpu(env); /* Begin with bits defined in base ARMv8.0. */ uint64_t valid_mask =3D MAKE_64BIT_MASK(0, 34); + uint64_t old_value; =20 if (arm_feature(env, ARM_FEATURE_EL3)) { valid_mask &=3D ~HCR_HCD; @@ -4680,15 +4700,25 @@ static void hcr_write(CPUARMState *env, const ARMCP= RegInfo *ri, uint64_t value) /* Clear RES0 bits. */ value &=3D valid_mask; =20 - /* These bits change the MMU setup: + old_value =3D env->cp15.hcr_el2; + env->cp15.hcr_el2 =3D 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 =3D value; =20 /* * Updates to VI and VF require us to update the status of --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606431; cv=none; d=zoho.com; s=zohoarc; b=MC07hF+T23JOMG4l/DNUkWo0WPDGLJIkblCxhDlplI3dFwGRd2Oz9+IhKnnfq6x3ce5cHUJkQluObcqfQZHmJ1G4IrkBXNb0O+yUam30OgqAsElhuurWFmYfLrUNlqYvf4Ab7GQh20ZSkUqradqhYvb3BNPhaU/EFPJNay9Ab0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606431; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YBFs9iOiLgu7VKenmzw4aXW6nYPbjotzvVPML6HKYTM=; b=QAziCPRJ2nHIDyXtkSrqvHcr4/IYtcEu1mtwyinSeFJ9CBcJuAg78zka0oaLnY88nvx1CdyBl8VgKILOaHR1F7WNL4yWtHVEa3EdNF+atcJv2qfhs1ADWegKeuGKr9fhaJhR+/Ay+ZyrnPPaB1+PNPxIUWlpcT9+9jecbNIBi5U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606431505351.82221731596985; Wed, 31 Jul 2019 13:53:51 -0700 (PDT) Received: from localhost ([::1]:44526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvba-0004Lq-I6 for importer@patchew.org; Wed, 31 Jul 2019 16:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33092) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN6-0005Tj-UP for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN2-0003jd-SB for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:51 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN2-0003iX-Kq for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:48 -0400 Received: by mail-pg1-x544.google.com with SMTP id t132so32632817pgb.9 for ; Wed, 31 Jul 2019 13:38:48 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:46 -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=YBFs9iOiLgu7VKenmzw4aXW6nYPbjotzvVPML6HKYTM=; b=k6Yc8ZuBX4U2Cf5P4Q38L4WBfL+KxeqRknh+AXILTGEQ6PRNkpVJa9gf4KdGj+GTcb 0bD1ELvDm4LRZtVLcHYvYdHus+mHicLOuU/hMLVTVWhC5jdvQCLcohfYwzVSMDEbsGB3 XTIqIhLnFrOXrR02pYdmjKHgqZDgwekvj+c8V2mIjYs1H1tvwDM+UrSqeVJAkFFcOm0z sn9sGlpsNaLxmcU/Z4QzX91A18J/jZy7uRcR2s5cF1WdcAcG1gh22MRBMoB0ymTvQU+9 2fsn9g5XmvZKmGwvzrMTyaFFzNeNajzhzUfcUmlfYNK1AeXUWuvHDkO+OqBexipY0/+i hD6w== 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=YBFs9iOiLgu7VKenmzw4aXW6nYPbjotzvVPML6HKYTM=; b=YfhhTWSvf94qBkgdMk/DV4YeYuBCxb3YuBnLDkKULA4YU7iJzTiR0ELYf9TmI48bAz n2vnjddb3MioYifddWBHRAN87mEts0hl+Yh1XmEMi8i0V8vd94uy9uk5RJlSwUCqWyGp JvS85zZYsUlnPHcqh/g9DSLTghH46mrS9+XtmOw3hRWgq4JTqcvNego2mVpoxkc7QpRd YhVyzKys2LRBhL8GHkRB4hehvbveDquqD0ScvWZHtg3i4/pfzOXEkP5sKutdFZsDcflZ o/M4aDFNQIQZXKxWS0D/c9ndqHfiRUoHt3Dt3/z9aNc1GBeD/GWz/22E/0fATrQqnGEj 3uVA== X-Gm-Message-State: APjAAAU+pxfMb8gEhvmWNQ+8aBaVZr6uLrrtUgvAg4T2sGVs6AELDrw0 g8geTC5WsJTzn9+y7Qpf9NJrb1bi2o8= X-Google-Smtp-Source: APXvYqzs+e0yce+b0Wn1L/LBNw7LkwwUyudDlOpEWjZbRa2l+ynSc3FUc9+06wJlMLvxDRLu2eneyA== X-Received: by 2002:a62:8246:: with SMTP id w67mr50443183pfd.226.1564605527448; Wed, 31 Jul 2019 13:38:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:07 -0700 Message-Id: <20190731203813.30765-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::544 Subject: [Qemu-devel] [PATCH v2 26/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/arm/helper.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 30f93f4792..b9f0d387f4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3917,8 +3917,11 @@ static CPAccessResult aa64_cacheop_access(CPUARMStat= e *env, =20 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_St= age2; } 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); } =20 +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 =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D env_cpu(env); + int mask =3D vae2_tlbmask(env); =20 - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx(cs, mask); } =20 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 =3D env_cpu(env); + int mask =3D vae2_tlbmask(env); =20 - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, mask); } =20 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 =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D env_cpu(env); + int mask =3D vae2_tlbmask(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, mask); } =20 static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri, --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606038; cv=none; d=zoho.com; s=zohoarc; b=N5Keh+/2Z+e8rtwgtbE4+7Q4NkAIdwsCAbbln0A7fFl6x5YvmriUffaQRu7pk12YhLAXAvCA2oPietoRONGMBwUO0gLO/V+EDxMv2+cDZwvEYj+FWyjTJiJO77hNe1iXvbkiGtnpBehaJxeU5EdF/F87UvpvUYEMGcnLAkQls84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606038; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=z5x3XqHQzkXZQb+8jCB+i1sKV2y2i8Y/ULFiYsKcHrY=; b=I0ai1vddOw1xlrna0Ond5551FmRw2Vs3hvz2j6rNAFY3z1PDXV92xlyF7zH2Bi0aW6EjsPfmKqCpVdyQDVHrgL7nAqZJIUQ/VqgnCXHkaMNJQ9fSrHbb1rcV9tP83iRHMR9VC6ZSRJCmkOURwgqZp+flBdyWywKzimL99fSLp5o= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606038441635.9203156561613; Wed, 31 Jul 2019 13:47:18 -0700 (PDT) Received: from localhost ([::1]:44406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvVF-00080C-GI for importer@patchew.org; Wed, 31 Jul 2019 16:47:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33125) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN7-0005UU-Sp for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN6-0003mV-UY for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:53 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:39326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN5-0003ju-4y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:51 -0400 Received: by mail-pf1-x444.google.com with SMTP id f17so28520722pfn.6 for ; Wed, 31 Jul 2019 13:38:49 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:47 -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=z5x3XqHQzkXZQb+8jCB+i1sKV2y2i8Y/ULFiYsKcHrY=; b=unuLZm42rCfAS60ozJ8safaC8nD5g8e6LVR3KeYDg1q53pmRe0lkVvvNHy+0ERYAcr 90sHJtzbhPU/PZeOJo6qqDShpBl+p8/30jic2Or34llqjfrj3godzX2M2OjfB1u0V2pY oCWfgFcJ6S22TBgXB/aPpe4m7Py+bf18Mi/IJNsteMgY+NveKvhnK2O0IDQlZirmys2B qwpYtL+JEumSF9rCTv6wkKAQiG0wPxLWPO3cs9aqw3n6IGlL7dbKdR9UfIQiWbx8T4r3 p0EnhK8Ws5jBfxeOuzSB/nGPuue8PQzOlti58271GPmD0KdMIuaNsu09sutaU4oa/W6G WICw== 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=z5x3XqHQzkXZQb+8jCB+i1sKV2y2i8Y/ULFiYsKcHrY=; b=ILTe957sGxq33m6F3FWFfCMrTuRWoYeu3100DetPOPI87NZOKB6FTtgboMkZmGsC/T LOUwZTGZCiCQFUFSBwqYDz0LCNIJaqYC36lG2b5xVfuivDPmtpjGPoRMyipTzetIhS2h koegOJwo3lOrg89vsNrk1Ygu2cRBf7/6sS/wYllOJUvljcRKVdr01GvJ1hNpvP9G5qGx ABPopDlPf8321mwVEzt8vPV/59a19aUZuQoUfvegyTum2qyEhxAbNzOGnJdZ6djnIauZ jrf6XrDnKKT2j9K3nYnToK8w22rBmqb2ikE6Zk6ULjjJ1Khfay2umvuhzvxrhx3bJwTz HQ5g== X-Gm-Message-State: APjAAAUQkfGw3Za3hVA3vq1QVo4IlGY9mCaSjETSkJ1HszbZhmaALIN1 bEZ3tfk7UOlYZJSotUDKpgEbH9Mt6l8= X-Google-Smtp-Source: APXvYqwKeOX88xREAURGqT8TV39GAj9Y+FheZvGgBkI7coD5tzOSsrTpB1fmstqXKVf5GIFu5q7ZsQ== X-Received: by 2002:a17:90a:b011:: with SMTP id x17mr4737759pjq.113.1564605528486; Wed, 31 Jul 2019 13:38:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:08 -0700 Message-Id: <20190731203813.30765-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 27/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The TGE bit routes all asynchronous exceptions to EL2. Signed-off-by: Richard Henderson --- target/arm/helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index b9f0d387f4..c6b40a12b4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7936,6 +7936,12 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint3= 2_t excp_idx, break; }; =20 + /* + * For these purposes, TGE and AMO/IMO/FMO both force the + * interrupt to EL2. Fold TGE into the bit extracted above. + */ + hcr |=3D (hcr_el2 & HCR_TGE) !=3D 0; + /* Perform a table-lookup for the target EL given the current state */ target_el =3D target_el_table[is64][scr][rw][hcr][secure][cur_el]; =20 --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606284; cv=none; d=zoho.com; s=zohoarc; b=WHK2mk2hwmtXomCvWMQ0cZbOZS1tvEq0B0jfAQqodk4DjP7wP4Z9UgpcpfHt4fqFZkUt29UBBjXLebHtbjexNb9zwtkDDGDMYEXLXXVVsDJhzF1F46/WL+nZgej+MxvZaK20aKSTkKROiVnYkviR64EPjopbXigzjmo2cG+/x/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606284; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Zz67J9BYvHkyirLYAvJnaBfIqywYlFR2wUnxCxYbY04=; b=ArrX1ZAwNCeP6UqtN8H1/l0yP6+z9R7uzU3SSV/XUaVIntZ3AHgS4xzijiqlydtPHBTLOPvtL4n1KoTLRnMbcJU7NWtzg8p32Raq1VHMFbi22aIQ5e9dEgITF98QoBSz1mkmtjk/Qsic6k/k7IR5G5bziz3o59jO1WnHgEtXgW0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606284106361.4499534330886; Wed, 31 Jul 2019 13:51:24 -0700 (PDT) Received: from localhost ([::1]:44484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvZC-0007mX-9H for importer@patchew.org; Wed, 31 Jul 2019 16:51:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33156) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN9-0005Uh-1C for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN7-0003nl-Gi for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:54 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:43349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN6-0003kw-TI for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:53 -0400 Received: by mail-pf1-x430.google.com with SMTP id i189so32518685pfg.10 for ; Wed, 31 Jul 2019 13:38:50 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:48 -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=Zz67J9BYvHkyirLYAvJnaBfIqywYlFR2wUnxCxYbY04=; b=L8+shBMp3yVjZG/WydqMY31Y7UzDlaO60sIBUkdhBOaavGxe1ryke/75AN8tUQrt9v oejc7f7waua8NcKbhXHZ6g0nvvGnCUUuuNqXSs+bYlAtZ87NWPmd3CvbFxcMHyHjOh8/ w1HTio11uGuyiJ7Fab6Y08/LUfrVdhi3sQgm0LLvKPxXwC0orrnT5OOXEHKG4+dvucK8 fZeW/HbIE0LXlKBOy66Ox9OArrCqptiUoox/3ND2VMjUX8sks7ALXweX8pUIf5Xtbu4t Vz/UIGAaoNrE6Dlfxyjpz4uA+Vp36EF9pOnliJFKHu5/DSGDD7ODk4ry7eQ0eUsb1PbP 4tAw== 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=Zz67J9BYvHkyirLYAvJnaBfIqywYlFR2wUnxCxYbY04=; b=DQUJbRCEjX6OMbALglnjTxQWmf3OLCF2njtvqhIBvN1TbWjTVl9SBRzFJ5X1BLl5pW tkm+lVhdDGP+LlegrrnfMRcVJCaBxBdPP/IF7qd76zXcusppGyBZ260oyIrHCNhmqnol WxlDAXIJnTflaBRvG/HCy9iy0cZWqysthka2F7Y1eUn1zMitY9S6AJHe0/SstXRn9rmV KjQanTL2dVNtu2y88oh5IpocZ7846Yh16XO7fz+v+T4ilmOYC2uPEhL7PNwk2TIC3wvh gEykJgMaZLg1T9JmpPzYqFjegdpjxjT99WVCc37F31XRtT0Zeal8kXUrMnbjbIOKd06R EQVg== X-Gm-Message-State: APjAAAWn8XXUifuzVm30XPPE/AG9JNufWXxAos9nHYmiqwJJb+hflebU IZuD/yt3nQlmfzgdJoo24caZaxuJY9Q= X-Google-Smtp-Source: APXvYqyO/bYu48vDK8KNFYcAnLNfhnN7o0hWF5s8xNobIlXNmRb10yEbsV6iQNHe2Y2xXzVtbw8XBg== X-Received: by 2002:a63:10a:: with SMTP id 10mr31711947pgb.281.1564605529644; Wed, 31 Jul 2019 13:38:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:09 -0700 Message-Id: <20190731203813.30765-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 28/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/arm/helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index c6b40a12b4..15a054a141 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8894,6 +8894,7 @@ static inline bool regime_is_user(CPUARMState *env, A= RMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_SE0: + case ARMMMUIdx_EL20_0: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_MUser: case ARMMMUIdx_MSUser: --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606190; cv=none; d=zoho.com; s=zohoarc; b=m51D4DpwYo7yTsJLmjpBw2lZ5AJd0aR4shMbFQMRVgBGvpTOfLcIDBZ3VoUk37y8vBtTIRjYB6QpxwGLyUXIoppqR+itXtKXyPCV8+2LwyiZJGrrp9u8v6f2OkulfwWbxVUtamrSGa+YAJsdFS0DhsESFQWI+lqHjyvnOgsWioQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606190; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+7keF6G5xzpT4+93ObrzwUEEy1FTEHDioAfRG1ABjog=; b=bi6pioiXe7kl8oqITFYS91RhJg9SI7sdl34FXNhJ4MDxBfx25t8waoqmYq0O9dk/h6FHyhFGgZBtxdopB1nfMP3PfO52tUZxPsBtK8MIfaJ0xqQ82iiXjEjgFU+HLMoAfPc1KqlGydNajzSCURsOzX9DFX8WmlZbfve+Vvcq5rg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606190950812.9379353754156; Wed, 31 Jul 2019 13:49:50 -0700 (PDT) Received: from localhost ([::1]:44454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvXh-0004KF-RF for importer@patchew.org; Wed, 31 Jul 2019 16:49:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33157) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN9-0005Ui-1Q for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN7-0003o4-Mu for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:54 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:46213) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN7-0003lg-FO for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:53 -0400 Received: by mail-pl1-x644.google.com with SMTP id c2so30962335plz.13 for ; Wed, 31 Jul 2019 13:38:51 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:50 -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=+7keF6G5xzpT4+93ObrzwUEEy1FTEHDioAfRG1ABjog=; b=Hb+iG6hikB6nHFx/0MT8WzAVyCuE4kWuAO6EzmOEnNm3pFGP9rMfaa1afO3UPUFGnv 17DQ2LWK+1yBpJTJLNPFOiJwODFNOF90nLDcIgpHG0kwEYnRZjq0JXk/KkvqdwvJg/CK pQch3+YjbwCiE2BwPmod0uoZT2TyuP7J2F6c4Z4mvkyo8QnjfDok7IReDNPNkQlp/tXw oDzcFFZZ2bb7UBYwaidmj5/YQClk1pXg8m0qIr38dxZrN1k3QhnzeXRXJcsfiLRAhSic fSiROngHfmDmaEwU3JQik0jKTVpRd//AbtSbbZk+IY1/siAwrNC1xfGOGTP91M302qm7 9SKA== 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=+7keF6G5xzpT4+93ObrzwUEEy1FTEHDioAfRG1ABjog=; b=HRP24J1xQU9UBJRzVh5jWdnC86Uiklpb5veBqUwO+lL9bJkDZI5jiyryr3ZqPf/PVJ BsNmPi2DmBA3qAh2HwrxPOVQ63dIdsYnS6miRjUo8Ju8LK0fJqyAS8LM16x1Vvq5ZeNA DzO2wH00fNLTjH2o+0y/f2lrXCBm/cmx9V46shcI6z2hOEGPu899sZGV+Xuq9UQRXRfu F+wjeWggF+tIDDqh3WN4PjmL05OUtbLsx5dUlHBA51P5R7jn+4d8PICyColeCo5LkqxB WHqbIN3WqW0eN+Dh9v3x9mx/3Q3SK5VDvTsVnTepT5bGb2YmuJoqpfkNWusMYj7X0KsY wCQw== X-Gm-Message-State: APjAAAUPO8TzugB+Crq24qqQU6ZwehHAaEIvHSiFgDrw8OCkeVuP5PIx Yx0/Dio3VY0ORmuQZAVRaKPZUrBpdZY= X-Google-Smtp-Source: APXvYqxPqhnHLkD9ZTEK6UndKKSKwUuWx9yFtf49NDBkQ9tTj1uBFc4OcS5nvaMeOGiudvRm9gc63w== X-Received: by 2002:a17:902:f81:: with SMTP id 1mr27243792plz.191.1564605530692; Wed, 31 Jul 2019 13:38:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:10 -0700 Message-Id: <20190731203813.30765-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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 v2 29/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 15a054a141..b29717edb6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5507,7 +5507,9 @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] =3D= { int sve_exception_el(CPUARMState *env, int el) { #ifndef CONFIG_USER_ONLY - if (el <=3D 1) { + uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); + + if (el <=3D 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) !=3D (HCR_E2H | HCR_T= GE)) { bool disabled =3D false; =20 /* The CPACR.ZEN controls traps to EL1: @@ -5522,8 +5524,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; } =20 /* Check CPACR.FPEN. */ @@ -11221,8 +11222,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 */ @@ -11250,30 +11249,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 =3D extract32(env->cp15.cpacr_el1, 20, 2); - switch (fpen) { - case 0: - case 2: - if (cur_el =3D=3D 0 || cur_el =3D=3D 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)) !=3D (HCR_E2H | HCR_T= GE)) { + int fpen =3D extract32(env->cp15.cpacr_el1, 20, 2); + + switch (fpen) { + case 0: + case 2: + if (cur_el =3D=3D 0 || cur_el =3D=3D 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 =3D=3D 3 && !is_a64(env)) { + /* Secure PL1 running at EL3 */ return 3; } - return 1; + break; + case 1: + if (cur_el =3D=3D 0) { + return 1; + } + break; + case 3: + break; } - if (cur_el =3D=3D 3 && !is_a64(env)) { - /* Secure PL1 running at EL3 */ - return 3; - } - break; - case 1: - if (cur_el =3D=3D 0) { - return 1; - } - break; - case 3: - break; } =20 /* --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606335; cv=none; d=zoho.com; s=zohoarc; b=PsSGX+ok91rKUsuGwVYwjGt6yhCRWAerRvuChQswzpb61bPh2s/vQnfysKFcKJ9XmA6BZLNzK4/nsBOVIuFNCHXtZygbH+j7W8mHJtl+0VLWqbr/lMvyrMxV+2BSaD87bSD7DGFh1kCnOuVZJzKlCzb7NJ/ph9z/mBVS1XyK38w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606335; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JBDZxP60+vIjwwzQbC3L2o1kpMj6601b/tqCyxFOHVI=; b=NpL8++MI7Elh5USwJJxhunVT1mLXmqum1ymcQ78E3ji4Gw5nqrGCS9CYYkRWdSWKTrHllvh5UL0VoQwUmzuFZsCvdAw2o1t9/qQsT0RePvLa/aVLPadjEA4OEkcr9d9sbWMx753ugKKXVncsThLJGk2kI+mPctzhbODlJacMses= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606335364672.3570615812108; Wed, 31 Jul 2019 13:52:15 -0700 (PDT) Received: from localhost ([::1]:44504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsva2-0001dI-Cf for importer@patchew.org; Wed, 31 Jul 2019 16:52:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33160) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN9-0005Ul-1U for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN7-0003nx-Ly for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:54 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:45401) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN7-0003lz-Ei for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:53 -0400 Received: by mail-pg1-x544.google.com with SMTP id o13so32626621pgp.12 for ; Wed, 31 Jul 2019 13:38:52 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:51 -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=ZjRzASgXz9DHZDSakRRsbVZIa9HlbQkZ8AqjWSJkkeFevKt5uLRm331a/WkVz39op/ CB6q2klZZaPbEc2XLGOxHnS/mh+mc5M2xOn3bcBXCXFLTcpG9+SEtLd+8N2MCeaGpuzq LXRpTEUhfVQ2tvE0uyUgrNugAwMgokamsNJEhQgCDKlqxbZKt1vZSG0qKYZbnFV2Eh2E cnRAi7Lp5ikJf2zs9BMsU5Bztq+dFR2DX2iI4YTZaVnU7RpBidquoeviL2v5//k9ng0V NsbU9V+eI2e5HbF5pNX1eJ6hS2eDTOFdiHyiW+VIBuo3wg/8bIL31q2nCObFvyKt+TQF nmUQ== 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=rhBM1111VHGdGJLTQKULvNtRIEvQVRIOq6jNEKX52MWrCftihuvI1iU0PP7HwNYTmK 7bYv7GowbV9Ph6lzVOHNsQXe08WnvRDC1bjYqPAtmYk0hz++aXpEG4uhlr23FNjiC/PD W3gnYw2HjzNjmRIaybdy6UFo1Y0RxtVSnmzJOn2Q2qxwTYMHK1YAOM2pmQ00SN1sQQuv g/bguF7LnNiXCv7/1p/3nfXAyW9VGFsR/wdPNl2YSR5lGZ3KICn8y/1ii6oi/O4gadmN PNa4rLGbRKG31F9pTP41yLRJhqctMSZdsRQLme0JI+QqT+xh2nFwwjcV8eAuXdTTaP4b UsYA== X-Gm-Message-State: APjAAAUigCqWtkG86t457Wma3Dks/S/9z/WmhGWMML+4lFg2QedBEh/H pqBFpLnvM7s79tVUc/0eONFij5LO6Eg= X-Google-Smtp-Source: APXvYqzoTV2iYyHbnFTznIJE1DRJopw832qhH+KMSW0UM1VaT8p8NpINLgsIQ64bhh0jkTh0rzld5A== X-Received: by 2002:a63:7a06:: with SMTP id v6mr116890815pgc.115.1564605531837; Wed, 31 Jul 2019 13:38:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:11 -0700 Message-Id: <20190731203813.30765-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::544 Subject: [Qemu-devel] [PATCH v2 30/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+) 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 =3D cpu->isar.id_aa64mmfr1; t =3D FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ t =3D FIELD_DP64(t, ID_AA64MMFR1, LO, 1); + t =3D FIELD_DP64(t, ID_AA64MMFR1, VH, 1); cpu->isar.id_aa64mmfr1 =3D t; =20 /* Replicate the same data to the 32-bit id registers. */ --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606429; cv=none; d=zoho.com; s=zohoarc; b=O8V8aDWA+U9HaFldolEtRaT+EM8xdv0ssuZhKAFFhcvlaiHwRJn9m+njBKZxtdtxl2zH+GhGsgE+CZ3Wr/Am3EvbW91q8r/z+qJajwGiRUhJU/DHr0sCIWnVwgL+c2xEZlDhDcFTThNZEmFz/ngMOnAJu9xz02bSQjID3glpbP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606429; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1OFhZYB7REGpAAmdzyA7otQ/hGEth32oUJ6nOIibRSY=; b=YI8qYDG3kF+ViY9xWotgnl7dF24+5W/wyu5Bi7MQmzRSmuGdcBI8Vm55GUawdDHvK9WWzSEgHJ28OfQI1k/+p0/zsmkjZSp9118OiEc9BKCVpfjjG1LEFCI239yuR1LhpumHPMX8SuExS2Jd3ClwDlVzl/bYqOQMR8gGRakdf/4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606429613557.2829420100686; Wed, 31 Jul 2019 13:53:49 -0700 (PDT) Received: from localhost ([::1]:44524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvbY-0004GM-Ik for importer@patchew.org; Wed, 31 Jul 2019 16:53:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33229) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvNG-0005du-Fk for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvNE-0003rp-Gl for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:02 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:37538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN8-0003oW-W5 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:58 -0400 Received: by mail-pf1-x443.google.com with SMTP id 19so32508020pfa.4 for ; Wed, 31 Jul 2019 13:38:54 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:52 -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=NDf7QpKnwte7o2e/AQwdvefCheNM2JdcDcBOF3wBDKoSgnTGFpCO9saXeQGplF+LTO pQeKjSPhi4mSD/xCCu8EReRtXylQ4qDXgMtQ6/pFUUqkBxhBGT7FX0Ys7NVUU5Irf0vL OQpPbWODiN95XCblrujJIMXYzVhYePWixrN3JAsghy5vnHTnvu6u/bt/+K6dtQx6HlHI xYaL+1H47ngKC9c4g9inXLp+PCRlaxa06Sk4PZLMzKdYA4T8VBg59Ucq/e7F0gplKOhm IvoTDlFg56dZD93W0+jiPZa3X2p3XAYbozan0337sMlmGrQoIguBwzz8vNGHqBqoHe58 eO3A== 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=UmRqo/w/9hiqvmFdWQl4mkmhXSnEn4oc7DwtrFvMM9wa1XSSq/I8jSxZ/22yCWVA32 VSrSYtjooYQNsbJSzXYIgP8kj6ZR+EP8UsG4Jamg1qjxb5OG5EwDiKAWFX9eCFoDOOlP vlIevvwQlDVPH6bO+NjmjZa/C/p9qq/BIfPhfVD4GIAS5aBMHeIi1NRbR0n/lavx78mB JcwFzUaa5aKocG2pCMLhGnJQNALk8/ezIwZzPXQI5qr3oMt8Cy7G5EKllxK5s2J5Bwxr 4VVfLqv2qsJtHQly+x6jbXSpUhBqHbCEKAUA18J95hqIMxjVehgMEZ1eCr65NwPkh5xt zhvw== X-Gm-Message-State: APjAAAUp2ofG4qh52oyJMfn0MrsW9i96Bp+HCQEVUkM50icNWgW0XR1Q +An1cTtdg4JAeiARoIBVXZheiwvDi14= X-Google-Smtp-Source: APXvYqxGYhWlVndlnlNldzfoXAoz0yztGfhbJKW3XqxS5inma4EnKr9T7KDJpzdp8PCTG2s3KVThDw== X-Received: by 2002:aa7:956d:: with SMTP id x13mr49793061pfq.132.1564605533112; Wed, 31 Jul 2019 13:38:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:12 -0700 Message-Id: <20190731203813.30765-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 31/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e According to ARM ARM we should only trap from EL0 when TCG or E2H are 0. Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/pauth_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 =3D arm_hcr_el2_eff(env); bool trap =3D !(hcr & HCR_API); - /* FIXME: ARMv8.1-VHE: trap only applies to EL1&0 regime. */ + if (el < 1) { + trap &=3D !(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); --=20 2.17.1 From nobody Tue May 7 11:09:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564606513; cv=none; d=zoho.com; s=zohoarc; b=Z6Op5iAM6G/QSL9wg9mGx9b+zUDJCJiF77AzUMIiNSROGkoEsADuKy9u0AfLDaF4/nSvrJlSjzde26lzMhENZ7PSp1JYZQIbg66V/EOrtLbtKVaGaSICeDzx/CsKzHIfeAN7694YtOEmYf2hExyGVxMqifOP/GuG4F5MEFd4s7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606513; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rCEnVED33NpbOad0FfG1c7z9lc80+f3mCsiBq0HqyvU=; b=CgDkh5sDon1UQ7IieeX+gpWaYaCsio5VG8OUkq8DQ9oG7+wVtcdWwkLF+K7NmTNTmJ5fVzubBrMO48QrlRdIlRE/HeXh6ccObwRM5xXag5SxTfSyozQneCP++k1YunmRWD37Wdnob5SWXos3igTIZ7oOMDUD5+AYaCdwoFQynL8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606513638879.5104700935581; Wed, 31 Jul 2019 13:55:13 -0700 (PDT) Received: from localhost ([::1]:44550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvcu-0006qE-MF for importer@patchew.org; Wed, 31 Jul 2019 16:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33255) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvNI-0005eH-3Y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvNG-0003t6-Ez for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:04 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41505) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvNC-0003pm-MM for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:00 -0400 Received: by mail-pg1-x542.google.com with SMTP id x15so22297600pgg.8 for ; Wed, 31 Jul 2019 13:38:55 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:53 -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=rCEnVED33NpbOad0FfG1c7z9lc80+f3mCsiBq0HqyvU=; b=DX5wfvfhHx0n2P2s6jl6RwziKqDkDxXUOzDh7/6cIrZEbTQqGsEd+W+FyUdIZ0RkGw P5arA1F6Y8ZC6vw5DUFCrz/he4PxGXmFRQJF35Dw3jLQEFo+QFxAjy61gKKerwr2lk9Y TNewzFtsTvvoWeenZLzItpoSeulZVmILyKKjRMeSM81X+JANzAn3L9ivEeaDzkmGZVU3 3rj2vJoEBSFbi8KNDlqG0VZJJ8ZEzVM3H17Y25SD35h6qqPZIAjwffvfOAsThAcK2M+l N52mDMflXcUB5Yl1qa1LhqLtrlMBOvc6TFUfo1iJuI3xal2npnqXgi2PbtiyCOTWmc+n XvMg== 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=rCEnVED33NpbOad0FfG1c7z9lc80+f3mCsiBq0HqyvU=; b=D5Ph5Lqq7v4om4m69mw5sVFAuBjIf6rYqMISxjy3d0ocQUnHZrQAG8l/5pESu/W5oR ZKFgVwfbM1362/C4SPKef9G2LWj3CJ6/wpSEd06H4gJ7WGAc/xU6OGQm8D4mL1L28Toe pOt5tiXqzexTlXDhLPX+aszLwZgFx8xJubq6qxcRelb59mwM18q/jyaeB8jvWhwYjKVI FdUW2jhXbWX0DfgEWmBNd5faylPdZLJieBCzs20JZGPsaPgjhLNlv6qVvSY9gt13H+x8 P8W+Dg3bblOWOfeb0qqrvtSh1+veeclhziytXw1BW9yZm6tqWBtxR30N7gJmzIAePD/C 8fGw== X-Gm-Message-State: APjAAAUGvYcczvsuTI11/g7weyBzUZbCrE/oMvfBvIrQc3BBVOfJKExz OPezRvrs2aSg/ky5qjMrEa2vNxvPq1U= X-Google-Smtp-Source: APXvYqzT69kO8SA8gFvdvWnfzS57ZpuhMi0E9khqmPD/SwfJjVZy7cSrTQm9JoqEoxEuXVAW+pCVeQ== X-Received: by 2002:a65:430b:: with SMTP id j11mr113663987pgq.383.1564605534112; Wed, 31 Jul 2019 13:38:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:13 -0700 Message-Id: <20190731203813.30765-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 32/32] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e 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=C3=A9e 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(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c41da1d791..bc9b6db9b4 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); =20 + /* + * 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 regi= sters + * 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 =3D FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); + t =3D FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); + t =3D FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); + t =3D FIELD_DP64(t, MIDR_EL1, VARIANT, 0); + t =3D FIELD_DP64(t, MIDR_EL1, REVISION, 0); + cpu->midr =3D t; + t =3D cpu->isar.id_aa64isar0; t =3D FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); --=20 2.17.1